* 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.
This commit is contained in:
Corinna Vinschen
2012-02-16 11:02:05 +00:00
parent fb97e87479
commit 9de0461985
6 changed files with 91 additions and 13 deletions

View File

@@ -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;
}