util-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Reisner <dreisner@archlinux.org>
To: util-linux@vger.kernel.org
Cc: Dave Reisner <dreisner@archlinux.org>
Subject: [PATCH] umount(recursive): add a cache to the table
Date: Thu, 15 Nov 2012 23:18:07 -0500	[thread overview]
Message-ID: <1353039487-9525-1-git-send-email-dreisner@archlinux.org> (raw)

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


             reply	other threads:[~2012-11-16  4:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-16  4:18 Dave Reisner [this message]
2012-11-16  9:54 ` [PATCH] umount(recursive): add a cache to the table Karel Zak

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1353039487-9525-1-git-send-email-dreisner@archlinux.org \
    --to=dreisner@archlinux.org \
    --cc=util-linux@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).