diff options
author | Zhilong Liu <zlliu@suse.com> | 2017-05-04 14:16:21 +0200 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2017-05-05 17:04:02 +0200 |
commit | 0a6bff09d41650f27136d56a0604c9af46b6f583 (patch) | |
tree | 77af2c5e53c1190e97e821eb5e2243a6276ec733 /Build.c | |
parent | mdassemble: Kill off the last remains (diff) | |
download | mdadm-0a6bff09d41650f27136d56a0604c9af46b6f583.tar.xz mdadm-0a6bff09d41650f27136d56a0604c9af46b6f583.zip |
mdadm/util: unify fstat checking blkdev into function
declare function fstat_is_blkdev() to integrate repeated fstat
checking block device operations, it returns true/1 when it is
a block device, and returns false/0 when it isn't.
The fd and devname are necessary parameters, *rdev is optional,
parse the pointer of dev_t *rdev, if valid, assigned the 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 'Build.c')
-rw-r--r-- | Build.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -42,6 +42,7 @@ int Build(char *mddev, struct mddev_dev *devlist, */ int i; struct stat stb; + dev_t rdev; int subdevs = 0, missing_disks = 0; struct mddev_dev *dv; int bitmap_fd; @@ -126,8 +127,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) |