diff options
author | Kent Overstreet <kmo@daterainc.com> | 2014-03-20 13:38:08 -0700 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2014-03-20 13:38:08 -0700 |
commit | a1aa5961dc606dc08c460e76e44901fc4920844e (patch) | |
tree | 9f3e0ba381a74f4cb7600d7b3baa7ebb5fd69268 /probe-bcache.c | |
parent | fc10e61267e43ea022959041d6f60c83995630da (diff) | |
parent | 89f11b135d1d57a5dbdc3548bfb9bfa0113075c4 (diff) |
Merge remote-tracking branch 'remotes/angband/master'
Conflicts:
make-bcache.c
Diffstat (limited to 'probe-bcache.c')
-rw-r--r-- | probe-bcache.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/probe-bcache.c b/probe-bcache.c index caff7b65..c94c9722 100644 --- a/probe-bcache.c +++ b/probe-bcache.c @@ -8,6 +8,7 @@ #define __USE_FILE_OFFSET64 #define _XOPEN_SOURCE 500 +#include <blkid.h> #include <fcntl.h> #include <linux/fs.h> #include <stdbool.h> @@ -30,6 +31,7 @@ int main(int argc, char **argv) extern char *optarg; struct cache_sb sb; char uuid[40]; + blkid_probe pr; while ((o = getopt(argc, argv, "o:")) != EOF) switch (o) { @@ -51,8 +53,20 @@ int main(int argc, char **argv) if (fd == -1) continue; + if (!(pr = blkid_new_probe())) + continue; + if (blkid_probe_set_device(pr, fd, 0, 0)) + continue; + /* probe partitions too */ + if (blkid_probe_enable_partitions(pr, true)) + continue; + /* bail if anything was found + * probe-bcache isn't needed once blkid recognizes bcache */ + if (!blkid_do_probe(pr)) { + continue; + } - if (pread(fd, &sb, sizeof(sb), 4096) != sizeof(sb)) + if (pread(fd, &sb, sizeof(sb), SB_START) != sizeof(sb)) continue; if (memcmp(sb.magic, bcache_magic, 16)) |