From f697d61b6efbcca777221de7f391307712cfba4e Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Tue, 23 Apr 2013 10:25:02 +0200 Subject: umount: use devno to identify --all-target devices # mount -t tmpfs tmp /mnt/A # mount --bind /mnt/A /mnt/B # mount -t tmpfs tmp /mnt/C the command: umount --all-targets /mnt/A has to umount only A and B, but not C. The C is a another filesystem. Signed-off-by: Karel Zak --- sys-utils/umount.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'sys-utils/umount.c') diff --git a/sys-utils/umount.c b/sys-utils/umount.c index e88320d65..17764b534 100644 --- a/sys-utils/umount.c +++ b/sys-utils/umount.c @@ -406,7 +406,7 @@ static int umount_alltargets(struct libmnt_context *cxt, const char *spec, int r struct libmnt_fs *fs; struct libmnt_table *tb; struct libmnt_iter *itr = NULL; - char *src = NULL; + dev_t devno = 0; int rc; /* Convert @spec to device name, Use the same logic like regular @@ -423,7 +423,7 @@ static int umount_alltargets(struct libmnt_context *cxt, const char *spec, int r if (rc < 0) return mk_exit_code(cxt, rc); /* error */ - if (!mnt_fs_get_srcpath(fs)) + if (!mnt_fs_get_srcpath(fs) || !mnt_fs_get_devno(fs)) err(MOUNT_EX_USAGE, _("%s: failed to determine source"), spec); itr = mnt_new_iter(MNT_ITER_BACKWARD); @@ -437,13 +437,13 @@ static int umount_alltargets(struct libmnt_context *cxt, const char *spec, int r /* Note that @fs is from mount context and the context will be reseted * after each umount() call */ - src = xstrdup(mnt_fs_get_srcpath(fs)); + devno = mnt_fs_get_devno(fs); fs = NULL; mnt_reset_context(cxt); while (mnt_table_next_fs(tb, itr, &fs) == 0) { - if (!mnt_fs_streq_srcpath(fs, src)) + if (mnt_fs_get_devno(fs) != devno) continue; mnt_context_disable_swapmatch(cxt, 1); if (rec) @@ -457,7 +457,6 @@ static int umount_alltargets(struct libmnt_context *cxt, const char *spec, int r mnt_free_iter(itr); mnt_free_table(tb); - free(src); return rc; } -- cgit v1.2.3-55-g7522