summaryrefslogtreecommitdiffstats
path: root/libblkid/src/probe.c
diff options
context:
space:
mode:
authorKarel Zak2011-11-11 15:13:33 +0100
committerKarel Zak2011-11-11 15:13:33 +0100
commit3c83b3b22f33fc7b17b504158e4a4db7b567bbe8 (patch)
tree05472f07239090d1884c67c923ebbb6e4067d3d6 /libblkid/src/probe.c
parentmkswap: wipe all old signatures (diff)
downloadkernel-qcow2-util-linux-3c83b3b22f33fc7b17b504158e4a4db7b567bbe8.tar.gz
kernel-qcow2-util-linux-3c83b3b22f33fc7b17b504158e4a4db7b567bbe8.tar.xz
kernel-qcow2-util-linux-3c83b3b22f33fc7b17b504158e4a4db7b567bbe8.zip
libblkid: add BLKID_PARTS_MAGIC
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libblkid/src/probe.c')
-rw-r--r--libblkid/src/probe.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c
index af1111943..49b042095 100644
--- a/libblkid/src/probe.c
+++ b/libblkid/src/probe.c
@@ -1213,6 +1213,39 @@ int blkid_probe_sprintf_value(blkid_probe pr, const char *name,
return rc;
}
+int blkid_probe_set_magic(blkid_probe pr, blkid_loff_t offset,
+ size_t len, unsigned char *magic)
+{
+ int rc = 0;
+ struct blkid_chain *chn = blkid_probe_get_chain(pr);
+
+ if (!chn || !magic || !len || chn->binary)
+ return 0;
+
+ switch (chn->driver->id) {
+ case BLKID_CHAIN_SUBLKS:
+ if (!(chn->flags & BLKID_SUBLKS_MAGIC))
+ return 0;
+ rc = blkid_probe_set_value(pr, "SBMAGIC", magic, len);
+ if (!rc)
+ rc = blkid_probe_sprintf_value(pr,
+ "SBMAGIC_OFFSET", "%llu", offset);
+ break;
+ case BLKID_CHAIN_PARTS:
+ if (!(chn->flags & BLKID_PARTS_MAGIC))
+ return 0;
+ rc = blkid_probe_set_value(pr, "PTMAGIC", magic, len);
+ if (!rc)
+ rc = blkid_probe_sprintf_value(pr,
+ "PTMAGIC_OFFSET", "%llu", offset);
+ break;
+ default:
+ break;
+ }
+
+ return rc;
+}
+
/**
* blkid_probe_get_devno:
* @pr: probe