diff options
author | Zhilong Liu <zlliu@suse.com> | 2017-05-05 11:09:41 +0800 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2017-05-05 11:05:32 -0400 |
commit | 9e04ac1c43e63eccb68eb196174069e5c23d0270 (patch) | |
tree | 956239ee16ae6d6ad3e8a44703a4bb6b7cd57226 /super-ddf.c | |
parent | 0a6bff09d41650f27136d56a0604c9af46b6f583 (diff) | |
download | mdadm-9e04ac1c43e63eccb68eb196174069e5c23d0270.tar.gz |
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 'super-ddf.c')
-rw-r--r-- | super-ddf.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/super-ddf.c b/super-ddf.c index 796eaa5..9c82f4f 100644 --- a/super-ddf.c +++ b/super-ddf.c @@ -3490,7 +3490,7 @@ static int validate_geometry_ddf_bvd(struct supertype *st, char *dev, unsigned long long *freesize, int verbose) { - struct stat stb; + dev_t rdev; struct ddf_super *ddf = st->sb; struct dl *dl; unsigned long long maxsize; @@ -3526,13 +3526,11 @@ static int validate_geometry_ddf_bvd(struct supertype *st, return 1; } /* This device must be a member of the set */ - if (stat(dev, &stb) < 0) - return 0; - if ((S_IFMT & stb.st_mode) != S_IFBLK) + if (!stat_is_blkdev(dev, NULL)) return 0; for (dl = ddf->dlist ; dl ; dl = dl->next) { - if (dl->major == (int)major(stb.st_rdev) && - dl->minor == (int)minor(stb.st_rdev)) + if (dl->major == (int)major(rdev) && + dl->minor == (int)minor(rdev)) break; } if (!dl) { |