summaryrefslogtreecommitdiffstats
path: root/patches/procps-3.2.8/65_fix_partition_format.dpatch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/procps-3.2.8/65_fix_partition_format.dpatch')
-rw-r--r--patches/procps-3.2.8/65_fix_partition_format.dpatch85
1 files changed, 85 insertions, 0 deletions
diff --git a/patches/procps-3.2.8/65_fix_partition_format.dpatch b/patches/procps-3.2.8/65_fix_partition_format.dpatch
new file mode 100644
index 000000000..d60f98627
--- /dev/null
+++ b/patches/procps-3.2.8/65_fix_partition_format.dpatch
@@ -0,0 +1,85 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## 65_fix_partition_format.dpatch by Daniel Novotny (see
+## https://bugzilla.redhat.com/show_bug.cgi?id=485243 )
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: The contents of /proc/diskstats have changed since 2.6.25
+
+@DPATCH@
+diff -urNad procps-3.2.7~/proc/sysinfo.c procps-3.2.7/proc/sysinfo.c
+--- procps-3.2.7~/proc/sysinfo.c 2009-05-27 18:33:13.443866133 +0000
++++ procps-3.2.7/proc/sysinfo.c 2009-05-27 18:33:13.735867382 +0000
+@@ -780,6 +780,18 @@
+ }
+
+ /////////////////////////////////////////////////////////////////////////////
++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;
+@@ -787,6 +799,7 @@
+ int cPartition = 0;
+ int fields;
+ unsigned dummy;
++ char devname[PATH_MAX];
+
+ *disks = NULL;
+ *partitions = NULL;
+@@ -799,8 +812,9 @@
+ 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",
+ //&disk_major,
+@@ -823,7 +837,9 @@
+ }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 -urNad procps-3.2.7~/proc/sysinfo.h procps-3.2.7/proc/sysinfo.h
+--- procps-3.2.7~/proc/sysinfo.h 2009-05-27 18:32:49.000000000 +0000
++++ procps-3.2.7/proc/sysinfo.h 2009-05-27 18:33:13.735867382 +0000
+@@ -113,7 +113,7 @@
+ 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);
+diff -urNad procps-3.2.7~/vmstat.c procps-3.2.7/vmstat.c
+--- procps-3.2.7~/vmstat.c 2009-05-27 18:33:13.603867748 +0000
++++ procps-3.2.7/vmstat.c 2009-05-27 18:33:13.735867382 +0000
+@@ -286,7 +286,7 @@
+ 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){