(root)/
util-linux-2.39/
libblkid/
src/
superblocks/
vxfs.c
       1  /*
       2   * Copyright (C) 2008 Karel Zak <kzak@redhat.com>
       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  
      10  #include "superblocks.h"
      11  
      12  struct vxfs_super_block {
      13  	uint32_t		vs_magic;
      14  	int32_t			vs_version;
      15  	uint32_t		vs_ctime;
      16  	uint32_t		vs_cutime;
      17  	uint32_t		__unused1;
      18  	uint32_t		__unused2;
      19  	uint32_t		vs_old_logstart;
      20  	uint32_t		vs_old_logend;
      21  	uint32_t		vs_bsize;
      22  	uint32_t		vs_size;
      23  	uint32_t		vs_dsize;
      24  };
      25  
      26  static int probe_vxfs(blkid_probe pr, const struct blkid_idmag *mag)
      27  {
      28  	struct vxfs_super_block *vxs;
      29  
      30  	vxs = blkid_probe_get_sb(pr, mag, struct vxfs_super_block);
      31  	if (!vxs)
      32  		return errno ? -errno : 1;
      33  
      34  	if (le32_to_cpu(vxs->vs_magic) == 0xa501fcf5) {
      35  		blkid_probe_sprintf_version(pr, "%u", (unsigned int)le32_to_cpu(vxs->vs_version));
      36  		blkid_probe_set_fsblocksize(pr, le32_to_cpu(vxs->vs_bsize));
      37  		blkid_probe_set_block_size(pr, le32_to_cpu(vxs->vs_bsize));
      38  	} else if (be32_to_cpu(vxs->vs_magic) == 0xa501fcf5) {
      39  		blkid_probe_sprintf_version(pr, "%u", (unsigned int)be32_to_cpu(vxs->vs_version));
      40  		blkid_probe_set_fsblocksize(pr, be32_to_cpu(vxs->vs_bsize));
      41  		blkid_probe_set_block_size(pr, be32_to_cpu(vxs->vs_bsize));
      42  	}
      43  	return 0;
      44  }
      45  
      46  
      47  const struct blkid_idinfo vxfs_idinfo =
      48  {
      49  	.name		= "vxfs",
      50  	.usage		= BLKID_USAGE_FILESYSTEM,
      51  	.probefunc	= probe_vxfs,
      52  	.magics		=
      53  	{
      54  		{ .magic = "\365\374\001\245", .len = 4, .kboff = 1 },
      55  		{ .magic = "\245\001\374\365", .len = 4, .kboff = 8 },
      56  		{ NULL }
      57  	}
      58  };
      59