From 9e04ac1c43e63eccb68eb196174069e5c23d0270 Mon Sep 17 00:00:00 2001 From: Zhilong Liu Date: Fri, 5 May 2017 11:09:41 +0800 Subject: 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 Signed-off-by: Jes Sorensen --- super-intel.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'super-intel.c') 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) { -- cgit v1.2.3