rpms/procps/devel procps-3.2.7-vmstat-partstats-long.patch, NONE, 1.1 procps.spec, 1.73, 1.74

Daniel Novotny dnovotny at fedoraproject.org
Thu Dec 4 16:32:12 UTC 2008


Author: dnovotny

Update of /cvs/extras/rpms/procps/devel
In directory cvs1.fedora.phx.redhat.com:/tmp/cvs-serv12332

Modified Files:
	procps.spec 
Added Files:
	procps-3.2.7-vmstat-partstats-long.patch 
Log Message:

fix #472783, extend to unsigned long


procps-3.2.7-vmstat-partstats-long.patch:

--- NEW FILE procps-3.2.7-vmstat-partstats-long.patch ---
diff -up procps-3.2.7/proc/sysinfo.c.vmstat procps-3.2.7/proc/sysinfo.c
--- procps-3.2.7/proc/sysinfo.c.vmstat	2008-12-04 15:25:50.000000000 +0100
+++ procps-3.2.7/proc/sysinfo.c	2008-12-04 16:54:29.000000000 +0100
@@ -784,6 +784,18 @@ unsigned int getpartitions_num(struct di
 }
 
 /////////////////////////////////////////////////////////////////////////////
+static int is_disk(char *dev)
+{
+  char syspath[PATH_MAX];
+  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){
   FILE* fd;
@@ -791,6 +803,7 @@ unsigned int getdiskstat(struct disk_sta
   int cPartition = 0;
   int fields;
   unsigned dummy;
+  char devname[PATH_MAX];
 
   *disks = NULL;
   *partitions = NULL;
@@ -803,10 +816,11 @@ unsigned int getdiskstat(struct disk_sta
       fclose(fd);
       break;
     }
-    fields = sscanf(buff, " %*d %*d %*s %*u %*u %*u %*u %*u %*u %*u %*u %*u %*u %u", &dummy);
-    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",
+      sscanf(buff,  "   %*d    %*d %15s %lu %lu %llu %lu %lu %lu %llu %lu %lu %lu %lu",
         //&disk_major,
         //&disk_minor,
         (*disks)[cDisk].disk_name,
@@ -827,7 +841,9 @@ unsigned int getdiskstat(struct disk_sta
     }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,
diff -up procps-3.2.7/proc/sysinfo.h.vmstat procps-3.2.7/proc/sysinfo.h
--- procps-3.2.7/proc/sysinfo.h.vmstat	2008-12-04 15:25:41.000000000 +0100
+++ procps-3.2.7/proc/sysinfo.h	2008-12-04 16:54:32.000000000 +0100
@@ -95,16 +95,16 @@ typedef struct disk_stat{
 	unsigned long long reads_sectors;
 	unsigned long long written_sectors;
 	char               disk_name [16];
-	unsigned           inprogress_IO;
-	unsigned           merged_reads;
-	unsigned           merged_writes;
-	unsigned           milli_reading;
-	unsigned           milli_spent_IO;
-	unsigned           milli_writing;
-	unsigned           partitions;
-	unsigned           reads;
-	unsigned           weighted_milli_spent_IO;
-	unsigned           writes;
+	unsigned long          inprogress_IO;
+	unsigned long          merged_reads;
+	unsigned long          merged_writes;
+	unsigned long          milli_reading;
+	unsigned long          milli_spent_IO;
+	unsigned long          milli_writing;
+	unsigned long          partitions;
+	unsigned long          reads;
+	unsigned long          weighted_milli_spent_IO;
+	unsigned long          writes;
 }disk_stat;
 
 typedef struct partition_stat{
@@ -113,7 +113,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: procps.spec
===================================================================
RCS file: /cvs/extras/rpms/procps/devel/procps.spec,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -r1.73 -r1.74
--- procps.spec	1 Sep 2008 09:59:00 -0000	1.73
+++ procps.spec	4 Dec 2008 16:31:41 -0000	1.74
@@ -1,7 +1,7 @@
 Summary: System and process monitoring utilities
 Name: procps
 Version: 3.2.7
-Release: 21%{?dist}
+Release: 22%{?dist}
 License: GPLv2+ and LGPLv2+
 Group: Applications/System
 URL: http://procps.sourceforge.net
@@ -72,6 +72,9 @@
 Patch34: procps-3.2.7-top-clrscr.patch
 #435453 - errors with man -t formatting of ps man page
 Patch35: procps-3.2.7-ps-man-fmt.patch
+#472783 - 'vmstat -p <partition name>', 
+# the detailed statistics of the partition name is not output.
+Patch36: procps-3.2.7-vmstat-partstats-long.patch
 
 BuildRequires: ncurses-devel
 
@@ -132,6 +135,7 @@
 %patch33 -p1
 %patch34 -p1
 %patch35 -p1
+%patch36 -p1
 
 cp %SOURCE1 .
 
@@ -169,6 +173,10 @@
 %attr(0644,root,root) %{_mandir}/man5/*
 
 %changelog
+* Thu Dec 04 2008 Daniel Novotny <dnovotny at redhat.com> 3.2.7-22
+- fix #472783 vmstat -p <partition name> not working
+- extended diskstat parameters to unsigned long to avoid overflow
+
 * Mon Sep 01 2008 Tomas Smetana <tsmetana at redhat.com> 3.2.7-21
 - rebase patches
 - clear screen in top when switching windows




More information about the fedora-extras-commits mailing list