diff options
author | Zhilong Liu <zlliu@suse.com> | 2017-05-05 05:09:41 +0200 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2017-05-05 17:05:32 +0200 |
commit | 9e04ac1c43e63eccb68eb196174069e5c23d0270 (patch) | |
tree | 956239ee16ae6d6ad3e8a44703a4bb6b7cd57226 /super-intel.c | |
parent | mdadm/util: unify fstat checking blkdev into function (diff) | |
download | mdadm-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 'super-intel.c')
-rw-r--r-- | super-intel.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/super-intel.c b/super-intel.c index c4196ea1..e13c9402 100644 --- a/super-intel.c +++ b/super-intel.c @@ -6855,7 +6855,7 @@ static int validate_geometry_imsm_volume(struct supertype *st, int level, unsigned long long *freesize, int verbose) { - struct stat stb; + dev_t rdev; struct intel_super *super = st->sb; struct imsm_super *mpb; struct dl *dl; @@ -6920,13 +6920,11 @@ static int validate_geometry_imsm_volume(struct supertype *st, int level, } /* 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, &rdev)) return 0; for (dl = super->disks ; 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) { |