summaryrefslogtreecommitdiffstats
path: root/libblkid/src/superblocks/bluestore.c
diff options
context:
space:
mode:
authorKarel Zak2018-12-17 10:45:33 +0100
committerKarel Zak2018-12-17 10:45:33 +0100
commitbe2762b862dc4c20bf6ff88ecab0cc99fb8ed76f (patch)
tree546e5aba0e7fcb37c929ae424a28360904691aaf /libblkid/src/superblocks/bluestore.c
parentdmesg: correct "-n, --console-level level" example in manual page (diff)
parentFinished up BlueStore support (diff)
downloadkernel-qcow2-util-linux-be2762b862dc4c20bf6ff88ecab0cc99fb8ed76f.tar.gz
kernel-qcow2-util-linux-be2762b862dc4c20bf6ff88ecab0cc99fb8ed76f.tar.xz
kernel-qcow2-util-linux-be2762b862dc4c20bf6ff88ecab0cc99fb8ed76f.zip
Merge branch 'master' of https://github.com/kvanals/util-linux
* 'master' of https://github.com/kvanals/util-linux: Finished up BlueStore support Added support for detecting Ceph BlueStore Block Devices
Diffstat (limited to 'libblkid/src/superblocks/bluestore.c')
-rw-r--r--libblkid/src/superblocks/bluestore.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/libblkid/src/superblocks/bluestore.c b/libblkid/src/superblocks/bluestore.c
new file mode 100644
index 000000000..24c56f24a
--- /dev/null
+++ b/libblkid/src/superblocks/bluestore.c
@@ -0,0 +1,54 @@
+/*
+ * Copyright (C) 2018 by Kenneth Van Alstyne <kvanals@kvanals.org>
+ *
+ * This file may be redistributed under the terms of the
+ * GNU Lesser General Public License.
+ *
+ *
+ * Ceph BlueStore is one of the supported storage
+ * methods for Object Storage Devices (OSDs).
+ * This is used to detect the backing block devices
+ * used for these types of OSDs in a Ceph Cluster.
+ *
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <errno.h>
+#include <ctype.h>
+#include <inttypes.h>
+#include <stddef.h>
+
+#include "bitops.h"
+#include "superblocks.h"
+
+#define BLUESTORE_MAGIC_L 22
+
+struct bluestore_phdr {
+ uint8_t magic[BLUESTORE_MAGIC_L];
+ uint32_t version;
+} __attribute__((packed));
+
+static int probe_bluestore(blkid_probe pr, const struct blkid_idmag *mag)
+{
+ struct bluestore_phdr *header;
+
+ header = blkid_probe_get_sb(pr, mag, struct bluestore_phdr);
+ if (header == NULL)
+ return errno ? -errno : 1;
+
+ blkid_probe_sprintf_version(pr, "%u", le32_to_cpu(header->version));
+ return 0;
+}
+
+const struct blkid_idinfo bluestore_idinfo =
+{
+ .name = "ceph_bluestore",
+ .usage = BLKID_USAGE_OTHER,
+ .probefunc = probe_bluestore,
+ .magics =
+ {
+ { .magic = "bluestore block device", .len = 22 }
+ }
+};