From 38a06045a37da92e99e9c75e2cfc298312fd00ed Mon Sep 17 00:00:00 2001 From: Bruno Haible Date: Sun, 24 Jul 2011 12:20:41 +0200 Subject: [PATCH] fsusage: Enable large volume support on AIX >= 5.2. * m4/fsusage.m4 (gl_FILE_SYSTEM_USAGE): If 'struct statvfs64' has a larger f_blocks field than 'struct statvfs', define STAT_STATVFS64 instead of STAT_STATVFS. * lib/fsusage.c (get_fs_usage) [STAT_STATVFS64]: Use statvfs64. --- ChangeLog | 6 ++++++ lib/fsusage.c | 16 ++++++++++++++-- m4/fsusage.m4 | 28 ++++++++++++++++++++++++++-- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 37dd892343..96e21ced5d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2011-07-24 Bruno Haible + fsusage: Enable large volume support on AIX >= 5.2. + * m4/fsusage.m4 (gl_FILE_SYSTEM_USAGE): If 'struct statvfs64' has a + larger f_blocks field than 'struct statvfs', define STAT_STATVFS64 + instead of STAT_STATVFS. + * lib/fsusage.c (get_fs_usage) [STAT_STATVFS64]: Use statvfs64. + fsusage: Restore previous behaviour on AIX, Cygwin, Interix. * m4/fsusage.m4 (gl_FILE_SYSTEM_USAGE): Enforce a 64-bit struct statvfs f_blocks field only on MacOS X. diff --git a/lib/fsusage.c b/lib/fsusage.c index d38137948e..a0c39d2b53 100644 --- a/lib/fsusage.c +++ b/lib/fsusage.c @@ -23,7 +23,7 @@ #include #include -#if STAT_STATVFS /* POSIX 1003.1-2001 (and later) with XSI */ +#if STAT_STATVFS || STAT_STATVFS64 /* POSIX 1003.1-2001 (and later) with XSI */ # include #else /* Don't include backward-compatibility files unless they're needed. @@ -106,6 +106,18 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) ? PROPAGATE_ALL_ONES (fsd.f_frsize) : PROPAGATE_ALL_ONES (fsd.f_bsize)); +#elif defined STAT_STATVFS64 /* AIX */ + + struct statvfs64 fsd; + + if (statvfs64 (file, &fsd) < 0) + return -1; + + /* f_frsize isn't guaranteed to be supported. */ + fsp->fsu_blocksize = (fsd.f_frsize + ? PROPAGATE_ALL_ONES (fsd.f_frsize) + : PROPAGATE_ALL_ONES (fsd.f_bsize)); + #elif defined STAT_STATFS2_FS_DATA /* Ultrix */ struct fs_data fsd; @@ -223,7 +235,7 @@ get_fs_usage (char const *file, char const *disk, struct fs_usage *fsp) #endif -#if (defined STAT_STATVFS \ +#if (defined STAT_STATVFS || defined STAT_STATVFS64 \ || (!defined STAT_STATFS2_FS_DATA && !defined STAT_READ_FILSYS)) fsp->fsu_blocks = PROPAGATE_ALL_ONES (fsd.f_blocks); diff --git a/m4/fsusage.m4 b/m4/fsusage.m4 index c0a6256388..8e9e2cb5be 100644 --- a/m4/fsusage.m4 +++ b/m4/fsusage.m4 @@ -81,8 +81,32 @@ int check_f_blocks_size[sizeof fsd.f_blocks * CHAR_BIT <= 32 ? -1 : 1]; [fu_cv_sys_stat_statvfs=no])]) if test $fu_cv_sys_stat_statvfs = yes; then ac_fsusage_space=yes - AC_DEFINE([STAT_STATVFS], [1], - [ Define if there is a function named statvfs. (SVR4)]) + # AIX >= 5.2 has statvfs64 that has a wider f_blocks field than statvfs. + # glibc, HP-UX, IRIX, Solaris have statvfs64 as well, but on these systems + # statvfs with large-file support is already equivalent to statvfs64. + AC_CACHE_CHECK([whether to use statvfs64], + [fu_cv_sys_stat_statvfs64], + [AC_LINK_IFELSE( + [AC_LANG_PROGRAM( + [[#include + #include + struct statvfs64 fsd; + int check_f_blocks_larger_in_statvfs64 + [sizeof (((struct statvfs64 *) 0)->f_blocks) + > sizeof (((struct statvfs *) 0)->f_blocks) + ? 1 : -1]; + ]], + [[statvfs64 (0, &fsd);]])], + [fu_cv_sys_stat_statvfs64=yes], + [fu_cv_sys_stat_statvfs64=no]) + ]) + if test $fu_cv_sys_stat_statvfs64 = yes; then + AC_DEFINE([STAT_STATVFS64], [1], + [ Define if statvfs64 should be preferred over statvfs.]) + else + AC_DEFINE([STAT_STATVFS], [1], + [ Define if there is a function named statvfs. (SVR4)]) + fi fi fi -- 2.30.2