Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-04-01 09:09:57 +0400
committerChristopher Faylor <me@cgf.cx>2001-04-01 09:09:57 +0400
commit5817ee2d0993c47af7142d59f762deaefce2a132 (patch)
tree242bbc76f429aafd3dac453ac32dd2dc0eb12f44
parentf2aeff27f06bf2b44faaef5b5de1131e8fc142c2 (diff)
* path.cc (fillout_mntent): Always remove drive root directories from future
consideration by "/cygdrive" reporting. (cygdrive_getmnt): Avoid reporting removable drives or drives with no media mounted.
-rw-r--r--winsup/cygwin/ChangeLog7
-rw-r--r--winsup/cygwin/path.cc45
2 files changed, 38 insertions, 14 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index f6f7674a5..d2d89058b 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,10 @@
+Sun Apr 1 00:08:15 2001 Christopher Faylor <cgf@cygnus.com>
+
+ * path.cc (fillout_mntent): Always remove drive root directories from
+ future consideration by "/cygdrive" reporting.
+ (cygdrive_getmnt): Avoid reporting removable drives or drives with no
+ media mounted.
+
Sat Mar 31 21:56:19 2001 Christopher Faylor <cgf@cygnus.com>
* thread.h (struct _winsup_t): Remove obsolete elements. Add
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index 78590635a..fe3c78c75 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -2036,6 +2036,14 @@ fillout_mntent (const char *native_path, const char *posix_path, unsigned flags)
static NO_COPY struct mntent ret;
#endif
+ /* Remove drivenum from list if we see a x: style path */
+ if (strlen (native_path) == 2 && native_path[1] == ':')
+ {
+ int drivenum = tolower (native_path[0]) - 'a';
+ if (drivenum >= 0 && drivenum <= 31)
+ available_drives &= ~(1 << drivenum);
+ }
+
/* Pass back pointers to mount_table strings reserved for use by
getmntent rather than pointers to strings in the internal mount
table because the mount table might change, causing weird effects
@@ -2087,22 +2095,31 @@ mount_item::getmntent ()
static struct mntent *
cygdrive_getmntent ()
{
- if (!available_drives)
- return NULL;
+ char native_path[4];
+ char posix_path[MAX_PATH];
+ DWORD mask = 1, drive = 'a';
+ struct mntent *ret = NULL;
- DWORD mask, drive;
- for (mask = 1, drive = 'a'; drive <= 'z'; mask <<= 1, drive++)
- if (available_drives & mask)
- {
- available_drives &= ~mask;
- break;
- }
+ while (available_drives)
+ {
+ for (/* nothing */; drive <= 'z'; mask <<= 1, drive++)
+ if (available_drives & mask)
+ break;
- char native_path[3];
- char posix_path[MAX_PATH];
- __small_sprintf (native_path, "%c:", drive);
- __small_sprintf (posix_path, "%s%c", mount_table->cygdrive, drive);
- return fillout_mntent (native_path, posix_path, mount_table->cygdrive_flags);
+ __small_sprintf (native_path, "%c:\\", drive);
+ if (GetDriveType (native_path) == DRIVE_REMOVABLE ||
+ GetFileAttributes (native_path) == (DWORD) -1)
+ {
+ available_drives &= ~mask;
+ continue;
+ }
+ native_path[2] = '\0';
+ __small_sprintf (posix_path, "%s%c", mount_table->cygdrive, drive);
+ ret = fillout_mntent (native_path, posix_path, mount_table->cygdrive_flags);
+ break;
+ }
+
+ return ret;
}
struct mntent *