summaryrefslogtreecommitdiffstats
path: root/chrome/browser/storage_monitor
diff options
context:
space:
mode:
authorgbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-15 08:38:05 +0000
committergbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-05-15 08:38:05 +0000
commit99e0c823f667c7a6bcee33833e56986015a90f58 (patch)
tree531b924540851cd5586dadb32a3af33a03499f5f /chrome/browser/storage_monitor
parent749fadd21aec1956873b3f8de5602874c7a52dc6 (diff)
downloadchromium_src-99e0c823f667c7a6bcee33833e56986015a90f58.zip
chromium_src-99e0c823f667c7a6bcee33833e56986015a90f58.tar.gz
chromium_src-99e0c823f667c7a6bcee33833e56986015a90f58.tar.bz2
[Storage Monitor] Check for floppy drives with both X: and \\.\X: forms of device name.
We observe that in Windows 7 and 8, it looks like using the "X:" device name for QueryDosDevice doesn't work -- just returns "/". Using the slash-ified name is working. We aren't sure whether this does or does not work for older windows versions yet, so for now, trying both variants. R=vandebo@chromium.org BUG=234318 Review URL: https://chromiumcodereview.appspot.com/14576016 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@200195 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/storage_monitor')
-rw-r--r--chrome/browser/storage_monitor/volume_mount_watcher_win.cc27
1 files changed, 21 insertions, 6 deletions
diff --git a/chrome/browser/storage_monitor/volume_mount_watcher_win.cc b/chrome/browser/storage_monitor/volume_mount_watcher_win.cc
index 6d1d806..daa4b36 100644
--- a/chrome/browser/storage_monitor/volume_mount_watcher_win.cc
+++ b/chrome/browser/storage_monitor/volume_mount_watcher_win.cc
@@ -62,15 +62,29 @@ DeviceType GetDeviceType(const string16& mount_point) {
if (drive_type != DRIVE_REMOVABLE)
return FLOPPY;
+ // Check device strings of the form "X:" and "\\.\X:"
+ // For floppy drives, these will return strings like "/Device/Floppy0"
string16 device = mount_point;
if (EndsWith(mount_point, L"\\", false))
- device = mount_point.substr(0, device.length() - 1);
+ device = mount_point.substr(0, mount_point.length() - 1);
string16 device_path;
- if (!QueryDosDevice(device.c_str(), WriteInto(&device_path, kMaxPathBufLen),
- kMaxPathBufLen))
- return REMOVABLE;
- VLOG(1) << "Got device path " << device_path;
- return device_path.find(L"Floppy") == string16::npos ? REMOVABLE : FLOPPY;
+ string16 device_path_slash;
+ DWORD dos_device = QueryDosDevice(
+ device.c_str(), WriteInto(&device_path, kMaxPathBufLen), kMaxPathBufLen);
+ string16 device_slash = string16(L"\\\\.\\");
+ device_slash += device;
+ DWORD dos_device_slash = QueryDosDevice(
+ device_slash.c_str(), WriteInto(&device_path_slash, kMaxPathBufLen),
+ kMaxPathBufLen);
+ if (dos_device == 0 && dos_device_slash == 0)
+ return FLOPPY;
+ VLOG(1) << "Got device path " << device_path << " and " << device_path_slash;
+ if (device_path.find(L"Floppy") != string16::npos ||
+ device_path_slash.find(L"Floppy") != string16::npos) {
+ return FLOPPY;
+ }
+
+ return REMOVABLE;
}
// Returns 0 if the devicetype is not volume.
@@ -111,6 +125,7 @@ bool GetDeviceDetails(const base::FilePath& device_path,
kMaxPathBufLen)) {
return false;
}
+ mount_point.resize(wcslen(mount_point.c_str()));
// Note: experimentally this code does not spin a floppy drive. It
// returns a GUID associated with the device, not the volume.