* fhandler_proc.cc (format_proc_partitions): Extend output to print

the windows mount points the device is mounted on.
This commit is contained in:
Corinna Vinschen 2014-10-16 15:35:10 +00:00
parent ec2a57f476
commit a3dfd53a74
2 changed files with 32 additions and 6 deletions

View File

@ -1,3 +1,8 @@
2014-10-16 Corinna Vinschen <corinna@vinschen.de>
* fhandler_proc.cc (format_proc_partitions): Extend output to print
the windows mount points the device is mounted on.
2014-10-14 Corinna Vinschen <corinna@vinschen.de>
* fhandler_socket.cc (fhandler_socket::connect): Don't change state

View File

@ -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);
}