diff options
author | Karel Zak | 2011-03-30 09:30:05 +0200 |
---|---|---|
committer | Karel Zak | 2011-03-30 09:30:05 +0200 |
commit | 5976114f628c96285c9b3f2cc55994f216afe6f2 (patch) | |
tree | 7ec6963afb34654f2f44810c31a04af1c413cc52 /shlibs/mount/src/tab_update.c | |
parent | docs: update TODO (diff) | |
download | kernel-qcow2-util-linux-5976114f628c96285c9b3f2cc55994f216afe6f2.tar.gz kernel-qcow2-util-linux-5976114f628c96285c9b3f2cc55994f216afe6f2.tar.xz kernel-qcow2-util-linux-5976114f628c96285c9b3f2cc55994f216afe6f2.zip |
libmount: block signals when writing to mtab
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 | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/shlibs/mount/src/tab_update.c b/shlibs/mount/src/tab_update.c index 9a56b6738..7cf166ba5 100644 --- a/shlibs/mount/src/tab_update.c +++ b/shlibs/mount/src/tab_update.c @@ -778,10 +778,15 @@ static int update_modify_options(struct libmnt_update *upd, struct libmnt_lock * /** * mnt_update_table: * @upd: update - * @lc: lock + * @lc: lock or NULL * * High-level API to update /etc/mtab (or private /dev/.mount/utab file). * + * The @lc lock is optional and will be created if necessary. Note that + * the automatically created lock blocks all signals. + * + * See also mnt_lock_block_signals() and mnt_context_get_lock(). + * * Returns: 0 on success, negative number on error. */ int mnt_update_table(struct libmnt_update *upd, struct libmnt_lock *lc) @@ -801,8 +806,11 @@ 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) + if (!lc && !upd->userspace_only) { lc = mnt_new_lock(upd->filename, 0); + if (lc) + mnt_lock_block_signals(lc, TRUE); + } if (!upd->fs && upd->target) rc = update_remove_entry(upd, lc); /* umount */ @@ -825,14 +833,6 @@ int mnt_update_table(struct libmnt_update *upd, struct libmnt_lock *lc) #ifdef TEST_PROGRAM -struct libmnt_lock *lock; - -static void lock_fallback(void) -{ - if (lock) - mnt_unlock_file(lock); -} - static int update(const char *target, struct libmnt_fs *fs, unsigned long mountflags) { int rc; @@ -858,13 +858,7 @@ static int update(const char *target, struct libmnt_fs *fs, unsigned long mountf /* [... here should be mount(2) call ...] */ - filename = mnt_update_get_filename(upd); - if (filename) { - lock = mnt_new_lock(filename, 0); - if (lock) - atexit(lock_fallback); - } - rc = mnt_update_table(upd, lock); + rc = mnt_update_table(upd, NULL); done: return rc; } |