Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   ArchLinux Pacman Development (http://www.linux-archive.org/archlinux-pacman-development/)
-   -   diskspace: add the actually used statfs type in ifdefs (http://www.linux-archive.org/archlinux-pacman-development/510000-diskspace-add-actually-used-statfs-type-ifdefs.html)

Rémy Oudompheng 04-04-2011 11:37 PM

diskspace: add the actually used statfs type in ifdefs
 
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@archlinux.org>
---
Rework of a previous patch. autoconf no longer spews errors
on Linux, but still complains on FreeBSD + autoconf 2.68
I don't know how to fix that, but the errors also appear
with current maint branch.

Still compiles correctly on ArchLinux and FreeBSD with this
patch.

On branch 'maint'

acinclude.m4 | 7 +++++++
lib/libalpm/diskspace.c | 4 ++--
2 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/acinclude.m4 b/acinclude.m4
index 7309d73..5adb3cc 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -123,6 +123,13 @@ extern int getmntinfo (struct statfs **, int);
)
AC_DEFINE_UNQUOTED(FSSTATSTYPE, [$fs_stats_cv_type],
[Defined as the filesystem stats type ('statvfs' or 'statfs')])
+ if test $ac_cv_func_getmntinfo = yes; then
+ if test "$fs_stats_cv_type" = "struct statvfs"; then
+ AC_DEFINE([HAVE_GETMNTINFO_STATVFS], 1, [Define if getmntinfo() uses statvfs.])
+ else
+ AC_DEFINE([HAVE_GETMNTINFO_STATFS], 1, [Define if getmntinfo() uses statfs.])
+ fi
+ fi
])

dnl Checks for PATH_MAX and defines it if not present
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


All times are GMT. The time now is 11:34 PM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.