From bd301d459fce7d4f7a09e5db1107d3de26bedaa7 Mon Sep 17 00:00:00 2001 From: Kenneth Van Alstyne Date: Fri, 14 Dec 2018 14:27:10 -0600 Subject: Added support for detecting Ceph BlueStore Block Devices --- libblkid/src/superblocks/bluestore.c | 54 ++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 libblkid/src/superblocks/bluestore.c (limited to 'libblkid') 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 + * + * 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 +#include +#include +#include +#include +#include +#include +#include + +#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 } + } +}; -- cgit v1.2.3-55-g7522