2 * ldm - Part of the Linux-NTFS project.
4 * Copyright (C) 2001,2002 Richard Russon <ldm@flatcap.org>
5 * Copyright (c) 2001-2007 Anton Altaparmakov
6 * Copyright (C) 2001,2002 Jakob Kemi <jakob.kemi@telia.com>
8 * Documentation is available at http://www.linux-ntfs.org/content/view/19/37/
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License as published by the Free
12 * Software Foundation; either version 2 of the License, or (at your option)
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program (in the main directory of the Linux-NTFS source
22 * in the file COPYING); if not, write to the Free Software Foundation,
23 * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
29 #include <linux/types.h>
30 #include <linux/list.h>
31 #include <linux/genhd.h>
33 #include <asm/unaligned.h>
34 #include <asm/byteorder.h>
36 struct parsed_partitions;
38 /* Magic numbers in CPU format. */
39 #define MAGIC_VMDB 0x564D4442 /* VMDB */
40 #define MAGIC_VBLK 0x56424C4B /* VBLK */
41 #define MAGIC_PRIVHEAD 0x5052495648454144ULL /* PRIVHEAD */
42 #define MAGIC_TOCBLOCK 0x544F43424C4F434BULL /* TOCBLOCK */
44 /* The defined vblk types. */
45 #define VBLK_VOL5 0x51 /* Volume, version 5 */
46 #define VBLK_CMP3 0x32 /* Component, version 3 */
47 #define VBLK_PRT3 0x33 /* Partition, version 3 */
48 #define VBLK_DSK3 0x34 /* Disk, version 3 */
49 #define VBLK_DSK4 0x44 /* Disk, version 4 */
50 #define VBLK_DGR3 0x35 /* Disk Group, version 3 */
51 #define VBLK_DGR4 0x45 /* Disk Group, version 4 */
53 /* vblk flags indicating extra information will be present */
54 #define VBLK_FLAG_COMP_STRIPE 0x10
55 #define VBLK_FLAG_PART_INDEX 0x08
56 #define VBLK_FLAG_DGR3_IDS 0x08
57 #define VBLK_FLAG_DGR4_IDS 0x08
58 #define VBLK_FLAG_VOLU_ID1 0x08
59 #define VBLK_FLAG_VOLU_ID2 0x20
60 #define VBLK_FLAG_VOLU_SIZE 0x80
61 #define VBLK_FLAG_VOLU_DRIVE 0x02
63 /* size of a vblk's static parts */
64 #define VBLK_SIZE_HEAD 16
65 #define VBLK_SIZE_CMP3 22 /* Name and version */
66 #define VBLK_SIZE_DGR3 12
67 #define VBLK_SIZE_DGR4 44
68 #define VBLK_SIZE_DSK3 12
69 #define VBLK_SIZE_DSK4 45
70 #define VBLK_SIZE_PRT3 28
71 #define VBLK_SIZE_VOL5 58
74 #define COMP_STRIPE 0x01 /* Stripe-set */
75 #define COMP_BASIC 0x02 /* Basic disk */
76 #define COMP_RAID 0x03 /* Raid-set */
78 /* Other constants. */
79 #define LDM_DB_SIZE 2048 /* Size in sectors (= 1MiB). */
81 #define OFF_PRIV1 6 /* Offset of the first privhead
82 relative to the start of the
85 /* Offsets to structures within the LDM Database in sectors. */
86 #define OFF_PRIV2 1856 /* Backup private headers. */
87 #define OFF_PRIV3 2047
89 #define OFF_TOCB1 1 /* Tables of contents. */
91 #define OFF_TOCB3 2045
92 #define OFF_TOCB4 2046
94 #define OFF_VMDB 17 /* List of partitions. */
96 #define LDM_PARTITION 0x42 /* Formerly SFS (Landis). */
98 #define TOC_BITMAP1 "config" /* Names of the two defined */
99 #define TOC_BITMAP2 "log" /* bitmaps in the TOCBLOCK. */
101 /* Most numbers we deal with are big-endian and won't be aligned. */
102 #define BE16(x) ((u16)be16_to_cpu(get_unaligned((__be16*)(x))))
103 #define BE32(x) ((u32)be32_to_cpu(get_unaligned((__be32*)(x))))
104 #define BE64(x) ((u64)be64_to_cpu(get_unaligned((__be64*)(x))))
106 /* Borrowed from msdos.c */
107 #define SYS_IND(p) (get_unaligned(&(p)->sys_ind))
109 struct frag { /* VBLK Fragment handling */
110 struct list_head list;
112 u8 num; /* Total number of records */
113 u8 rec; /* This is record number n */
114 u8 map; /* Which portions are in use */
118 /* In memory LDM database structures. */
122 struct privhead { /* Offsets and sizes are in sectors. */
125 u64 logical_disk_start;
126 u64 logical_disk_size;
129 u8 disk_id[GUID_SIZE];
132 struct tocblock { /* We have exactly two bitmaps. */
141 struct vmdb { /* VMDB: The database header */
149 struct vblk_comp { /* VBLK Component */
157 struct vblk_dgrp { /* VBLK Disk Group */
161 struct vblk_disk { /* VBLK Disk */
162 u8 disk_id[GUID_SIZE];
166 struct vblk_part { /* VBLK Partition */
168 u64 size; /* start, size and vol_off in sectors */
175 struct vblk_volu { /* VBLK Volume */
184 struct vblk_head { /* VBLK standard header */
190 struct vblk { /* Generalised VBLK */
197 struct vblk_comp comp;
198 struct vblk_dgrp dgrp;
199 struct vblk_disk disk;
200 struct vblk_part part;
201 struct vblk_volu volu;
203 struct list_head list;
206 struct ldmdb { /* Cache of the database */
210 struct list_head v_dgrp;
211 struct list_head v_disk;
212 struct list_head v_volu;
213 struct list_head v_comp;
214 struct list_head v_part;
217 int ldm_partition (struct parsed_partitions *state, struct block_device *bdev);
219 #endif /* _FS_PT_LDM_H_ */