summaryrefslogtreecommitdiffstats
path: root/lib/libalpm/diskspace.c
diff options
context:
space:
mode:
authorDan McGee <dan@archlinux.org>2010-12-15 07:14:25 +0100
committerDan McGee <dan@archlinux.org>2010-12-15 07:41:41 +0100
commitab9c0814d291db840f60073b4e63d58f932e5e64 (patch)
tree58eacd28fdd55a6a66e71f1449ad173e8c0ce20d /lib/libalpm/diskspace.c
parent6605637b5317ad82f2177cc27c5a29450a8a1ef7 (diff)
downloadpacman-ab9c0814d291db840f60073b4e63d58f932e5e64.tar.gz
pacman-ab9c0814d291db840f60073b4e63d58f932e5e64.tar.xz
Add a cushion for diskspace checking
It is the minimum of 5% of disk capacity or 20 MiB on a per-partition basis. Signed-off-by: Dan McGee <dan@archlinux.org>
Diffstat (limited to 'lib/libalpm/diskspace.c')
-rw-r--r--lib/libalpm/diskspace.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/lib/libalpm/diskspace.c b/lib/libalpm/diskspace.c
index 5ed8e0be..97f28ab2 100644
--- a/lib/libalpm/diskspace.c
+++ b/lib/libalpm/diskspace.c
@@ -294,10 +294,15 @@ int _alpm_check_diskspace(pmtrans_t *trans, pmdb_t *db_local)
for(i = mount_points; i; i = alpm_list_next(i)) {
alpm_mountpoint_t *data = i->data;
if(data->used == 1) {
- _alpm_log(PM_LOG_DEBUG, "partition %s, needed %ld, free %ld\n",
- data->mount_dir, data->max_blocks_needed,
+ /* cushion is roughly min(5% capacity, 20MiB) */
+ long fivepc = (data->fsp.f_blocks / 20) + 1;
+ long twentymb = (20 * 1024 * 1024 / data->fsp.f_bsize) + 1;
+ long cushion = fivepc < twentymb ? fivepc : twentymb;
+
+ _alpm_log(PM_LOG_DEBUG, "partition %s, needed %ld, cushion %ld, free %ld\n",
+ data->mount_dir, data->max_blocks_needed, cushion,
(unsigned long)data->fsp.f_bfree);
- if(data->max_blocks_needed > data->fsp.f_bfree) {
+ if(data->max_blocks_needed + cushion > data->fsp.f_bfree) {
abort = 1;
}
}