summaryrefslogtreecommitdiffstats
path: root/Assemble.c
diff options
context:
space:
mode:
authorZhilong Liu <zlliu@suse.com>2017-05-05 05:09:41 +0200
committerJes Sorensen <jsorensen@fb.com>2017-05-05 17:05:32 +0200
commit9e04ac1c43e63eccb68eb196174069e5c23d0270 (patch)
tree956239ee16ae6d6ad3e8a44703a4bb6b7cd57226 /Assemble.c
parentmdadm/util: unify fstat checking blkdev into function (diff)
downloadmdadm-9e04ac1c43e63eccb68eb196174069e5c23d0270.tar.xz
mdadm-9e04ac1c43e63eccb68eb196174069e5c23d0270.zip
mdadm/util: unify stat checking blkdev into function
declare function stat_is_blkdev() to integrate repeated stat checking blkdev operations, it returns 'true/1' when it is a block device, and returns 'false/0' when it isn't. The devname is necessary parameter, *rdev is optional, parse the pointer of dev_t *rdev, if valid, assigned device number to dev_t *rdev, if NULL, ignores. Signed-off-by: Zhilong Liu <zlliu@suse.com> Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'Assemble.c')
-rw-r--r--Assemble.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/Assemble.c b/Assemble.c
index 9d0a89ff..30d5838c 100644
--- a/Assemble.c
+++ b/Assemble.c
@@ -512,15 +512,12 @@ static int select_devices(struct mddev_dev *devlist,
/* Now reject spares that don't match domains of identified members */
for (tmpdev = devlist; tmpdev; tmpdev = tmpdev->next) {
- struct stat stb;
if (tmpdev->used != 3)
continue;
- if (stat(tmpdev->devname, &stb)< 0) {
- pr_err("fstat failed for %s: %s\n",
- tmpdev->devname, strerror(errno));
+ if (!stat_is_blkdev(tmpdev->devname, &rdev)) {
tmpdev->used = 2;
} else {
- struct dev_policy *pol = devid_policy(stb.st_rdev);
+ struct dev_policy *pol = devid_policy(rdev);
int dt = domain_test(domains, pol, NULL);
if (inargv && dt != 0)
/* take this spare as domains match