summaryrefslogtreecommitdiff
path: root/probe-bcache.c
diff options
context:
space:
mode:
authorGabriel <g2p.code@gmail.com>2013-10-05 21:16:21 +0200
committerGabriel <g2p.code@gmail.com>2013-10-05 22:16:22 +0200
commit0c7a484a5b09d710814451c06ad30e894deb7ff5 (patch)
treea2112a892f9f11c157c6b9c4d47db4f27e6fb6d0 /probe-bcache.c
parent866e21a35d40e8c5df75cdc7146da88c17cc18d1 (diff)
udev: Fit into the standard rule sequencev1.0.2
Move the rule to run a bit later, after the standard udev rules have called blkid. Don't run blkid manually, and run probe-bcache as a fallback which can be patched out in a package that depends on util-linux 2.24+. probe-bcache: bail if libblkid finds anything Preserve our last-resort safety check here in case earlier rules fail to call blkid.
Diffstat (limited to 'probe-bcache.c')
-rw-r--r--probe-bcache.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/probe-bcache.c b/probe-bcache.c
index e1ad614..c94c972 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,6 +53,18 @@ 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), SB_START) != sizeof(sb))
continue;