Handle up to 63 partitions per drive
Revamp device parsing code. Introducing support for more partitions into the shilka-generated parser has the unfortunate side-effect of raising the size of the DLL by almost 2 Megs. Therefore we split out the handling for /dev/sdXY devices into a tiny bit of hand-written code. While at it, remove some unused cruft from devices.* and generally clean up the device class to provide access methods instead of direct access to members. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
@ -1334,7 +1334,6 @@ format_proc_partitions (void *, char *&destbuf)
|
||||
DWORD bytes_read;
|
||||
DWORD part_cnt = 0;
|
||||
unsigned long long size;
|
||||
device dev;
|
||||
|
||||
restart = FALSE;
|
||||
/* ... and check for a "Harddisk[0-9]*" entry. */
|
||||
@ -1385,10 +1384,10 @@ format_proc_partitions (void *, char *&destbuf)
|
||||
"IOCTL_DISK_GET_PARTITION_INFO{_EX}) %E", &upath);
|
||||
size = 0;
|
||||
}
|
||||
dev.parsedisk (drive_num, 0);
|
||||
device dev (drive_num, 0);
|
||||
bufptr += __small_sprintf (bufptr, "%5d %5d %9U %s\n",
|
||||
dev.get_major (), dev.get_minor (),
|
||||
size >> 10, dev.name + 5);
|
||||
size >> 10, dev.name () + 5);
|
||||
/* Fetch drive layout info to get size of all partitions on the disk. */
|
||||
if (DeviceIoControl (devhdl, IOCTL_DISK_GET_DRIVE_LAYOUT_EX,
|
||||
NULL, 0, ioctl_buf, NT_MAX_PATH, &bytes_read, NULL))
|
||||
@ -1410,7 +1409,7 @@ format_proc_partitions (void *, char *&destbuf)
|
||||
"IOCTL_DISK_GET_DRIVE_LAYOUT{_EX}): %E", &upath);
|
||||
/* Loop over partitions. */
|
||||
if (pix || pi)
|
||||
for (DWORD i = 0; i < part_cnt; ++i)
|
||||
for (DWORD i = 0; i < part_cnt && i < 64; ++i)
|
||||
{
|
||||
DWORD part_num;
|
||||
|
||||
@ -1431,11 +1430,11 @@ format_proc_partitions (void *, char *&destbuf)
|
||||
Just skip. */
|
||||
if (part_num == 0)
|
||||
continue;
|
||||
dev.parsedisk (drive_num, part_num);
|
||||
device dev (drive_num, part_num);
|
||||
|
||||
bufptr += __small_sprintf (bufptr, "%5d %5d %9U %s",
|
||||
dev.get_major (), dev.get_minor (),
|
||||
size >> 10, dev.name + 5);
|
||||
size >> 10, dev.name () + 5);
|
||||
/* Check if the partition is mounted in Windows and, if so,
|
||||
print the mount point list. */
|
||||
__small_swprintf (fpath,
|
||||
@ -1445,7 +1444,7 @@ format_proc_partitions (void *, char *&destbuf)
|
||||
&& GetVolumePathNamesForVolumeNameW (gpath, mp_buf,
|
||||
NT_MAX_PATH, &len))
|
||||
{
|
||||
len = strlen (dev.name + 5);
|
||||
len = strlen (dev.name () + 5);
|
||||
while (len++ < 6)
|
||||
*bufptr++ = ' ';
|
||||
for (PWCHAR p = mp_buf; *p; p = wcschr (p, L'\0') + 1)
|
||||
|
Reference in New Issue
Block a user