summaryrefslogtreecommitdiffstats
path: root/bitmap.c
diff options
context:
space:
mode:
authorNeil Brown <neilb@suse.de>2005-06-07 23:03:47 +0000
committerNeil Brown <neilb@suse.de>2005-06-07 23:03:47 +0000
commit55935d51800231d7c4ee26fafe5553f8a1471d09 (patch)
treeba5714b8195ff6ccaf4913a7d29024ce98ac2b9c /bitmap.c
parente793c2e583740e9364c1285f61e14e687a1fbca1 (diff)
downloadmdadm-55935d51800231d7c4ee26fafe5553f8a1471d09.tar.gz
mdadm-55935d51800231d7c4ee26fafe5553f8a1471d09.tar.xz
mdadm-55935d51800231d7c4ee26fafe5553f8a1471d09.zip
Add support for internal bitmaps
For version 0.90 superblocks, an internal bitmap can be specified at create. Signed-off-by: Neil Brown <neilb@cse.unsw.edu.au>
Diffstat (limited to 'bitmap.c')
-rw-r--r--bitmap.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/bitmap.c b/bitmap.c
index 57969a6..83a70bc 100644
--- a/bitmap.c
+++ b/bitmap.c
@@ -177,10 +177,11 @@ out:
return info;
}
-bitmap_info_t *bitmap_file_read(char *filename, int brief)
+bitmap_info_t *bitmap_file_read(char *filename, int brief, struct supertype *st)
{
int fd;
bitmap_info_t *info;
+ struct stat stb;
fd = open(filename, O_RDONLY);
if (fd < 0) {
@@ -188,13 +189,24 @@ bitmap_info_t *bitmap_file_read(char *filename, int brief)
filename, strerror(errno));
return NULL;
}
+ fstat(fd, &stb);
+ if ((S_IFMT & stb.st_mode) == S_IFBLK) {
+ /* block device, so we are probably after an internal bitmap */
+ if (!st) st = guess_super(fd);
+ if (!st) {
+ /* just look at device... */
+ lseek(fd, 0, 0);
+ } else {
+ st->ss->locate_bitmap(st, fd);
+ }
+ }
info = bitmap_fd_read(fd, brief);
close(fd);
return info;
}
-int ExamineBitmap(char *filename, int brief)
+int ExamineBitmap(char *filename, int brief, struct supertype *st)
{
/*
* Read the bitmap file and display its contents
@@ -204,7 +216,7 @@ int ExamineBitmap(char *filename, int brief)
bitmap_info_t *info;
int rv = 1;
- info = bitmap_file_read(filename, brief);
+ info = bitmap_file_read(filename, brief, st);
if (!info)
return rv;