summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--acinclude.m428
-rw-r--r--configure.ac22
-rw-r--r--lib/libalpm/diskspace.c51
-rw-r--r--lib/libalpm/diskspace.h11
4 files changed, 50 insertions, 62 deletions
diff --git a/acinclude.m4 b/acinclude.m4
index 740d9ecc..6693da44 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -77,7 +77,7 @@ AC_DEFUN([GCC_VISIBILITY_CC],[
if test $visibility_cv_cc = yes; then
AC_DEFINE([ENABLE_VISIBILITY_CC], 1, [Define if symbol visibility C support is enabled.])
fi
- AM_CONDITIONAL([ENABLE_VISIBILITY_CC], test "x$visibility_cv_cc" = "xyes")
+ AM_CONDITIONAL([ENABLE_VISIBILITY_CC], test "x$visibility_cv_cc" = "xyes")
fi
])
@@ -97,7 +97,31 @@ AC_DEFUN([GCC_GNU89_INLINE_CC],[
if test $gnu89_inline_cv_cc = yes; then
AC_DEFINE([ENABLE_GNU89_INLINE_CC], 1, [Define if gnu89 inlining semantics should be used.])
fi
- AM_CONDITIONAL([ENABLE_GNU89_INLINE_CC], test "x$gnu89_inline_cv_cc" = "xyes")
+ AM_CONDITIONAL([ENABLE_GNU89_INLINE_CC], test "x$gnu89_inline_cv_cc" = "xyes")
fi
])
+dnl Checks for getmntinfo and determines whether it uses statfs or statvfs
+AC_DEFUN([FS_STATS_TYPE],
+ [AC_CACHE_CHECK([filesystem statistics type], fs_stats_cv_type,
+ [AC_CHECK_FUNC(getmntinfo,
+ [AC_COMPILE_IFELSE(
+ [AC_LANG_PROGRAM([[
+# include <sys/param.h>
+# include <sys/mount.h>
+#if HAVE_SYS_UCRED_H
+#include <sys/ucred.h>
+#endif
+extern int getmntinfo (struct statfs **, int);
+]],
+ [])],
+ [fs_stats_cv_type="struct statfs"],
+ [fs_stats_cv_type="struct statvfs"])],
+ [AC_CHECK_FUNC(getmntent,
+ [fs_stats_cv_type="struct statvfs"])]
+ )]
+ )
+ AC_DEFINE_UNQUOTED(FSSTATSTYPE, [$fs_stats_cv_type],
+ [Defined as the filesystem stats type ('statvfs' or 'statfs')])
+])
+
diff --git a/configure.ac b/configure.ac
index 56e1ed88..473b2906 100644
--- a/configure.ac
+++ b/configure.ac
@@ -191,27 +191,11 @@ AC_FUNC_FORK
AC_FUNC_GETMNTENT
AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
AC_FUNC_MKTIME
-AC_CHECK_FUNCS([geteuid realpath regcomp strcasecmp \
+AC_CHECK_FUNCS([geteuid getmntinfo realpath regcomp strcasecmp \
strndup strrchr strsep swprintf \
wcwidth uname])
-
-# Checks for getmntinfo and determines whether it uses statfs or statvfs
-AC_CHECK_FUNC(getmntinfo,
- [AC_MSG_CHECKING(parameter style for getmntinfo)
- AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-# include <sys/param.h>
-# include <sys/mount.h>
-#if HAVE_SYS_UCRED_H
-#include <sys/ucred.h>
-#endif
-extern int getmntinfo (struct statfs **, int);
- ]], [])],
- [AC_DEFINE(HAVE_GETMNTINFO_STATFS, [], [getmntinfo uses statfs])
- AC_MSG_RESULT(statfs)],
- [AC_DEFINE(HAVE_GETMNTINFO_STATVFS, [], [getmntinfo uses statvfs])
- AC_MSG_RESULT(statvfs)])
- ])
-
+# For the diskspace code
+FS_STATS_TYPE
# Enable large file support if available
AC_SYS_LARGEFILE
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c
index 1f1a6201..ad6ceba5 100644
--- a/lib/libalpm/diskspace.c
+++ b/lib/libalpm/diskspace.c
@@ -19,18 +19,23 @@
#include "config.h"
-#if defined HAVE_GETMNTENT
+#if defined(HAVE_MNTENT_H)
#include <mntent.h>
+#endif
+#if defined(HAVE_SYS_STATVFS_H)
#include <sys/statvfs.h>
-#elif defined HAVE_GETMNTINFO_STATFS
+#endif
+#if defined(HAVE_SYS_PARAM_H)
#include <sys/param.h>
+#endif
+#if defined(HAVE_SYS_MOUNT_H)
#include <sys/mount.h>
-#if HAVE_SYS_UCRED_H
+#endif
+#if defined(HAVE_SYS_UCRED_H)
#include <sys/ucred.h>
#endif
-#elif defined HAVE_GETMNTINFO_STATVFS
+#if defined(HAVE_SYS_TYPES_H)
#include <sys/types.h>
-#include <sys/statvfs.h>
#endif
#include <math.h>
@@ -60,7 +65,7 @@ static alpm_list_t *mount_point_list()
#if defined HAVE_GETMNTENT
struct mntent *mnt;
FILE *fp;
- struct statvfs fsp;
+ FSSTATSTYPE fsp;
fp = setmntent(MOUNTED, "r");
@@ -77,8 +82,8 @@ static alpm_list_t *mount_point_list()
MALLOC(mp, sizeof(alpm_mountpoint_t), RET_ERR(PM_ERR_MEMORY, NULL));
mp->mount_dir = strdup(mnt->mnt_dir);
- MALLOC(mp->fsp, sizeof(struct statvfs), RET_ERR(PM_ERR_MEMORY, NULL));
- memcpy((void *)(mp->fsp), (void *)(&fsp), sizeof(struct statvfs));
+ MALLOC(mp->fsp, sizeof(FSSTATSTYPE), RET_ERR(PM_ERR_MEMORY, NULL));
+ memcpy((void *)(mp->fsp), (void *)(&fsp), sizeof(FSSTATSTYPE));
mp->blocks_needed = 0;
mp->max_blocks_needed = 0;
@@ -88,9 +93,9 @@ static alpm_list_t *mount_point_list()
}
endmntent(fp);
-#elif defined HAVE_GETMNTINFO_STATFS
+#elif defined HAVE_GETMNTINFO
int entries;
- struct statfs *fsp;
+ FSSTATSTYPE *fsp;
entries = getmntinfo(&fsp, MNT_NOWAIT);
@@ -102,30 +107,8 @@ static alpm_list_t *mount_point_list()
MALLOC(mp, sizeof(alpm_mountpoint_t), RET_ERR(PM_ERR_MEMORY, NULL));
mp->mount_dir = strdup(fsp->f_mntonname);
- MALLOC(mp->fsp, sizeof(struct statfs), RET_ERR(PM_ERR_MEMORY, NULL));
- memcpy((void *)(mp->fsp), (void *)fsp, sizeof(struct statfs));
-
- mp->blocks_needed = 0;
- mp->max_blocks_needed = 0;
-
- mount_points = alpm_list_add(mount_points, mp);
- }
-#elif defined HAVE_GETMNTINFO_STATVFS
- int entries;
- struct statvfs *fsp;
-
- entries = getmntinfo(&fsp, MNT_NOWAIT);
-
- if (entries < 0) {
- return NULL;
- }
-
- for (; entries-- > 0; fsp++) {
- MALLOC(mp, sizeof(alpm_mountpoint_t), RET_ERR(PM_ERR_MEMORY, NULL));
- mp->mount_dir = strdup(fsp->f_mntonname);
-
- MALLOC(mp->fsp, sizeof(struct statvfs), RET_ERR(PM_ERR_MEMORY, NULL));
- memcpy((void *)(mp->fsp), (void *)fsp, sizeof(struct statvfs));
+ MALLOC(mp->fsp, sizeof(FSSTATSTYPE), RET_ERR(PM_ERR_MEMORY, NULL));
+ memcpy((void *)(mp->fsp), (void *)fsp, sizeof(FSSTATSTYPE));
mp->blocks_needed = 0;
mp->max_blocks_needed = 0;
diff --git a/lib/libalpm/diskspace.h b/lib/libalpm/diskspace.h
index 15ff2f67..60c00280 100644
--- a/lib/libalpm/diskspace.h
+++ b/lib/libalpm/diskspace.h
@@ -20,9 +20,10 @@
#ifndef _ALPM_DISKSPACE_H
#define _ALPM_DISKSPACE_H
-#if defined HAVE_GETMNTINFO_STATFS
+#if defined(HAVE_SYS_MOUNT_H)
#include <sys/mount.h>
-#else
+#endif
+#if defined(HAVE_SYS_STATVFS_H)
#include <sys/statvfs.h>
#endif
@@ -31,15 +32,11 @@
typedef struct __alpm_mountpoint_t {
/* mount point information */
char *mount_dir;
-#if defined HAVE_GETMNTINFO_STATFS
- struct statfs *fsp;
-#else
- struct statvfs *fsp;
-#endif
/* storage for additional disk usage calculations */
long blocks_needed;
long max_blocks_needed;
int used;
+ FSSTATSTYPE *fsp;
} alpm_mountpoint_t;
int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db);