Skip to contentSkip to conversation

bug: dmsetup fails to parse concise tables

DISCUSSION Kurt Garloff 2 participants 5 messages Feb 23, 2019 – Feb 25, 2019 Device mapper

lore
Share & tools
lore
#0 lore raw

Hi,

if I store device-mapper tables with dmsetup table --concise, I would expect that dmsetup create --concise would be able to parse the tables.

dmsetup however fails this with a simple three-entry table like this one:

joined,77f15d24-943c-4dff-91e2-e43a4b0d9a23,1,rw,0 8 linear 7:1 0,8 8 linear 7:2 0,16 8 linear 7:3 0

A full test case to be added to the test/shell/ directory is attached.

PS: I'm not on the list, please copy me on responses.

Signature · 2 lines
Kurt Garloff <[email protected]>
Cologne, Germany
#1 lore raw

Hi,

Quoted 4 lines · Kurt Garloff

if I store device-mapper tables with dmsetup table --concise, I would expect that dmsetup create --concise would be able to parse the tables.

dmsetup however fails this with a simple three-entry table like this one

Fixing patch is attached. The parser not never get to the third entry ...

Best,

Signature · 2 lines
Kurt Garloff <[email protected]>
Cologne, Germany

From: Kurt Garloff <[email protected]>
Subject: Fix parsing of concise multi-entry tables.

The parser would never proceed to the third entry and restart to process from the beginning. The patch fixes this typo.

tools/dmsetup.c renamed from tools/dmsetup.c.orig +1 -1
@@ -369,7 +369,7 @@ static int _parse_table_lines(struct dm_
 
 	do {
 		/* Identify and terminate each line */
-		if ((next_pos = strchr(_table, '\n')))
+		if ((next_pos = strchr(pos, '\n')))
 			*next_pos++ = '\0';
 		if (!_parse_line(dmt, pos, "", ++line))
 			return_0;
#2 lore raw
Quoted 1 line · Kurt Garloff

Fixing patch is attached. The parser not never get to the third entry ...

Try this.

Alasdair

tools/dmsetup.c +1 -1
@@ -369,7 +369,7 @@ static int _parse_table_lines(struct dm_task *dmt)
 
 	do {
 		/* Identify and terminate each line */
-		if ((next_pos = strchr(_table, '\n')))
+		if ((next_pos = strchr(pos, '\n')))
 			*next_pos++ = '\0';
 		if (!_parse_line(dmt, pos, "", ++line))
 			return_0;
#3 lore raw

Hi Alasdair,

Quoted 10 lines · Alasdair G Kergon
Quoted 1 line · Kurt Garloff

Fixing patch is attached. The parser not never get to the third entry ...

Try this.

Alasdair

tools/dmsetup.c static int _parse_table_lines(struct dm_task *dmt) · line 375

Quoted 8 lines
tools/dmsetup.c +1 -1
@@ -369,7 +369,7 @@ static int _parse_table_lines(struct dm_task *dmt)
 
 	do {
 		/* Identify and terminate each line */
-		if ((next_pos = strchr(_table, '\n')))
+		if ((next_pos = strchr(pos, '\n')))
 			*next_pos++ = '\0';
 		if (!_parse_line(dmt, pos, "", ++line))
 			return_0;

Yes, that is identical to what I attached :-)

Thanks for applying!

Signature · 2 lines
Kurt Garloff <[email protected]>
Cologne, Germany
#4 lore raw
In reply to Kurt Garloff
Quoted 2 lines · Kurt Garloff

if I store device-mapper tables with dmsetup table --concise, I would expect that dmsetup create --concise would be able to parse the tables.

That was the intention. Thanks for reporting the bug - fix applied upstream.

Alasdair