From 4d35a5af43550e9f7e7dca2aa09e5f54e1a772d4 Mon Sep 17 00:00:00 2001 From: ban Date: Thu, 16 Dec 1999 09:12:55 +0000 Subject: [PATCH] Added check for the type of statfs function in use --- acinclude.m4 | 177 +++++++++++++++++++++++++++++++++++++++++ clients/lcdproc/disk.c | 35 +++++--- 2 files changed, 202 insertions(+), 10 deletions(-) diff --git a/acinclude.m4 b/acinclude.m4 index 98c4e70..fe429c8 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -25,6 +25,10 @@ else DRIVERS="$DRIVERS CFontz.o" AC_DEFINE(CFONTZ_DRV) ;; + sli) + DRIVERS="$DRIVERS wirz-sli.o" + AC_DEFINE(SLI_DRV) + ;; curses) AC_CHECK_LIB(curses, main, LIBCURSES="-lcurses", AC_CHECK_LIB(ncurses, main, LIBCURSES="-lncurses", @@ -60,3 +64,176 @@ AC_SUBST(LIBCURSES) AC_SUBST(LIBIRMAN) AC_SUBST(DRIVERS) ]) + + +dnl +dnl Filesystem information detection +dnl +dnl To get information about the disk, mount points, etc. +dnl +dnl This code is stolen from mc-4.5.41, which in turn has stolen it +dnl from GNU fileutils-3.12. +dnl + +AC_DEFUN(AC_GET_FS_INFO, [ + AC_CHECK_HEADERS(fcntl.h sys/dustat.h sys/param.h sys/statfs.h sys/fstyp.h) + AC_CHECK_HEADERS(mnttab.h mntent.h utime.h sys/statvfs.h sys/vfs.h) + AC_CHECK_HEADERS(sys/mount.h sys/filsys.h sys/fs_types.h) + AC_CHECK_FUNCS(getmntinfo) + + AC_CHECKING(how to get filesystem space usage) + space=no + + # Here we'll compromise a little (and perform only the link test) + # since it seems there are no variants of the statvfs function. + if test $space = no; then + # SVR4 + AC_CHECK_FUNCS(statvfs) + if test $ac_cv_func_statvfs = yes; then + space=yes + AC_DEFINE(STAT_STATVFS) + fi + fi + + if test $space = no; then + # DEC Alpha running OSF/1 + AC_MSG_CHECKING([for 3-argument statfs function (DEC OSF/1)]) + AC_CACHE_VAL(fu_cv_sys_stat_statfs3_osf1, + [AC_TRY_RUN([ +#include +#include +#include + main () + { + struct statfs fsd; + fsd.f_fsize = 0; + exit (statfs (".", &fsd, sizeof (struct statfs))); + }], + fu_cv_sys_stat_statfs3_osf1=yes, + fu_cv_sys_stat_statfs3_osf1=no, + fu_cv_sys_stat_statfs3_osf1=no)]) + AC_MSG_RESULT($fu_cv_sys_stat_statfs3_osf1) + if test $fu_cv_sys_stat_statfs3_osf1 = yes; then + space=yes + AC_DEFINE(STAT_STATFS3_OSF1) + fi + fi + + if test $space = no; then + # AIX + AC_MSG_CHECKING([for two-argument statfs with statfs.bsize member (AIX, 4.3BSD)]) + AC_CACHE_VAL(fu_cv_sys_stat_statfs2_bsize, + [AC_TRY_RUN([ +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#ifdef HAVE_SYS_MOUNT_H +#include +#endif +#ifdef HAVE_SYS_VFS_H +#include +#endif + main () + { + struct statfs fsd; + fsd.f_bsize = 0; + exit (statfs (".", &fsd)); + }], + fu_cv_sys_stat_statfs2_bsize=yes, + fu_cv_sys_stat_statfs2_bsize=no, + fu_cv_sys_stat_statfs2_bsize=no)]) + AC_MSG_RESULT($fu_cv_sys_stat_statfs2_bsize) + if test $fu_cv_sys_stat_statfs2_bsize = yes; then + space=yes + AC_DEFINE(STAT_STATFS2_BSIZE) + fi + fi + + if test $space = no; then + # SVR3 + AC_MSG_CHECKING([for four-argument statfs (AIX-3.2.5, SVR3)]) + AC_CACHE_VAL(fu_cv_sys_stat_statfs4, + [AC_TRY_RUN([#include +#include + main () + { + struct statfs fsd; + exit (statfs (".", &fsd, sizeof fsd, 0)); + }], + fu_cv_sys_stat_statfs4=yes, + fu_cv_sys_stat_statfs4=no, + fu_cv_sys_stat_statfs4=no)]) + AC_MSG_RESULT($fu_cv_sys_stat_statfs4) + if test $fu_cv_sys_stat_statfs4 = yes; then + space=yes + AC_DEFINE(STAT_STATFS4) + fi + fi + if test $space = no; then + # 4.4BSD and NetBSD + AC_MSG_CHECKING([for two-argument statfs with statfs.fsize dnl + member (4.4BSD and NetBSD)]) + AC_CACHE_VAL(fu_cv_sys_stat_statfs2_fsize, + [AC_TRY_RUN([#include +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#ifdef HAVE_SYS_MOUNT_H +#include +#endif + main () + { + struct statfs fsd; + fsd.f_fsize = 0; + exit (statfs (".", &fsd)); + }], + fu_cv_sys_stat_statfs2_fsize=yes, + fu_cv_sys_stat_statfs2_fsize=no, + fu_cv_sys_stat_statfs2_fsize=no)]) + AC_MSG_RESULT($fu_cv_sys_stat_statfs2_fsize) + if test $fu_cv_sys_stat_statfs2_fsize = yes; then + space=yes + AC_DEFINE(STAT_STATFS2_FSIZE) + fi + fi + + if test $space = no; then + # Ultrix + AC_MSG_CHECKING([for two-argument statfs with struct fs_data (Ultrix)]) + AC_CACHE_VAL(fu_cv_sys_stat_fs_data, + [AC_TRY_RUN([ +#include +#ifdef HAVE_SYS_PARAM_H +#include +#endif +#ifdef HAVE_SYS_MOUNT_H +#include +#endif +#ifdef HAVE_SYS_FS_TYPES_H +#include +#endif + main () + { + struct fs_data fsd; + /* Ultrix's statfs returns 1 for success, + 0 for not mounted, -1 for failure. */ + exit (statfs (".", &fsd) != 1); + }], + fu_cv_sys_stat_fs_data=yes, + fu_cv_sys_stat_fs_data=no, + fu_cv_sys_stat_fs_data=no)]) + AC_MSG_RESULT($fu_cv_sys_stat_fs_data) + if test $fu_cv_sys_stat_fs_data = yes; then + space=yes + AC_DEFINE(STAT_STATFS2_FS_DATA) + fi + fi + + dnl Not supported + dnl if test $space = no; then + dnl # SVR2 + dnl AC_TRY_CPP([#include ], + dnl AC_DEFINE(STAT_READ_FILSYS) space=yes) + dnl fi +]) + diff --git a/clients/lcdproc/disk.c b/clients/lcdproc/disk.c index a44ac42..bae1779 100644 --- a/clients/lcdproc/disk.c +++ b/clients/lcdproc/disk.c @@ -8,19 +8,25 @@ #include "config.h" #endif -#ifdef LINUX -#include -#else -#ifdef xBSD +#ifdef HAVE_SYS_PARAM_H #include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_MOUNT_H #include -#else +#endif +#ifdef HAVE_SYS_VFS_H +#include +#endif +#ifdef HAVE_SYS_STATVFS_H +#include +#endif +#ifdef HAVE_SYS_STATFS_H #include #endif -#endif - - #include "../../shared/sockets.h" #include "main.h" @@ -40,7 +46,11 @@ typedef struct mounts static int get_fs(mounts fs[]) { +#ifdef STAT_STATVFS + struct statvfs fsinfo; +#else struct statfs fsinfo; +#endif char line[256]; int x = 0, y; @@ -68,11 +78,16 @@ static int get_fs(mounts fs[]) #endif ) { -#if LINUX || BSD +#ifdef STAT_STATVFS + y = statvfs(fs[x].mpoint, &fsinfo); +#elif STAT_STATFS2_BSIZE y = statfs(fs[x].mpoint, &fsinfo); -#else +#elif STAT_STATFS4 y = statfs(fs[x].mpoint, &fsinfo, sizeof(fsinfo), 0); +#else +#error "statfs for this system noy yet supported" #endif + fs[x].blocks = fsinfo.f_blocks; if(fs[x].blocks > 0) {