]> granicus.if.org Git - procps-ng/commitdiff
vmstat -p <part> works and updated version to 3.3.1
authorCraig Small <csmall@enc.com.au>
Sun, 27 Nov 2011 11:47:17 +0000 (22:47 +1100)
committerCraig Small <csmall@enc.com.au>
Sun, 27 Nov 2011 11:47:17 +0000 (22:47 +1100)
configure.ac now set to 3.3.1
vmstat -p has not worked for a long time, this applies Debian patch
vmstat_part_format, the details:

Author: Daniel Novotny
Description: The contents of /proc/diskstats have changed since 2.6.25
 Changed PATH_MAX to 32 because its missing on hurd
Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=485243
Bug-Debian: http://bugs.debian.org/588677
Last-Update: 2010-11-17

NEWS
configure.ac
proc/sysinfo.c
proc/sysinfo.h
vmstat.c

diff --git a/NEWS b/NEWS
index d7169cce599083efb65e9a4800ceb1a7bb6e1b55..564074878423e18a15d1548d8c14bb05c170ec93 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,11 @@
+procps-3.3.0 --> procps-ng-3.3.1
+--------------------------------
+
+  * Fixed pgrep -u not finding processes
+  * Fixed pgrep crashing
+  * vmstat -p <part> finds partitions. Was Debian patch vmstat_part_format
+    fixes closed bugs RH#485243 and Debian#588677
+
 procps-3.2.8 --> procps-ng-3.3.0
 ------------------------------------------------------
 Debian, Fedora and openSUSE fork of procps.
index 88aaafda878244a7c2971461dd2e64efe15d8466..83cb56f099c94310cc2cdcf60a689478ec5a03d0 100644 (file)
@@ -4,7 +4,7 @@
 AC_PREREQ([2.64])
 AC_CONFIG_MACRO_DIR([m4])
 AC_INIT([procps-ng],
-       [3.3.0],
+       [3.3.1],
        [procps@freelists.org],,[http://gitorious.org/procps])
 AM_INIT_AUTOMAKE
 AC_CONFIG_SRCDIR([top.c])
index 3fe70da05f81d8632edce902d59aa0cda2771703..8e3ea19d3b23aa9d1f28bc11204dfd0f24a0b99d 100644 (file)
@@ -835,6 +835,18 @@ unsigned int getpartitions_num(struct disk_stat *disks, int ndisks){
 
 }
 
+/////////////////////////////////////////////////////////////////////////////
+static int is_disk(char *dev)
+{
+  char syspath[32];
+  char *slash;
+
+  while ((slash = strchr(dev, '/')))
+    *slash = '!';
+  snprintf(syspath, sizeof(syspath), "/sys/block/%s", dev);
+  return !(access(syspath, F_OK));
+}
+
 /////////////////////////////////////////////////////////////////////////////
 
 unsigned int getdiskstat(struct disk_stat **disks, struct partition_stat **partitions){
@@ -843,6 +855,7 @@ unsigned int getdiskstat(struct disk_stat **disks, struct partition_stat **parti
   int cPartition = 0;
   int fields;
   unsigned dummy;
+  char devname[32];
 
   *disks = NULL;
   *partitions = NULL;
@@ -855,9 +868,9 @@ unsigned int getdiskstat(struct disk_stat **disks, struct partition_stat **parti
       fclose(fd);
       break;
     }
-    fields = sscanf(buff, " %*d %*d %*s %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %u", &dummy);
-    (*disks) = realloc(*disks, (cDisk+1)*sizeof(struct disk_stat));
-    if (fields == 1){
+    fields = sscanf(buff, " %*d %*d %15s %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %u", devname, &dummy);
+    if (fields == 2 && is_disk(devname)){
+      (*disks) = realloc(*disks, (cDisk+1)*sizeof(struct disk_stat));
       sscanf(buff,  "   %*d    %*d %15s %u %u %llu %u %u %u %llu %u %u %u %u",
         //&disk_major,
         //&disk_minor,
@@ -879,7 +892,9 @@ unsigned int getdiskstat(struct disk_stat **disks, struct partition_stat **parti
     }else{
       (*partitions) = realloc(*partitions, (cPartition+1)*sizeof(struct partition_stat));
       fflush(stdout);
-      sscanf(buff,  "   %*d    %*d %15s %u %llu %u %u",
+      sscanf(buff,  (fields == 2)
+          ? "   %*d    %*d %15s %u %*u %llu %*u %u %*u %llu %*u %*u %*u %*u"
+          : "   %*d    %*d %15s %u %llu %u %llu",
         //&part_major,
         //&part_minor,
         (*partitions)[cPartition].partition_name,
index 194cb2a63db1146ef87ed26ad7bcdcc6b34386e2..8dbb9795eed4af06e64c32583600f73108ea3064 100644 (file)
@@ -114,7 +114,7 @@ typedef struct partition_stat{
        unsigned           parent_disk;  // index into a struct disk_stat array
        unsigned           reads;
        unsigned           writes;
-       unsigned           requested_writes;
+       unsigned long long requested_writes;
 }partition_stat;
 
 extern unsigned int getpartitions_num(struct disk_stat *disks, int ndisks);
index 756ec4f96b459684d07cc9b65beca89df309e681..e7a28d75e51129be8412427d65aa2e5e7c32109e 100644 (file)
--- a/vmstat.c
+++ b/vmstat.c
@@ -286,7 +286,7 @@ static int diskpartition_format(const char* partition_name){
     struct disk_stat *disks;
     struct partition_stat *partitions, *current_partition=NULL;
     unsigned long ndisks, j, k, npartitions;
-    const char format[] = "%20u %10llu %10u %10u\n";
+    const char format[] = "%20u %10llu %10u %10llu\n";
 
     fDiskstat=fopen("/proc/diskstats","rb");
     if(!fDiskstat){