Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2014-10-16 19:35:10 +0400
committerCorinna Vinschen <corinna@vinschen.de>2014-10-16 19:35:10 +0400
commita3dfd53a74e65b8acac10292f9da1406d379eb9e (patch)
tree83bc5ac5b5c9763fdcd49cadf7ed048212e6502e /winsup/cygwin/fhandler_proc.cc
parentec2a57f4764ae33d232399166243898b23055cf3 (diff)
* fhandler_proc.cc (format_proc_partitions): Extend output to print
the windows mount points the device is mounted on.
Diffstat (limited to 'winsup/cygwin/fhandler_proc.cc')
-rw-r--r--winsup/cygwin/fhandler_proc.cc33
1 files changed, 27 insertions, 6 deletions
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);
}