xbps-install: abort transaction if there's insufficient disk space on rootdir.

The free disk space wasn't computed correctly and xbps-install(8) wasn't
handling ENOSPC rval in xbps_transaction_prepare().
This commit is contained in:
Juan RP 2014-09-18 12:11:02 +02:00
parent 20326738ed
commit f52eea34d4
3 changed files with 7 additions and 1 deletions

3
NEWS
View File

@ -1,5 +1,8 @@
xbps-0.40 (???):
* xbps-install(8): handle xbps_transaction_prepare() returning ENOSPC, to
abort a transaction when there's insufficient disk space on rootdir.
* xbps-query(8): -S/--show mode no longer prints ANSI escape codes if stdout
is not a tty; suggested by @chneukirchen.

View File

@ -322,6 +322,9 @@ exec_transaction(struct xbps_handle *xhp, int maxcols, bool yes, bool drun)
array = xbps_dictionary_get(xhp->transd, "conflicts");
print_array(array);
fprintf(stderr, "Transaction aborted due to conflicting packages.\n");
} else if (rv == ENOSPC) {
/* not enough free space */
fprintf(stderr, "Transaction aborted due to insufficient disk space.\n");
} else {
xbps_dbg_printf(xhp, "Empty transaction dictionary: %s\n",
strerror(errno));

View File

@ -173,7 +173,7 @@ compute_transaction_stats(struct xbps_handle *xhp)
return 0;
}
/* compute free space on disk */
rootdir_free_size = svfs.f_bavail * svfs.f_bsize - instsize;
rootdir_free_size = svfs.f_bfree * svfs.f_bsize;
if (!xbps_dictionary_set_uint64(xhp->transd,
"disk-free-size", rootdir_free_size))