[pacman-dev] [PATCH 3/3] diskspace: add the actually used statfs type in ifdefs

Rémy Oudompheng remyoudompheng at gmail.com
Fri Apr 1 18:36:50 EDT 2011


Some systems, like FreeBSD might define both statfs
and statvfs: however if statvfs exists whereas getmntinfo()
uses a statfs struct, the current ifdefs would select the wrong
line of code.

Signed-off-by: Rémy Oudompheng <remy at archlinux.org>
---
 acinclude.m4            |    8 ++++++--
 lib/libalpm/diskspace.c |    4 ++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index 7309d73..1e51e92 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -115,8 +115,12 @@ AC_DEFUN([FS_STATS_TYPE],
 extern int getmntinfo (struct statfs **, int);
 ]],
           [])],
-        [fs_stats_cv_type="struct statfs"],
-        [fs_stats_cv_type="struct statvfs"])],
+        [fs_stats_cv_type="struct statfs"
+         AC_DEFINE([HAVE_GETMNTINFO_STATFS], 1, [Define if getmntinfo() uses statfs.])
+        ],
+        [fs_stats_cv_type="struct statvfs"
+         AC_DEFINE([HAVE_GETMNTINFO_STATVFS], 1, [Define if getmntinfo() uses statvfs.])
+        ])],
       [AC_CHECK_FUNC(getmntent,
         [fs_stats_cv_type="struct statvfs"])]
     )]
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c
index 281173a..066107d 100644
--- a/lib/libalpm/diskspace.c
+++ b/lib/libalpm/diskspace.c
@@ -112,9 +112,9 @@ static alpm_list_t *mount_point_list(void)
 		mp->mount_dir = strdup(fsp->f_mntonname);
 		mp->mount_dir_len = strlen(mp->mount_dir);
 		memcpy(&(mp->fsp), fsp, sizeof(FSSTATSTYPE));
-#if defined HAVE_STRUCT_STATVFS_F_FLAG
+#if defined(HAVE_GETMNTINFO_STATVFS) && defined(HAVE_STRUCT_STATVFS_F_FLAG)
 		mp->read_only = fsp->f_flag & ST_RDONLY;
-#elif defined HAVE_STRUCT_STATFS_F_FLAGS
+#elif defined(HAVE_GETMNTINFO_STATFS) && defined(HAVE_STRUCT_STATFS_F_FLAGS)
 		mp->read_only = fsp->f_flags & MNT_RDONLY;
 #endif
 
-- 
1.7.4.2



More information about the pacman-dev mailing list