cdown / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

Blame SOURCES/0013-libfdisk-Fix-multipath-partition-seperators-for-user.patch

fe1ca8
From 5aea6937edf77a753e0d504bb637214e116aaed2 Mon Sep 17 00:00:00 2001
fe1ca8
From: KyleMahlkuch <Kyle.Mahlkuch@ibm.com>
fe1ca8
Date: Mon, 25 Jun 2018 14:52:01 -0500
fe1ca8
Subject: [PATCH 13/14] libfdisk: Fix multipath partition seperators for
fe1ca8
 user-friendly names
fe1ca8
fe1ca8
The current code assumes "-part" is the only partition sepereator
fe1ca8
but this is not true for some distros.
fe1ca8
fe1ca8
For example in Ubuntu 18.04 fdisk does not print the correct names for
fe1ca8
mpatha:
fe1ca8
fe1ca8
~# ls -l /dev/mapper/mpatha*
fe1ca8
lrwxrwxrwx 1 root root 7 Feb  1 04:39 /dev/mapper/mpatha -> ../dm-0
fe1ca8
lrwxrwxrwx 1 root root 7 Feb  1 04:38 /dev/mapper/mpatha1 -> ../dm-4
fe1ca8
lrwxrwxrwx 1 root root 7 Feb  1 04:38 /dev/mapper/mpatha2 -> ../dm-5
fe1ca8
lrwxrwxrwx 1 root root 7 Feb  1 04:38 /dev/mapper/mpatha3 -> ../dm-6
fe1ca8
fe1ca8
~# fdisk -l /dev/mapper/mpatha
fe1ca8
Device                   Boot     Start        End   Sectors  Size Id Type
fe1ca8
/dev/mapper/mpatha-part1           2048  419432447 419430400  200G 83 Linux
fe1ca8
/dev/mapper/mpatha-part2      419432448  838862847 419430400  200G 83 Linux
fe1ca8
/dev/mapper/mpatha-part3      838862848 1258291199 419428352  200G 83 Linux
fe1ca8
fe1ca8
Instead of assuming a partition seperator of "-part" this patch uses
fe1ca8
access to check the file system for a partition seperator of "p" or
fe1ca8
the absense of a partition seperator. If neither of these work the patch
fe1ca8
defaults to "-part" like we had before this patch.
fe1ca8
fe1ca8
Upstream: http://github.com/karelzak/util-linux/commit/73775189767195f1d9f5b6b6f6a54e51f61c4356
fe1ca8
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1655650
fe1ca8
Signed-off-by: Karel Zak <kzak@redhat.com>
fe1ca8
---
fe1ca8
 libfdisk/src/utils.c | 15 ++++++++++++++-
fe1ca8
 1 file changed, 14 insertions(+), 1 deletion(-)
fe1ca8
fe1ca8
diff --git a/libfdisk/src/utils.c b/libfdisk/src/utils.c
fe1ca8
index 5ba9e0466..54e28b2fa 100644
fe1ca8
--- a/libfdisk/src/utils.c
fe1ca8
+++ b/libfdisk/src/utils.c
fe1ca8
@@ -153,7 +153,20 @@ char *fdisk_partname(const char *dev, size_t partno)
fe1ca8
 	if ((strncmp(dev, _PATH_DEV_BYID, sizeof(_PATH_DEV_BYID) - 1) == 0) ||
fe1ca8
 	     strncmp(dev, _PATH_DEV_BYPATH, sizeof(_PATH_DEV_BYPATH) - 1) == 0 ||
fe1ca8
 	     strncmp(dev, "/dev/mapper", sizeof("/dev/mapper") - 1) == 0) {
fe1ca8
-	       p = "-part";
fe1ca8
+		asprintf(&res, "%.*s%zu", w, dev, partno);
fe1ca8
+		if (access(res, F_OK) == 0){
fe1ca8
+			p = "";
fe1ca8
+		} else {
fe1ca8
+			/* check for partition seperator "p" */
fe1ca8
+			p = "p";
fe1ca8
+			free(res);
fe1ca8
+			asprintf(&res, "%.*s%s%zu", w, dev, p, partno);
fe1ca8
+			if (access(res, F_OK) != 0){
fe1ca8
+				/* otherwise, default to "-path" */
fe1ca8
+				p = "-part";
fe1ca8
+			}
fe1ca8
+		}
fe1ca8
+		free(res);
fe1ca8
 	}
fe1ca8
 
fe1ca8
 	if (asprintf(&res, "%.*s%s%zu", w, dev, p, partno) <= 0)
fe1ca8
-- 
fe1ca8
2.17.2
fe1ca8