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:
@@ -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,
|
||||
|
Reference in New Issue
Block a user