diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2012-02-16 11:02:05 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2012-02-16 11:02:05 +0000 |
commit | 9de04619852a9e83433b311e5d7ca60d0587d385 (patch) | |
tree | f5a38797fdce787d787faf582f4891ade56c724b /winsup/cygwin/mount.cc | |
parent | fb97e87479ea60a6c3ce21b193b83991a0fc0fc9 (diff) | |
download | cygnal-9de04619852a9e83433b311e5d7ca60d0587d385.tar.gz cygnal-9de04619852a9e83433b311e5d7ca60d0587d385.tar.bz2 cygnal-9de04619852a9e83433b311e5d7ca60d0587d385.zip |
* autoload.cc (NetUseGetInfo): Define.
* fhandler_disk_file.cc (fhandler_cygdrive::opendir): Rename flptst
to drive. Call new get_disk_type function rather than is_floppy and
check SMB drives with the NetUseGetInfo function. Explain why.
* mount.cc (get_disk_type): New function to evaluate disk type from
native NT device name.
(is_floppy): Remove.
* mount.h (enum disk_type): Define.
(get_disk_type): Declare.
* path.h (is_floppy): Drop declaration.
Diffstat (limited to 'winsup/cygwin/mount.cc')
-rw-r--r-- | winsup/cygwin/mount.cc | 47 |
1 files changed, 39 insertions, 8 deletions
diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc index ef7d746df..17d5c571f 100644 --- a/winsup/cygwin/mount.cc +++ b/winsup/cygwin/mount.cc @@ -1840,13 +1840,42 @@ cygwin_umount (const char *path, unsigned flags) return res; } -bool -is_floppy (const char *dos) +#define is_dev(d,s) wcsncmp((d),(s),sizeof(s) - 1) + +disk_type +get_disk_type (LPCWSTR dos) { - char dev[256]; - if (!QueryDosDevice (dos, dev, 256)) - return false; - return ascii_strncasematch (dev, "\\Device\\Floppy", 14); + WCHAR dev[MAX_PATH], *d = dev; + if (!QueryDosDeviceW (dos, dev, MAX_PATH)) + return DT_NODISK; + if (is_dev (dev, L"\\Device\\")) + { + d += 8; + switch (toupper (*d)) + { + case 'C': + if (is_dev (d, L"CdRom")) + return DT_CDROM; + break; + case 'F': + if (is_dev (d, L"Floppy")) + return DT_FLOPPY; + break; + case 'H': + if (is_dev (d, L"Harddisk")) + return DT_HARDDISK; + break; + case 'L': + if (is_dev (d, L"LanmanRedirector\\")) + return DT_SHARE_SMB; + break; + case 'M': + if (is_dev (d, L"MRxNfs\\")) + return DT_SHARE_NFS; + break; + } + } + return DT_NODISK; } extern "C" FILE * @@ -1855,9 +1884,11 @@ setmntent (const char *filep, const char *) _my_tls.locals.iteration = 0; _my_tls.locals.available_drives = GetLogicalDrives (); /* Filter floppy drives on A: and B: */ - if ((_my_tls.locals.available_drives & 1) && is_floppy ("A:")) + if ((_my_tls.locals.available_drives & 1) + && get_disk_type (L"A:") == DT_FLOPPY) _my_tls.locals.available_drives &= ~1; - if ((_my_tls.locals.available_drives & 2) && is_floppy ("B:")) + if ((_my_tls.locals.available_drives & 2) + && get_disk_type (L"B:") == DT_FLOPPY) _my_tls.locals.available_drives &= ~2; return (FILE *) filep; } |