linux-raid.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] FIX: Verify if array name doesn't exist already
@ 2011-12-22 14:21 Adam Kwolek
  2011-12-22 20:15 ` NeilBrown
  0 siblings, 1 reply; 2+ messages in thread
From: Adam Kwolek @ 2011-12-22 14:21 UTC (permalink / raw)
  To: neilb; +Cc: linux-raid, ed.ciechanowski, marcin.labun, dan.j.williams

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@intel.com>
---

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


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-12-22 20:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-12-22 14:21 [PATCH] FIX: Verify if array name doesn't exist already Adam Kwolek
2011-12-22 20:15 ` NeilBrown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).