diff options
author | Adam Kwolek <adam.kwolek@intel.com> | 2011-12-22 21:13:55 +0100 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2011-12-22 21:13:55 +0100 |
commit | 3e9df86add05b3a759148a8a1760a44887654322 (patch) | |
tree | 67042a2bcd3aeddac438f66d49241014a1cc7f3d /Create.c | |
parent | Grow.c: fix lots of white-space issues. (diff) | |
download | mdadm-3e9df86add05b3a759148a8a1760a44887654322.tar.xz mdadm-3e9df86add05b3a759148a8a1760a44887654322.zip |
FIX: Verify if array name doesn't exist already
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.
[Changed to use map_by_name() rather than stat() to determine prior
existence - NeilBrown]
Signed-off-by: Adam Kwolek <adam.kwolek@intel.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Create.c')
-rw-r--r-- | Create.c | 12 |
1 files changed, 12 insertions, 0 deletions
@@ -558,6 +558,18 @@ 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 (strncmp(chosen_name, "/dev/md/", 8) == 0 + && map_by_name(&map, chosen_name+8) != NULL) { + 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); |