05ad79
From e8c8b5f97c864f0fd65378ccde0c45526e6916c9 Mon Sep 17 00:00:00 2001
05ad79
From: Sweet Tea Dorminy <sweettea@mit.edu>
05ad79
Date: Wed, 6 Dec 2017 18:26:59 -0500
05ad79
Subject: [PATCH 146/146] libblkid: Add VDO superblock information into blkid
05ad79
05ad79
[kzak@redhat.com: - add tests/expected/blkid/low-probe-vdo
05ad79
                  - enlarge the image (must be > 1024)]
05ad79
05ad79
[RHEL7: exclude vdo regression test doe to binary stuff in the patch]
05ad79
05ad79
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1521163
05ad79
Upstream: http://github.com/karelzak/util-linux/commit/6418cba457a701d44294d934c2bc4b766bbcfa2b
05ad79
Signed-off-by: Karel Zak <kzak@redhat.com>
05ad79
---
05ad79
 libblkid/src/Makemodule.am             |   1 +
05ad79
 libblkid/src/superblocks/superblocks.c |   1 +
05ad79
 libblkid/src/superblocks/superblocks.h |   1 +
05ad79
 libblkid/src/superblocks/vdo.c         |  48 +++++++++++++++++++++++++++++++++
05ad79
 4 files changed, 55 insertions(+)
05ad79
 create mode 100644 libblkid/src/superblocks/vdo.c
05ad79
05ad79
diff --git a/libblkid/src/Makemodule.am b/libblkid/src/Makemodule.am
05ad79
index 15639768a..791d7cbe8 100644
05ad79
--- a/libblkid/src/Makemodule.am
05ad79
+++ b/libblkid/src/Makemodule.am
05ad79
@@ -88,6 +88,7 @@ libblkid_la_SOURCES = \
05ad79
 	libblkid/src/superblocks/ubifs.c \
05ad79
 	libblkid/src/superblocks/udf.c \
05ad79
 	libblkid/src/superblocks/ufs.c \
05ad79
+	libblkid/src/superblocks/vdo.c \
05ad79
 	libblkid/src/superblocks/vfat.c \
05ad79
 	libblkid/src/superblocks/via_raid.c \
05ad79
 	libblkid/src/superblocks/vmfs.c \
05ad79
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
05ad79
index 3721544ff..8210fc17b 100644
05ad79
--- a/libblkid/src/superblocks/superblocks.c
05ad79
+++ b/libblkid/src/superblocks/superblocks.c
05ad79
@@ -109,6 +109,7 @@ static const struct blkid_idinfo *idinfos[] =
05ad79
 	&verity_hash_idinfo,
05ad79
 	&luks_idinfo,
05ad79
 	&vmfs_volume_idinfo,
05ad79
+	&vdo_idinfo,
05ad79
 
05ad79
 	/* Filesystems */
05ad79
 	&vfat_idinfo,
05ad79
diff --git a/libblkid/src/superblocks/superblocks.h b/libblkid/src/superblocks/superblocks.h
05ad79
index 90847151b..487fe38c2 100644
05ad79
--- a/libblkid/src/superblocks/superblocks.h
05ad79
+++ b/libblkid/src/superblocks/superblocks.h
05ad79
@@ -72,6 +72,7 @@ extern const struct blkid_idinfo befs_idinfo;
05ad79
 extern const struct blkid_idinfo nilfs2_idinfo;
05ad79
 extern const struct blkid_idinfo exfat_idinfo;
05ad79
 extern const struct blkid_idinfo f2fs_idinfo;
05ad79
+extern const struct blkid_idinfo vdo_idinfo;
05ad79
 
05ad79
 /*
05ad79
  * superblock functions
05ad79
diff --git a/libblkid/src/superblocks/vdo.c b/libblkid/src/superblocks/vdo.c
05ad79
new file mode 100644
05ad79
index 000000000..bec686f4f
05ad79
--- /dev/null
05ad79
+++ b/libblkid/src/superblocks/vdo.c
05ad79
@@ -0,0 +1,48 @@
05ad79
+/*
05ad79
+ * Copyright (C) 2017 Red Hat, Inc.
05ad79
+ *
05ad79
+ * This file may be redistributed under the terms of the
05ad79
+ * GNU Lesser General Public License.
05ad79
+ */
05ad79
+
05ad79
+#include <stdio.h>
05ad79
+#include <stdlib.h>
05ad79
+#include <unistd.h>
05ad79
+#include <string.h>
05ad79
+#include <errno.h>
05ad79
+#include <ctype.h>
05ad79
+#include <stdint.h>
05ad79
+
05ad79
+#include "superblocks.h"
05ad79
+
05ad79
+struct vdo_super_block {
05ad79
+	char magic[8];			/* magic number 'dmvdo001'*/
05ad79
+	char unused[32];		/* 32 bytes of unimportant space */
05ad79
+	unsigned char sb_uuid[16];	/* vdo unique id */
05ad79
+
05ad79
+	/* this is not all... but enough for libblkid */
05ad79
+} __attribute__((packed));
05ad79
+
05ad79
+static int probe_vdo(blkid_probe pr, const struct blkid_idmag *mag)
05ad79
+{
05ad79
+	struct vdo_super_block *vsb;
05ad79
+
05ad79
+	vsb = blkid_probe_get_sb(pr, mag, struct vdo_super_block);
05ad79
+	if (!vsb)
05ad79
+		return errno ? -errno : 1;
05ad79
+
05ad79
+	blkid_probe_set_uuid(pr, vsb->sb_uuid);
05ad79
+	return 0;
05ad79
+}
05ad79
+
05ad79
+const struct blkid_idinfo vdo_idinfo =
05ad79
+{
05ad79
+	.name		= "vdo",
05ad79
+	.usage		= BLKID_USAGE_OTHER,
05ad79
+	.probefunc	= probe_vdo,
05ad79
+	.magics		=
05ad79
+	{
05ad79
+		{ .magic = "dmvdo001", .len = 8 },
05ad79
+		{ NULL }
05ad79
+	}
05ad79
+};
05ad79
-- 
05ad79
2.13.6
05ad79