1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * ldm - Part of the Linux-NTFS project.
5 * Copyright (C) 2001,2002 Richard Russon <ldm@flatcap.org>
6 * Copyright (c) 2001-2007 Anton Altaparmakov
7 * Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com>
9 * Documentation is available at http://www.linux-ntfs.org/doku.php?id=downloads
15 #include <linux/types.h>
16 #include <linux/list.h>
17 #include <linux/genhd.h>
19 #include <asm/unaligned.h>
20 #include <asm/byteorder.h>
22 struct parsed_partitions;
24 /* Magic numbers in CPU format. */
25 #define MAGIC_VMDB 0x564D4442 /* VMDB */
26 #define MAGIC_VBLK 0x56424C4B /* VBLK */
27 #define MAGIC_PRIVHEAD 0x5052495648454144ULL /* PRIVHEAD */
28 #define MAGIC_TOCBLOCK 0x544F43424C4F434BULL /* TOCBLOCK */
30 /* The defined vblk types. */
31 #define VBLK_VOL5 0x51 /* Volume, version 5 */
32 #define VBLK_CMP3 0x32 /* Component, version 3 */
33 #define VBLK_PRT3 0x33 /* Partition, version 3 */
34 #define VBLK_DSK3 0x34 /* Disk, version 3 */
35 #define VBLK_DSK4 0x44 /* Disk, version 4 */
36 #define VBLK_DGR3 0x35 /* Disk Group, version 3 */
37 #define VBLK_DGR4 0x45 /* Disk Group, version 4 */
39 /* vblk flags indicating extra information will be present */
40 #define VBLK_FLAG_COMP_STRIPE 0x10
41 #define VBLK_FLAG_PART_INDEX 0x08
42 #define VBLK_FLAG_DGR3_IDS 0x08
43 #define VBLK_FLAG_DGR4_IDS 0x08
44 #define VBLK_FLAG_VOLU_ID1 0x08
45 #define VBLK_FLAG_VOLU_ID2 0x20
46 #define VBLK_FLAG_VOLU_SIZE 0x80
47 #define VBLK_FLAG_VOLU_DRIVE 0x02
49 /* size of a vblk's static parts */
50 #define VBLK_SIZE_HEAD 16
51 #define VBLK_SIZE_CMP3 22 /* Name and version */
52 #define VBLK_SIZE_DGR3 12
53 #define VBLK_SIZE_DGR4 44
54 #define VBLK_SIZE_DSK3 12
55 #define VBLK_SIZE_DSK4 45
56 #define VBLK_SIZE_PRT3 28
57 #define VBLK_SIZE_VOL5 58
60 #define COMP_STRIPE 0x01 /* Stripe-set */
61 #define COMP_BASIC 0x02 /* Basic disk */
62 #define COMP_RAID 0x03 /* Raid-set */
64 /* Other constants. */
65 #define LDM_DB_SIZE 2048 /* Size in sectors (= 1MiB). */
67 #define OFF_PRIV1 6 /* Offset of the first privhead
68 relative to the start of the
71 /* Offsets to structures within the LDM Database in sectors. */
72 #define OFF_PRIV2 1856 /* Backup private headers. */
73 #define OFF_PRIV3 2047
75 #define OFF_TOCB1 1 /* Tables of contents. */
77 #define OFF_TOCB3 2045
78 #define OFF_TOCB4 2046
80 #define OFF_VMDB 17 /* List of partitions. */
82 #define LDM_PARTITION 0x42 /* Formerly SFS (Landis). */
84 #define TOC_BITMAP1 "config" /* Names of the two defined */
85 #define TOC_BITMAP2 "log" /* bitmaps in the TOCBLOCK. */
87 /* Borrowed from msdos.c */
88 #define SYS_IND(p) (get_unaligned(&(p)->sys_ind))
90 struct frag { /* VBLK Fragment handling */
91 struct list_head list;
93 u8 num; /* Total number of records */
94 u8 rec; /* This is record number n */
95 u8 map; /* Which portions are in use */
99 /* In memory LDM database structures. */
101 struct privhead { /* Offsets and sizes are in sectors. */
104 u64 logical_disk_start;
105 u64 logical_disk_size;
111 struct tocblock { /* We have exactly two bitmaps. */
120 struct vmdb { /* VMDB: The database header */
128 struct vblk_comp { /* VBLK Component */
136 struct vblk_dgrp { /* VBLK Disk Group */
140 struct vblk_disk { /* VBLK Disk */
145 struct vblk_part { /* VBLK Partition */
147 u64 size; /* start, size and vol_off in sectors */
154 struct vblk_volu { /* VBLK Volume */
163 struct vblk_head { /* VBLK standard header */
169 struct vblk { /* Generalised VBLK */
176 struct vblk_comp comp;
177 struct vblk_dgrp dgrp;
178 struct vblk_disk disk;
179 struct vblk_part part;
180 struct vblk_volu volu;
182 struct list_head list;
185 struct ldmdb { /* Cache of the database */
189 struct list_head v_dgrp;
190 struct list_head v_disk;
191 struct list_head v_volu;
192 struct list_head v_comp;
193 struct list_head v_part;
196 #endif /* _FS_PT_LDM_H_ */