From dc29c1224e877dc6c8156f40e53042f06a42173f Mon Sep 17 00:00:00 2001
From: chrfranke <chrfranke@4ea69e1a-61f1-4043-bf83-b5c94c648137>
Date: Sun, 19 Aug 2007 14:29:45 +0000
Subject: [PATCH] Windows: Modified drive letter handling: try SCSI if type is
 unknown, allow 'X:\.' syntax.

git-svn-id: https://smartmontools.svn.sourceforge.net/svnroot/smartmontools/trunk@2423 4ea69e1a-61f1-4043-bf83-b5c94c648137
---
 sm5/CHANGELOG    |  5 ++++-
 sm5/os_win32.cpp | 14 +++++++++-----
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/sm5/CHANGELOG b/sm5/CHANGELOG
index 1c21b7dac..b69bbae20 100644
--- a/sm5/CHANGELOG
+++ b/sm5/CHANGELOG
@@ -1,6 +1,6 @@
 CHANGELOG for smartmontools
 
-$Id: CHANGELOG,v 1.628 2007/07/28 13:17:38 chrfranke Exp $
+$Id: CHANGELOG,v 1.629 2007/08/19 14:29:45 chrfranke Exp $
 
 The most recent version of this file is:
 http://smartmontools.cvs.sourceforge.net/smartmontools/sm5/CHANGELOG?view=markup
@@ -33,6 +33,9 @@ NOTES FOR FUTURE RELEASES: see TODO file.
 
 <DEVELOPERS: ADDITIONS TO THE CHANGE LOG GO JUST BELOW HERE, PLEASE>
 
+  [CF] Windows: Modified drive letter handling for explorer drive
+       context menu: try SCSI if type is unknown, allow 'X:\.' syntax.
+
   [CF] Windows: Added automatic ATA/SCSI device type detection and
        SCSI device scanning. The device names '/dev/sdX' and
        '/dev/pd<n>' now work for both ATA and SCSI disks.
diff --git a/sm5/os_win32.cpp b/sm5/os_win32.cpp
index fd8b01159..3a78d357f 100644
--- a/sm5/os_win32.cpp
+++ b/sm5/os_win32.cpp
@@ -44,7 +44,7 @@ extern int64_t bytes; // malloc() byte count
 
 
 // Needed by '-V' option (CVS versioning) of smartd/smartctl
-const char *os_XXXX_c_cvsid="$Id: os_win32.cpp,v 1.56 2007/07/28 13:17:38 chrfranke Exp $"
+const char *os_XXXX_c_cvsid="$Id: os_win32.cpp,v 1.57 2007/08/19 14:29:45 chrfranke Exp $"
 ATACMDS_H_CVSID CONFIG_H_CVSID EXTERN_H_CVSID INT64_H_CVSID SCSICMDS_H_CVSID UTILITY_H_CVSID;
 
 
@@ -174,12 +174,14 @@ static int is_permissive()
 }
 
 // return number for drive letter, -1 on error
-// "[A-Za-z]:[/\\]?" => 0-25
+// "[A-Za-z]:([/\\][.]?)?" => 0-25
 // Accepts trailing '"' to fix broken "X:\" parameter passing from .bat files
 static int drive_letter(const char * s)
 {
 	return (   (('A' <= s[0] && s[0] <= 'Z') || ('a' <= s[0] && s[0] <= 'z'))
-	        && s[1] == ':' && (!s[2] || (strchr("/\\\"", s[2]) && !s[3])) ?
+	        && s[1] == ':'
+	        && (!s[2] || (   strchr("/\\\"", s[2])
+	                      && (!s[3] || (s[3] == '.' && !s[4])))              ) ?
 	        (s[0] & 0x1f) - 1 : -1);
 }
 
@@ -208,8 +210,10 @@ int guess_device_type (const char * dev_name)
 	if (!strncmp(dev_name, "tape", 4))
 		return CONTROLLER_SCSI;
 	int logdrive = drive_letter(dev_name);
-	if (logdrive >= 0)
-		return get_controller_type(-1, logdrive);
+	if (logdrive >= 0) {
+		int type = get_controller_type(-1, logdrive);
+		return (type != CONTROLLER_UNKNOWN ? type : CONTROLLER_SCSI);
+	}
 	char drive[1+1] = "";
 	if (sscanf(dev_name, "sd%1[a-z]", drive) == 1)
 		return get_controller_type(drive[0]-'a', -1);
-- 
GitLab