summaryrefslogtreecommitdiffstats
path: root/patches/procps-3.2.8/0055-vmstat_part_format.patch
diff options
context:
space:
mode:
Diffstat (limited to 'patches/procps-3.2.8/0055-vmstat_part_format.patch')
-rw-r--r--patches/procps-3.2.8/0055-vmstat_part_format.patch94
1 files changed, 94 insertions, 0 deletions
diff --git a/patches/procps-3.2.8/0055-vmstat_part_format.patch b/patches/procps-3.2.8/0055-vmstat_part_format.patch
new file mode 100644
index 000000000..3146ac808
--- /dev/null
+++ b/patches/procps-3.2.8/0055-vmstat_part_format.patch
@@ -0,0 +1,94 @@
+From f619f8629a5915c900f984c1caf44241ff077f32 Mon Sep 17 00:00:00 2001
+From: http://ftp.de.debian.org/debian/pool/main/p/procps/procps_3.2.8-8.debian.tar.gz <info@debian.org>
+Date: Fri, 19 Mar 2010 21:58:46 +0100
+Subject: [PATCH 55/70] vmstat_part_format
+
+---
+ proc/sysinfo.c | 22 +++++++++++++++++++---
+ proc/sysinfo.h | 2 +-
+ vmstat.c | 2 +-
+ 3 files changed, 21 insertions(+), 5 deletions(-)
+
+diff --git a/proc/sysinfo.c b/proc/sysinfo.c
+index 8dbabdf..444ee5b 100644
+--- a/proc/sysinfo.c
++++ b/proc/sysinfo.c
+@@ -796,6 +796,18 @@ unsigned int getpartitions_num(struct disk_stat *disks, int ndisks){
+ }
+
+ /////////////////////////////////////////////////////////////////////////////
++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;
+@@ -803,6 +815,7 @@ unsigned int getdiskstat(struct disk_stat **disks, struct partition_stat **parti
+ int cPartition = 0;
+ int fields;
+ unsigned dummy;
++ char devname[PATH_MAX];
+
+ *disks = NULL;
+ *partitions = NULL;
+@@ -815,8 +828,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);
+- 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,
+@@ -839,7 +853,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,
+diff --git a/proc/sysinfo.h b/proc/sysinfo.h
+index e30a38b..494c4b3 100644
+--- a/proc/sysinfo.h
++++ b/proc/sysinfo.h
+@@ -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);
+diff --git a/vmstat.c b/vmstat.c
+index e0d3c23..e81a4ac 100644
+--- 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){
+--
+1.7.0
+