* 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.
This commit is contained in:
Christopher Faylor 2001-04-01 05:09:57 +00:00
parent f2aeff27f0
commit 5817ee2d09
2 changed files with 39 additions and 15 deletions
winsup/cygwin

View File

@ -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> Sat Mar 31 21:56:19 2001 Christopher Faylor <cgf@cygnus.com>
* thread.h (struct _winsup_t): Remove obsolete elements. Add * thread.h (struct _winsup_t): Remove obsolete elements. Add

View File

@ -2036,6 +2036,14 @@ fillout_mntent (const char *native_path, const char *posix_path, unsigned flags)
static NO_COPY struct mntent ret; static NO_COPY struct mntent ret;
#endif #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 /* Pass back pointers to mount_table strings reserved for use by
getmntent rather than pointers to strings in the internal mount getmntent rather than pointers to strings in the internal mount
table because the mount table might change, causing weird effects table because the mount table might change, causing weird effects
@ -2087,22 +2095,31 @@ mount_item::getmntent ()
static struct mntent * static struct mntent *
cygdrive_getmntent () cygdrive_getmntent ()
{ {
if (!available_drives) char native_path[4];
return NULL; char posix_path[MAX_PATH];
DWORD mask = 1, drive = 'a';
struct mntent *ret = NULL;
DWORD mask, drive; while (available_drives)
for (mask = 1, drive = 'a'; drive <= 'z'; mask <<= 1, drive++) {
for (/* nothing */; drive <= 'z'; mask <<= 1, drive++)
if (available_drives & mask) if (available_drives & mask)
break;
__small_sprintf (native_path, "%c:\\", drive);
if (GetDriveType (native_path) == DRIVE_REMOVABLE ||
GetFileAttributes (native_path) == (DWORD) -1)
{ {
available_drives &= ~mask; 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; break;
} }
char native_path[3]; return ret;
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);
} }
struct mntent * struct mntent *