]> glassweightruler.freedombox.rocks Git - Ventoy.git/blob - VtoyTool/BabyISO/biso_rockridge.h
added Spanish (Latinoamérica) translation (#1865)
[Ventoy.git] / VtoyTool / BabyISO / biso_rockridge.h
1 /******************************************************************************
2 * biso_rockridge.h
3 *
4 * Copyright (c) 2020, longpanda <admin@ventoy.net>
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 3 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, see <http://www.gnu.org/licenses/>.
18 *
19 */
20
21
22
23 /*
24 * 本文件中定义了SUSP(ystem Use Sharing Protocol)协议(IEEE P1281)
25 * 以及Rock Ridge 扩展中定义的各种表项结构(IEEE P1282)
26 * 其中SUSP是规定了ISO-9660中Directory Record中System Use字段的使用方法
27 * Rock Ridge是基于SUSP,在System Use字段中扩展记录了文件的属性、名称等POSIX文件信息
28 * 详细的说明请参考标准文档(IEEE P1281、IEEE P1282)
29 * SUSP定义的每一条Entry都是不定长的,其长度在结构里面描述
30 */
31
32 #ifndef __BISO_ROCKRIDGE_H__
33 #define __BISO_ROCKRIDGE_H__
34
35 #ifndef S_IFLNK
36 #define S_IFLNK 0120000
37 #define S_IFREG 0100000
38 #define S_IFDIR 0040000
39 #endif
40
41 typedef VOID (* BISO_DUMP_ENTRY_PF)(IN VOID *pEntry);
42
43 typedef struct tagBISO_DUMP_ENTRY_CB
44 {
45 CHAR szSignature[3];
46 BISO_DUMP_ENTRY_PF pfDump;
47 }BISO_DUMP_ENTRY_CB_S;
48
49 typedef VOID (* BISO_RRIP_PARSE_ENTRY_PF)
50 (
51 IN VOID *pEntry,
52 OUT BISO_DIR_TREE_S *pstDirTree
53 );
54
55 typedef struct tagBISO_RRIP_PARSE_ENTRY_CB
56 {
57 CHAR szSignature[3];
58 BISO_RRIP_PARSE_ENTRY_PF pfFunc;
59 }BISO_RRIP_PARSE_ENTRY_CB_S;
60
61
62 #pragma pack(1)
63
64 /* SUSP: System Use Sharing Protocol */
65
66 /* SUSP中定义的标准Entry结构 */
67 typedef struct tagBISO_SUSP_ENTRY
68 {
69 /* 两个控制字 */
70 CHAR cSignature1;
71 CHAR cSignature2;
72
73 /* 长度,包括控制字 */
74 UCHAR ucEntryLen;
75
76 /* 版本号 */
77 UCHAR ucVersion;
78
79 /* 数据,具体长度有ucEntryLen确定 */
80 UCHAR aucData[1];
81 }BISO_SUSP_ENTRY_S;
82
83 /*
84 * Continuation Area(可选)
85 * !!!!!!!!!!!!!!!!!
86 * !!!!!!!!!!!!!!!!!
87 * !!!!!!!!!!!!!!!!!
88 * 之所以有CE这个控制字是因为ISO-9660标准定义的Directory Record
89 * 的长度是用1个字节表示的.最大就255 Byte,所以System Use字段的长度也就
90 * 不可能大于255,而有些扩展信息可能需要很多个Entry才能描述,255的长度不够
91 * 就需要扩展,所以才有了这个用于扩展的Entry格式
92 * 每个Directory Record的System Use字段或者扩展区域中只能最多有1个CE表项,
93 * 而且一般也应该是最后1条表项,不过整个System Use区域的CE表项个数的没有限制的。
94 */
95 typedef struct tagBISO_SUSP_ENTRY_CE
96 {
97 /* 两个控制字 */
98 CHAR cSignature1; /* 必须为 'C' */
99 CHAR cSignature2; /* 必须为 'E' */
100
101 /* 长度,包括控制字, 必须为28 */
102 UCHAR ucEntryLen;
103
104 /* 版本号, 必须为1 */
105 UCHAR ucVersion;
106
107 BISO_DEF_733(uiBlockLoc)
108 BISO_DEF_733(uiByteOffset)
109 BISO_DEF_733(uiContinuationLen)
110 }BISO_SUSP_ENTRY_CE_S;
111
112 /* Padding Filed(可选) */
113 typedef struct tagBISO_SUSP_ENTRY_PD
114 {
115 /* 两个控制字 */
116 CHAR cSignature1; /* 必须为 'P' */
117 CHAR cSignature2; /* 必须为 'D' */
118
119 /* 长度,包括控制字 */
120 UCHAR ucEntryLen;
121
122 /* 版本号, 必须为1 */
123 UCHAR ucVersion;
124
125 /* 数据,具体长度有ucEntryLen确定 */
126 UCHAR aucData[1];
127 }BISO_SUSP_ENTRY_PD_S;
128
129 /*
130 * System Use Sharing Protocol Indicator(必须存在)
131 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
132 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
133 * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
134 * SP必须是在Root Directory Record的System Use里面从1个字节开始的第1条表项
135 * 另外,SP表项还有一个作用就是它里面的Skip Len字段,它的意思是
136 * 在除了ROOT之外的所有Directory Record中,System Use字段不一定是从第1个字节开始就是
137 * SUSP的各种表项,可以统一跳过一定的偏移(为了兼容性考虑),就是这里的Skip Len
138 * 注意这个Skip Len对ROOT根目录无效,对于ROOT永远是从SYSTEM Use的第1个字节开始是SP Entry
139 */
140 typedef struct tagBISO_SUSP_ENTRY_SP
141 {
142 /* 两个控制字 */
143 CHAR cSignature1; /* 必须为 'S' */
144 CHAR cSignature2; /* 必须为 'P' */
145
146 /* 长度,包括控制字, 必须为7 */
147 UCHAR ucEntryLen;
148
149 /* 版本号, 必须为1 */
150 UCHAR ucVersion;
151
152 /* 检查字段 */
153 UCHAR ucChkBE;
154 UCHAR ucChkEF;
155 UCHAR ucSkipLen;
156 }BISO_SUSP_ENTRY_SP_S;
157
158 /* System Use Sharing Protocol Termonitor: System Use或者CE区域最后一条表项 */
159 typedef struct tagBISO_SUSP_ENTRY_ST
160 {
161 /* 两个控制字 */
162 CHAR cSignature1; /* 必须为 'S' */
163 CHAR cSignature2; /* 必须为 'T' */
164
165 /* 长度,包括控制字, 必须为4 */
166 UCHAR ucEntryLen;
167
168 /* 版本号, 必须为1 */
169 UCHAR ucVersion;
170 }BISO_SUSP_ENTRY_ST_S;
171
172 /* Extensions Reference */
173 typedef struct tagBISO_SUSP_ENTRY_ER
174 {
175 /* 两个控制字 */
176 CHAR cSignature1; /* 必须为 'E' */
177 CHAR cSignature2; /* 必须为 'R' */
178
179 /* 长度,包括控制字 */
180 UCHAR ucEntryLen;
181
182 /* 版本号, 必须为1 */
183 UCHAR ucVersion;
184
185 UCHAR ucIdLen;
186
187 UCHAR ucDescLen;
188
189 UCHAR ucSrcLen;
190
191 UCHAR ucExtVer;
192
193 /* 后面跟着数据 */
194 /* UCHAR aucId[ucIdLen]; */
195 /* UCHAR aucDesc[ucDescLen]; */
196 /* UCHAR aucSrc[ucSrcLen]; */
197 }BISO_SUSP_ENTRY_ER_S;
198
199 /* Extension Selector */
200 typedef struct tagBISO_SUSP_ENTRY_ES
201 {
202 /* 两个控制字 */
203 CHAR cSignature1; /* 必须为 'E' */
204 CHAR cSignature2; /* 必须为 'S' */
205
206 /* 长度,包括控制字, 必须为5 */
207 UCHAR ucEntryLen;
208
209 /* 版本号, 必须为1 */
210 UCHAR ucVersion;
211
212 /* 扩展编号 */
213 UCHAR ucExtSeq;
214 }BISO_SUSP_ENTRY_ES_S;
215
216 /* Rock Ridge In Use RRIP 1991A版本里定义的结构, 新版本已经废弃 */
217 typedef struct tagBISO_ROCK_RIDGE_ENTRY_RR
218 {
219 /* 两个控制字 */
220 CHAR cSignature1; /* 必须为 'R' */
221 CHAR cSignature2; /* 必须为 'R' */
222
223 /* 长度,包括控制字, 必须为5 */
224 UCHAR ucEntryLen;
225
226 /* 版本号, 必须为1 */
227 UCHAR ucVersion;
228
229 /*
230 * ucFlags, 各Bit含义如下:
231 * Bit0: "PX" System Use Field recorded
232 * Bit1: "PN" System Use Field recorded
233 * Bit2: "SL" System Use Field recorded
234 * Bit3: "NM" System Use Field recorded
235 * Bit4: "CL" System Use Field recorded
236 * Bit5: "PL" System Use Field recorded
237 * Bit6: "RE" System Use Field recorded
238 * Bit7: "TF" System Use Field recorded
239 */
240 UCHAR ucFlags;
241 }BISO_ROCK_RIDGE_ENTRY_RR_S;
242
243
244 /* POSIX file attributes */
245 typedef struct tagBISO_ROCK_RIDGE_ENTRY_PX
246 {
247 /* 两个控制字 */
248 CHAR cSignature1; /* 必须为 'P' */
249 CHAR cSignature2; /* 必须为 'X' */
250
251 /* 长度,包括控制字, 必须为44
252 * !!!!!!!!!!!!!!!!!!!!!!!!!!
253 * !!!!!!!!!!!!!!!!!!!!!!!!!!
254 * !!!!!!!!!!!!!!!!!!!!!!!!!!
255 * !!!!!!!!!!!!!!!!!!!!!!!!!!
256 * IEEE P1282 V1.10之前是36不是44
257 */
258 UCHAR ucEntryLen;
259
260 /* 版本号, 必须为1 */
261 UCHAR ucVersion;
262
263 /* File Mode的比特位图, 就是linux里面stat结构里面的st_mode字段 */
264 BISO_DEF_733(uiPosixFileMode)
265
266 /* st_nlink字段 */
267 BISO_DEF_733(uiPosixFileLink)
268
269 /* st_uid字段 */
270 BISO_DEF_733(uiPosixFileUserId)
271
272 /* st_gid字段 */
273 BISO_DEF_733(uiPosixFileGroupId)
274
275 /* st_ino字段, 注意这个字段在IEEE P1282 V1.10之前是没有的 */
276 BISO_DEF_733(uiPosixFileSNO)
277 }BISO_ROCK_RIDGE_ENTRY_PX_S;
278
279 /* POSIX device number */
280 typedef struct tagBISO_ROCK_RIDGE_ENTRY_PN
281 {
282 /* 两个控制字 */
283 CHAR cSignature1; /* 必须为 'P' */
284 CHAR cSignature2; /* 必须为 'N' */
285
286 /* 长度,包括控制字, 必须为20 */
287 UCHAR ucEntryLen;
288
289 /* 版本号, 必须为1 */
290 UCHAR ucVersion;
291
292 /* Device Number的高低32位 */
293 BISO_DEF_733(uiDevNumHigh)
294 BISO_DEF_733(uiDevNumLow)
295 }BISO_ROCK_RIDGE_ENTRY_PN_S;
296
297 /* Symbol Link */
298 typedef struct tagBISO_ROCK_RIDGE_ENTRY_SL
299 {
300 /* 两个控制字 */
301 CHAR cSignature1; /* 必须为 'S' */
302 CHAR cSignature2; /* 必须为 'L' */
303
304 /* 长度,包括控制字, 必须为5+Componet长度 */
305 UCHAR ucEntryLen;
306
307 /* 版本号, 必须为1 */
308 UCHAR ucVersion;
309
310 /*
311 * 0:最后一个软链接
312 * 1:后面还有
313 */
314 UCHAR ucFlags;
315
316 /* Componet内容,有具体的格式定义ISO_RRIP_SL_COMPONENT_S */
317 UCHAR aucComponet[1];
318 }BISO_ROCK_RIDGE_ENTRY_SL_S;
319
320 typedef struct tagBISO_RRIP_SL_COMPONENT
321 {
322 /* ucFlags
323 * Bit0: Continue
324 * Bit1: Current当前目录 '.'
325 * Bit2: Parent父目录 '..'
326 * Bit3: Root 目录 '/'
327 * 其他位保留
328 */
329 UCHAR ucFlags;
330
331 /* 长度,不包括ucFlags和自己,纯粹是后面aucData的长度 */
332 UCHAR ucLength;
333
334 UCHAR aucData[1];
335 }BISO_RRIP_SL_COMPONENT_S;
336
337 #define BISO_SLCOMP_IS_CONTINUE(ucFlag) (((ucFlag >> 0) & 0x1) > 0 ? BOOL_TRUE : BOOL_FALSE)
338 #define BISO_SLCOMP_IS_CURRENT(ucFlag) (((ucFlag >> 1) & 0x1) > 0 ? BOOL_TRUE : BOOL_FALSE)
339 #define BISO_SLCOMP_IS_PARENT(ucFlag) (((ucFlag >> 2) & 0x1) > 0 ? BOOL_TRUE : BOOL_FALSE)
340 #define BISO_SLCOMP_IS_ROOT(ucFlag) (((ucFlag >> 3) & 0x1) > 0 ? BOOL_TRUE : BOOL_FALSE)
341
342 /*
343 * Alternate Name 用来记录POSIX文件名
344 * 注意NM表项可以有很多个,一直到ucFlags的比特0为0
345 * 多个NM表项里面的szFileName部分要拼接在一起表示整个完整的文件名
346 * 这个应该主要是为了解决长文件名的问题
347 */
348 typedef struct tagBISO_ROCK_RIDGE_ENTRY_NM
349 {
350 /* 两个控制字 */
351 CHAR cSignature1; /* 必须为 'N' */
352 CHAR cSignature2; /* 必须为 'M' */
353
354 /* 长度,包括控制字, 必须为5+Name长度 */
355 UCHAR ucEntryLen;
356
357 /* 版本号, 必须为1 */
358 UCHAR ucVersion;
359
360 /*
361 * ucFlags
362 * Bit0: Continue
363 * Bit1: Current当前目录 '.'
364 * Bit2: Parent父目录 '..'
365 * 其他位保留
366 */
367 UCHAR ucFlags;
368
369 /* 后面跟着具体的名称,如果Flag的Bit1 2 5置为则后面就没有了 */
370 CHAR szFileName[1];
371 }BISO_ROCK_RIDGE_ENTRY_NM_S;
372
373
374 /* 后面的CL PL RE用来扩展超过8级目录的情况 */
375
376 /* Child Link */
377 typedef struct tagBISO_ROCK_RIDGE_ENTRY_CL
378 {
379 /* 两个控制字 */
380 CHAR cSignature1; /* 必须为 'C' */
381 CHAR cSignature2; /* 必须为 'L' */
382
383 /* 长度,包括控制字, 必须为12 */
384 UCHAR ucEntryLen;
385
386 /* 版本号, 必须为1 */
387 UCHAR ucVersion;
388
389 BISO_DEF_733(uiChildDirLoc)
390 }BISO_ROCK_RIDGE_ENTRY_CL_S;
391
392 /* Parent Link */
393 typedef struct tagBISO_ROCK_RIDGE_ENTRY_PL
394 {
395 /* 两个控制字 */
396 CHAR cSignature1; /* 必须为 'P' */
397 CHAR cSignature2; /* 必须为 'L' */
398
399 /* 长度,包括控制字, 必须为12 */
400 UCHAR ucEntryLen;
401
402 /* 版本号, 必须为1 */
403 UCHAR ucVersion;
404
405 BISO_DEF_733(uiParentDirLoc)
406 }BISO_ROCK_RIDGE_ENTRY_PL_S;
407
408 /* Relocated Directory */
409 typedef struct tagBISO_ROCK_RIDGE_ENTRY_RE
410 {
411 /* 两个控制字 */
412 CHAR cSignature1; /* 必须为 'R' */
413 CHAR cSignature2; /* 必须为 'E' */
414
415 /* 长度,包括控制字, 必须为4 */
416 UCHAR ucEntryLen;
417
418 /* 版本号, 必须为1 */
419 UCHAR ucVersion;
420 }BISO_ROCK_RIDGE_ENTRY_RE_S;
421
422 /* Time Stamps For File */
423 typedef struct tagBISO_ROCK_RIDGE_ENTRY_TF
424 {
425 /* 两个控制字 */
426 CHAR cSignature1; /* 必须为 'T' */
427 CHAR cSignature2; /* 必须为 'F' */
428
429 /* 长度,包括控制字 */
430 UCHAR ucEntryLen;
431
432 /* 版本号, 必须为1 */
433 UCHAR ucVersion;
434
435 /*
436 * ucFlags:
437 * Bit0: Create Time 是否记录
438 * Bit1: Modify Time 是否记录
439 * Bit2: Last Access Time 是否记录
440 * Bit3: Last Attribute Change Time 是否记录
441 * Bit4: Last Backup Time 是否记录
442 * Bit5: Expiration Time 是否记录
443 * Bit6: Effective Time 是否记录
444 * Bit7: Long-Form 时间格式
445 * 0 表示7字节数组格式(ECMA-119 9.1.5)
446 * 1 表示17字符串格式(ECMA-119 8.4.26.1)
447 */
448 UCHAR ucFlags;
449
450 /* 具体的每一个时间戳,每个时间戳7字节或者17字节,取决于ucFlags的Bit7 */
451 UCHAR aucTimeStamp[1];
452 }BISO_ROCK_RIDGE_ENTRY_TF_S;
453
454 /* File Data in sparse format 稀疏文件 */
455 typedef struct tagBISO_ROCK_RIDGE_ENTRY_SF
456 {
457 /* 两个控制字 */
458 CHAR cSignature1; /* 必须为 'S' */
459 CHAR cSignature2; /* 必须为 'F' */
460
461 /* 长度,包括控制字, 必须为21 */
462 UCHAR ucEntryLen;
463
464 /* 版本号, 必须为1 */
465 UCHAR ucVersion;
466
467 BISO_DEF_733(uiVirFileSizeHigh)
468 BISO_DEF_733(uiVirFileSizeLow)
469
470 /*
471 * ucDepth:
472 * 1-->64KB
473 * 2-->16MB
474 * 3-->4GB
475 * 4-->1TB
476 * 5-->256TB
477 * 6-->64K TB
478 * 7-->16M TB
479 */
480 UCHAR ucDepth;
481 }BISO_ROCK_RIDGE_ENTRY_SF_S;
482
483 #pragma pack()
484
485 ULONG BISO_RRIP_ReadIndicator(INOUT BISO_PARSER_S *pstParser);
486 ULONG BISO_RRIP_ReadExtInfo
487 (
488 IN BISO_FILE_S *pstFile,
489 IN BISO_PARSER_S *pstParser,
490 IN BISO_DIR_RECORD_S *pstRecord,
491 OUT BISO_DIR_TREE_S *pstDirTree
492 );
493 VOID BISO_RRIP_GetPXInfo(IN VOID *pEntry, OUT BISO_DIR_TREE_S *pstDirTree);
494 VOID BISO_RRIP_GetNMInfo(IN VOID *pEntry, OUT BISO_DIR_TREE_S *pstDirTree);
495 VOID BISO_RRIP_GetTFInfo(IN VOID *pEntry, OUT BISO_DIR_TREE_S *pstDirTree);
496 VOID BISO_RRIP_GetSLInfo(IN VOID *pEntry, OUT BISO_DIR_TREE_S *pstDirTree);
497 VOID BISO_RRIP_GetPNInfo(IN VOID *pEntry, OUT BISO_DIR_TREE_S *pstDirTree);
498
499 #endif /* __BISO_ROCKRIDGE_H__ */
500