Check for presence of disks in vmstat

vmstat -d or vmstat -p would crash mysteriously under different
circumstances. The problem was eventually tracked down to /sys not
being mounted which meant is_disk() always returned false.
The partition would then be attempted to be linked to a non-existent
disk causing a segfault.

vmstat will now not link to a disk if none exists.
The change in testing will skip those tests when /sys/block doesn't
exist.

Many thanks to Daniel Schepler for his analysis and suggestions.

Bug-Debian: http://bugs.debian.org/736628
This commit is contained in:
Craig Small
2014-01-29 22:22:11 +11:00
parent 4359cf0698
commit 5a34ff0a99
2 changed files with 20 additions and 9 deletions

View File

@ -938,8 +938,11 @@ unsigned int getdiskstat(struct disk_stat **disks, struct partition_stat **parti
&(*partitions)[cPartition].writes,
&(*partitions)[cPartition].requested_writes
);
(*partitions)[cPartition++].parent_disk = cDisk-1;
(*disks)[cDisk-1].partitions++;
if (cDisk > 0) {
(*partitions)[cPartition++].parent_disk = cDisk-1;
(*disks)[cDisk-1].partitions++;
}
}
}