summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2010-11-16 07:24:52 +0100
committerDan McGee <dan@archlinux.org>2010-12-13 03:29:49 +0100
commit695656d25279342f80c307035721ced6d37ee08b (patch)
tree79a76e61175824ef0c66abeaf97818fb1d7fa9c4 /lib
parentf4e9deb6d74614ac427b37513359d91588dd1542 (diff)
downloadpacman-695656d25279342f80c307035721ced6d37ee08b.tar.gz
pacman-695656d25279342f80c307035721ced6d37ee08b.tar.xz
Add function to match file to mount point
For a given file, determine which mount point it is on or will be installed to. Take into account that we might be using an alternative installation root. Add additional helper function added to sort mount point list for easier matching. Signed-off-by: Allan McRae <allan@archlinux.org> Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/diskspace.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c
index a5beb84f..9d153fb4 100644
--- a/lib/libalpm/diskspace.c
+++ b/lib/libalpm/diskspace.c
@@ -38,6 +38,12 @@
#include "alpm_list.h"
#include "util.h"
#include "log.h"
+#include "handle.h"
+
+static int mount_point_cmp(const alpm_mountpoint_t *mp1, const alpm_mountpoint_t *mp2)
+{
+ return(strcmp(mp1->mount_dir, mp2->mount_dir));
+}
static alpm_list_t *mount_point_list()
{
@@ -121,9 +127,31 @@ static alpm_list_t *mount_point_list()
}
#endif
+ mount_points = alpm_list_msort(mount_points, alpm_list_count(mount_points),
+ (alpm_list_fn_cmp)mount_point_cmp);
return(mount_points);
}
+static alpm_list_t *match_mount_point(const alpm_list_t *mount_points, const char *file)
+{
+ char real_path[PATH_MAX];
+ snprintf(real_path, PATH_MAX, "%s%s", handle->root, file);
+
+ alpm_list_t *mp = alpm_list_last(mount_points);
+ do {
+ alpm_mountpoint_t *data = mp->data;
+
+ if(strncmp(data->mount_dir, real_path, strlen(data->mount_dir)) == 0) {
+ return mp;
+ }
+
+ mp = mp->prev;
+ } while (mp != alpm_list_last(mount_points));
+
+ /* should not get here... */
+ return NULL;
+}
+
int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db)
{
alpm_list_t *mount_points;