[PATCH 04/17] fix variable offset when ':' is present in the device name

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Dan Williams <djbw@xxxxxx>

Stopping at the first ':' precludes using device names like
/dev/disk/by-path/pci-0000:04:00.0-sas-0x500605b005846060:1:0-0x5000cca01a7c5605:10

so, check that the name is not ambiguous before chopping off the offset at the end

Signed-off-by: Dan Williams <dan.j.williams@xxxxxxxxx>
Signed-off-by: Song Liu <songliubraving@xxxxxx>
---
 Create.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/Create.c b/Create.c
index 21d1374..2642b36 100644
--- a/Create.c
+++ b/Create.c
@@ -306,7 +306,13 @@ int Create(struct supertype *st, char *mddev,
 			continue;
 		}
 		if (data_offset == VARIABLE_OFFSET) {
-			doff = strchr(dname, ':');
+			doff = strrchr(dname, ':');
+			if (stat(dname, &stb) == 0) {
+				pr_err("cannot determine if %s is a device name, or a device with a data-offset argument of '%s'\n",
+				       dname, doff+1);
+				pr_err("check that you have specified a data-offset for all array members\n");
+				exit(2);
+			}
 			if (doff) {
 				*doff++ = 0;
 				dv->data_offset = parse_size(doff);
-- 
2.4.6

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux RAID Wiki]     [ATA RAID]     [Linux SCSI Target Infrastructure]     [Linux Block]     [Linux IDE]     [Linux SCSI]     [Linux Hams]     [Device Mapper]     [Device Mapper Cryptographics]     [Kernel]     [Linux Admin]     [Linux Net]     [GFS]     [RPM]     [git]     [Yosemite Forum]


  Powered by Linux