1
2
3
4
5
6
7
8
9
10
11
12 #ifndef _FS_PT_LDM_H_
13 #define _FS_PT_LDM_H_
14
15 #include <linux/types.h>
16 #include <linux/list.h>
17 #include <linux/genhd.h>
18 #include <linux/fs.h>
19 #include <asm/unaligned.h>
20 #include <asm/byteorder.h>
21
22 struct parsed_partitions;
23
24
25 #define MAGIC_VMDB 0x564D4442
26 #define MAGIC_VBLK 0x56424C4B
27 #define MAGIC_PRIVHEAD 0x5052495648454144ULL
28 #define MAGIC_TOCBLOCK 0x544F43424C4F434BULL
29
30
31 #define VBLK_VOL5 0x51
32 #define VBLK_CMP3 0x32
33 #define VBLK_PRT3 0x33
34 #define VBLK_DSK3 0x34
35 #define VBLK_DSK4 0x44
36 #define VBLK_DGR3 0x35
37 #define VBLK_DGR4 0x45
38
39
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
48
49
50 #define VBLK_SIZE_HEAD 16
51 #define VBLK_SIZE_CMP3 22
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
58
59
60 #define COMP_STRIPE 0x01
61 #define COMP_BASIC 0x02
62 #define COMP_RAID 0x03
63
64
65 #define LDM_DB_SIZE 2048
66
67 #define OFF_PRIV1 6
68
69
70
71
72 #define OFF_PRIV2 1856
73 #define OFF_PRIV3 2047
74
75 #define OFF_TOCB1 1
76 #define OFF_TOCB2 2
77 #define OFF_TOCB3 2045
78 #define OFF_TOCB4 2046
79
80 #define OFF_VMDB 17
81
82 #define LDM_PARTITION 0x42
83
84 #define TOC_BITMAP1 "config"
85 #define TOC_BITMAP2 "log"
86
87
88 #define SYS_IND(p) (get_unaligned(&(p)->sys_ind))
89
90 struct frag {
91 struct list_head list;
92 u32 group;
93 u8 num;
94 u8 rec;
95 u8 map;
96 u8 data[0];
97 };
98
99
100
101 struct privhead {
102 u16 ver_major;
103 u16 ver_minor;
104 u64 logical_disk_start;
105 u64 logical_disk_size;
106 u64 config_start;
107 u64 config_size;
108 uuid_t disk_id;
109 };
110
111 struct tocblock {
112 u8 bitmap1_name[16];
113 u64 bitmap1_start;
114 u64 bitmap1_size;
115 u8 bitmap2_name[16];
116 u64 bitmap2_start;
117 u64 bitmap2_size;
118 };
119
120 struct vmdb {
121 u16 ver_major;
122 u16 ver_minor;
123 u32 vblk_size;
124 u32 vblk_offset;
125 u32 last_vblk_seq;
126 };
127
128 struct vblk_comp {
129 u8 state[16];
130 u64 parent_id;
131 u8 type;
132 u8 children;
133 u16 chunksize;
134 };
135
136 struct vblk_dgrp {
137 u8 disk_id[64];
138 };
139
140 struct vblk_disk {
141 uuid_t disk_id;
142 u8 alt_name[128];
143 };
144
145 struct vblk_part {
146 u64 start;
147 u64 size;
148 u64 volume_offset;
149 u64 parent_id;
150 u64 disk_id;
151 u8 partnum;
152 };
153
154 struct vblk_volu {
155 u8 volume_type[16];
156 u8 volume_state[16];
157 u8 guid[16];
158 u8 drive_hint[4];
159 u64 size;
160 u8 partition_type;
161 };
162
163 struct vblk_head {
164 u32 group;
165 u16 rec;
166 u16 nrec;
167 };
168
169 struct vblk {
170 u8 name[64];
171 u64 obj_id;
172 u32 sequence;
173 u8 flags;
174 u8 type;
175 union {
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;
181 } vblk;
182 struct list_head list;
183 };
184
185 struct ldmdb {
186 struct privhead ph;
187 struct tocblock toc;
188 struct vmdb vm;
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;
194 };
195
196 int ldm_partition(struct parsed_partitions *state);
197
198 #endif
199