9d84b2
From 3f420a49dd4d0c413b635dd621aa34eebce2d3d2 Mon Sep 17 00:00:00 2001
9d84b2
From: Karel Zak <kzak@redhat.com>
9d84b2
Date: Mon, 5 Aug 2013 13:58:01 +0200
9d84b2
Subject: [PATCH] libmount: canonicalize for conversion from loopdev backing
9d84b2
 file
9d84b2
9d84b2
  # mount foo.img /mnt
9d84b2
  # umount foo.img
9d84b2
  umount: foo.img: not mounted
9d84b2
9d84b2
The loopdev code (and sysfs backing_file) uses absolute paths, but
9d84b2
libmount does not canonicalize the path before lookup for the backing file.
9d84b2
9d84b2
References: https://bugzilla.redhat.com/show_bug.cgi?id=950497
9d84b2
Signed-off-by: Karel Zak <kzak@redhat.com>
9d84b2
---
9d84b2
 libmount/src/context_umount.c | 7 ++++++-
9d84b2
 1 file changed, 6 insertions(+), 1 deletion(-)
9d84b2
9d84b2
diff --git a/libmount/src/context_umount.c b/libmount/src/context_umount.c
9d84b2
index 2b791c4..b02902c 100644
9d84b2
--- a/libmount/src/context_umount.c
9d84b2
+++ b/libmount/src/context_umount.c
9d84b2
@@ -161,7 +161,12 @@ try_loopdev:
9d84b2
 		struct stat st;
9d84b2
 
9d84b2
 		if (stat(tgt, &st) == 0 && S_ISREG(st.st_mode)) {
9d84b2
-			int count = loopdev_count_by_backing_file(tgt, &loopdev);
9d84b2
+			int count;
9d84b2
+
9d84b2
+			cn_tgt = mnt_resolve_path(tgt, cache);
9d84b2
+			count = loopdev_count_by_backing_file(cn_tgt, &loopdev);
9d84b2
+			if (!cache)
9d84b2
+				free(cn_tgt);
9d84b2
 			if (count == 1) {
9d84b2
 				DBG(CXT, mnt_debug_h(cxt,
9d84b2
 					"umount: %s --> %s (retry)", tgt, loopdev));
9d84b2
-- 
9d84b2
1.8.1.4
9d84b2