Check mountpoint read-only status when checking space
This is a bit of a stopgap solution for the problem, but an easier one than
revamping the file conflict checking code to support the same stuff. Using
some more gross autoconf magic, figure out which struct field we need to
look at to determine read-only status and store that on our mountpoint
struct. If we find out we needed this partition after calculating size
requirements, then toss an error.
Signed-off-by: Dan McGee <dan@archlinux.org>
---
Note: there are two definite areas for improvement here- we would fail on a
package uninstall due to us not setting the ->used flag there. We may want two
flags for this purpose- used, and "getting installed to" or something. Second
is we don't do anything with directories and symlinks, so this would still fail
if /boot was read-only:
while((mnt = getmntent(fp))) {
+ if(!mnt) {
+ _alpm_log(PM_LOG_WARNING, _("could not get filesystem information
"));
+ continue;
+ }
if(statvfs(mnt->mnt_dir, &fsp) != 0) {
_alpm_log(PM_LOG_WARNING,
- _("could not get filesystem information for %s
"), mnt->mnt_dir);
+ _("could not get filesystem information for %s: %s
"),
+ mnt->mnt_dir, strerror(errno));
continue;
}
for(i = mount_points; i; i = alpm_list_next(i)) {
alpm_mountpoint_t *data = i->data;
- if(data->used == 1) {
+ if(data->used && data->read_only) {
+ _alpm_log(PM_LOG_ERROR, _("Partition %s is mounted read only
"),
+ data->mount_dir);
+ abort = 1;
+ } else if(data->used) {
/* cushion is roughly min(5% capacity, 20MiB) */
long fivepc = ((long)data->fsp.f_blocks / 20) + 1;
long twentymb = (20 * 1024 * 1024 / (long)data->fsp.f_bsize) + 1;
diff --git a/lib/libalpm/diskspace.h b/lib/libalpm/diskspace.h
index ae99d0c..7c7dceb 100644
--- a/lib/libalpm/diskspace.h
+++ b/lib/libalpm/diskspace.h
@@ -37,6 +37,7 @@ typedef struct __alpm_mountpoint_t {
long blocks_needed;
long max_blocks_needed;
int used;
+ int read_only;
FSSTATSTYPE fsp;
} alpm_mountpoint_t;
--
1.7.4
02-10-2011, 12:47 AM
Allan McRae
Check mountpoint read-only status when checking space
On 09/02/11 13:23, Dan McGee wrote:
This is a bit of a stopgap solution for the problem, but an easier one than
revamping the file conflict checking code to support the same stuff. Using
some more gross autoconf magic, figure out which struct field we need to
look at to determine read-only status and store that on our mountpoint
struct. If we find out we needed this partition after calculating size
requirements, then toss an error.
Signed-off-by: Dan McGee<dan@archlinux.org>
---
Note: there are two definite areas for improvement here- we would fail on a
package uninstall due to us not setting the ->used flag there. We may want two
flags for this purpose- used, and "getting installed to" or something. Second
is we don't do anything with directories and symlinks, so this would still fail
if /boot was read-only: