diff options
author | Karel Zak | 2011-03-28 12:40:24 +0200 |
---|---|---|
committer | Karel Zak | 2011-03-28 12:40:24 +0200 |
commit | c570f567eb4ab90e9d28853da48d1600782d0b19 (patch) | |
tree | e6a5bf16b4410a8078de4c7696425d8e1c7e8a06 /shlibs/mount/src/tab_update.c | |
parent | build-sys: do not ignore datarootdir (diff) | |
download | kernel-qcow2-util-linux-c570f567eb4ab90e9d28853da48d1600782d0b19.tar.gz kernel-qcow2-util-linux-c570f567eb4ab90e9d28853da48d1600782d0b19.tar.xz kernel-qcow2-util-linux-c570f567eb4ab90e9d28853da48d1600782d0b19.zip |
libmount: create a default lock for mtab update
Now it's necessary to explicitly create a lock for mnt_update_table().
It seems better to create the lock in mnt_update_table() by default to
skip this extra step.
Reported-by: Jan Engelhardt <jengelh@medozas.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount/src/tab_update.c')
-rw-r--r-- | shlibs/mount/src/tab_update.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/shlibs/mount/src/tab_update.c b/shlibs/mount/src/tab_update.c index 47a3e5fe9..9a56b6738 100644 --- a/shlibs/mount/src/tab_update.c +++ b/shlibs/mount/src/tab_update.c @@ -85,7 +85,8 @@ void mnt_free_update(struct libmnt_update *upd) /* * Returns 0 on success, 1 if not file available, -1 in case of error. */ -int mnt_update_set_filename(struct libmnt_update *upd, const char *filename, int userspace_only) +int mnt_update_set_filename(struct libmnt_update *upd, const char *filename, + int userspace_only) { const char *path = NULL; int rw = 0; @@ -785,6 +786,7 @@ static int update_modify_options(struct libmnt_update *upd, struct libmnt_lock * */ int mnt_update_table(struct libmnt_update *upd, struct libmnt_lock *lc) { + struct libmnt_lock *lc0 = lc; int rc = -EINVAL; assert(upd); @@ -799,6 +801,9 @@ int mnt_update_table(struct libmnt_update *upd, struct libmnt_lock *lc) DBG(UPDATE, mnt_fs_print_debug(upd->fs, stderr)); } + if (!lc && !upd->userspace_only) + lc = mnt_new_lock(upd->filename, 0); + if (!upd->fs && upd->target) rc = update_remove_entry(upd, lc); /* umount */ else if (upd->mountflags & MS_MOVE) @@ -811,6 +816,10 @@ int mnt_update_table(struct libmnt_update *upd, struct libmnt_lock *lc) upd->ready = FALSE; DBG(UPDATE, mnt_debug_h(upd, "%s: update tab: done [rc=%d]", upd->filename, rc)); + + if (lc != lc0) + mnt_free_lock(lc); + return rc; } |