summaryrefslogtreecommitdiffstats
path: root/Create.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2011-05-10 09:58:41 +0200
committerNeilBrown <neilb@suse.de>2011-05-10 09:58:41 +0200
commite9b11feec86972ee9a1afab4b6fb63d93221484b (patch)
tree0963bfbfbdd3118a8e447ecd8c5c96b7dd44cab0 /Create.c
parentCreate: allow chunksize to be non-power-of-2. (diff)
downloadmdadm-e9b11feec86972ee9a1afab4b6fb63d93221484b.tar.xz
mdadm-e9b11feec86972ee9a1afab4b6fb63d93221484b.zip
Create: give better error message if member device unusable.
Rather than just saying "unusable", report if device is busy or is no a block device. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'Create.c')
-rw-r--r--Create.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/Create.c b/Create.c
index ef60244a..fb7f2289 100644
--- a/Create.c
+++ b/Create.c
@@ -292,6 +292,8 @@ int Create(struct supertype *st, char *mddev,
for (dv=devlist; dv && !have_container; dv=dv->next, dnum++) {
char *dname = dv->devname;
unsigned long long freesize;
+ int dfd;
+
if (strcasecmp(dname, "missing")==0) {
if (first_missing > dnum)
first_missing = dnum;
@@ -300,6 +302,20 @@ int Create(struct supertype *st, char *mddev,
missing_disks ++;
continue;
}
+ dfd = open(dname, O_RDONLY|O_EXCL);
+ if (dfd < 0) {
+ fprintf(stderr, Name ": cannot open %s: %s\n",
+ dname, strerror(errno));
+ exit(2);
+ }
+ if (fstat(dfd, &stb) != 0 ||
+ (stb.st_mode & S_IFMT) != S_IFBLK) {
+ close(dfd);
+ fprintf(stderr, Name ": %s is not a block device\n",
+ dname);
+ exit(2);
+ }
+ close(dfd);
info.array.working_disks++;
if (dnum < raiddisks)
info.array.active_disks++;