diff options
author | Karel Zak | 2012-11-15 16:44:07 +0100 |
---|---|---|
committer | Karel Zak | 2012-11-15 16:44:07 +0100 |
commit | ae978c4d6ca376bdab6398e635be1664be370ffa (patch) | |
tree | 890bd3c6e1818b5efa028e7ff7e7bbaaf4f5922c /libmount/src | |
parent | tests: add shared subtrees to umount --recursive test (diff) | |
download | kernel-qcow2-util-linux-ae978c4d6ca376bdab6398e635be1664be370ffa.tar.gz kernel-qcow2-util-linux-ae978c4d6ca376bdab6398e635be1664be370ffa.tar.xz kernel-qcow2-util-linux-ae978c4d6ca376bdab6398e635be1664be370ffa.zip |
umount: (recursive) don't call umount(2) for already unmounted targets
In the umount --recursive we follow entries from mountinfo, but the
entries maybe already obsolete. Especially if the hierarchy of the
mountpoints contains shared subtrees and umount(2) for one entry may
generate umount for some other entry too.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src')
-rw-r--r-- | libmount/src/tab.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/libmount/src/tab.c b/libmount/src/tab.c index e5eb1063e..5287da4a5 100644 --- a/libmount/src/tab.c +++ b/libmount/src/tab.c @@ -901,8 +901,6 @@ static int is_mountinfo(struct libmnt_table *tb) * * This function is designed mostly for "mount -a". * - * TODO: check for loopdev (see mount/mount.c is_fstab_entry_mounted(). - * * Returns: 0 or 1 */ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs) @@ -918,8 +916,13 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs) assert(tb); assert(fstab_fs); - if (mnt_fs_is_swaparea(fstab_fs) || mnt_table_get_nents(tb) == 0) + DBG(FS, mnt_debug_h(fstab_fs, "is FS mounted? [target=%s]", + mnt_fs_get_target(fstab_fs))); + + if (mnt_fs_is_swaparea(fstab_fs) || mnt_table_get_nents(tb) == 0) { + DBG(FS, mnt_debug_h(fstab_fs, "- ignore (swap or no data)")); return 0; + } if (is_mountinfo(tb)) { /* @tb is mountinfo, so we can try to use fs-roots */ @@ -942,9 +945,10 @@ int mnt_table_is_fs_mounted(struct libmnt_table *tb, struct libmnt_fs *fstab_fs) tgt = mnt_fs_get_target(fstab_fs); - if (!tgt || !src) + if (!tgt || !src) { + DBG(FS, mnt_debug_h(fstab_fs, "- ignore (no source/target)")); goto done; - + } mnt_reset_iter(&itr, MNT_ITER_FORWARD); while (mnt_table_next_fs(tb, &itr, &fs) == 0) { |