summaryrefslogtreecommitdiff
path: root/lib/util
diff options
context:
space:
mode:
authorTim Prouty <tprouty@samba.org>2008-10-13 11:50:27 -0700
committerTim Prouty <tprouty@samba.org>2008-10-13 14:24:08 -0700
commit0a33d8bd312cc4497d08bbe0f4dd2abcce67bd0b (patch)
treefd4aff08971ad2ff3111fa43c8d3b29bc0f0aa75 /lib/util
parent783818d956fd6e22d1affae808f240b6189e3140 (diff)
downloadsamba-0a33d8bd312cc4497d08bbe0f4dd2abcce67bd0b.tar.gz
samba-0a33d8bd312cc4497d08bbe0f4dd2abcce67bd0b.tar.bz2
samba-0a33d8bd312cc4497d08bbe0f4dd2abcce67bd0b.zip
Check for f_frsize when using statvfs
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
Diffstat (limited to 'lib/util')
-rw-r--r--lib/util/fsusage.c5
-rw-r--r--lib/util/fsusage.m431
2 files changed, 36 insertions, 0 deletions
diff --git a/lib/util/fsusage.c b/lib/util/fsusage.c
index 43c8787216..30f9f9c795 100644
--- a/lib/util/fsusage.c
+++ b/lib/util/fsusage.c
@@ -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;
diff --git a/lib/util/fsusage.m4 b/lib/util/fsusage.m4
index 6d5d13fe25..5023c36dff 100644
--- a/lib/util/fsusage.m4
+++ b/lib/util/fsusage.m4
@@ -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)])