ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/disk_stats.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/disk_stats.c (file contents):
Revision 1.87 by tdb, Sat May 16 01:01:31 2009 UTC vs.
Revision 1.88 by tdb, Fri Dec 4 22:09:30 2009 UTC

# Line 66 | Line 66
66   #if defined(FREEBSD) || defined(DFBSD)
67   #include <sys/dkstat.h>
68   #include <devstat.h>
69 < #define VALID_FS_TYPES {"hpfs", "msdosfs", "ntfs", "udf", "ext2fs", \
70 <                        "ufs", "mfs", "nfs", "zfs"}
69 > #include <sys/param.h>
70 > #include <sys/mount.h>
71 > #include <sys/sysctl.h>
72 > /*#define VALID_FS_TYPES {"hpfs", "msdosfs", "ntfs", "udf", "ext2fs", \
73 >                        "ufs", "mfs", "nfs", "zfs", "tmpfs", "reiserfs", \
74 >                        "xfs"}*/
75   #endif
76   #if defined(NETBSD) || defined(OPENBSD)
77   #include <sys/param.h>
# Line 151 | Line 155 | static void disk_stat_destroy(sg_fs_stats *d) {
155  
156   #ifndef WIN32 /* not used by WIN32, so stop compiler throwing warnings */
157   static int is_valid_fs_type(const char *type) {
154        const char *types[] = VALID_FS_TYPES;
158          int i;
159  
160 + #if defined(FREEBSD) || defined(DFBSD)
161 +        struct xvfsconf *xvfsp;
162 +        size_t buflen;
163 +        int cnt, nbvfs = 0;
164 +
165 +        if (sysctlbyname("vfs.conflist", NULL, &buflen, NULL, 0) < 0) {
166 +                sg_set_error_with_errno(SG_ERROR_SYSCTLBYNAME, "vfs.conflist");
167 +                return 0;
168 +        }
169 +        xvfsp = alloca(buflen);
170 +        if (sysctlbyname("vfs.conflist", xvfsp, &buflen, NULL, 0) < 0) {
171 +                sg_set_error_with_errno(SG_ERROR_SYSCTLBYNAME, "vfs.conflist");
172 +                return 0;
173 +        }
174 +        cnt = buflen / sizeof(struct xvfsconf);
175 +        for (i = 0; i < cnt; i++) {
176 +                if (strcmp(xvfsp[i].vfc_name, type) == 0) {
177 +                        return 1;
178 +                }
179 +        }
180 + #else
181 +        const char *types[] = VALID_FS_TYPES;
182 +
183          for (i = 0; i < (int) (sizeof types / sizeof *types); i++) {
184                  if (strcmp(types[i], type) == 0) {
185                          return 1;
186                  }
187          }
188 + #endif
189          return 0;
190   }
191   #endif

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines