Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib/libalpm/diskspace.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2012-01-23 12:19:51 -0600
committerDan McGee <dan@archlinux.org>2012-01-23 12:20:52 -0600
commite50c4a8837cedf47c2fe1a2c6064b4dc03dc5b03 (patch)
treedf2e33d95d02b17e5d720320c19e267893d68bdf /lib/libalpm/diskspace.c
parentb3612e9cc198f198b3806efa461bf6fc04dd4502 (diff)
parent825b4ff35aa676b139dc24bc651724b092f2fded (diff)
Merge branch 'maint'
Conflicts: lib/libalpm/diskspace.c src/pacman/util.h
Diffstat (limited to 'lib/libalpm/diskspace.c')
-rw-r--r--lib/libalpm/diskspace.c56
1 files changed, 51 insertions, 5 deletions
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c
index 274aa676..91b655e5 100644
--- a/lib/libalpm/diskspace.c
+++ b/lib/libalpm/diskspace.c
@@ -1,7 +1,7 @@
/*
* diskspace.c
*
- * Copyright (c) 2010-2011 Pacman Development Team <pacman-dev@archlinux.org>
+ * Copyright (c) 2010-2012 Pacman Development Team <pacman-dev@archlinux.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -17,10 +17,17 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#include "config.h"
+
+#include <stdio.h>
#include <errno.h>
+
#if defined(HAVE_MNTENT_H)
#include <mntent.h>
#endif
+#if defined(HAVE_SYS_MNTTAB_H)
+#include <sys/mnttab.h>
+#endif
#if defined(HAVE_SYS_STATVFS_H)
#include <sys/statvfs.h>
#endif
@@ -69,10 +76,10 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
alpm_list_t *mount_points = NULL, *ptr;
alpm_mountpoint_t *mp;
-#if defined HAVE_GETMNTENT
+#if defined(HAVE_GETMNTENT) && defined(HAVE_MNTENT_H)
+ /* Linux */
struct mntent *mnt;
FILE *fp;
- struct statvfs fsp;
fp = setmntent(MOUNTED, "r");
@@ -81,8 +88,10 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
}
while((mnt = getmntent(fp))) {
+ struct statvfs fsp;
if(!mnt) {
- _alpm_log(handle, ALPM_LOG_WARNING, _("could not get filesystem information\n"));
+ _alpm_log(handle, ALPM_LOG_WARNING,
+ _("could not get filesystem information\n"));
continue;
}
if(statvfs(mnt->mnt_dir, &fsp) != 0) {
@@ -102,7 +111,44 @@ static alpm_list_t *mount_point_list(alpm_handle_t *handle)
}
endmntent(fp);
-#elif defined HAVE_GETMNTINFO
+#elif defined(HAVE_GETMNTENT) && defined(HAVE_MNTTAB_H)
+ /* Solaris, Illumos */
+ struct mnttab mnt;
+ FILE *fp;
+ int ret;
+
+ fp = fopen("/etc/mnttab", "r");
+
+ if(fp == NULL) {
+ return NULL;
+ }
+
+ while((ret = getmntent(fp, &mnt)) == 0) {
+ struct statvfs fsp;
+ if(statvfs(mnt->mnt_mountp, &fsp) != 0) {
+ _alpm_log(handle, ALPM_LOG_WARNING,
+ _("could not get filesystem information for %s: %s\n"),
+ mnt->mnt_mountp, strerror(errno));
+ continue;
+ }
+
+ CALLOC(mp, 1, sizeof(alpm_mountpoint_t), RET_ERR(handle, ALPM_ERR_MEMORY, NULL));
+ mp->mount_dir = strdup(mnt->mnt_mountp);
+ mp->mount_dir_len = strlen(mp->mount_dir);
+ memcpy(&(mp->fsp), &fsp, sizeof(struct statvfs));
+ mp->read_only = fsp.f_flag & ST_RDONLY;
+
+ mount_points = alpm_list_add(mount_points, mp);
+ }
+ /* -1 == EOF */
+ if(ret != -1) {
+ _alpm_log(handle, ALPM_LOG_WARNING,
+ _("could not get filesystem information\n"));
+ }
+
+ fclose(fp);
+#elif defined(HAVE_GETMNTINFO)
+ /* FreeBSD (statfs), NetBSD (statvfs), OpenBSD (statfs), OS X (statfs) */
int entries;
FSSTATSTYPE *fsp;