From: <jgroves@micron.com>
To: Karel Zak <kzak@redhat.com>
Cc: <util-linux@vger.kernel.org>, <John@Groves.net>,
John Groves <jgroves@micron.com>
Subject: [PATCH 2/2] Add support for Micron mpool formatted drives
Date: Mon, 13 Nov 2017 18:45:13 -0600 [thread overview]
Message-ID: <1510620313-6045-3-git-send-email-jgroves@micron.com> (raw)
In-Reply-To: <1510620313-6045-1-git-send-email-jgroves@micron.com>
From: John Groves <jgroves@micron.com>
---
libblkid/src/Makemodule.am | 1 +
libblkid/src/superblocks/mpool.c | 74 ++++++++++++++++++++++++++++++++++
libblkid/src/superblocks/superblocks.c | 3 +-
libblkid/src/superblocks/superblocks.h | 1 +
4 files changed, 78 insertions(+), 1 deletion(-)
create mode 100644 libblkid/src/superblocks/mpool.c
diff --git a/libblkid/src/Makemodule.am b/libblkid/src/Makemodule.am
index 1fa00e9..ceece42 100644
--- a/libblkid/src/Makemodule.am
+++ b/libblkid/src/Makemodule.am
@@ -70,6 +70,7 @@ libblkid_la_SOURCES = \
libblkid/src/superblocks/luks.c \
libblkid/src/superblocks/lvm.c \
libblkid/src/superblocks/minix.c \
+ libblkid/src/superblocks/mpool.c \
libblkid/src/superblocks/netware.c \
libblkid/src/superblocks/nilfs.c \
libblkid/src/superblocks/ntfs.c \
diff --git a/libblkid/src/superblocks/mpool.c b/libblkid/src/superblocks/mpool.c
new file mode 100644
index 0000000..8688121
--- /dev/null
+++ b/libblkid/src/superblocks/mpool.c
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2016-2017 Micron Technology, Inc.
+ *
+ * This file may be redistributed under the terms of the
+ * GNU Lesser General Public License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdint.h>
+#include "crc32c.h"
+#include "superblocks.h"
+
+#include <uuid.h>
+
+#define MAX_MPOOL_NAME_LEN 32
+
+struct omf_sb_descriptor {
+ uint64_t osb_magic;
+ uint8_t osb_name[MAX_MPOOL_NAME_LEN];
+ uuid_t osb_poolid; /* UUID of pool this drive belongs to */
+ uint16_t osb_vers;
+ uint32_t osb_gen;
+ uint32_t osb_cksum1; /* crc32c of the preceding fields */
+} __attribute__((packed));
+
+const char *no = "no";
+const char *yes = "yes";
+
+static int probe_mpool(blkid_probe pr, const struct blkid_idmag *mag)
+{
+ struct omf_sb_descriptor *osd;
+ uint32_t sb_crc;
+
+ osd = blkid_probe_get_sb(pr, mag, struct omf_sb_descriptor);
+ if (!osd)
+ return errno ? -errno : 1;
+
+ sb_crc = crc32c(~0L, (const void *)osd,
+ offsetof(struct omf_sb_descriptor, osb_cksum1));
+ sb_crc ^= ~0L;
+
+ if (!blkid_probe_verify_csum(pr, sb_crc, osd->osb_cksum1)) {
+ blkid_probe_set_value(pr, "VALID",
+ (unsigned char *)no, strlen(no) + 1);
+ return -EINVAL;
+ }
+
+ blkid_probe_set_value(pr, "VALID",
+ (unsigned char *)yes, strlen(yes) + 1);
+ blkid_probe_set_label(pr, osd->osb_name, sizeof(osd->osb_name));
+ blkid_probe_set_uuid(pr, osd->osb_poolid);
+
+ return 0;
+}
+
+/**
+ * Superblock (sb) -- magic = ASCII "mpoolDev"
+ */
+#define MPOOL_SB_MAGIC "\x6D\x70\x6f\x6f\x6c\x44\x65\x76"
+
+const struct blkid_idinfo mpool_idinfo =
+{
+ .name = "mpool",
+ .usage = BLKID_USAGE_FILESYSTEM,
+ .probefunc = probe_mpool,
+ .magics =
+ {
+ { .magic = MPOOL_SB_MAGIC, .len = 8},
+ { NULL }
+ }
+};
diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c
index 341cd8a..3123d53 100644
--- a/libblkid/src/superblocks/superblocks.c
+++ b/libblkid/src/superblocks/superblocks.c
@@ -156,7 +156,8 @@ static const struct blkid_idinfo *idinfos[] =
&befs_idinfo,
&nilfs2_idinfo,
&exfat_idinfo,
- &f2fs_idinfo
+ &f2fs_idinfo,
+ &mpool_idinfo
};
/*
diff --git a/libblkid/src/superblocks/superblocks.h b/libblkid/src/superblocks/superblocks.h
index 79dba1a..5b5c6c2 100644
--- a/libblkid/src/superblocks/superblocks.h
+++ b/libblkid/src/superblocks/superblocks.h
@@ -75,6 +75,7 @@ extern const struct blkid_idinfo nilfs2_idinfo;
extern const struct blkid_idinfo exfat_idinfo;
extern const struct blkid_idinfo f2fs_idinfo;
extern const struct blkid_idinfo bcache_idinfo;
+extern const struct blkid_idinfo mpool_idinfo;
/*
* superblock functions
--
2.9.3
next prev parent reply other threads:[~2017-11-14 0:45 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-11-14 0:45 [PATCH 0/2] libblkid: recognize Micron mpool formatted devices jgroves
2017-11-14 0:45 ` [PATCH 1/2] Add simple crc32c() function jgroves
2017-11-14 0:45 ` jgroves [this message]
2017-11-14 10:02 ` [PATCH 2/2] Add support for Micron mpool formatted drives Karel Zak
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1510620313-6045-3-git-send-email-jgroves@micron.com \
--to=jgroves@micron.com \
--cc=John@Groves.net \
--cc=kzak@redhat.com \
--cc=util-linux@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).