summaryrefslogtreecommitdiff
path: root/sysutils/libgtop2/patches/patch-ad
blob: faf3f1d3f1397a8152a1bb913f5fb9631883ebc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
$NetBSD: patch-ad,v 1.2 2005/03/27 11:18:37 jmmv Exp $

--- sysdeps/freebsd/fsusage.c.orig	2005-02-28 09:54:41.000000000 +0100
+++ sysdeps/freebsd/fsusage.c
@@ -1,3 +1,7 @@
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
 #include <glibtop.h>
 #include <glibtop/error.h>
 #include <glibtop/fsusage.h>
@@ -9,6 +13,9 @@
 #include <unistd.h>
 #include <sys/param.h>
 #include <sys/mount.h>
+#ifdef HAVE_SYS_STATVFS_H
+#include <sys/statvfs.h>
+#endif
 
 #include <stdio.h>
 #include <string.h>
@@ -26,16 +33,26 @@ _glibtop_freebsd_get_fsusage_read_write(
 				      const char *path)
 {
 	int result;
+#ifdef STAT_STATVFS
+	struct statvfs sfs;
+
+	result = statvfs (path, &sfs);
+#else
 	struct statfs sfs;
 
 	result = statfs (path, &sfs);
+#endif
 
 	if (result == -1) {
 		return;
 	}
 
+#ifdef HAVE_STATVFS_READS_COUNT
 	buf->read = sfs.f_syncreads + sfs.f_asyncreads;
+	buf->flags |= (1 << GLIBTOP_FSUSAGE_READ);
+#endif
+#ifdef HAVE_STATVFS_WRITES_COUNT
 	buf->write = sfs.f_syncwrites + sfs.f_asyncwrites;
-
-	buf->flags |= (1 << GLIBTOP_FSUSAGE_READ) | (1 << GLIBTOP_FSUSAGE_WRITE);
+	buf->flags |= (1 << GLIBTOP_FSUSAGE_WRITE);
+#endif
 }