Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
SUSE:SLE-12-SP2:GA
util-linux.3352
util-linux-fdisk-dm-partname.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File util-linux-fdisk-dm-partname.patch of Package util-linux.3352
From 97c68d42041bb8761568f988b27cbfc470f6fb7d Mon Sep 17 00:00:00 2001 From: Stanislav Brabec <sbrabec@suse.cz> Date: Tue, 26 May 2015 17:59:29 +0200 Subject: [PATCH] libfdisk: Use predictable /dev/mapper partition names for /dev/dm-N It is impossible to predict /dev/dm-N partition names. Use predictable and better readable /dev/mapper names instead. [kzak@redhat.com: - remove if-before-free] Signed-off-by: Stanislav Brabec <sbrabec@suse.cz> Signed-off-by: Karel Zak <kzak@redhat.com> --- libfdisk/src/utils.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) Index: util-linux-2.25/libfdisk/src/utils.c =================================================================== --- util-linux-2.25.orig/libfdisk/src/utils.c +++ util-linux-2.25/libfdisk/src/utils.c @@ -1,6 +1,7 @@ #include "fdiskP.h" #include "pathnames.h" +#include "canonicalize.h" #include <ctype.h> @@ -68,6 +69,7 @@ char *fdisk_partname(const char *dev, si { char *res = NULL; const char *p = ""; + char *dev_mapped = NULL; int w = 0; if (!dev || !*dev) { @@ -76,6 +78,13 @@ char *fdisk_partname(const char *dev, si return NULL; } + /* It is impossible to predict /dev/dm-N partition names. */ + if (strncmp(dev, "/dev/dm-", sizeof("/dev/dm-") - 1) == 0) { + dev_mapped = canonicalize_dm_name (dev + 5); + if (dev_mapped) + dev = dev_mapped; + } + w = strlen(dev); if (isdigit(dev[w - 1])) p = "p"; @@ -96,10 +105,11 @@ char *fdisk_partname(const char *dev, si p = "-part"; } - if (asprintf(&res, "%.*s%s%zu", w, dev, p, partno) > 0) - return res; + if (asprintf(&res, "%.*s%s%zu", w, dev, p, partno) <= 0) + res = NULL; - return NULL; + free(dev_mapped); + return res; } #ifdef TEST_PROGRAM
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor