Bit of commentary/review on my own patch. On Fri, 7 Feb 2025, Jeremy Drake via Cygwin-patches wrote:
> diff --git a/winsup/cygwin/local_includes/cygtls.h > b/winsup/cygwin/local_includes/cygtls.h > index d814814b19..ba9e980ec1 100644 > --- a/winsup/cygwin/local_includes/cygtls.h > +++ b/winsup/cygwin/local_includes/cygtls.h > @@ -93,10 +93,13 @@ struct _local_storage > int dl_error; > char dl_buffer[256]; > > - /* path.cc */ > + /* mount.cc */ > struct mntent mntbuf; > int iteration; > - unsigned available_drives; > + int volumemountpointoffset; > + HANDLE volumesearchhandle; > + WCHAR *volumemountpoints; // note: malloced > + DWORD volumemountpointslen; > char mnt_type[80]; > char mnt_opts[80]; > char mnt_fsname[CYG_MAX_PATH]; I'm regretting the length of those variable names now... > diff --git a/winsup/cygwin/local_includes/mount.h > b/winsup/cygwin/local_includes/mount.h > index b2acdf08b4..7120281069 100644 > --- a/winsup/cygwin/local_includes/mount.h > +++ b/winsup/cygwin/local_includes/mount.h > @@ -216,6 +216,7 @@ class mount_info > bool from_fstab (bool user, WCHAR [], PWCHAR); > > int cygdrive_win32_path (const char *src, char *dst, int& unit); > + struct mntent *cygdrive_getmntent (); > }; > > class dos_drive_mappings I wasn't sure about making that a member. The existing code was already accessing things in mount_info via mount_table->whatever. This code could just do that too. > + _my_tls.locals.volumemountpoints = (WCHAR *) malloc (NT_MAX_PATH * > sizeof (WCHAR)); Forgot to check for NULL return and fail. Got that in my working copy now. > struct mntent * > mount_info::getmntent (int x) > { > if (x < 0 || x >= nmounts) > - return cygdrive_getmntent (); > - > + { > + struct mntent *ret; > + /* de-duplicate against explicit mount entries */ > + while ((ret = cygdrive_getmntent ())) > + { > + for (int i = 0; i < nmounts; ++i) > + { > + if (!strcmp (ret->mnt_dir, mount[i].posix_path) && > + strcasematch (ret->mnt_fsname, mount[i].native_path)) This could be improved by using a sorted version, and breaking from the for loop once past where it could possibly still match.