From 640c3ce5df63845cb038e7008000eb51ec99a702 Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Thu, 10 Mar 2005 17:02:52 +0000 Subject: * path.cc (is_floppy): New function. (setmntent): Drop floppy drives on A: and B: from logical drive DWORD. * syscalls.cc (sync): Don't sync floppies on A: and B:. --- winsup/cygwin/ChangeLog | 6 ++++++ winsup/cygwin/path.cc | 15 +++++++++++++++ winsup/cygwin/syscalls.cc | 5 ++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index b246f1279..c0ae04f9d 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2005-03-10 Corinna Vinschen + + * path.cc (is_floppy): New function. + (setmntent): Drop floppy drives on A: and B: from logical drive DWORD. + * syscalls.cc (sync): Don't sync floppies on A: and B:. + 2005-03-10 Christopher Faylor * autoload.cc (LoadDLLprime): Use nocopy segment or forked processes diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 31f646e5b..151c8ea82 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2472,11 +2472,26 @@ cygwin_umount (const char *path, unsigned flags) return res; } +static bool +is_floppy (const char *dos) +{ + char dev[256]; + if (!QueryDosDevice (dos, dev, 256)) + return false; + return strncasematch (dev, "\\Device\\Floppy", 14) + || strcasematch (dev, "A:"); +} + extern "C" FILE * 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:")) + _my_tls.locals.available_drives &= ~1; + if ((_my_tls.locals.available_drives & 2) && is_floppy ("B:")) + _my_tls.locals.available_drives &= ~2; return (FILE *) filep; } diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 180a2e808..b2375e650 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -964,11 +964,14 @@ sync () } else if (wincap.is_winnt ()) /* 9x has no concept for opening volumes */ { - DWORD drives = GetLogicalDrives (); + extern FILE *setmntent (const char *, const char *); + setmntent ("", ""); + DWORD drives = _my_tls.locals.available_drives; DWORD mask = 1; strcpy (vol, "\\\\.\\A:"); do { + /* Geeh. Try to sync only non-floppy drives. */ if (drives & mask) { debug_printf ("Try volume %s", vol); -- cgit v1.2.3