summaryrefslogtreecommitdiffstats
path: root/libmount/src/context_umount.c
diff options
context:
space:
mode:
authorKarel Zak2014-11-19 11:07:40 +0100
committerKarel Zak2014-11-19 11:07:40 +0100
commit7deae03fb4a70ed64881ef92b9f456ed41897c6d (patch)
treee255ab7f0edabf503d15c217e36431582a79249c /libmount/src/context_umount.c
parentlibmount: reuse allocated fs in parser (diff)
downloadkernel-qcow2-util-linux-7deae03fb4a70ed64881ef92b9f456ed41897c6d.tar.gz
kernel-qcow2-util-linux-7deae03fb4a70ed64881ef92b9f456ed41897c6d.tar.xz
kernel-qcow2-util-linux-7deae03fb4a70ed64881ef92b9f456ed41897c6d.zip
libmount: add private mnt_context_get_mtab_for_target()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/context_umount.c')
-rw-r--r--libmount/src/context_umount.c41
1 files changed, 6 insertions, 35 deletions
diff --git a/libmount/src/context_umount.c b/libmount/src/context_umount.c
index 6c1d9a2f4..c50b97bfb 100644
--- a/libmount/src/context_umount.c
+++ b/libmount/src/context_umount.c
@@ -38,21 +38,6 @@
# define UMOUNT_UNUSED 0x80000000 /* Flag guaranteed to be unused */
#endif
-/*
- * Called by mtab parser to filter out entries, non-zero means that
- * an entry has to be filtered out.
- */
-static int mtab_filter(struct libmnt_fs *fs, void *data)
-{
- if (!fs || !data)
- return 0;
- if (mnt_fs_streq_target(fs, data))
- return 0;
- if (mnt_fs_streq_srcpath(fs, data))
- return 0;
- return 1;
-}
-
/**
* mnt_context_find_umount_fs:
* @cxt: mount context
@@ -68,8 +53,7 @@ int mnt_context_find_umount_fs(struct libmnt_context *cxt,
int rc;
struct libmnt_table *mtab = NULL;
struct libmnt_fs *fs;
- struct libmnt_cache *cache = NULL;
- char *cn_tgt = NULL, *loopdev = NULL;
+ char *loopdev = NULL;
if (pfs)
*pfs = NULL;
@@ -93,24 +77,10 @@ int mnt_context_find_umount_fs(struct libmnt_context *cxt,
* it's usable only for canonicalized stuff (e.g. kernel mountinfo).
*/
if (!mnt_context_mtab_writable(cxt) && *tgt == '/' &&
- !mnt_context_is_force(cxt) && !mnt_context_is_lazy(cxt)) {
-
- struct stat st;
-
- if (stat(tgt, &st) == 0 && S_ISDIR(st.st_mode)) {
- cache = mnt_context_get_cache(cxt);
- cn_tgt = mnt_resolve_path(tgt, cache);
- if (cn_tgt)
- mnt_context_set_tabfilter(cxt, mtab_filter, cn_tgt);
- }
- }
- rc = mnt_context_get_mtab(cxt, &mtab);
-
- if (cn_tgt) {
- mnt_context_set_tabfilter(cxt, NULL, NULL);
- if (!cache)
- free(cn_tgt);
- }
+ !mnt_context_is_force(cxt) && !mnt_context_is_lazy(cxt))
+ rc = mnt_context_get_mtab_for_target(cxt, &mtab, tgt);
+ else
+ rc = mnt_context_get_mtab(cxt, &mtab);
if (rc) {
DBG(CXT, ul_debugobj(cxt, "umount: failed to read mtab"));
@@ -161,6 +131,7 @@ try_loopdev:
if (stat(tgt, &st) == 0 && S_ISREG(st.st_mode)) {
int count;
+ struct libmnt_cache *cache = mnt_context_get_cache(cxt);
const char *bf = cache ? mnt_resolve_path(tgt, cache) : tgt;
count = loopdev_count_by_backing_file(bf, &loopdev);