ldm.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /**
  3. * ldm - Part of the Linux-NTFS project.
  4. *
  5. * Copyright (C) 2001,2002 Richard Russon <[email protected]>
  6. * Copyright (c) 2001-2007 Anton Altaparmakov
  7. * Copyright (C) 2001,2002 Jakob Kemi <[email protected]>
  8. *
  9. * Documentation is available at http://www.linux-ntfs.org/doku.php?id=downloads
  10. */
  11. #ifndef _FS_PT_LDM_H_
  12. #define _FS_PT_LDM_H_
  13. #include <linux/types.h>
  14. #include <linux/list.h>
  15. #include <linux/fs.h>
  16. #include <asm/unaligned.h>
  17. #include <asm/byteorder.h>
  18. struct parsed_partitions;
  19. /* Magic numbers in CPU format. */
  20. #define MAGIC_VMDB 0x564D4442 /* VMDB */
  21. #define MAGIC_VBLK 0x56424C4B /* VBLK */
  22. #define MAGIC_PRIVHEAD 0x5052495648454144ULL /* PRIVHEAD */
  23. #define MAGIC_TOCBLOCK 0x544F43424C4F434BULL /* TOCBLOCK */
  24. /* The defined vblk types. */
  25. #define VBLK_VOL5 0x51 /* Volume, version 5 */
  26. #define VBLK_CMP3 0x32 /* Component, version 3 */
  27. #define VBLK_PRT3 0x33 /* Partition, version 3 */
  28. #define VBLK_DSK3 0x34 /* Disk, version 3 */
  29. #define VBLK_DSK4 0x44 /* Disk, version 4 */
  30. #define VBLK_DGR3 0x35 /* Disk Group, version 3 */
  31. #define VBLK_DGR4 0x45 /* Disk Group, version 4 */
  32. /* vblk flags indicating extra information will be present */
  33. #define VBLK_FLAG_COMP_STRIPE 0x10
  34. #define VBLK_FLAG_PART_INDEX 0x08
  35. #define VBLK_FLAG_DGR3_IDS 0x08
  36. #define VBLK_FLAG_DGR4_IDS 0x08
  37. #define VBLK_FLAG_VOLU_ID1 0x08
  38. #define VBLK_FLAG_VOLU_ID2 0x20
  39. #define VBLK_FLAG_VOLU_SIZE 0x80
  40. #define VBLK_FLAG_VOLU_DRIVE 0x02
  41. /* size of a vblk's static parts */
  42. #define VBLK_SIZE_HEAD 16
  43. #define VBLK_SIZE_CMP3 22 /* Name and version */
  44. #define VBLK_SIZE_DGR3 12
  45. #define VBLK_SIZE_DGR4 44
  46. #define VBLK_SIZE_DSK3 12
  47. #define VBLK_SIZE_DSK4 45
  48. #define VBLK_SIZE_PRT3 28
  49. #define VBLK_SIZE_VOL5 58
  50. /* component types */
  51. #define COMP_STRIPE 0x01 /* Stripe-set */
  52. #define COMP_BASIC 0x02 /* Basic disk */
  53. #define COMP_RAID 0x03 /* Raid-set */
  54. /* Other constants. */
  55. #define LDM_DB_SIZE 2048 /* Size in sectors (= 1MiB). */
  56. #define OFF_PRIV1 6 /* Offset of the first privhead
  57. relative to the start of the
  58. device in sectors */
  59. /* Offsets to structures within the LDM Database in sectors. */
  60. #define OFF_PRIV2 1856 /* Backup private headers. */
  61. #define OFF_PRIV3 2047
  62. #define OFF_TOCB1 1 /* Tables of contents. */
  63. #define OFF_TOCB2 2
  64. #define OFF_TOCB3 2045
  65. #define OFF_TOCB4 2046
  66. #define OFF_VMDB 17 /* List of partitions. */
  67. #define LDM_PARTITION 0x42 /* Formerly SFS (Landis). */
  68. #define TOC_BITMAP1 "config" /* Names of the two defined */
  69. #define TOC_BITMAP2 "log" /* bitmaps in the TOCBLOCK. */
  70. struct frag { /* VBLK Fragment handling */
  71. struct list_head list;
  72. u32 group;
  73. u8 num; /* Total number of records */
  74. u8 rec; /* This is record number n */
  75. u8 map; /* Which portions are in use */
  76. u8 data[];
  77. };
  78. /* In memory LDM database structures. */
  79. struct privhead { /* Offsets and sizes are in sectors. */
  80. u16 ver_major;
  81. u16 ver_minor;
  82. u64 logical_disk_start;
  83. u64 logical_disk_size;
  84. u64 config_start;
  85. u64 config_size;
  86. uuid_t disk_id;
  87. };
  88. struct tocblock { /* We have exactly two bitmaps. */
  89. u8 bitmap1_name[16];
  90. u64 bitmap1_start;
  91. u64 bitmap1_size;
  92. u8 bitmap2_name[16];
  93. u64 bitmap2_start;
  94. u64 bitmap2_size;
  95. };
  96. struct vmdb { /* VMDB: The database header */
  97. u16 ver_major;
  98. u16 ver_minor;
  99. u32 vblk_size;
  100. u32 vblk_offset;
  101. u32 last_vblk_seq;
  102. };
  103. struct vblk_comp { /* VBLK Component */
  104. u8 state[16];
  105. u64 parent_id;
  106. u8 type;
  107. u8 children;
  108. u16 chunksize;
  109. };
  110. struct vblk_dgrp { /* VBLK Disk Group */
  111. u8 disk_id[64];
  112. };
  113. struct vblk_disk { /* VBLK Disk */
  114. uuid_t disk_id;
  115. u8 alt_name[128];
  116. };
  117. struct vblk_part { /* VBLK Partition */
  118. u64 start;
  119. u64 size; /* start, size and vol_off in sectors */
  120. u64 volume_offset;
  121. u64 parent_id;
  122. u64 disk_id;
  123. u8 partnum;
  124. };
  125. struct vblk_volu { /* VBLK Volume */
  126. u8 volume_type[16];
  127. u8 volume_state[16];
  128. u8 guid[16];
  129. u8 drive_hint[4];
  130. u64 size;
  131. u8 partition_type;
  132. };
  133. struct vblk_head { /* VBLK standard header */
  134. u32 group;
  135. u16 rec;
  136. u16 nrec;
  137. };
  138. struct vblk { /* Generalised VBLK */
  139. u8 name[64];
  140. u64 obj_id;
  141. u32 sequence;
  142. u8 flags;
  143. u8 type;
  144. union {
  145. struct vblk_comp comp;
  146. struct vblk_dgrp dgrp;
  147. struct vblk_disk disk;
  148. struct vblk_part part;
  149. struct vblk_volu volu;
  150. } vblk;
  151. struct list_head list;
  152. };
  153. struct ldmdb { /* Cache of the database */
  154. struct privhead ph;
  155. struct tocblock toc;
  156. struct vmdb vm;
  157. struct list_head v_dgrp;
  158. struct list_head v_disk;
  159. struct list_head v_volu;
  160. struct list_head v_comp;
  161. struct list_head v_part;
  162. };
  163. #endif /* _FS_PT_LDM_H_ */