bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: bug#6331: [sshfs] df reports wrong disk space usage on solaris


From: Bruno Haible
Subject: Re: bug#6331: [sshfs] df reports wrong disk space usage on solaris
Date: Sun, 4 Jul 2010 20:38:12 +0200
User-agent: KMail/1.9.9

Hi Jim,

> > Upon inspection, it appears that the fu_cv_sys_stat_statfs2_bsize
> > test in m4/fsusage.m4 (labelled "AIX") would succeed on
> >   glibc, MacOS X, FreeBSD, NetBSD, OpenBSD, AIX, HP-UX, Solaris, Cygwin
> > ...
> > without a clear overview of which platform ends up using which code,
> > I can't assert this.
> ...
> If necessary, we add additional guards later.

Sorry, slight misunderstanding: I did not want to object against Miklos'
patch, but rather ask for better comments. Currently,
  - the code labelled "POSIX" is not used for glibc/Linux,
  - the code labelled "AIX" is not used on AIX 4 and 5,
  - the code laballed "4.4BSD and NetBSD" is not used on NetBSD 3.

Here's a proposed patch that updates the comments to match currently available
platforms, in a way that indicates why the order of the tests in fsusage.m4
matters.

Also it changes the message
  "checking for two-argument statfs with statfs.bsize"
to
  "checking for two-argument statfs with statfs.f_bsize"

and
  "checking for two-argument statfs with statfs.fsize"
to
  "checking for two-argument statfs with statfs.f_fsize"

since that's what the tests actually check for.

OK to commit?


2010-07-04  Bruno Haible  <address@hidden>

        fsusage: Clarify which code applies to which platforms.
        * m4/fsusage.m4 (gl_FSUSAGE): Clarify which test succeeds on which
        platform.
        * lib/fsusage.c (get_fs_usage): Likewise.

--- m4/fsusage.m4.orig  Sun Jul  4 20:18:12 2010
+++ m4/fsusage.m4       Sun Jul  4 20:15:03 2010
@@ -1,4 +1,4 @@
-# serial 25
+# serial 26
 # Obtaining file system usage information.
 
 # Copyright (C) 1997-1998, 2000-2001, 2003-2010 Free Software Foundation, Inc.
@@ -44,7 +44,8 @@
 # systems.  That system is reported to work fine with STAT_STATFS4 which
 # is what it gets when this test fails.
 if test $ac_fsusage_space = no; then
-  # SVR4
+  # glibc/{Hurd,kFreeBSD}, FreeBSD, NetBSD, AIX, HP-UX, IRIX, Solaris, Cygwin,
+  # Interix, BeOS.
   AC_CACHE_CHECK([for statvfs function (SVR4)], [fu_cv_sys_stat_statvfs],
                  [AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>
 #if defined __GLIBC__ && defined __linux__
@@ -97,8 +98,13 @@
 fi
 
 if test $ac_fsusage_space = no; then
-# AIX
-  AC_MSG_CHECKING([for two-argument statfs with statfs.bsize dnl
+  # glibc/Linux, MacOS X, OpenBSD.
+  # (glibc/{Hurd,kFreeBSD}, FreeBSD, NetBSD, AIX, HP-UX, OSF/1, Cygwin already
+  # handled above.)
+  # (On IRIX you need to include <sys/statfs.h>, not only <sys/mount.h> and
+  # <sys/vfs.h>.)
+  # (On Solaris, statfs has 4 arguments.)
+  AC_MSG_CHECKING([for two-argument statfs with statfs.f_bsize dnl
 member (AIX, 4.3BSD)])
   AC_CACHE_VAL([fu_cv_sys_stat_statfs2_bsize],
   [AC_RUN_IFELSE([AC_LANG_SOURCE([[
@@ -131,7 +137,8 @@
 fi
 
 if test $ac_fsusage_space = no; then
-# SVR3
+  # SVR3
+  # (Solaris already handled above.)
   AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)])
   AC_CACHE_VAL([fu_cv_sys_stat_statfs4],
   [AC_RUN_IFELSE([AC_LANG_SOURCE([[
@@ -150,13 +157,17 @@
   if test $fu_cv_sys_stat_statfs4 = yes; then
     ac_fsusage_space=yes
     AC_DEFINE([STAT_STATFS4], [1],
-              [  Define if statfs takes 4 args.  (SVR3, Dynix, Irix, Dolphin)])
+      [  Define if statfs takes 4 args.  (SVR3, Dynix, old Irix, old AIX, 
Dolphin)])
   fi
 fi
 
 if test $ac_fsusage_space = no; then
-# 4.4BSD and NetBSD
-  AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl
+  # 4.4BSD and older NetBSD
+  # (OSF/1 already handled above.)
+  # (On AIX, you need to include <sys/statfs.h>, not only <sys/mount.h>.)
+  # (On Solaris, statfs has 4 arguments and 'struct statfs' is not declared in
+  # <sys/mount.h>.)
+  AC_MSG_CHECKING([for two-argument statfs with statfs.f_fsize dnl
 member (4.4BSD and NetBSD)])
   AC_CACHE_VAL([fu_cv_sys_stat_statfs2_fsize],
   [AC_RUN_IFELSE([AC_LANG_SOURCE([[
@@ -223,6 +234,7 @@
 
 if test $ac_fsusage_space = no; then
   # SVR2
+  # (AIX, HP-UX, OSF/1 already handled above.)
   AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <sys/filsys.h>
         ]])],
     [AC_DEFINE([STAT_READ_FILSYS], [1],
--- lib/fsusage.c.orig  Sun Jul  4 20:18:12 2010
+++ lib/fsusage.c       Sun Jul  4 20:17:52 2010
@@ -94,7 +94,7 @@
 int
 get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp)
 {
-#if defined STAT_STATVFS                /* POSIX */
+#if defined STAT_STATVFS                /* POSIX, except glibc/Linux */
 
   struct statvfs fsd;
 
@@ -156,7 +156,7 @@
                     : (fsd.s_isize - 2) * INOPB * (fsd.s_type == Fs2b ? 2 : 
1));
   fsp->fsu_ffree = PROPAGATE_ALL_ONES (fsd.s_tinode);
 
-#elif defined STAT_STATFS3_OSF1
+#elif defined STAT_STATFS3_OSF1         /* OSF/1 */
 
   struct statfs fsd;
 
@@ -165,7 +165,8 @@
 
   fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
 
-#elif defined STAT_STATFS2_BSIZE        /* 4.3BSD, SunOS 4, HP-UX, AIX */
+#elif defined STAT_STATFS2_BSIZE        /* glibc/Linux, 4.3BSD, SunOS 4, \
+                                           MacOS X, OpenBSD */
 
   struct statfs fsd;
 
@@ -189,7 +190,7 @@
     }
 # endif /* STATFS_TRUNCATES_BLOCK_COUNTS */
 
-#elif defined STAT_STATFS2_FSIZE        /* 4.4BSD */
+#elif defined STAT_STATFS2_FSIZE        /* 4.4BSD and older NetBSD */
 
   struct statfs fsd;
 
@@ -198,7 +199,8 @@
 
   fsp->fsu_blocksize = PROPAGATE_ALL_ONES (fsd.f_fsize);
 
-#elif defined STAT_STATFS4              /* SVR3, Dynix, Irix, AIX */
+#elif defined STAT_STATFS4              /* SVR3, Dynix, old Irix, old AIX, \
+                                           Dolphin */
 
 # if !_AIX && !defined _SEQUENT_ && !defined DOLPHIN
 #  define f_bavail f_bfree



reply via email to

[Prev in Thread] Current Thread [Next in Thread]