531551
diff -up util-linux-2.23.2/libblkid/src/superblocks/superblocks.c.kzak util-linux-2.23.2/libblkid/src/superblocks/superblocks.c
531551
--- util-linux-2.23.2/libblkid/src/superblocks/superblocks.c.kzak	2015-06-24 12:58:20.790115492 +0200
531551
+++ util-linux-2.23.2/libblkid/src/superblocks/superblocks.c	2015-06-24 12:57:57.961286166 +0200
531551
@@ -49,6 +49,8 @@
531551
  *
531551
  * @UUID_SUB: subvolume uuid (e.g. btrfs)
531551
  *
531551
+ * @LOGUUID: external log UUID (e.g. xfs)
531551
+ *
531551
  * @UUID_RAW: raw UUID from FS superblock
531551
  *
531551
  * @EXT_JOURNAL: external journal UUID
531551
@@ -113,6 +115,7 @@ static const struct blkid_idinfo *idinfo
531551
 	&swsuspend_idinfo,
531551
 	&swap_idinfo,
531551
 	&xfs_idinfo,
531551
+	&xfs_log_idinfo,
531551
 	&ext4dev_idinfo,
531551
 	&ext4_idinfo,
531551
 	&ext3_idinfo,
531551
diff -up util-linux-2.23.2/libblkid/src/superblocks/superblocks.h.kzak util-linux-2.23.2/libblkid/src/superblocks/superblocks.h
531551
--- util-linux-2.23.2/libblkid/src/superblocks/superblocks.h.kzak	2015-06-24 12:58:48.533908071 +0200
531551
+++ util-linux-2.23.2/libblkid/src/superblocks/superblocks.h	2015-06-24 12:59:00.098821476 +0200
531551
@@ -29,6 +29,7 @@ extern const struct blkid_idinfo ext2_id
531551
 extern const struct blkid_idinfo jbd_idinfo;
531551
 extern const struct blkid_idinfo jfs_idinfo;
531551
 extern const struct blkid_idinfo xfs_idinfo;
531551
+extern const struct blkid_idinfo xfs_log_idinfo;
531551
 extern const struct blkid_idinfo gfs_idinfo;
531551
 extern const struct blkid_idinfo gfs2_idinfo;
531551
 extern const struct blkid_idinfo romfs_idinfo;
531551
diff -up util-linux-2.23.2/libblkid/src/superblocks/xfs.c.kzak util-linux-2.23.2/libblkid/src/superblocks/xfs.c
531551
--- util-linux-2.23.2/libblkid/src/superblocks/xfs.c.kzak	2015-06-24 12:39:34.300507071 +0200
531551
+++ util-linux-2.23.2/libblkid/src/superblocks/xfs.c	2015-06-24 12:39:45.389427015 +0200
531551
@@ -4,6 +4,7 @@
531551
  * Copyright (C) 2001 by Andreas Dilger
531551
  * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
531551
  * Copyright (C) 2008 Karel Zak <kzak@redhat.com>
531551
+ * Copyright (C) 2013 Eric Sandeen <sandeen@redhat.com>
531551
  *
531551
  * This file may be redistributed under the terms of the
531551
  * GNU Lesser General Public License.
531551
@@ -187,3 +188,90 @@ const struct blkid_idinfo xfs_idinfo =
531551
 	}
531551
 };
531551
 
531551
+struct xlog_rec_header {
531551
+	uint32_t	h_magicno;
531551
+	uint32_t	h_dummy1[1];
531551
+	uint32_t	h_version;
531551
+	uint32_t	h_len;
531551
+	uint32_t	h_dummy2[71];
531551
+	uint32_t	h_fmt;
531551
+	unsigned char	h_uuid[16];
531551
+} __attribute__((packed));
531551
+
531551
+#define XLOG_HEADER_MAGIC_NUM 0xFEEDbabe
531551
+
531551
+/*
531551
+ * For very small filesystems, the minimum log size
531551
+ * can be smaller, but that seems vanishingly unlikely
531551
+ * when used with an external log (which is used for
531551
+ * performance reasons; tiny conflicts with that goal).
531551
+ */
531551
+#define XFS_MIN_LOG_BYTES	(10 * 1024 * 1024)
531551
+
531551
+#define XLOG_FMT_LINUX_LE	1
531551
+#define XLOG_FMT_LINUX_BE	2
531551
+#define XLOG_FMT_IRIX_BE	3
531551
+
531551
+#define XLOG_VERSION_1		1
531551
+#define XLOG_VERSION_2		2	/* Large IClogs, Log sunit */
531551
+#define XLOG_VERSION_OKBITS	(XLOG_VERSION_1 | XLOG_VERSION_2)
531551
+
531551
+static int xlog_valid_rec_header(struct xlog_rec_header *rhead)
531551
+{
531551
+	uint32_t hlen;
531551
+
531551
+	if (rhead->h_magicno != cpu_to_be32(XLOG_HEADER_MAGIC_NUM))
531551
+		return 0;
531551
+
531551
+	if (!rhead->h_version ||
531551
+            (be32_to_cpu(rhead->h_version) & (~XLOG_VERSION_OKBITS)))
531551
+		return 0;
531551
+
531551
+	/* LR body must have data or it wouldn't have been written */
531551
+	hlen = be32_to_cpu(rhead->h_len);
531551
+	if (hlen <= 0 || hlen > INT_MAX)
531551
+		return 0;
531551
+
531551
+	if (rhead->h_fmt != cpu_to_be32(XLOG_FMT_LINUX_LE) &&
531551
+	    rhead->h_fmt != cpu_to_be32(XLOG_FMT_LINUX_BE) &&
531551
+	    rhead->h_fmt != cpu_to_be32(XLOG_FMT_IRIX_BE))
531551
+		return 0;
531551
+
531551
+	return 1;
531551
+}
531551
+
531551
+/* xlog record header will be in some sector in the first 256k */
531551
+static int probe_xfs_log(blkid_probe pr, const struct blkid_idmag *mag)
531551
+{
531551
+	int i;
531551
+	struct xlog_rec_header *rhead;
531551
+	unsigned char *buf;
531551
+
531551
+	buf = blkid_probe_get_buffer(pr, 0, 256*1024);
531551
+	if (!buf)
531551
+		return errno ? -errno : 1;
531551
+
531551
+	if (memcmp(buf, "XFSB", 4) == 0)
531551
+		return 1;			/* this is regular XFS, ignore */
531551
+
531551
+	/* check the first 512 512-byte sectors */
531551
+	for (i = 0; i < 512; i++) {
531551
+		rhead = (struct xlog_rec_header *)&buf[i*512];
531551
+
531551
+		if (xlog_valid_rec_header(rhead)) {
531551
+			blkid_probe_set_uuid_as(pr, rhead->h_uuid, "LOGUUID");
531551
+			return 0;
531551
+		}
531551
+	}
531551
+
531551
+	return 1;
531551
+}
531551
+
531551
+const struct blkid_idinfo xfs_log_idinfo =
531551
+{
531551
+	.name		= "xfs_external_log",
531551
+	.usage		= BLKID_USAGE_OTHER,
531551
+	.probefunc	= probe_xfs_log,
531551
+	.magics		= BLKID_NONE_MAGIC,
531551
+	.minsz		= XFS_MIN_LOG_BYTES,
531551
+};