(root)/
util-linux-2.39/
libblkid/
src/
superblocks/
vdo.c
       1  /*
       2   * Copyright (C) 2017 Red Hat, Inc.
       3   *
       4   * This file may be redistributed under the terms of the
       5   * GNU Lesser General Public License.
       6   */
       7  
       8  #include <stdio.h>
       9  #include <stdlib.h>
      10  #include <unistd.h>
      11  #include <string.h>
      12  #include <errno.h>
      13  #include <ctype.h>
      14  #include <stdint.h>
      15  
      16  #include "superblocks.h"
      17  
      18  struct vdo_super_block {
      19  	char magic[8];			/* magic number 'dmvdo001'*/
      20  	char unused[32];		/* 32 bytes of unimportant space */
      21  	unsigned char sb_uuid[16];	/* vdo unique id */
      22  
      23  	/* this is not all... but enough for libblkid */
      24  } __attribute__((packed));
      25  
      26  static int probe_vdo(blkid_probe pr, const struct blkid_idmag *mag)
      27  {
      28  	struct vdo_super_block *vsb;
      29  
      30  	vsb = blkid_probe_get_sb(pr, mag, struct vdo_super_block);
      31  	if (!vsb)
      32  		return errno ? -errno : 1;
      33  
      34  	blkid_probe_set_uuid(pr, vsb->sb_uuid);
      35  	return 0;
      36  }
      37  
      38  const struct blkid_idinfo vdo_idinfo =
      39  {
      40  	.name		= "vdo",
      41  	.usage		= BLKID_USAGE_OTHER,
      42  	.probefunc	= probe_vdo,
      43  	.magics		=
      44  	{
      45  		{ .magic = "dmvdo001", .len = 8 },
      46  		{ NULL }
      47  	}
      48  };