summaryrefslogtreecommitdiff
path: root/net/nagios-plugin-snmp/patches/patch-ak
blob: 2dd1f0d7dfe0c68c1875ab54f6a03bd22c20c4dd (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
$NetBSD: patch-ak,v 1.1.1.1 2006/02/18 17:23:43 bouyer Exp $

--- lib/mountlist.c.orig	2005-10-14 22:09:29.000000000 +0200
+++ lib/mountlist.c	2005-10-14 22:23:14.000000000 +0200
@@ -66,7 +66,11 @@
 # if HAVE_STRUCT_FSSTAT_F_FSTYPENAME
 #  define FS_TYPE(Ent) ((Ent).f_fstypename)
 # else
-#  define FS_TYPE(Ent) mnt_names[(Ent).f_type]
+#  ifdef STAT_STATVFS
+#   define FS_TYPE(Ent) mnt_names[(Ent).f_fsid]
+#  else
+#   define FS_TYPE(Ent) mnt_names[(Ent).f_type]
+#  endif
 # endif
 #endif /* MOUNTED_GETFSSTAT */
 
@@ -109,6 +113,10 @@
 # include <sys/statfs.h>
 #endif
 
+#ifdef HAVE_SYS_STATVFS_H
+#include <sys/statvfs.h>
+#endif
+
 #ifdef MOUNTED_LISTMNTENT
 # include <mntent.h>
 #endif
@@ -173,7 +181,7 @@
 
 #if MOUNTED_GETMNTINFO
 
-# if ! HAVE_F_FSTYPENAME_IN_STATFS
+# if ! HAVE_F_FSTYPENAME_IN_STATFS && ! STAT_STATVFS
 static char *
 fstype_to_string (short t)
 {
@@ -271,12 +279,16 @@
 
 /* __NetBSD__ || BSD_NET2 || __OpenBSD__ */
 static char *
+#ifdef STAT_STATVFS
+fsp_to_string (const struct statvfs *fsp)
+#else
 fsp_to_string (const struct statfs *fsp)
+#endif
 {
-# if defined HAVE_F_FSTYPENAME_IN_STATFS
+# if defined HAVE_F_FSTYPENAME_IN_STATFS || defined STAT_STATVFS
   return (char *) (fsp->f_fstypename);
 # else
-  return fstype_to_string (fsp->f_type);
+   return fstype_to_string (fsp->f_type);
 # endif
 }
 
@@ -381,7 +393,11 @@
 
 #ifdef MOUNTED_GETMNTINFO	/* 4.4BSD.  */
   {
+#ifdef STAT_STATVFS
+    struct statvfs *fsp;
+#else
     struct statfs *fsp;
+#endif
     int entries;
 
     entries = getmntinfo (&fsp, MNT_NOWAIT);
@@ -543,9 +559,17 @@
   {
     int numsys, counter;
     size_t bufsize;
+#ifdef STAT_STATVFS
+    struct statvfs *stats;
+#else
     struct statfs *stats;
+#endif
 
+#ifdef STAT_STATVFS
+    numsys = getfsstat ((struct statvfs *)0, 0L, MNT_NOWAIT);
+#else
     numsys = getfsstat ((struct statfs *)0, 0L, MNT_NOWAIT);
+#endif
     if (numsys < 0)
       return (NULL);
     if (SIZE_MAX / sizeof *stats <= numsys)
@@ -608,10 +632,18 @@
 # ifdef GETFSTYP			/* SVR3.  */
 	if (need_fs_type)
 	  {
+#ifdef STAT_STATVFS
+	    struct statvfs fsd;
+#else
 	    struct statfs fsd;
+#endif
 	    char typebuf[FSTYPSZ];
 
+#ifdef STAT_STATVFS
+	    if (statvfs (me->me_mountdir, &fsd, sizeof fsd, 0) != -1
+#else
 	    if (statfs (me->me_mountdir, &fsd, sizeof fsd, 0) != -1
+#endif
 		&& sysfs (GETFSTYP, fsd.f_fstyp, typebuf) != -1)
 	      {
 		me->me_type = xstrdup (typebuf);