Check for f_frsize when using statvfs
authorTim Prouty <tprouty@samba.org>
Mon, 13 Oct 2008 18:50:27 +0000 (11:50 -0700)
committerTim Prouty <tprouty@samba.org>
Mon, 13 Oct 2008 21:24:08 +0000 (14:24 -0700)
Add a configure test for the availability of f_frsize in struct
statvfs (for broken platforms that define statvfs but still have
f_bsize/f_iosize). Ported from source3's fsusage:
commit 472519eb6941bc0972212cc416ab89801fe3ee0c

lib/util/fsusage.c
lib/util/fsusage.m4

index 43c87872164d8ef08cb3650267d6aa834b4a86c2..30f9f9c795a1bb8cdee21f79b8abe21782e11d60 100644 (file)
@@ -124,8 +124,13 @@ _PUBLIC_ int sys_fsusage(const char *path, uint64_t *dfree, uint64_t *dsize)
 #endif /* STAT_STATFS4 */
 
 #if defined(STAT_STATVFS) || defined(STAT_STATVFS64)           /* SVR4 */
+#ifdef HAVE_FRSIZE
 # define CONVERT_BLOCKS(B) \
        adjust_blocks ((uint64_t)(B), fsd.f_frsize ? (uint64_t)fsd.f_frsize : (uint64_t)fsd.f_bsize, (uint64_t)512)
+#else
+# define CONVERT_BLOCKS(B) \
+       adjust_blocks ((uint64_t)(B), (uint64_t)fsd.f_bsize, (uint64_t)512)
+#endif
 
 #ifdef STAT_STATVFS64
        struct statvfs64 fsd;
index 6d5d13fe253876641e9da329d4a59a9babe2d880..5023c36dff67f3137260864aacc8fd3e0530bfa4 100644 (file)
@@ -54,6 +54,37 @@ if test $space = no; then
   fi
 fi
 
+# fsusage.c assumes that statvfs has an f_frsize entry. Some weird
+# systems use f_bsize.
+AC_CACHE_CHECK([that statvfs.f_frsize works],samba_cv_frsize, [
+    AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/statvfs.h>],[struct statvfs buf; buf.f_frsize = 0],
+       samba_cv_frsize=yes,samba_cv_frsize=no)])
+if test x"$samba_cv_frsize" = x"yes"; then
+    AC_DEFINE(HAVE_FRSIZE, 1, [Whether statvfs.f_frsize exists])
+fi
+
+
+# if test $fu_cv_sys_stat_statvfs64 = yes || test $fu_cv_sys_stat_statvfs = yes ; then
+#   AC_MSG_CHECKING([for struct statvfs with statvfs.f_frsize (SVR4)])
+#   AC_CACHE_VAL(fu_cv_struct_statvfs_f_frsize,
+#   [AC_TRY_RUN([
+# #include <sys/statvfs.h>
+#   main ()
+#   {
+#   struct statvfs fsd;
+#   fsd.f_frsize = 0;
+#   exit (statvfs (".", &fsd));
+#   }],
+#   fu_cv_struct_statvfs_f_frsize=yes,
+#   fu_cv_struct_statvfs_f_frsize=no,
+#   fu_cv_struct_statvfs_f_frsize=no)])
+#   AC_MSG_RESULT($fu_cv_sys_stat_statvfs_f_frsize)
+#   if test $fu_cv_struct_statvfs_f_frsize = yes; then
+#     AC_DEFINE(HAVE_STRUCT_STATVFS_F_FRSIZE,1,[Whether struct statvfs has f_frsize property])
+#   fi
+# fi
+
 if test $space = no; then
   # DEC Alpha running OSF/1
   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])