From 0a33d8bd312cc4497d08bbe0f4dd2abcce67bd0b Mon Sep 17 00:00:00 2001 From: Tim Prouty Date: Mon, 13 Oct 2008 11:50:27 -0700 Subject: 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 --- lib/util/fsusage.c | 5 +++++ lib/util/fsusage.m4 | 31 +++++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) (limited to 'lib') 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 +#include ],[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 +# 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)]) -- cgit