summaryrefslogtreecommitdiffstats
path: root/libblkid/src/superblocks/vdo.c
blob: 4e9f445cd48b88eb1b99f1d52ea7283b9b6eb2a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
 * Copyright (C) 2017 Red Hat, 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 <errno.h>
#include <ctype.h>
#include <stdint.h>

#include "superblocks.h"

struct vdo_super_block {
	char magic[8];			/* magic number 'dmvdo001'*/
	char unused[32];		/* 32 bytes of unimportant space */
	unsigned char sb_uuid[16];	/* vdo unique id */

	/* this is not all... but enough for libblkid */
} __attribute__((packed));

static int probe_vdo(blkid_probe pr, const struct blkid_idmag *mag)
{
	const struct vdo_super_block *vsb;

	vsb = blkid_probe_get_sb(pr, mag, struct vdo_super_block);
	if (!vsb)
		return errno ? -errno : 1;

	blkid_probe_set_uuid(pr, vsb->sb_uuid);
	return 0;
}

const struct blkid_idinfo vdo_idinfo =
{
	.name		= "vdo",
	.usage		= BLKID_USAGE_OTHER,
	.probefunc	= probe_vdo,
	.magics		=
	{
		{ .magic = "dmvdo001", .len = 8 },
		{ NULL }
	}
};