vmstat -p <part> works and updated version to 3.3.1

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
This commit is contained in:
Craig Small 2011-11-27 22:47:17 +11:00
parent 618c52167b
commit 20463f1a13
5 changed files with 30 additions and 7 deletions

8
NEWS
View File

@ -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.

View 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])

View 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,

View 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);

View File

@ -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){