[pacman-dev] [PATCH] Ensure we have a root partition when checking space
Partially addresses the "why doesn't CheckSpace work in a chroot" issue. We can't make it work, but we can at least detect when it won't work by the lack of a root partition to bucket the stragglers into. Check the last item in the mountpoint list to ensure it is our root device, and if not, bail out with an error. Signed-off-by: Dan McGee <dan@archlinux.org> --- For maint? Allan, Eric, enjoy, I think this should help address things, but testing it out in a chroot would be much appreciated. -Dan lib/libalpm/diskspace.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-) diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index 892b1aa..19eaeea 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -61,7 +61,7 @@ static int mount_point_cmp(const void *p1, const void *p2) static alpm_list_t *mount_point_list(void) { - alpm_list_t *mount_points = NULL; + alpm_list_t *mount_points = NULL, *ptr; alpm_mountpoint_t *mp; #if defined HAVE_GETMNTENT @@ -124,6 +124,10 @@ static alpm_list_t *mount_point_list(void) mount_points = alpm_list_msort(mount_points, alpm_list_count(mount_points), mount_point_cmp); + for(ptr = mount_points; ptr != NULL; ptr = ptr->next) { + mp = ptr->data; + _alpm_log(PM_LOG_DEBUG, "mountpoint: %s\n", mp->mount_dir); + } return(mount_points); } @@ -256,6 +260,7 @@ cleanup: int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local) { alpm_list_t *mount_points, *i; + alpm_mountpoint_t *last; size_t replaces = 0, current = 0, numtargs; int abort = 0; alpm_list_t *targ; @@ -266,6 +271,13 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local) _alpm_log(PM_LOG_ERROR, _("could not determine filesystem mount points")); return(-1); } + /* due to sorting, the last entry in our mountpoint list should be '/' */ + i = alpm_list_last(mount_points); + last = i->data; + if(strcmp("/", last->mount_dir) != 0) { + _alpm_log(PM_LOG_ERROR, _("could not determine root filesystem mount")); + return(-1); + } replaces = alpm_list_count(trans->remove); if(replaces) { -- 1.7.4.1
On 17/03/11 20:16, Dan McGee wrote:
Partially addresses the "why doesn't CheckSpace work in a chroot" issue. We can't make it work, but we can at least detect when it won't work by the lack of a root partition to bucket the stragglers into. Check the last item in the mountpoint list to ensure it is our root device, and if not, bail out with an error.
Signed-off-by: Dan McGee<dan@archlinux.org> ---
For maint? Allan, Eric, enjoy, I think this should help address things, but testing it out in a chroot would be much appreciated.
This looks good. I will do some testing with it later, but it seems fine for a maint release. But... lets look for an extreme edge case! Using "pacman -r <dir>" does not necessarily need the / partition to be found, just the one containing <dir>. I'm not sure such a set-up is possible, so I am happy ignoring it until someone actually reports it... As an asdie, with this check, we should never encounter the error when a file can not be matched to a mountpoint. So that string update should never be seen. :P
lib/libalpm/diskspace.c | 14 +++++++++++++- 1 files changed, 13 insertions(+), 1 deletions(-)
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index 892b1aa..19eaeea 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -61,7 +61,7 @@ static int mount_point_cmp(const void *p1, const void *p2)
static alpm_list_t *mount_point_list(void) { - alpm_list_t *mount_points = NULL; + alpm_list_t *mount_points = NULL, *ptr; alpm_mountpoint_t *mp;
#if defined HAVE_GETMNTENT @@ -124,6 +124,10 @@ static alpm_list_t *mount_point_list(void)
mount_points = alpm_list_msort(mount_points, alpm_list_count(mount_points), mount_point_cmp); + for(ptr = mount_points; ptr != NULL; ptr = ptr->next) { + mp = ptr->data; + _alpm_log(PM_LOG_DEBUG, "mountpoint: %s\n", mp->mount_dir); + } return(mount_points); }
@@ -256,6 +260,7 @@ cleanup: int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local) { alpm_list_t *mount_points, *i; + alpm_mountpoint_t *last; size_t replaces = 0, current = 0, numtargs; int abort = 0; alpm_list_t *targ; @@ -266,6 +271,13 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local) _alpm_log(PM_LOG_ERROR, _("could not determine filesystem mount points")); return(-1); } + /* due to sorting, the last entry in our mountpoint list should be '/' */ + i = alpm_list_last(mount_points); + last = i->data; + if(strcmp("/", last->mount_dir) != 0) { + _alpm_log(PM_LOG_ERROR, _("could not determine root filesystem mount")); + return(-1); + }
replaces = alpm_list_count(trans->remove); if(replaces) {
Partially addresses the "why doesn't CheckSpace work in a chroot" issue. We can't make it work, but we can at least detect when it won't work by checking for a partition for our given installation root. If we can't determine the mountpoint for this, bail out with an error. Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/diskspace.c | 15 +++++++++++++-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index 892b1aa..281173a 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -61,7 +61,7 @@ static int mount_point_cmp(const void *p1, const void *p2) static alpm_list_t *mount_point_list(void) { - alpm_list_t *mount_points = NULL; + alpm_list_t *mount_points = NULL, *ptr; alpm_mountpoint_t *mp; #if defined HAVE_GETMNTENT @@ -124,6 +124,10 @@ static alpm_list_t *mount_point_list(void) mount_points = alpm_list_msort(mount_points, alpm_list_count(mount_points), mount_point_cmp); + for(ptr = mount_points; ptr != NULL; ptr = ptr->next) { + mp = ptr->data; + _alpm_log(PM_LOG_DEBUG, "mountpoint: %s\n", mp->mount_dir); + } return(mount_points); } @@ -256,6 +260,7 @@ cleanup: int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local) { alpm_list_t *mount_points, *i; + alpm_mountpoint_t *root_mp; size_t replaces = 0, current = 0, numtargs; int abort = 0; alpm_list_t *targ; @@ -263,7 +268,13 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local) numtargs = alpm_list_count(trans->add); mount_points = mount_point_list(); if(mount_points == NULL) { - _alpm_log(PM_LOG_ERROR, _("could not determine filesystem mount points")); + _alpm_log(PM_LOG_ERROR, _("could not determine filesystem mount points\n")); + return(-1); + } + root_mp = match_mount_point(mount_points, handle->root); + if(root_mp == NULL) { + _alpm_log(PM_LOG_ERROR, _("could not determine root mount point %s\n"), + handle->root); return(-1); } -- 1.7.4.1
Hey guys is there a bug tracking list that I've missed somewhere? I'd like to get involved and start on something simple to get my feet wet..... thx A
On Thu, Mar 17, 2011 at 11:04 AM, Adrian <arbiterxero@gmail.com> wrote:
Hey guys is there a bug tracking list that I've missed somewhere? I'd like to get involved and start on something simple to get my feet wet.....
participants (4)
-
Adrian
-
Allan McRae
-
Dan McGee
-
Dan McGee