Upgraded GRUB2 to 2.00 release.
[AROS.git] / arch / all-pc / boot / grub2-aros / include / grub / ntfs.h
blob093534205e8c4c6654be7238aecdf204506609df
1 /* ntfs.h - header for the NTFS filesystem */
2 /*
3 * GRUB -- GRand Unified Bootloader
4 * Copyright (C) 2007,2009 Free Software Foundation, Inc.
6 * GRUB is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * GRUB is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
20 #ifndef GRUB_NTFS_H
21 #define GRUB_NTFS_H 1
23 enum
25 GRUB_NTFS_FILE_MFT = 0,
26 GRUB_NTFS_FILE_MFTMIRR = 1,
27 GRUB_NTFS_FILE_LOGFILE = 2,
28 GRUB_NTFS_FILE_VOLUME = 3,
29 GRUB_NTFS_FILE_ATTRDEF = 4,
30 GRUB_NTFS_FILE_ROOT = 5,
31 GRUB_NTFS_FILE_BITMAP = 6,
32 GRUB_NTFS_FILE_BOOT = 7,
33 GRUB_NTFS_FILE_BADCLUS = 8,
34 GRUB_NTFS_FILE_QUOTA = 9,
35 GRUB_NTFS_FILE_UPCASE = 10,
38 enum
40 GRUB_NTFS_AT_STANDARD_INFORMATION = 0x10,
41 GRUB_NTFS_AT_ATTRIBUTE_LIST = 0x20,
42 GRUB_NTFS_AT_FILENAME = 0x30,
43 GRUB_NTFS_AT_OBJECT_ID = 0x40,
44 GRUB_NTFS_AT_SECURITY_DESCRIPTOR = 0x50,
45 GRUB_NTFS_AT_VOLUME_NAME = 0x60,
46 GRUB_NTFS_AT_VOLUME_INFORMATION = 0x70,
47 GRUB_NTFS_AT_DATA = 0x80,
48 GRUB_NTFS_AT_INDEX_ROOT = 0x90,
49 GRUB_NTFS_AT_INDEX_ALLOCATION = 0xA0,
50 GRUB_NTFS_AT_BITMAP = 0xB0,
51 GRUB_NTFS_AT_SYMLINK = 0xC0,
52 GRUB_NTFS_AT_EA_INFORMATION = 0xD0,
53 GRUB_NTFS_AT_EA = 0xE0,
56 enum
58 GRUB_NTFS_ATTR_READ_ONLY = 0x1,
59 GRUB_NTFS_ATTR_HIDDEN = 0x2,
60 GRUB_NTFS_ATTR_SYSTEM = 0x4,
61 GRUB_NTFS_ATTR_ARCHIVE = 0x20,
62 GRUB_NTFS_ATTR_DEVICE = 0x40,
63 GRUB_NTFS_ATTR_NORMAL = 0x80,
64 GRUB_NTFS_ATTR_TEMPORARY = 0x100,
65 GRUB_NTFS_ATTR_SPARSE = 0x200,
66 GRUB_NTFS_ATTR_REPARSE = 0x400,
67 GRUB_NTFS_ATTR_COMPRESSED = 0x800,
68 GRUB_NTFS_ATTR_OFFLINE = 0x1000,
69 GRUB_NTFS_ATTR_NOT_INDEXED = 0x2000,
70 GRUB_NTFS_ATTR_ENCRYPTED = 0x4000,
71 GRUB_NTFS_ATTR_DIRECTORY = 0x10000000,
72 GRUB_NTFS_ATTR_INDEX_VIEW = 0x20000000
75 enum
77 GRUB_NTFS_FLAG_COMPRESSED = 1,
78 GRUB_NTFS_FLAG_ENCRYPTED = 0x4000,
79 GRUB_NTFS_FLAG_SPARSE = 0x8000
82 #define GRUB_NTFS_BLK_SHR GRUB_DISK_SECTOR_BITS
84 #define GRUB_NTFS_MAX_MFT (4096 >> GRUB_NTFS_BLK_SHR)
85 #define GRUB_NTFS_MAX_IDX (16384 >> GRUB_NTFS_BLK_SHR)
87 #define GRUB_NTFS_COM_LEN 4096
88 #define GRUB_NTFS_COM_LOG_LEN 12
89 #define GRUB_NTFS_COM_SEC (GRUB_NTFS_COM_LEN >> GRUB_NTFS_BLK_SHR)
91 enum
93 GRUB_NTFS_AF_ALST = 1,
94 GRUB_NTFS_AF_MMFT = 2,
95 GRUB_NTFS_AF_GPOS = 4,
98 enum
100 GRUB_NTFS_RF_COMP = 1,
101 GRUB_NTFS_RF_CBLK = 2,
102 GRUB_NTFS_RF_BLNK = 4
105 struct grub_ntfs_bpb
107 grub_uint8_t jmp_boot[3];
108 grub_uint8_t oem_name[8];
109 grub_uint16_t bytes_per_sector;
110 grub_uint8_t sectors_per_cluster;
111 grub_uint8_t reserved_1[7];
112 grub_uint8_t media;
113 grub_uint16_t reserved_2;
114 grub_uint16_t sectors_per_track;
115 grub_uint16_t num_heads;
116 grub_uint32_t num_hidden_sectors;
117 grub_uint32_t reserved_3;
118 grub_uint8_t bios_drive;
119 grub_uint8_t reserved_4[3];
120 grub_uint64_t num_total_sectors;
121 grub_uint64_t mft_lcn;
122 grub_uint64_t mft_mirr_lcn;
123 grub_int8_t clusters_per_mft;
124 grub_int8_t reserved_5[3];
125 grub_int8_t clusters_per_index;
126 grub_int8_t reserved_6[3];
127 grub_uint64_t num_serial;
128 grub_uint32_t checksum;
129 } __attribute__ ((packed));
131 struct grub_ntfs_attr
133 int flags;
134 char *emft_buf, *edat_buf;
135 char *attr_cur, *attr_nxt, *attr_end;
136 grub_uint32_t save_pos;
137 char *sbuf;
138 struct grub_ntfs_file *mft;
141 struct grub_ntfs_file
143 struct grub_ntfs_data *data;
144 char *buf;
145 grub_uint64_t size;
146 grub_uint64_t mtime;
147 grub_uint32_t ino;
148 int inode_read;
149 struct grub_ntfs_attr attr;
152 struct grub_ntfs_data
154 struct grub_ntfs_file cmft;
155 struct grub_ntfs_file mmft;
156 grub_disk_t disk;
157 grub_uint32_t mft_size;
158 grub_uint32_t idx_size;
159 grub_uint32_t spc;
160 grub_uint32_t mft_start;
161 grub_uint64_t uuid;
164 struct grub_ntfs_comp_table_element
166 grub_uint32_t next_vcn;
167 grub_uint32_t next_lcn;
170 struct grub_ntfs_comp
172 grub_disk_t disk;
173 int comp_head, comp_tail;
174 struct grub_ntfs_comp_table_element comp_table[16];
175 grub_uint32_t cbuf_ofs, cbuf_vcn, spc;
176 char *cbuf;
179 struct grub_ntfs_rlst
181 int flags;
182 grub_disk_addr_t target_vcn, curr_vcn, next_vcn, curr_lcn;
183 char *cur_run;
184 struct grub_ntfs_attr *attr;
185 struct grub_ntfs_comp comp;
188 typedef grub_err_t (*grub_ntfscomp_func_t) (struct grub_ntfs_attr * at,
189 char *dest,
190 grub_disk_addr_t ofs,
191 grub_size_t len,
192 struct grub_ntfs_rlst * ctx,
193 grub_disk_addr_t vcn);
195 extern grub_ntfscomp_func_t grub_ntfscomp_func;
197 grub_err_t grub_ntfs_read_run_list (struct grub_ntfs_rlst *ctx);
199 #endif /* ! GRUB_NTFS_H */