Previously, if there was an explicit mount entry for a drive letter
(say, C:), the output of the corresponding cygdrive mntent (like
/cygdrive/c) would be suppressed.  Once Windows directory mounts were
added to cygdrive mounts, the de-duplication code got more complicated.
Instead, always output the cygdrive mounts, under the cygdrive prefix.

Addresses: https://cygwin.com/pipermail/cygwin-patches/2025q1/013367.html
Signed-off-by: Jeremy Drake <cyg...@jdrake.com>
---
 winsup/cygwin/mount.cc | 38 +++-----------------------------------
 1 file changed, 3 insertions(+), 35 deletions(-)

diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc
index 722dc2aef5..b8d8d4a974 100644
--- a/winsup/cygwin/mount.cc
+++ b/winsup/cygwin/mount.cc
@@ -1744,7 +1744,6 @@ mount_info::cygdrive_getmntent ()
   tmp_pathbuf tp;
   const wchar_t *wide_path;
   char *win32_path, *posix_path;
-  int err;

   if (!_my_tls.locals.drivemappings)
     _my_tls.locals.drivemappings = new dos_drive_mappings ();
@@ -1755,12 +1754,7 @@ mount_info::cygdrive_getmntent ()
       win32_path = tp.c_get ();
       sys_wcstombs (win32_path, NT_MAX_PATH, wide_path);
       posix_path = tp.c_get ();
-      if ((err = conv_to_posix_path (win32_path, posix_path, 0)))
-      {
-       set_errno (err);
-       return NULL;
-      }
-
+      cygdrive_posix_path (win32_path, posix_path, 0);
       return fillout_mntent (win32_path, posix_path, cygdrive_flags);
     }
   else
@@ -1778,34 +1772,8 @@ struct mntent *
 mount_info::getmntent (int x)
 {
   if (x < 0 || x >= nmounts)
-    {
-      struct mntent *ret;
-      /* de-duplicate against explicit mount entries */
-      while ((ret = cygdrive_getmntent ()))
-       {
-         tmp_pathbuf tp;
-         char *backslash_fsname = NULL;
-         for (int i = 0; i < nmounts; ++i)
-           {
-             if (!strcmp (ret->mnt_dir, mount[i].posix_path))
-               {
-                 /* mount_item::native_path has backslashes, but
-                    mntent::mnt_fsname has forward slashes.  Lazily
-                    backslashify only if mnt_dir equals posix_path. */
-                 if (!backslash_fsname)
-                   {
-                     backslash_fsname = tp.c_get ();
-                     backslashify (ret->mnt_fsname, backslash_fsname, false);
-                   }
-                 if (strcasematch (backslash_fsname, mount[i].native_path))
-                   goto cygdrive_mntent_continue;
-               }
-           }
-         break;
-cygdrive_mntent_continue:;
-       }
-      return ret;
-    }
+    return cygdrive_getmntent ();
+
   return mount[native_sorted[x]].getmntent ();
 }

-- 
2.47.1.windows.2

Reply via email to