dcavalca / rpms / util-linux

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