fix handling of mmcblkN SD disk partition numbers
Partition numbers for mmcblkN disks have partition numbers with a leading 'p' and a bug caused these partitions to be considered full disks.
This commit is contained in:
parent
eff1865a4b
commit
7f9617d817
|
@ -537,6 +537,8 @@ gkrellm_disk_subdisk_assign_data_by_name(gchar *subdisk_name, gchar *disk_name,
|
||||||
| appended. Eg. "hda1" is a subdisk_name of disk_name "hda"
|
| appended. Eg. "hda1" is a subdisk_name of disk_name "hda"
|
||||||
*/
|
*/
|
||||||
s = subdisk_name + strlen(disk_name);
|
s = subdisk_name + strlen(disk_name);
|
||||||
|
if (*s == 'p') /* except mmcblkN SD disks have "pN" partition numbers */
|
||||||
|
++s;
|
||||||
subdisk = strtol(s, &endptr, 0);
|
subdisk = strtol(s, &endptr, 0);
|
||||||
if (!*s || *endptr)
|
if (!*s || *endptr)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -366,6 +366,8 @@ gkrellm_disk_subdisk_assign_data_by_name(gchar *subdisk_name, gchar *disk_name,
|
||||||
| appended. Eg. "hda1" is a subdisk_name of disk_name "hda"
|
| appended. Eg. "hda1" is a subdisk_name of disk_name "hda"
|
||||||
*/
|
*/
|
||||||
s = subdisk_name + strlen(disk_name);
|
s = subdisk_name + strlen(disk_name);
|
||||||
|
if (*s == 'p') /* except mmcblkN SD disks have "pN" partition numbers */
|
||||||
|
++s;
|
||||||
subdisk = strtol(s, &endptr, 0);
|
subdisk = strtol(s, &endptr, 0);
|
||||||
if (!*s || *endptr)
|
if (!*s || *endptr)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -412,6 +412,7 @@ static struct _disk_name_map
|
||||||
{"cc5d", COMPAQ_CISS_MAJOR + 5, 16, '0' }, /* 109: c5d0-c5d15 */
|
{"cc5d", COMPAQ_CISS_MAJOR + 5, 16, '0' }, /* 109: c5d0-c5d15 */
|
||||||
{"cc6d", COMPAQ_CISS_MAJOR + 6, 16, '0' }, /* 110: c6d0-c6d15 */
|
{"cc6d", COMPAQ_CISS_MAJOR + 6, 16, '0' }, /* 110: c6d0-c6d15 */
|
||||||
{"cc7d", COMPAQ_CISS_MAJOR + 7, 16, '0' }, /* 111: c7d0-c7d15 */
|
{"cc7d", COMPAQ_CISS_MAJOR + 7, 16, '0' }, /* 111: c7d0-c7d15 */
|
||||||
|
|
||||||
{"dm-", DM_MAJOR, 256, '0' }, /* 254: dm-0 - dm-255 */
|
{"dm-", DM_MAJOR, 256, '0' }, /* 254: dm-0 - dm-255 */
|
||||||
|
|
||||||
{"fd", FLOPPY_MAJOR, 0, '0' } /* 2: fd0-fd3 */
|
{"fd", FLOPPY_MAJOR, 0, '0' } /* 2: fd0-fd3 */
|
||||||
|
@ -499,6 +500,7 @@ disk_get_device_name(gint major, gint minor, gchar *disk, gchar *partition)
|
||||||
struct _disk_name_map *dm = NULL;
|
struct _disk_name_map *dm = NULL;
|
||||||
gint i, unit = 0;
|
gint i, unit = 0;
|
||||||
gchar *p, *d;
|
gchar *p, *d;
|
||||||
|
gboolean valid_partition_number = FALSE;
|
||||||
|
|
||||||
for (p = partition; *p; ++p)
|
for (p = partition; *p; ++p)
|
||||||
if (*p == '/')
|
if (*p == '/')
|
||||||
|
@ -509,7 +511,16 @@ disk_get_device_name(gint major, gint minor, gchar *disk, gchar *partition)
|
||||||
p = partition;
|
p = partition;
|
||||||
while (*d && *p && *d++ == *p++)
|
while (*d && *p && *d++ == *p++)
|
||||||
;
|
;
|
||||||
if (d == disk || *d || *p < '0' || *p > '9')
|
|
||||||
|
/* Check that p points to valid partition number. Should be a digit
|
||||||
|
| unless disk is mmcblkN where the partition number has a leading 'p'
|
||||||
|
*/
|
||||||
|
if (*p == 'p' && !strncmp(partition, "mmcblk", 6))
|
||||||
|
++p;
|
||||||
|
if (*p >= '0' && *p <= '9')
|
||||||
|
valid_partition_number = TRUE;
|
||||||
|
|
||||||
|
if (d == disk || *d || !valid_partition_number)
|
||||||
{
|
{
|
||||||
strcpy(disk, partition);
|
strcpy(disk, partition);
|
||||||
partition[0] = '\0';
|
partition[0] = '\0';
|
||||||
|
@ -596,6 +607,7 @@ linux_read_proc_diskstats(void)
|
||||||
)
|
)
|
||||||
continue;
|
continue;
|
||||||
is_MD = (major == MD_MAJOR);
|
is_MD = (major == MD_MAJOR);
|
||||||
|
|
||||||
if (part[0] == '\0')
|
if (part[0] == '\0')
|
||||||
gkrellm_disk_assign_data_by_name(disk, 512 * rd, 512 * wr, is_MD);
|
gkrellm_disk_assign_data_by_name(disk, 512 * rd, 512 * wr, is_MD);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in New Issue