Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /**
0003  * ldm - Part of the Linux-NTFS project.
0004  *
0005  * Copyright (C) 2001,2002 Richard Russon <ldm@flatcap.org>
0006  * Copyright (c) 2001-2007 Anton Altaparmakov
0007  * Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com>
0008  *
0009  * Documentation is available at http://www.linux-ntfs.org/doku.php?id=downloads 
0010  */
0011 
0012 #ifndef _FS_PT_LDM_H_
0013 #define _FS_PT_LDM_H_
0014 
0015 #include <linux/types.h>
0016 #include <linux/list.h>
0017 #include <linux/fs.h>
0018 #include <asm/unaligned.h>
0019 #include <asm/byteorder.h>
0020 
0021 struct parsed_partitions;
0022 
0023 /* Magic numbers in CPU format. */
0024 #define MAGIC_VMDB  0x564D4442      /* VMDB */
0025 #define MAGIC_VBLK  0x56424C4B      /* VBLK */
0026 #define MAGIC_PRIVHEAD  0x5052495648454144ULL   /* PRIVHEAD */
0027 #define MAGIC_TOCBLOCK  0x544F43424C4F434BULL   /* TOCBLOCK */
0028 
0029 /* The defined vblk types. */
0030 #define VBLK_VOL5       0x51        /* Volume,     version 5 */
0031 #define VBLK_CMP3       0x32        /* Component,  version 3 */
0032 #define VBLK_PRT3       0x33        /* Partition,  version 3 */
0033 #define VBLK_DSK3       0x34        /* Disk,       version 3 */
0034 #define VBLK_DSK4       0x44        /* Disk,       version 4 */
0035 #define VBLK_DGR3       0x35        /* Disk Group, version 3 */
0036 #define VBLK_DGR4       0x45        /* Disk Group, version 4 */
0037 
0038 /* vblk flags indicating extra information will be present */
0039 #define VBLK_FLAG_COMP_STRIPE   0x10
0040 #define VBLK_FLAG_PART_INDEX    0x08
0041 #define VBLK_FLAG_DGR3_IDS  0x08
0042 #define VBLK_FLAG_DGR4_IDS  0x08
0043 #define VBLK_FLAG_VOLU_ID1  0x08
0044 #define VBLK_FLAG_VOLU_ID2  0x20
0045 #define VBLK_FLAG_VOLU_SIZE 0x80
0046 #define VBLK_FLAG_VOLU_DRIVE    0x02
0047 
0048 /* size of a vblk's static parts */
0049 #define VBLK_SIZE_HEAD      16
0050 #define VBLK_SIZE_CMP3      22      /* Name and version */
0051 #define VBLK_SIZE_DGR3      12
0052 #define VBLK_SIZE_DGR4      44
0053 #define VBLK_SIZE_DSK3      12
0054 #define VBLK_SIZE_DSK4      45
0055 #define VBLK_SIZE_PRT3      28
0056 #define VBLK_SIZE_VOL5      58
0057 
0058 /* component types */
0059 #define COMP_STRIPE     0x01        /* Stripe-set */
0060 #define COMP_BASIC      0x02        /* Basic disk */
0061 #define COMP_RAID       0x03        /* Raid-set */
0062 
0063 /* Other constants. */
0064 #define LDM_DB_SIZE     2048        /* Size in sectors (= 1MiB). */
0065 
0066 #define OFF_PRIV1       6       /* Offset of the first privhead
0067                            relative to the start of the
0068                            device in sectors */
0069 
0070 /* Offsets to structures within the LDM Database in sectors. */
0071 #define OFF_PRIV2       1856        /* Backup private headers. */
0072 #define OFF_PRIV3       2047
0073 
0074 #define OFF_TOCB1       1       /* Tables of contents. */
0075 #define OFF_TOCB2       2
0076 #define OFF_TOCB3       2045
0077 #define OFF_TOCB4       2046
0078 
0079 #define OFF_VMDB        17      /* List of partitions. */
0080 
0081 #define LDM_PARTITION       0x42        /* Formerly SFS (Landis). */
0082 
0083 #define TOC_BITMAP1     "config"    /* Names of the two defined */
0084 #define TOC_BITMAP2     "log"       /* bitmaps in the TOCBLOCK. */
0085 
0086 struct frag {               /* VBLK Fragment handling */
0087     struct list_head list;
0088     u32     group;
0089     u8      num;        /* Total number of records */
0090     u8      rec;        /* This is record number n */
0091     u8      map;        /* Which portions are in use */
0092     u8      data[];
0093 };
0094 
0095 /* In memory LDM database structures. */
0096 
0097 struct privhead {           /* Offsets and sizes are in sectors. */
0098     u16 ver_major;
0099     u16 ver_minor;
0100     u64 logical_disk_start;
0101     u64 logical_disk_size;
0102     u64 config_start;
0103     u64 config_size;
0104     uuid_t  disk_id;
0105 };
0106 
0107 struct tocblock {           /* We have exactly two bitmaps. */
0108     u8  bitmap1_name[16];
0109     u64 bitmap1_start;
0110     u64 bitmap1_size;
0111     u8  bitmap2_name[16];
0112     u64 bitmap2_start;
0113     u64 bitmap2_size;
0114 };
0115 
0116 struct vmdb {               /* VMDB: The database header */
0117     u16 ver_major;
0118     u16 ver_minor;
0119     u32 vblk_size;
0120     u32 vblk_offset;
0121     u32 last_vblk_seq;
0122 };
0123 
0124 struct vblk_comp {          /* VBLK Component */
0125     u8  state[16];
0126     u64 parent_id;
0127     u8  type;
0128     u8  children;
0129     u16 chunksize;
0130 };
0131 
0132 struct vblk_dgrp {          /* VBLK Disk Group */
0133     u8  disk_id[64];
0134 };
0135 
0136 struct vblk_disk {          /* VBLK Disk */
0137     uuid_t  disk_id;
0138     u8  alt_name[128];
0139 };
0140 
0141 struct vblk_part {          /* VBLK Partition */
0142     u64 start;
0143     u64 size;           /* start, size and vol_off in sectors */
0144     u64 volume_offset;
0145     u64 parent_id;
0146     u64 disk_id;
0147     u8  partnum;
0148 };
0149 
0150 struct vblk_volu {          /* VBLK Volume */
0151     u8  volume_type[16];
0152     u8  volume_state[16];
0153     u8  guid[16];
0154     u8  drive_hint[4];
0155     u64 size;
0156     u8  partition_type;
0157 };
0158 
0159 struct vblk_head {          /* VBLK standard header */
0160     u32 group;
0161     u16 rec;
0162     u16 nrec;
0163 };
0164 
0165 struct vblk {               /* Generalised VBLK */
0166     u8  name[64];
0167     u64 obj_id;
0168     u32 sequence;
0169     u8  flags;
0170     u8  type;
0171     union {
0172         struct vblk_comp comp;
0173         struct vblk_dgrp dgrp;
0174         struct vblk_disk disk;
0175         struct vblk_part part;
0176         struct vblk_volu volu;
0177     } vblk;
0178     struct list_head list;
0179 };
0180 
0181 struct ldmdb {              /* Cache of the database */
0182     struct privhead ph;
0183     struct tocblock toc;
0184     struct vmdb     vm;
0185     struct list_head v_dgrp;
0186     struct list_head v_disk;
0187     struct list_head v_volu;
0188     struct list_head v_comp;
0189     struct list_head v_part;
0190 };
0191 
0192 #endif /* _FS_PT_LDM_H_ */
0193