libblkid: Add support for Micron mpool formatted drives

Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
John Groves 2017-11-15 23:01:39 -06:00 committed by Karel Zak
parent 277e777fe8
commit b0a89709bf
4 changed files with 70 additions and 1 deletions

View File

@ -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 \

View File

@ -0,0 +1,66 @@
/*
* Copyright (C) 2016 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));
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))
return 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 }
}
};

View File

@ -159,7 +159,8 @@ static const struct blkid_idinfo *idinfos[] =
&befs_idinfo,
&nilfs2_idinfo,
&exfat_idinfo,
&f2fs_idinfo
&f2fs_idinfo,
&mpool_idinfo
};
/*

View File

@ -78,6 +78,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