Improve error message when trying to create an array that already exists.

From: Doug Ledford <dledford@redhat.com>

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.
This commit is contained in:
Doug Ledford 2007-07-09 09:59:50 +10:00 committed by Neil Brown
parent a17a3de364
commit 32e5a4ee4c
1 changed files with 11 additions and 1 deletions

View File

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