[PATCH] FIX: Verify if array name doesn't exist already

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

 



When e.g. array name (an) is correct and it is the same as container name (cn),
file element creation /dev/md/an will replace /dev/md/cn.
This can cause that user cannot access container using /dev/md/cn.

Verify during array creation if chosen name is not already existing one.

Signed-off-by: Adam Kwolek <adam.kwolek@xxxxxxxxx>
---

 Create.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/Create.c b/Create.c
index 5d1548b..e522d8e 100644
--- a/Create.c
+++ b/Create.c
@@ -558,6 +558,17 @@ int Create(struct supertype *st, char *mddev,
 		map_unlock(&map);
 		return 1;
 	}
+	/* verify if chosen_name is not in use,
+	 * it could be in conflict with already existing device
+	 * e.g. container, array
+	 */
+	if (stat(chosen_name, &stb) != -1) {
+		fprintf(stderr, Name ": Array name %s is in use already.\n",
+			chosen_name);
+		close(mdfd);
+		map_unlock(&map);
+		return 1;
+	}
 	mddev = chosen_name;
 
 	vers = md_get_version(mdfd);

--
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