Reduce permission to avoid to spin up disks in Windows
Some checks failed
Build / build-mac (push) Has been cancelled
Build / build-linux (push) Has been cancelled
Build / build-win (push) Has been cancelled
CodeQL Advanced / Analyze (c-cpp) (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled

This commit is contained in:
Andrea Mazzoleni 2026-06-23 10:57:21 +02:00
parent 65ad555779
commit bbadcf252f
2 changed files with 18 additions and 3 deletions

10
HISTORY
View file

@ -1,6 +1,16 @@
SnapRAID HISTORY
================
14.8 2026/06
============
* Avoid spinning up standby disks on Windows in some machines during
the 'probe' and other device-monitoring commands. Direct system
queries for disk properties, size, and geometry are now performed
using zero-access handles.
* Fixed the smartctl type detection retry during probe on Windows to
properly preserve the standby check option, preventing standby disks
from spinning up if a retry is needed.
14.7 2026/06
============
* Fix the 'touch' command on Windows for files with the read-only

View file

@ -2740,7 +2740,7 @@ static void devattr(uint64_t device, const char* name, const char* wfile, uint64
(void)family; /* not available, smartctl uses an internal database to get it */
/* open the volume */
h = CreateFileW(convert(conv_buf, wfile), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH, 0);
h = CreateFileW(convert(conv_buf, wfile), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
if (h == INVALID_HANDLE_VALUE) {
DWORD error = GetLastError();
windows_errno(error);
@ -3247,9 +3247,14 @@ int devmap(void)
HANDLE h;
/* open the volume */
h = CreateFileW(convert(conv_buf, wfile), GENERIC_READ, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, FILE_FLAG_NO_BUFFERING | FILE_FLAG_WRITE_THROUGH, 0);
if (h == INVALID_HANDLE_VALUE)
h = CreateFileW(convert(conv_buf, wfile), 0, FILE_SHARE_READ | FILE_SHARE_WRITE, 0, OPEN_EXISTING, 0, 0);
if (h == INVALID_HANDLE_VALUE) {
DWORD error = GetLastError();
if (error != ERROR_FILE_NOT_FOUND)
log_tag("enumeration:/dev/pd%d::error:%lu\n", i, error);
continue;
}
char serial[SMART_MAX];
serial[0] = 0;
devattr_property(h, serial, 0, 0);