|
|
72abff |
From 9728faf84cdc4acc674cc862a99f57d4e6552beb Mon Sep 17 00:00:00 2001
|
|
|
72abff |
From: Sebastien GODARD <sysstat@users.noreply.github.com>
|
|
|
72abff |
Date: Sun, 22 Jun 2014 16:09:18 +0200
|
|
|
72abff |
Subject: [PATCH] Use statvfs() instead of statfs() system call
|
|
|
72abff |
|
|
|
72abff |
Use statvfs() system call instead of statfs() to get filesystems
|
|
|
72abff |
statistics with sar since:
|
|
|
72abff |
1) statfs() has been deprecated by the LSB (useful only to get fs
|
|
|
72abff |
type which is not needed here),
|
|
|
72abff |
2) statvfs() better handles large file sizes.
|
|
|
72abff |
|
|
|
72abff |
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
|
|
|
72abff |
(cherry picked from commit 0936618a799918422012036aecbf7a2b0ee32354)
|
|
|
72abff |
---
|
|
|
72abff |
rd_stats.c | 18 +++++++++---------
|
|
|
72abff |
1 file changed, 9 insertions(+), 9 deletions(-)
|
|
|
72abff |
|
|
|
72abff |
diff --git a/rd_stats.c b/rd_stats.c
|
|
|
72abff |
index 24a98f7..9f7fc37 100644
|
|
|
72abff |
--- a/rd_stats.c
|
|
|
72abff |
+++ b/rd_stats.c
|
|
|
72abff |
@@ -27,7 +27,7 @@
|
|
|
72abff |
#include <ctype.h>
|
|
|
72abff |
#include <sys/types.h>
|
|
|
72abff |
#include <sys/stat.h>
|
|
|
72abff |
-#include <sys/vfs.h>
|
|
|
72abff |
+#include <sys/statvfs.h>
|
|
|
72abff |
#include <unistd.h>
|
|
|
72abff |
|
|
|
72abff |
#include "common.h"
|
|
|
72abff |
@@ -1918,7 +1918,7 @@ void read_filesystem(struct stats_filesystem *st_filesystem, int nbr)
|
|
|
72abff |
char line[256], fs_name[MAX_FS_LEN], mountp[128];
|
|
|
72abff |
int fs = 0;
|
|
|
72abff |
struct stats_filesystem *st_filesystem_i;
|
|
|
72abff |
- struct statfs buf;
|
|
|
72abff |
+ struct statvfs buf;
|
|
|
72abff |
|
|
|
72abff |
if ((fp = fopen(MTAB, "r")) == NULL)
|
|
|
72abff |
return;
|
|
|
72abff |
@@ -1931,14 +1931,14 @@ void read_filesystem(struct stats_filesystem *st_filesystem, int nbr)
|
|
|
72abff |
|
|
|
72abff |
/* Replace octal codes */
|
|
|
72abff |
oct2chr(mountp);
|
|
|
72abff |
-
|
|
|
72abff |
- if ((statfs(mountp, &buf) < 0) || (!buf.f_blocks))
|
|
|
72abff |
+
|
|
|
72abff |
+ if ((statvfs(mountp, &buf) < 0) || (!buf.f_blocks))
|
|
|
72abff |
continue;
|
|
|
72abff |
|
|
|
72abff |
st_filesystem_i = st_filesystem + fs++;
|
|
|
72abff |
- st_filesystem_i->f_blocks = buf.f_blocks * buf.f_bsize;
|
|
|
72abff |
- st_filesystem_i->f_bfree = buf.f_bfree * buf.f_bsize;
|
|
|
72abff |
- st_filesystem_i->f_bavail = buf.f_bavail * buf.f_bsize;
|
|
|
72abff |
+ st_filesystem_i->f_blocks = buf.f_blocks * buf.f_frsize;
|
|
|
72abff |
+ st_filesystem_i->f_bfree = buf.f_bfree * buf.f_frsize;
|
|
|
72abff |
+ st_filesystem_i->f_bavail = buf.f_bavail * buf.f_frsize;
|
|
|
72abff |
st_filesystem_i->f_files = buf.f_files;
|
|
|
72abff |
st_filesystem_i->f_ffree = buf.f_ffree;
|
|
|
72abff |
strcpy(st_filesystem_i->fs_name, fs_name);
|
|
|
72abff |
@@ -2382,7 +2382,7 @@ int get_filesystem_nr(void)
|
|
|
72abff |
FILE *fp;
|
|
|
72abff |
char line[256], fs_name[MAX_FS_LEN], mountp[128];
|
|
|
72abff |
int fs = 0;
|
|
|
72abff |
- struct statfs buf;
|
|
|
72abff |
+ struct statvfs buf;
|
|
|
72abff |
|
|
|
72abff |
if ((fp = fopen(MTAB, "r")) == NULL)
|
|
|
72abff |
/* File non-existent */
|
|
|
72abff |
@@ -2399,7 +2399,7 @@ int get_filesystem_nr(void)
|
|
|
72abff |
oct2chr(mountp);
|
|
|
72abff |
|
|
|
72abff |
/* Check that total size is not null */
|
|
|
72abff |
- if (statfs(mountp, &buf) < 0)
|
|
|
72abff |
+ if (statvfs(mountp, &buf) < 0)
|
|
|
72abff |
continue;
|
|
|
72abff |
|
|
|
72abff |
if (buf.f_blocks) {
|
|
|
72abff |
--
|
|
|
72abff |
2.14.3
|
|
|
72abff |
|