cdown / rpms / util-linux

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