+ if ((S_IFMT & stb.st_mode) == S_IFBLK) {
+ fd = open(filename, O_RDONLY);
+ if (fd < 0) {
+ fprintf(stderr, Name ": failed to open bitmap file %s: %s\n",
+ filename, strerror(errno));
+ return NULL;
+ }
+ /* 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 if (!st->ss->locate_bitmap) {
+ fprintf(stderr, Name ": No bitmap possible with %s metadata\n",
+ st->ss->name);
+ return NULL;
+ } else
+ st->ss->locate_bitmap(st, fd);
+
+ ioctl(fd, BLKFLSBUF, 0); /* make sure we read current data */
+ *stp = st;
+ } else {
+ fd = open(filename, O_RDONLY|O_DIRECT);
+ if (fd < 0) {
+ fprintf(stderr, Name ": failed to open bitmap file %s: %s\n",
+ filename, strerror(errno));
+ return NULL;
+ }
+ }