]> granicus.if.org Git - procps-ng/commitdiff
vmstat: disallow 'disks' under that 'partition' switch
authorJim Warner <james.warner@comcast.net>
Mon, 11 Jul 2016 05:00:00 +0000 (00:00 -0500)
committerCraig Small <csmall@enc.com.au>
Sat, 16 Jul 2016 22:49:48 +0000 (08:49 +1000)
Emulating the presumed proper behavior of the original
program, when the -p switch is used we will now report
an error if that provided name matches some disk name.

Signed-off-by: Jim Warner <james.warner@comcast.net>
vmstat.c

index 0b1d79a31aa57cbff2fc8f27bbf69b02f30e0f59..3c37ab54bddb18df9512a89ae597780e79860fb1 100644 (file)
--- a/vmstat.c
+++ b/vmstat.c
@@ -479,8 +479,8 @@ static int diskpartition_format(const char *partition_name)
     if (procps_diskstat_read(disk_stat) < 0)
         xerr(EXIT_FAILURE,
              _("Unable to read diskstat"));
-    if ((partid = procps_diskstat_dev_getbyname(disk_stat, partition_name))
-        < 0)
+    if ((partid = procps_diskstat_dev_getbyname(disk_stat, partition_name)) < 0
+    || procps_diskstat_dev_isdisk(disk_stat, partid))
         xerrx(EXIT_FAILURE, _("Partition %s not found"), partition_name);
 
     diskpartition_header(partition_name);