summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2013-07-04 12:36:20 +0200
committerAllan McRae <allan@archlinux.org>2013-07-05 06:34:58 +0200
commit897e2b121a107f6d250d38ff4d1d0a4960885c94 (patch)
tree9259dbec8880ea0cee26c4b8eb7424fa188a34bc
parenteb19d41d5f85f169cee7570f783821cb705ad37a (diff)
downloadpacman-897e2b121a107f6d250d38ff4d1d0a4960885c94.tar.gz
pacman-897e2b121a107f6d250d38ff4d1d0a4960885c94.tar.xz
use full path when checking for mountpoints
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com> Signed-off-by: Allan McRae <allan@archlinux.org>
-rw-r--r--lib/libalpm/remove.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/lib/libalpm/remove.c b/lib/libalpm/remove.c
index 0b4f80cd..7cb86ff6 100644
--- a/lib/libalpm/remove.c
+++ b/lib/libalpm/remove.c
@@ -267,6 +267,16 @@ int _alpm_remove_prepare(alpm_handle_t *handle, alpm_list_t **data)
return 0;
}
+/**
+ * @brief Test if a directory is being used as a mountpoint.
+ *
+ * @param handle context handle
+ * @param directory path to test, must be absolute and include trailing '/'
+ * @param stbuf stat result for @a directory, may be NULL
+ *
+ * @return 0 if @a directory is not a mountpoint or on error, 1 if @a directory
+ * is a mountpoint
+ */
static int dir_is_mountpoint(alpm_handle_t *handle, const char *directory,
const struct stat *stbuf)
{
@@ -317,13 +327,14 @@ static int can_remove_file(alpm_handle_t *handle, const alpm_file_t *file,
return 1;
}
+ snprintf(filepath, PATH_MAX, "%s%s", handle->root, file->name);
+
if(file->name[strlen(file->name) - 1] == '/' &&
- dir_is_mountpoint(handle, file->name, NULL)) {
+ dir_is_mountpoint(handle, filepath, NULL)) {
/* we do not remove mountpoints */
return 1;
}
- snprintf(filepath, PATH_MAX, "%s%s", handle->root, file->name);
/* If we fail write permissions due to a read-only filesystem, abort.
* Assume all other possible failures are covered somewhere else */
if(_alpm_access(handle, NULL, filepath, W_OK) == -1) {