[pacman-dev] [PATCH 1/2] Unify two free diskspace error messages
Although they won't be the same in the gettext catalog because of the '\n' we should still use the same text. Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/error.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/lib/libalpm/error.c b/lib/libalpm/error.c index 4dab9fa..1b144a5 100644 --- a/lib/libalpm/error.c +++ b/lib/libalpm/error.c @@ -58,7 +58,7 @@ const char SYMEXPORT *alpm_strerror(int err) case PM_ERR_WRONG_ARGS: return _("wrong or NULL argument passed"); case PM_ERR_DISK_SPACE: - return _("not enough disk space"); + return _("not enough free disk space"); /* Interface */ case PM_ERR_HANDLE_NULL: return _("library not initialized"); -- 1.7.3.5
This is helpful anyway to the user, and should also be helpful to us if we see problems cropping up in the check during development. Also add a missing ->used = 0 initialization in the code path less taken. Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/diskspace.c | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-) diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index bc5f512..972b8f2 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -84,8 +84,8 @@ static alpm_list_t *mount_point_list(void) mp->mount_dir = strdup(mnt->mnt_dir); memcpy(&(mp->fsp), &fsp, sizeof(FSSTATSTYPE)); - mp->blocks_needed = 0; - mp->max_blocks_needed = 0; + mp->blocks_needed = 0l; + mp->max_blocks_needed = 0l; mp->used = 0; mount_points = alpm_list_add(mount_points, mp); @@ -107,8 +107,9 @@ static alpm_list_t *mount_point_list(void) mp->mount_dir = strdup(fsp->f_mntonname); memcpy(&(mp->fsp), fsp, sizeof(FSSTATSTYPE)); - mp->blocks_needed = 0; - mp->max_blocks_needed = 0; + mp->blocks_needed = 0l; + mp->max_blocks_needed = 0l; + mp->used = 0; mount_points = alpm_list_add(mount_points, mp); } @@ -178,8 +179,7 @@ static int calculate_removed_size(const alpm_list_t *mount_points, data = mp->data; /* the addition of (divisor - 1) performs ceil() with integer division */ data->blocks_needed -= - (st.st_size + data->fsp.f_bsize - 1) / data->fsp.f_bsize; - data->used = 1; + (st.st_size + data->fsp.f_bsize - 1l) / data->fsp.f_bsize; } return(0); @@ -230,7 +230,7 @@ static int calculate_installed_size(const alpm_list_t *mount_points, data = mp->data; /* the addition of (divisor - 1) performs ceil() with integer division */ data->blocks_needed += - (archive_entry_size(entry) + data->fsp.f_bsize - 1) / data->fsp.f_bsize; + (archive_entry_size(entry) + data->fsp.f_bsize - 1l) / data->fsp.f_bsize; data->used = 1; } @@ -306,11 +306,19 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local) (unsigned long)data->fsp.f_bfree); if(data->max_blocks_needed + cushion >= 0 && (unsigned long)(data->max_blocks_needed + cushion) > data->fsp.f_bfree) { + _alpm_log(PM_LOG_ERROR, _("Partition %s too full: %ld blocks needed, %ld blocks free)\n"), + data->mount_dir, data->max_blocks_needed + cushion, + (unsigned long)data->fsp.f_bfree); abort = 1; } } } + if(!abort) { + _alpm_log(PM_LOG_DEBUG, "proceeding with fake abort\n"); + abort = 1; + } + for(i = mount_points; i; i = alpm_list_next(i)) { alpm_mountpoint_t *data = i->data; FREE(data->mount_dir); -- 1.7.3.5
On Tue, Jan 11, 2011 at 7:51 PM, Dan McGee <dan@archlinux.org> wrote:
This is helpful anyway to the user, and should also be helpful to us if we see problems cropping up in the check during development.
Also add a missing ->used = 0 initialization in the code path less taken.
Signed-off-by: Dan McGee <dan@archlinux.org> --- lib/libalpm/diskspace.c | 22 +++++++++++++++------- 1 files changed, 15 insertions(+), 7 deletions(-)
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c index bc5f512..972b8f2 100644 --- a/lib/libalpm/diskspace.c +++ b/lib/libalpm/diskspace.c @@ -84,8 +84,8 @@ static alpm_list_t *mount_point_list(void) mp->mount_dir = strdup(mnt->mnt_dir); memcpy(&(mp->fsp), &fsp, sizeof(FSSTATSTYPE));
- mp->blocks_needed = 0; - mp->max_blocks_needed = 0; + mp->blocks_needed = 0l; + mp->max_blocks_needed = 0l; mp->used = 0;
mount_points = alpm_list_add(mount_points, mp); @@ -107,8 +107,9 @@ static alpm_list_t *mount_point_list(void) mp->mount_dir = strdup(fsp->f_mntonname); memcpy(&(mp->fsp), fsp, sizeof(FSSTATSTYPE));
- mp->blocks_needed = 0; - mp->max_blocks_needed = 0; + mp->blocks_needed = 0l; + mp->max_blocks_needed = 0l; + mp->used = 0;
mount_points = alpm_list_add(mount_points, mp); } @@ -178,8 +179,7 @@ static int calculate_removed_size(const alpm_list_t *mount_points, data = mp->data; /* the addition of (divisor - 1) performs ceil() with integer division */ data->blocks_needed -= - (st.st_size + data->fsp.f_bsize - 1) / data->fsp.f_bsize; - data->used = 1; + (st.st_size + data->fsp.f_bsize - 1l) / data->fsp.f_bsize; }
return(0); @@ -230,7 +230,7 @@ static int calculate_installed_size(const alpm_list_t *mount_points, data = mp->data; /* the addition of (divisor - 1) performs ceil() with integer division */ data->blocks_needed += - (archive_entry_size(entry) + data->fsp.f_bsize - 1) / data->fsp.f_bsize; + (archive_entry_size(entry) + data->fsp.f_bsize - 1l) / data->fsp.f_bsize; data->used = 1; }
@@ -306,11 +306,19 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local) (unsigned long)data->fsp.f_bfree); if(data->max_blocks_needed + cushion >= 0 && (unsigned long)(data->max_blocks_needed + cushion) > data->fsp.f_bfree) { + _alpm_log(PM_LOG_ERROR, _("Partition %s too full: %ld blocks needed, %ld blocks free)\n"), + data->mount_dir, data->max_blocks_needed + cushion, + (unsigned long)data->fsp.f_bfree); abort = 1; } } }
+ if(!abort) { + _alpm_log(PM_LOG_DEBUG, "proceeding with fake abort\n"); + abort = 1; + } + Just checking to see if anyone was actually paying attention...obviously this shouldn't be in the commit. :)
for(i = mount_points; i; i = alpm_list_next(i)) { alpm_mountpoint_t *data = i->data; FREE(data->mount_dir); -- 1.7.3.5
participants (1)
-
Dan McGee