diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index cf18bb19d..2ebd950a1 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2014-10-16 Corinna Vinschen + + * fhandler_proc.cc (format_proc_partitions): Extend output to print + the windows mount points the device is mounted on. + 2014-10-14 Corinna Vinschen * fhandler_socket.cc (fhandler_socket::connect): Don't change state diff --git a/winsup/cygwin/fhandler_proc.cc b/winsup/cygwin/fhandler_proc.cc index 796d58d9f..1c335c429 100644 --- a/winsup/cygwin/fhandler_proc.cc +++ b/winsup/cygwin/fhandler_proc.cc @@ -1184,6 +1184,10 @@ format_proc_partitions (void *, char *&destbuf) char *buf = tp.c_get (); char *bufptr = buf; char *ioctl_buf = tp.c_get (); + PWCHAR mp_buf = tp.w_get (); + WCHAR fpath[MAX_PATH]; + WCHAR gpath[MAX_PATH]; + DWORD len; /* Open \Device object directory. */ wchar_t wpath[MAX_PATH] = L"\\Device"; @@ -1222,13 +1226,12 @@ format_proc_partitions (void *, char *&destbuf) continue; /* Got it. Now construct the path to the entire disk, which is "\\Device\\HarddiskX\\Partition0", and open the disk with - minimum permssions. */ + minimum permissions. */ unsigned long drive_num = wcstoul (dbi->ObjectName.Buffer + 8, NULL, 10); wcscpy (wpath, dbi->ObjectName.Buffer); PWCHAR wpart = wpath + dbi->ObjectName.Length / sizeof (WCHAR); - __small_swprintf (wpart, L"\\Partition0"); - upath.Length = dbi->ObjectName.Length - + wcslen (wpart) * sizeof (WCHAR); + wcpcpy (wpart, L"\\Partition0"); + upath.Length = dbi->ObjectName.Length + 22; upath.MaximumLength = upath.Length + sizeof (WCHAR); InitializeObjectAttributes (&attr, &upath, OBJ_CASE_INSENSITIVE, dirhdl, NULL); @@ -1242,7 +1245,7 @@ format_proc_partitions (void *, char *&destbuf) } if (!got_one) { - print ("major minor #blocks name\n\n"); + print ("major minor #blocks name win-mounts\n\n"); got_one = true; } /* Fetch partition info for the entire disk to get its size. */ @@ -1311,9 +1314,27 @@ format_proc_partitions (void *, char *&destbuf) if (part_num == 0) continue; dev.parsedisk (drive_num, part_num); - bufptr += __small_sprintf (bufptr, "%5d %5d %9U %s\n", + + bufptr += __small_sprintf (bufptr, "%5d %5d %9U %s", dev.get_major (), dev.get_minor (), size >> 10, dev.name + 5); + /* Check if the partition is mounted in Windows and, if so, + print the mount point list. */ + __small_swprintf (fpath, + L"\\\\?\\GLOBALROOT\\Device\\%S\\Partition%u\\", + &dbi->ObjectName, part_num); + if (GetVolumeNameForVolumeMountPointW (fpath, gpath, MAX_PATH) + && GetVolumePathNamesForVolumeNameW (gpath, mp_buf, + NT_MAX_PATH, &len)) + { + len = strlen (dev.name + 5); + while (len++ < 6) + *bufptr++ = ' '; + for (PWCHAR p = mp_buf; *p; p = wcschr (p, L'\0') + 1) + bufptr += __small_sprintf (bufptr, " %W", p); + } + + *bufptr++ = '\n'; } NtClose (devhdl); }