39 lines
886 B
Plaintext
39 lines
886 B
Plaintext
---
|
|
vmstat.c | 7 +++----
|
|
1 file changed, 3 insertions(+), 4 deletions(-)
|
|
|
|
--- vmstat.c
|
|
+++ vmstat.c 2018-04-04 11:16:07.577968520 +0000
|
|
@@ -40,6 +40,7 @@
|
|
#include <string.h>
|
|
#include <sys/ioctl.h>
|
|
#include <sys/types.h>
|
|
+#include <sys/stat.h>
|
|
#include <termios.h>
|
|
#include <unistd.h>
|
|
#include <time.h>
|
|
@@ -686,13 +687,12 @@ static void slabheader(void)
|
|
|
|
static void slabformat(void)
|
|
{
|
|
- FILE *fSlab;
|
|
+ struct stat fSlab;
|
|
struct slab_cache *slabs;
|
|
unsigned long nSlab, i, j, k;
|
|
const char format[] = "%-24s %6u %6u %6u %6u\n";
|
|
|
|
- fSlab = fopen("/proc/slabinfo", "rb");
|
|
- if (!fSlab) {
|
|
+ if (stat("/proc/slabinfo", &fSlab) < 0) {
|
|
xwarnx(_("your kernel does not support slabinfo or your permissions are insufficient"));
|
|
return;
|
|
}
|
|
@@ -724,7 +724,6 @@ static void slabformat(void)
|
|
}
|
|
free(slabs);
|
|
}
|
|
- fclose(fSlab);
|
|
}
|
|
|
|
static void disksum_format(void)
|