summaryrefslogtreecommitdiffstats
path: root/gl/fsusage.c
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2010-04-07 21:11:46 -0400
committerThomas Guyot-Sionnest <dermoth@aei.ca>2010-04-12 21:26:35 -0400
commit74da141e618ef99959d509cb2e7be35a348a39db (patch)
tree88ebc38b381a1021fc2d74864a71e230ae591c3d /gl/fsusage.c
parentc63a4f726a0b6ad8cf6040f947754a81fd4683bb (diff)
downloadmonitoring-plugins-74da141e618ef99959d509cb2e7be35a348a39db.tar.gz
Sync with the latest Gnulib code (177f525)
Signed-off-by: Thomas Guyot-Sionnest <dermoth@aei.ca>
Diffstat (limited to 'gl/fsusage.c')
-rw-r--r--gl/fsusage.c38
1 files changed, 19 insertions, 19 deletions
diff --git a/gl/fsusage.c b/gl/fsusage.c
index db0d3bc5..10db467d 100644
--- a/gl/fsusage.c
+++ b/gl/fsusage.c
@@ -1,7 +1,7 @@
1/* fsusage.c -- return space usage of mounted file systems 1/* fsusage.c -- return space usage of mounted file systems
2 2
3 Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009 3 Copyright (C) 1991-1992, 1996, 1998-1999, 2002-2006, 2009-2010 Free Software
4 Free Software Foundation, Inc. 4 Foundation, Inc.
5 5
6 This program is free software: you can redistribute it and/or modify 6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by 7 it under the terms of the GNU General Public License as published by
@@ -23,7 +23,7 @@
23#include <limits.h> 23#include <limits.h>
24#include <sys/types.h> 24#include <sys/types.h>
25 25
26#if STAT_STATVFS /* POSIX 1003.1-2001 (and later) with XSI */ 26#if STAT_STATVFS /* POSIX 1003.1-2001 (and later) with XSI */
27# include <sys/statvfs.h> 27# include <sys/statvfs.h>
28#else 28#else
29/* Don't include backward-compatibility files unless they're needed. 29/* Don't include backward-compatibility files unless they're needed.
@@ -40,16 +40,16 @@
40# if HAVE_SYS_VFS_H 40# if HAVE_SYS_VFS_H
41# include <sys/vfs.h> 41# include <sys/vfs.h>
42# endif 42# endif
43# if HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */ 43# if HAVE_SYS_FS_S5PARAM_H /* Fujitsu UXP/V */
44# include <sys/fs/s5param.h> 44# include <sys/fs/s5param.h>
45# endif 45# endif
46# if defined HAVE_SYS_FILSYS_H && !defined _CRAY 46# if defined HAVE_SYS_FILSYS_H && !defined _CRAY
47# include <sys/filsys.h> /* SVR2 */ 47# include <sys/filsys.h> /* SVR2 */
48# endif 48# endif
49# if HAVE_SYS_STATFS_H 49# if HAVE_SYS_STATFS_H
50# include <sys/statfs.h> 50# include <sys/statfs.h>
51# endif 51# endif
52# if HAVE_DUSTAT_H /* AIX PS/2 */ 52# if HAVE_DUSTAT_H /* AIX PS/2 */
53# include <sys/dustat.h> 53# include <sys/dustat.h>
54# endif 54# endif
55# include "full-read.h" 55# include "full-read.h"
@@ -67,13 +67,13 @@
67#define PROPAGATE_ALL_ONES(x) \ 67#define PROPAGATE_ALL_ONES(x) \
68 ((sizeof (x) < sizeof (uintmax_t) \ 68 ((sizeof (x) < sizeof (uintmax_t) \
69 && (~ (x) == (sizeof (x) < sizeof (int) \ 69 && (~ (x) == (sizeof (x) < sizeof (int) \
70 ? - (1 << (sizeof (x) * CHAR_BIT)) \ 70 ? - (1 << (sizeof (x) * CHAR_BIT)) \
71 : 0))) \ 71 : 0))) \
72 ? UINTMAX_MAX : (uintmax_t) (x)) 72 ? UINTMAX_MAX : (uintmax_t) (x))
73 73
74/* Extract the top bit of X as an uintmax_t value. */ 74/* Extract the top bit of X as an uintmax_t value. */
75#define EXTRACT_TOP_BIT(x) ((x) \ 75#define EXTRACT_TOP_BIT(x) ((x) \
76 & ((uintmax_t) 1 << (sizeof (x) * CHAR_BIT - 1))) 76 & ((uintmax_t) 1 << (sizeof (x) * CHAR_BIT - 1)))
77 77
78/* If a value is negative, many space usage primitives store it into an 78/* If a value is negative, many space usage primitives store it into an
79 integer variable by assignment, even if the variable's type is unsigned. 79 integer variable by assignment, even if the variable's type is unsigned.
@@ -94,7 +94,7 @@
94int 94int
95get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) 95get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
96{ 96{
97#if defined STAT_STATVFS /* POSIX */ 97#if defined STAT_STATVFS /* POSIX */
98 98
99 struct statvfs fsd; 99 struct statvfs fsd;
100 100
@@ -103,10 +103,10 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
103 103
104 /* f_frsize isn't guaranteed to be supported. */ 104 /* f_frsize isn't guaranteed to be supported. */
105 fsp->fsu_blocksize = (fsd.f_frsize 105 fsp->fsu_blocksize = (fsd.f_frsize
106 ? PROPAGATE_ALL_ONES (fsd.f_frsize) 106 ? PROPAGATE_ALL_ONES (fsd.f_frsize)
107 : PROPAGATE_ALL_ONES (fsd.f_bsize)); 107 : PROPAGATE_ALL_ONES (fsd.f_bsize));
108 108
109#elif defined STAT_STATFS2_FS_DATA /* Ultrix */ 109#elif defined STAT_STATFS2_FS_DATA /* Ultrix */
110 110
111 struct fs_data fsd; 111 struct fs_data fsd;
112 112
@@ -121,7 +121,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
121 fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.fd_req.gtot); 121 fsp->fsu_files = PROPAGATE_ALL_ONES (fsd.fd_req.gtot);
122 fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.fd_req.gfree); 122 fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.fd_req.gfree);
123 123
124#elif defined STAT_READ_FILSYS /* SVR2 */ 124#elif defined STAT_READ_FILSYS /* SVR2 */
125# ifndef SUPERBOFF 125# ifndef SUPERBOFF
126# define SUPERBOFF (SUPERB * 512) 126# define SUPERBOFF (SUPERB * 512)
127# endif 127# endif
@@ -152,8 +152,8 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
152 fsp->fsu_bavail = PROPAGATE_TOP_BIT (fsd.s_tfree); 152 fsp->fsu_bavail = PROPAGATE_TOP_BIT (fsd.s_tfree);
153 fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.s_tfree) != 0; 153 fsp->fsu_bavail_top_bit_set = EXTRACT_TOP_BIT (fsd.s_tfree) != 0;
154 fsp->fsu_files = (fsd.s_isize == -1 154 fsp->fsu_files = (fsd.s_isize == -1
155 ? UINTMAX_MAX 155 ? UINTMAX_MAX
156 : (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1)); 156 : (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 1));
157 fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.s_tinode); 157 fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.s_tinode);
158 158
159#elif defined STAT_STATFS3_OSF1 159#elif defined STAT_STATFS3_OSF1
@@ -165,7 +165,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
165 165
166 fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); 166 fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
167 167
168#elif defined STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */ 168#elif defined STAT_STATFS2_BSIZE /* 4.3BSD, SunOS 4, HP-UX, AIX */
169 169
170 struct statfs fsd; 170 struct statfs fsd;
171 171
@@ -189,7 +189,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
189 } 189 }
190# endif /* STATFS_TRUNCATES_BLOCK_COUNTS */ 190# endif /* STATFS_TRUNCATES_BLOCK_COUNTS */
191 191
192#elif defined STAT_STATFS2_FSIZE /* 4.4BSD */ 192#elif defined STAT_STATFS2_FSIZE /* 4.4BSD */
193 193
194 struct statfs fsd; 194 struct statfs fsd;
195 195
@@ -198,7 +198,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
198 198
199 fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize); 199 fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
200 200
201#elif defined STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */ 201#elif defined STAT_STATFS4 /* SVR3, Dynix, Irix, AIX */
202 202
203# if !_AIX && !defined _SEQUENT_ && !defined DOLPHIN 203# if !_AIX && !defined _SEQUENT_ && !defined DOLPHIN
204# define f_bavail f_bfree 204# define f_bavail f_bfree