diff options
Diffstat (limited to 'gl/fsusage.c')
-rw-r--r-- | gl/fsusage.c | 38 |
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 @@ | |||
94 | int | 94 | int |
95 | get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) | 95 | get_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 |