Skip to contentSkip to conversation

Don't add 'p' delimiter when you shouldn't

PATCH In review Phillip Susi 2 participants 3 messages Jan 9, 2012 – Feb 9, 2012 Device mapper

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Don't add 'p' delimiter when you shouldn't

The 'p' delimiter is supposed to be added when the base disk name ends in a digit. This decision was based on the name given on the command line, not the canonical device name, so giving /dev/dm-0 instead of /dev/mapper/foo triggered the digit test and added the 'p'. Changed test to use the canonical name rather than the given name.

kpartx/kpartx.c +6 -6
Index: b/kpartx/kpartx.c
===================================================================
@@ -310,12 +310,6 @@
 		device = loopdev;
 	}
 
-	if (delim == NULL) {
-		delim = malloc(DELIM_SIZE);
-		memset(delim, 0, DELIM_SIZE);
-		set_delimiter(device, delim);
-	}
-
 	off = find_devname_offset(device);
 
 	if (!loopdev) {
@@ -331,6 +325,12 @@
 	if (!mapname)
 		mapname = device + off;
 
+	if (delim == NULL) {
+		delim = malloc(DELIM_SIZE);
+		memset(delim, 0, DELIM_SIZE);
+		set_delimiter(mapname, delim);
+	}
+
 	fd = open(device, O_RDONLY);
 
 	if (fd == -1) {
#1 lore raw

Not heard anything back about this yet. Does anyone have any comments or care to merge it?

Quoted 42 lines · Phillip Susi

The 'p' delimiter is supposed to be added when the base disk name ends in a digit. This decision was based on the name given on the command line, not the canonical device name, so giving /dev/dm-0 instead of /dev/mapper/foo triggered the digit test and added the 'p'. Changed test to use the canonical name rather than the given name.

Index: b/kpartx/kpartx.c
===================================================================

kpartx/kpartx.c +6 -7
@@ -310,12 +310,6 @@
 		device = loopdev;
 	}
 
-	if (delim == NULL) {
-		delim = malloc(DELIM_SIZE);
-		memset(delim, 0, DELIM_SIZE);
-		set_delimiter(device, delim);
-	}
-
 	off = find_devname_offset(device);
 
 	if (!loopdev) {
@@ -331,6 +325,12 @@
 	if (!mapname)
 		mapname = device + off;
 
+	if (delim == NULL) {
+		delim = malloc(DELIM_SIZE);
+		memset(delim, 0, DELIM_SIZE);
+		set_delimiter(mapname, delim);
+	}
+
 	fd = open(device, O_RDONLY);
 
 	if (fd == -1) {
 
 
 
 
--
#2 lore raw
In reply to Phillip Susi
Quoted 6 lines · Phillip Susi

The 'p' delimiter is supposed to be added when the base disk name ends in a digit. This decision was based on the name given on the command line, not the canonical device name, so giving /dev/dm-0 instead of /dev/mapper/foo triggered the digit test and added the 'p'. Changed test to use the canonical name rather than the given name.

Rebased and merged.

Thanks.