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> --- I finally got a chance to test on a machine that still has a physical floppy drive, and running "mount" resulted in the annoying floppy-drive-spinup sound. I changed next_dos_mount () to return both the device and mount point, and used the existing logic from get_disk_type without the extra call to QueryDosDeviceW. This same function could be used by https://cygwin.com/pipermail/cygwin-patches/2023q3/012436.html if that ever comes up again. winsup/cygwin/local_includes/mount.h | 8 ++++++- winsup/cygwin/mount.cc | 31 ++++++++++++++++++---------- 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/winsup/cygwin/local_includes/mount.h b/winsup/cygwin/local_includes/mount.h index 3049de8ba3..2ae67a7035 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! @@ -239,6 +240,11 @@ public: dos_drive_mappings (); ~dos_drive_mappings (); wchar_t *fixup_if_match (wchar_t *path); - const wchar_t *next_dos_mount (); + struct dos_device_mountpoint + { + const wchar_t *device; + const wchar_t *mountpoint; + }; + dos_device_mountpoint next_dos_mount (); }; #endif diff --git a/winsup/cygwin/mount.cc b/winsup/cygwin/mount.cc index b8d8d4a974..a3d9e5bd0f 100644 --- a/winsup/cygwin/mount.cc +++ b/winsup/cygwin/mount.cc @@ -1742,17 +1742,19 @@ struct mntent * mount_info::cygdrive_getmntent () { tmp_pathbuf tp; - const wchar_t *wide_path; + dos_drive_mappings::dos_device_mountpoint dos_mount; char *win32_path, *posix_path; if (!_my_tls.locals.drivemappings) _my_tls.locals.drivemappings = new dos_drive_mappings (); - wide_path = _my_tls.locals.drivemappings->next_dos_mount (); - if (wide_path) + dos_mount = _my_tls.locals.drivemappings->next_dos_mount (); + while (dos_mount.device && get_device_type (dos_mount.device) == DT_FLOPPY) + dos_mount = _my_tls.locals.drivemappings->next_dos_mount (); + if (dos_mount.mountpoint) { win32_path = tp.c_get (); - sys_wcstombs (win32_path, NT_MAX_PATH, wide_path); + sys_wcstombs (win32_path, NT_MAX_PATH, dos_mount.mountpoint); posix_path = tp.c_get (); cygdrive_posix_path (win32_path, posix_path, 0); return fillout_mntent (win32_path, posix_path, cygdrive_flags); @@ -1899,11 +1901,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 +1934,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 *) { @@ -2106,7 +2115,7 @@ dos_drive_mappings::fixup_if_match (wchar_t *path) return path; } -const wchar_t * +dos_drive_mappings::dos_device_mountpoint dos_drive_mappings::next_dos_mount () { if (cur_dos) @@ -2118,10 +2127,10 @@ dos_drive_mappings::next_dos_mount () else cur_mapping = mappings; if (!cur_mapping) - return NULL; + return {NULL, NULL}; cur_dos = &cur_mapping->dos; } - return cur_dos->path; + return {cur_mapping->ntdevpath, cur_dos->path}; } dos_drive_mappings::~dos_drive_mappings () -- 2.48.1.windows.1