summaryrefslogtreecommitdiffstats
path: root/libmount/src/tab_update.c
diff options
context:
space:
mode:
authorKarel Zak2017-11-08 16:47:40 +0100
committerKarel Zak2017-11-08 17:03:59 +0100
commit06ff935ec3ad2290025b555ff32b590680af565f (patch)
treee9650c7c99554bae3fa903e865048f99509fd806 /libmount/src/tab_update.c
parentlibmount: Allow MNT_FORCE and MNT_DETACH at umount (diff)
downloadkernel-qcow2-util-linux-06ff935ec3ad2290025b555ff32b590680af565f.tar.gz
kernel-qcow2-util-linux-06ff935ec3ad2290025b555ff32b590680af565f.tar.xz
kernel-qcow2-util-linux-06ff935ec3ad2290025b555ff32b590680af565f.zip
libmount: fix access() utab write test
The commit c08396c7691e1e6a04b6b45892e7e4612ceed8d7 replaces open(O_CREATE) with ecaccess(). Unfortunately, another code depends on the original behavior. * let's make utab when really necessary rather than in the try_write() test * __mnt_new_table_from_file() returns NULL if tab-file does not exists. This is incorrect for tab_update.c stuff. We need empty table in this case. * we can check /run/mount/ directory for write access if eaccess(filename) return ENOENT (because file does not exist) Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/tab_update.c')
-rw-r--r--libmount/src/tab_update.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/libmount/src/tab_update.c b/libmount/src/tab_update.c
index e95713301..23a5a8bc5 100644
--- a/libmount/src/tab_update.c
+++ b/libmount/src/tab_update.c
@@ -571,6 +571,7 @@ leave:
unlink(uq); /* be paranoid */
free(uq);
+ DBG(UPDATE, ul_debugobj(upd, "%s: done [rc=%d]", upd->filename, rc));
return rc;
}
@@ -699,7 +700,7 @@ static int update_add_entry(struct libmnt_update *upd, struct libmnt_lock *lc)
return -MNT_ERR_LOCK;
tb = __mnt_new_table_from_file(upd->filename,
- upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB);
+ upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB, 1);
if (tb)
rc = add_file_entry(tb, upd);
if (lc)
@@ -725,7 +726,7 @@ static int update_remove_entry(struct libmnt_update *upd, struct libmnt_lock *lc
return -MNT_ERR_LOCK;
tb = __mnt_new_table_from_file(upd->filename,
- upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB);
+ upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB, 1);
if (tb) {
struct libmnt_fs *rem = mnt_table_find_target(tb, upd->target, MNT_ITER_BACKWARD);
if (rem) {
@@ -754,7 +755,7 @@ static int update_modify_target(struct libmnt_update *upd, struct libmnt_lock *l
return -MNT_ERR_LOCK;
tb = __mnt_new_table_from_file(upd->filename,
- upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB);
+ upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB, 1);
if (tb) {
struct libmnt_fs *cur = mnt_table_find_target(tb,
mnt_fs_get_srcpath(upd->fs), MNT_ITER_BACKWARD);
@@ -791,7 +792,7 @@ static int update_modify_options(struct libmnt_update *upd, struct libmnt_lock *
return -MNT_ERR_LOCK;
tb = __mnt_new_table_from_file(upd->filename,
- upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB);
+ upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB, 1);
if (tb) {
struct libmnt_fs *cur = mnt_table_find_target(tb,
mnt_fs_get_target(fs),
@@ -894,7 +895,7 @@ int mnt_update_already_done(struct libmnt_update *upd, struct libmnt_lock *lc)
}
tb = __mnt_new_table_from_file(upd->filename,
- upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB);
+ upd->userspace_only ? MNT_FMT_UTAB : MNT_FMT_MTAB, 1);
if (lc)
mnt_unlock_file(lc);
if (!tb)