diff options
author | Neil Brown <neilb@suse.de> | 2005-06-07 23:03:47 +0000 |
---|---|---|
committer | Neil Brown <neilb@suse.de> | 2005-06-07 23:03:47 +0000 |
commit | 55935d51800231d7c4ee26fafe5553f8a1471d09 (patch) | |
tree | ba5714b8195ff6ccaf4913a7d29024ce98ac2b9c /bitmap.c | |
parent | e793c2e583740e9364c1285f61e14e687a1fbca1 (diff) | |
download | mdadm-55935d51800231d7c4ee26fafe5553f8a1471d09.tar.gz |
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.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -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; |