Check for f_frsize when using statvfs
authorZach Loafman <zachary.loafman@isilon.com>
Thu, 3 Jul 2008 18:52:53 +0000 (11:52 -0700)
committerVolker Lendecke <vl@samba.org>
Tue, 22 Jul 2008 13:00:48 +0000 (15:00 +0200)
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). Also add sys/types.h to the other struct statvfs test
(again, some platforms need it).
(This used to be commit 591bf1d15ff3b93db908cc3a4b6e10d09e5b74b6)

source3/configure.in
source3/lib/fsusage.c

index 0fe938764ad2544266ac7699666add72e6fbc6d3..6806ed22aeddeace0bf489a2a5a24d528a095073 100644 (file)
@@ -4755,12 +4755,23 @@ fi
 # This is not the case on ancient Linux systems.
 
 AC_CACHE_CHECK([that statvfs.f_fsid is an integer],samba_cv_fsid_int, [
-    AC_TRY_COMPILE([#include <sys/statvfs.h>],[struct statvfs buf; buf.f_fsid = 0],
+    AC_TRY_COMPILE([#include <sys/types.h>
+#include <sys/statvfs.h>],[struct statvfs buf; buf.f_fsid = 0],
        samba_cv_fsid_int=yes,samba_cv_fsid_int=no)])
 if test x"$samba_cv_fsid_int" = x"yes"; then
     AC_DEFINE(HAVE_FSID_INT, 1, [Whether statvfs.f_fsid is an integer])
 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 $space = no; then
   # DEC Alpha running OSF/1
   AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)])
index c5dec5ee8dcc51f5347789c8bc4f5672fd057503..66ffb9f44299e1662c7a25263b4a75a3f18f7956 100644 (file)
@@ -122,8 +122,13 @@ int sys_fsusage(const char *path, SMB_BIG_UINT *dfree, SMB_BIG_UINT *dsize)
 #endif /* STAT_STATFS4 */
 
 #if defined(STAT_STATVFS) || defined(STAT_STATVFS64)           /* SVR4 */
+#if defined HAVE_FRSIZE
 # define CONVERT_BLOCKS(B) \
        adjust_blocks ((SMB_BIG_UINT)(B), fsd.f_frsize ? (SMB_BIG_UINT)fsd.f_frsize : (SMB_BIG_UINT)fsd.f_bsize, (SMB_BIG_UINT)512)
+#else
+# define CONVERT_BLOCKS(B) \
+       adjust_blocks ((SMB_BIG_UINT)(B), (SMB_BIG_UINT)fsd.f_bsize, (SMB_BIG_UINT)512)
+#endif
 
 #ifdef STAT_STATVFS64
        struct statvfs64 fsd;