From: Doug Ledford Date: Sun, 8 Jul 2007 23:59:50 +0000 (+1000) Subject: Improve error message when trying to create an array that already exists. X-Git-Tag: mdadm-2.6.3~14 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=32e5a4ee4c7a310c67faa7d1301af2ae6d75e884;p=thirdparty%2Fmdadm.git Improve error message when trying to create an array that already exists. From: Doug Ledford Simple bugfix. If an array already exists and we are asked to create this array, error out with an error message that makes sense to people instead of an error that the SET_ARRAY_INFO ioctl had an invalid argument. Plus a typo correction. --- diff --git a/Create.c b/Create.c index 2a4335a8..08972ae1 100644 --- a/Create.c +++ b/Create.c @@ -81,6 +81,15 @@ int Create(struct supertype *st, char *mddev, int mdfd, if (vers < 9000) { fprintf(stderr, Name ": Create requires md driver version 0.90.0 or later\n"); return 1; + } else { + mdu_array_info_t inf; + memset(&inf, 0, sizeof(inf)); + ioctl(mdfd, GET_ARRAY_INFO, &inf); + if (inf.working_disks != 0) { + fprintf(stderr, Name ": another array by this name" + " is already running.\n"); + return 1; + } } if (level == UnSet) { fprintf(stderr, @@ -225,7 +234,8 @@ int Create(struct supertype *st, char *mddev, int mdfd, } if (st->ss->major != 0 || st->minor_version != 90) - fprintf(stderr, Name ": Defaulting to verion %d.%d metadata\n", + fprintf(stderr, Name ": Defaulting to version" + " %d.%d metadata\n", st->ss->major, st->minor_version); }