From bbadcf252fe9d5708774fd9a40027c84afdee1de Mon Sep 17 00:00:00 2001 From: Andrea Mazzoleni Date: Tue, 23 Jun 2026 10:57:21 +0200 Subject: [PATCH] Reduce permission to avoid to spin up disks in Windows --- HISTORY | 10 ++++++++++ cmdline/mingw.c | 11 ++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/HISTORY b/HISTORY index 00e04daf..531efada 100644 --- a/HISTORY +++ b/HISTORY @@ -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 diff --git a/cmdline/mingw.c b/cmdline/mingw.c index ccae49c7..e1dd7a46 100644 --- a/cmdline/mingw.c +++ b/cmdline/mingw.c @@ -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);