This was previously done, but was lost when the function was updated to
list all Windows mount points, not just drive letters.

Fixes: 04a5b072940cc ("Cygwin: expose all windows volume mount points.")
Signed-off-by: Jeremy Drake <cyg...@jdrake.com>
---
 winsup/cygwin/local_includes/mount.h |  3 ++-
 winsup/cygwin/mount.cc               | 23 +++++++++++++++++------
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/winsup/cygwin/local_includes/mount.h 
b/winsup/cygwin/local_includes/mount.h
index 3049de8ba3..b719d98359 100644
--- a/winsup/cygwin/local_includes/mount.h
+++ b/winsup/cygwin/local_includes/mount.h
@@ -23,6 +23,7 @@ enum disk_type
   DT_SHARE_NFS
 };

+disk_type get_device_type (LPCWSTR);
 disk_type get_disk_type (LPCWSTR);

 /* Don't add new fs types without adding them to fs_names in mount.cc!
@@ -236,7 +237,7 @@ class dos_drive_mappings
   mapping::dosmount *cur_dos;

 public:
-  dos_drive_mappings ();
+  dos_drive_mappings (bool with_floppies = true);
   ~dos_drive_mappings ();
   wchar_t *fixup_if_match (wchar_t *path);
   const wchar_t *next_dos_mount ();
diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc
index ab07c5abef..c921c7691c 100644
--- a/winsup/cygwin/mount.cc
+++ b/winsup/cygwin/mount.cc
@@ -1746,7 +1746,7 @@ mount_info::cygdrive_getmntent ()
   char *win32_path, *posix_path;

   if (!_my_tls.locals.drivemappings)
-    _my_tls.locals.drivemappings = new dos_drive_mappings ();
+    _my_tls.locals.drivemappings = new dos_drive_mappings (false);

   wide_path = _my_tls.locals.drivemappings->next_dos_mount ();
   if (wide_path)
@@ -1899,11 +1899,9 @@ cygwin_umount (const char *path, unsigned flags)
 #define is_dev(d,s)    wcsncmp((d),(s),sizeof(s) - 1)

 disk_type
-get_disk_type (LPCWSTR dos)
+get_device_type (LPCWSTR dev)
 {
-  WCHAR dev[MAX_PATH], *d = dev;
-  if (!QueryDosDeviceW (dos, dev, MAX_PATH))
-    return DT_NODISK;
+  const WCHAR *d = dev;
   if (is_dev (dev, L"\\Device\\"))
     {
       d += 8;
@@ -1934,6 +1932,15 @@ get_disk_type (LPCWSTR dos)
   return DT_NODISK;
 }

+disk_type
+get_disk_type (LPCWSTR dos)
+{
+  WCHAR dev[MAX_PATH];
+  if (!QueryDosDeviceW (dos, dev, MAX_PATH))
+    return DT_NODISK;
+  return get_device_type (dev);
+}
+
 extern "C" FILE *
 setmntent (const char *filep, const char *)
 {
@@ -2020,7 +2027,7 @@ resolve_dos_device (const wchar_t *dosname, wchar_t 
*devpath)
   return false;
 }

-dos_drive_mappings::dos_drive_mappings ()
+dos_drive_mappings::dos_drive_mappings (bool with_floppies)
 : mappings(0)
 , cur_mapping(0)
 , cur_dos(0)
@@ -2044,6 +2051,8 @@ dos_drive_mappings::dos_drive_mappings ()
        mount[--len] = L'\0'; /* Drop trailing backslash */
        if (resolve_dos_device (mount, devpath))
          {
+           if (!with_floppies && get_device_type (devpath) == DT_FLOPPY)
+             continue;
            mapping *m = new mapping ();
            if (m)
              {
@@ -2088,6 +2097,8 @@ dos_drive_mappings::dos_drive_mappings ()
        *wcsrchr (vol, L'\\') = L'\0';
        if (resolve_dos_device (vol + 4, devpath))
          {
+           if (!with_floppies && get_device_type (devpath) == DT_FLOPPY)
+             continue;
            mapping *m = new mapping ();
            bool hadrootmount = false;
            if (m)
-- 
2.48.1.windows.1

Reply via email to