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/508736-diskspace-add-actually-used-statfs-type-ifdefs.html)

Rémy Oudompheng 04-01-2011 10:36 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>
---
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


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

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