X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=Build.c;h=962c2e3776b91ccb15135b9c0cff91f322a8c9fe;hb=69068584f9ed68b8b2736287a1c9863e11b741d5;hp=665d9067b8d6c34ccb0abb9e7e2bf5f46281e4e0;hpb=cd6cbb08c458cee07acb1d854e04532b29ec87bf;p=thirdparty%2Fmdadm.git diff --git a/Build.c b/Build.c index 665d9067..962c2e37 100644 --- a/Build.c +++ b/Build.c @@ -24,10 +24,6 @@ #include "mdadm.h" -#define REGISTER_DEV _IO (MD_MAJOR, 1) -#define START_MD _IO (MD_MAJOR, 2) -#define STOP_MD _IO (MD_MAJOR, 3) - int Build(char *mddev, struct mddev_dev *devlist, struct shape *s, struct context *c) { @@ -41,7 +37,7 @@ int Build(char *mddev, struct mddev_dev *devlist, * cc = chunk size factor: 0==4k, 1==8k etc. */ int i; - struct stat stb; + dev_t rdev; int subdevs = 0, missing_disks = 0; struct mddev_dev *dv; int bitmap_fd; @@ -64,16 +60,8 @@ int Build(char *mddev, struct mddev_dev *devlist, missing_disks++; continue; } - if (stat(dv->devname, &stb)) { - pr_err("Cannot find %s: %s\n", - dv->devname, strerror(errno)); - return 1; - } - if ((stb.st_mode & S_IFMT) != S_IFBLK) { - pr_err("%s is not a block device.\n", - dv->devname); + if (!stat_is_blkdev(dv->devname, NULL)) return 1; - } } if (s->raiddisks != subdevs) { @@ -126,8 +114,8 @@ int Build(char *mddev, struct mddev_dev *devlist, array.nr_disks = s->raiddisks; array.raid_disks = s->raiddisks; array.md_minor = 0; - if (fstat(mdfd, &stb) == 0) - array.md_minor = minor(stb.st_rdev); + if (fstat_is_blkdev(mdfd, mddev, &rdev)) + array.md_minor = minor(rdev); array.not_persistent = 1; array.state = 0; /* not clean, but no errors */ if (s->assume_clean) @@ -161,16 +149,8 @@ int Build(char *mddev, struct mddev_dev *devlist, if (strcmp("missing", dv->devname) == 0) continue; - if (stat(dv->devname, &stb)) { - pr_err("Weird: %s has disappeared.\n", - dv->devname); - goto abort; - } - if ((stb.st_mode & S_IFMT)!= S_IFBLK) { - pr_err("Weird: %s is no longer a block device.\n", - dv->devname); + if (!stat_is_blkdev(dv->devname, &rdev)) goto abort; - } fd = open(dv->devname, O_RDONLY|O_EXCL); if (fd < 0) { pr_err("Cannot open %s: %s\n", @@ -186,8 +166,8 @@ int Build(char *mddev, struct mddev_dev *devlist, disk.state = (1<writemostly == FlagSet) disk.state |= 1<devname, strerror(errno)); @@ -201,7 +181,7 @@ int Build(char *mddev, struct mddev_dev *devlist, int major = BITMAP_MAJOR_HI; #if 0 if (s->bitmap_chunk == UnSet) { - pr_err("%s cannot be openned.", s->bitmap_file); + pr_err("%s cannot be opened.\n", s->bitmap_file); goto abort; } #endif @@ -213,7 +193,7 @@ int Build(char *mddev, struct mddev_dev *devlist, } bitmap_fd = open(s->bitmap_file, O_RDWR); if (bitmap_fd < 0) { - pr_err("%s cannot be openned.", s->bitmap_file); + pr_err("%s cannot be opened.\n", s->bitmap_file); goto abort; } }