umount(recursive): add a cache to the table
PATCH 1/1 umount(recursive): add a cache to the table
Without this table libmount will not resolve paths, meaning that umounting by relative path will fail.
Signed-off-by Dave Reisner <[email protected]>
---
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(+)
sys-utils/umount.c +7 -0
@@ -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; }
Signature · 1 line
1.8.0
Karel Zak
maintainerQuoted 2 lines · Dave Reisner
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
Signature · 2 lines
Karel Zak <[email protected]> http://karelzak.blogspot.com