--- projects/libstatgrab/src/libstatgrab/disk_stats.c 2009/05/16 01:01:31 1.87 +++ projects/libstatgrab/src/libstatgrab/disk_stats.c 2009/12/04 22:09:30 1.88 @@ -18,7 +18,7 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA * 02111-1307 USA * - * $Id: disk_stats.c,v 1.87 2009/05/16 01:01:31 tdb Exp $ + * $Id: disk_stats.c,v 1.88 2009/12/04 22:09:30 tdb Exp $ */ #ifdef HAVE_CONFIG_H @@ -66,8 +66,12 @@ #if defined(FREEBSD) || defined(DFBSD) #include #include -#define VALID_FS_TYPES {"hpfs", "msdosfs", "ntfs", "udf", "ext2fs", \ - "ufs", "mfs", "nfs", "zfs"} +#include +#include +#include +/*#define VALID_FS_TYPES {"hpfs", "msdosfs", "ntfs", "udf", "ext2fs", \ + "ufs", "mfs", "nfs", "zfs", "tmpfs", "reiserfs", \ + "xfs"}*/ #endif #if defined(NETBSD) || defined(OPENBSD) #include @@ -151,14 +155,37 @@ static void disk_stat_destroy(sg_fs_stats *d) { #ifndef WIN32 /* not used by WIN32, so stop compiler throwing warnings */ static int is_valid_fs_type(const char *type) { - const char *types[] = VALID_FS_TYPES; int i; +#if defined(FREEBSD) || defined(DFBSD) + struct xvfsconf *xvfsp; + size_t buflen; + int cnt, nbvfs = 0; + + if (sysctlbyname("vfs.conflist", NULL, &buflen, NULL, 0) < 0) { + sg_set_error_with_errno(SG_ERROR_SYSCTLBYNAME, "vfs.conflist"); + return 0; + } + xvfsp = alloca(buflen); + if (sysctlbyname("vfs.conflist", xvfsp, &buflen, NULL, 0) < 0) { + sg_set_error_with_errno(SG_ERROR_SYSCTLBYNAME, "vfs.conflist"); + return 0; + } + cnt = buflen / sizeof(struct xvfsconf); + for (i = 0; i < cnt; i++) { + if (strcmp(xvfsp[i].vfc_name, type) == 0) { + return 1; + } + } +#else + const char *types[] = VALID_FS_TYPES; + for (i = 0; i < (int) (sizeof types / sizeof *types); i++) { if (strcmp(types[i], type) == 0) { return 1; } } +#endif return 0; } #endif