util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] umount(recursive): add a cache to the table
@ 2012-11-16  4:18 Dave Reisner
  2012-11-16  9:54 ` Karel Zak
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Reisner @ 2012-11-16  4:18 UTC (permalink / raw)
  To: util-linux; +Cc: Dave Reisner

Without this table libmount will not resolve paths, meaning that
umounting by relative path will fail.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
---
Alternatively, one could call mnt_resolve_path(spec, NULL) and avoid attaching
the cache for the single lookup.

 sys-utils/umount.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sys-utils/umount.c b/sys-utils/umount.c
index b21e396..87812ac 100644
--- a/sys-utils/umount.c
+++ b/sys-utils/umount.c
@@ -364,6 +364,7 @@ done:
 static int umount_recursive(struct libmnt_context *cxt, const char *spec)
 {
 	struct libmnt_table *tb;
+	struct libmnt_cache *cache;
 	int rc;
 
 	/* it's always real mountpoint, don't assume that the target maybe a device */
@@ -374,6 +375,11 @@ static int umount_recursive(struct libmnt_context *cxt, const char *spec)
 		err(MOUNT_EX_SYSERR, _("libmount table allocation failed"));
 	mnt_table_set_parser_errcb(tb, table_parser_errcb);
 
+	cache = mnt_new_cache();
+	if (!cache)
+		err(MOUNT_EX_SYSERR, _("libmount cache allocation failed"));
+	mnt_table_set_cache(tb, cache);
+
 	/*
 	 * Don't use mtab here. The recursive umount depends on child-parent
 	 * relationship defined by mountinfo file.
@@ -395,6 +401,7 @@ static int umount_recursive(struct libmnt_context *cxt, const char *spec)
 		}
 	}
 
+	mnt_free_cache(cache);
 	mnt_free_table(tb);
 	return rc;
 }
-- 
1.8.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] umount(recursive): add a cache to the table
  2012-11-16  4:18 [PATCH] umount(recursive): add a cache to the table Dave Reisner
@ 2012-11-16  9:54 ` Karel Zak
  0 siblings, 0 replies; 2+ messages in thread
From: Karel Zak @ 2012-11-16  9:54 UTC (permalink / raw)
  To: Dave Reisner; +Cc: util-linux

On Thu, Nov 15, 2012 at 11:18:07PM -0500, Dave Reisner wrote:
> Without this table libmount will not resolve paths, meaning that
> umounting by relative path will fail.

Oh, good catch! Applied, thanks.

It seems better too use mnt_context_get_cache() to make it sensitive
to --no-canonicalize cmdline option (it's used very rarely by some
external helpers (fuse) to make sure that the path won't be
modified.)

    Karel

-- 
 Karel Zak  <kzak@redhat.com>
 http://karelzak.blogspot.com

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-11-16  9:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-16  4:18 [PATCH] umount(recursive): add a cache to the table Dave Reisner
2012-11-16  9:54 ` Karel Zak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).