int fd = open(dev, O_RDONLY);
if (fd < 0) {
printf("Can't open dev %s: %s\n", dev, strerror(errno));
- exit(2);
+ return NULL;
}
if (pread(fd, sb, bytes, SB_START) != bytes) {
fprintf(stderr, "Couldn't read\n");
- exit(2);
+ return NULL;
}
if (sb->keys) {
if (pread(fd, sb, bytes, SB_START) != bytes) {
fprintf(stderr, "Couldn't read\n");
- exit(2);
+ return NULL;
}
}
buf[len] = '\0';
int i, end = strlen(buf);
char tmp[32], devname[32];
+ struct cache_sb *sb;
/* Chop off "/bcache", then look for the
* next '/' from the end
strcpy(devname, "/dev");
strcat(devname, tmp);
- query_dev(devname, false, false, true, dev_uuid);
+ err = "Unable to open superblock";
+ sb = query_dev(devname, false, false, true, dev_uuid);
+ if(!sb)
+ return err;
+
if(!strcmp(stats_dev_uuid, dev_uuid)) {
strcat(subdir, intbuf);
- return err;
+ return NULL;
}
}