* [PATCH] mdadm/bitmap: regular file descriptor is omissive in bitmap_file_open
@ 2017-07-20 7:11 Zhilong Liu
0 siblings, 0 replies; only message in thread
From: Zhilong Liu @ 2017-07-20 7:11 UTC (permalink / raw)
To: Jes.Sorensen; +Cc: linux-raid, Zhilong Liu
External bitmap supports to store bitmap in a regular file,
bitmap_file_open() also supports to return the regular file
descriptor.
This commit is partial revert of commit 0a6bff09d416
(mdadm/util: unify fstat checking blkdev into function)
Signed-off-by: Zhilong Liu <zlliu@suse.com>
---
bitmap.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/bitmap.c b/bitmap.c
index 3653660..989cfb1 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -183,6 +183,7 @@ static int
bitmap_file_open(char *filename, struct supertype **stp, int node_num)
{
int fd;
+ struct stat stb;
struct supertype *st = *stp;
fd = open(filename, O_RDONLY|O_DIRECT);
@@ -191,8 +192,13 @@ bitmap_file_open(char *filename, struct supertype **stp, int node_num)
filename, strerror(errno));
return -1;
}
-
- if (fstat_is_blkdev(fd, filename, NULL)) {
+ if (fstat(fd, &stb) < 0) {
+ pr_err("fstat failed for %s: %s\n",
+ filename, strerror(errno));
+ close(fd);
+ return -1;
+ }
+ if ((stb.st_mode & S_IFMT) == S_IFBLK) {
/* block device, so we are probably after an internal bitmap */
if (!st)
st = guess_super(fd);
@@ -211,11 +217,7 @@ bitmap_file_open(char *filename, struct supertype **stp, int node_num)
fd = -1;
}
}
-
*stp = st;
- } else {
- close(fd);
- return -1;
}
return fd;
--
2.6.6
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2017-07-20 7:11 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-20 7:11 [PATCH] mdadm/bitmap: regular file descriptor is omissive in bitmap_file_open Zhilong Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox