1 /******************************************************************************
4 * Copyright (c) 2020, longpanda <admin@ventoy.net>
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.
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.
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/>.
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都是不定长的,其长度在结构里面描述
32 #ifndef __BISO_ROCKRIDGE_H__
33 #define __BISO_ROCKRIDGE_H__
36 #define S_IFLNK 0120000
37 #define S_IFREG 0100000
38 #define S_IFDIR 0040000
41 typedef VOID (* BISO_DUMP_ENTRY_PF
)(IN VOID
*pEntry
);
43 typedef struct tagBISO_DUMP_ENTRY_CB
46 BISO_DUMP_ENTRY_PF pfDump
;
47 }BISO_DUMP_ENTRY_CB_S
;
49 typedef VOID (* BISO_RRIP_PARSE_ENTRY_PF
)
52 OUT BISO_DIR_TREE_S
*pstDirTree
55 typedef struct tagBISO_RRIP_PARSE_ENTRY_CB
58 BISO_RRIP_PARSE_ENTRY_PF pfFunc
;
59 }BISO_RRIP_PARSE_ENTRY_CB_S
;
64 /* SUSP: System Use Sharing Protocol */
66 /* SUSP中定义的标准Entry结构 */
67 typedef struct tagBISO_SUSP_ENTRY
79 /* 数据,具体长度有ucEntryLen确定 */
84 * Continuation Area(可选)
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表项个数的没有限制的。
95 typedef struct tagBISO_SUSP_ENTRY_CE
98 CHAR cSignature1
; /* 必须为 'C' */
99 CHAR cSignature2
; /* 必须为 'E' */
101 /* 长度,包括控制字, 必须为28 */
107 BISO_DEF_733(uiBlockLoc
)
108 BISO_DEF_733(uiByteOffset
)
109 BISO_DEF_733(uiContinuationLen
)
110 }BISO_SUSP_ENTRY_CE_S
;
112 /* Padding Filed(可选) */
113 typedef struct tagBISO_SUSP_ENTRY_PD
116 CHAR cSignature1
; /* 必须为 'P' */
117 CHAR cSignature2
; /* 必须为 'D' */
125 /* 数据,具体长度有ucEntryLen确定 */
127 }BISO_SUSP_ENTRY_PD_S
;
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
140 typedef struct tagBISO_SUSP_ENTRY_SP
143 CHAR cSignature1
; /* 必须为 'S' */
144 CHAR cSignature2
; /* 必须为 'P' */
156 }BISO_SUSP_ENTRY_SP_S
;
158 /* System Use Sharing Protocol Termonitor: System Use或者CE区域最后一条表项 */
159 typedef struct tagBISO_SUSP_ENTRY_ST
162 CHAR cSignature1
; /* 必须为 'S' */
163 CHAR cSignature2
; /* 必须为 'T' */
170 }BISO_SUSP_ENTRY_ST_S
;
172 /* Extensions Reference */
173 typedef struct tagBISO_SUSP_ENTRY_ER
176 CHAR cSignature1
; /* 必须为 'E' */
177 CHAR cSignature2
; /* 必须为 'R' */
194 /* UCHAR aucId[ucIdLen]; */
195 /* UCHAR aucDesc[ucDescLen]; */
196 /* UCHAR aucSrc[ucSrcLen]; */
197 }BISO_SUSP_ENTRY_ER_S
;
199 /* Extension Selector */
200 typedef struct tagBISO_SUSP_ENTRY_ES
203 CHAR cSignature1
; /* 必须为 'E' */
204 CHAR cSignature2
; /* 必须为 'S' */
214 }BISO_SUSP_ENTRY_ES_S
;
216 /* Rock Ridge In Use RRIP 1991A版本里定义的结构, 新版本已经废弃 */
217 typedef struct tagBISO_ROCK_RIDGE_ENTRY_RR
220 CHAR cSignature1
; /* 必须为 'R' */
221 CHAR cSignature2
; /* 必须为 'R' */
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
241 }BISO_ROCK_RIDGE_ENTRY_RR_S
;
244 /* POSIX file attributes */
245 typedef struct tagBISO_ROCK_RIDGE_ENTRY_PX
248 CHAR cSignature1
; /* 必须为 'P' */
249 CHAR cSignature2
; /* 必须为 'X' */
252 * !!!!!!!!!!!!!!!!!!!!!!!!!!
253 * !!!!!!!!!!!!!!!!!!!!!!!!!!
254 * !!!!!!!!!!!!!!!!!!!!!!!!!!
255 * !!!!!!!!!!!!!!!!!!!!!!!!!!
256 * IEEE P1282 V1.10之前是36不是44
263 /* File Mode的比特位图, 就是linux里面stat结构里面的st_mode字段 */
264 BISO_DEF_733(uiPosixFileMode
)
267 BISO_DEF_733(uiPosixFileLink
)
270 BISO_DEF_733(uiPosixFileUserId
)
273 BISO_DEF_733(uiPosixFileGroupId
)
275 /* st_ino字段, 注意这个字段在IEEE P1282 V1.10之前是没有的 */
276 BISO_DEF_733(uiPosixFileSNO
)
277 }BISO_ROCK_RIDGE_ENTRY_PX_S
;
279 /* POSIX device number */
280 typedef struct tagBISO_ROCK_RIDGE_ENTRY_PN
283 CHAR cSignature1
; /* 必须为 'P' */
284 CHAR cSignature2
; /* 必须为 'N' */
286 /* 长度,包括控制字, 必须为20 */
292 /* Device Number的高低32位 */
293 BISO_DEF_733(uiDevNumHigh
)
294 BISO_DEF_733(uiDevNumLow
)
295 }BISO_ROCK_RIDGE_ENTRY_PN_S
;
298 typedef struct tagBISO_ROCK_RIDGE_ENTRY_SL
301 CHAR cSignature1
; /* 必须为 'S' */
302 CHAR cSignature2
; /* 必须为 'L' */
304 /* 长度,包括控制字, 必须为5+Componet长度 */
316 /* Componet内容,有具体的格式定义ISO_RRIP_SL_COMPONENT_S */
317 UCHAR aucComponet
[1];
318 }BISO_ROCK_RIDGE_ENTRY_SL_S
;
320 typedef struct tagBISO_RRIP_SL_COMPONENT
324 * Bit1: Current当前目录 '.'
325 * Bit2: Parent父目录 '..'
331 /* 长度,不包括ucFlags和自己,纯粹是后面aucData的长度 */
335 }BISO_RRIP_SL_COMPONENT_S
;
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)
343 * Alternate Name 用来记录POSIX文件名
344 * 注意NM表项可以有很多个,一直到ucFlags的比特0为0
345 * 多个NM表项里面的szFileName部分要拼接在一起表示整个完整的文件名
348 typedef struct tagBISO_ROCK_RIDGE_ENTRY_NM
351 CHAR cSignature1
; /* 必须为 'N' */
352 CHAR cSignature2
; /* 必须为 'M' */
354 /* 长度,包括控制字, 必须为5+Name长度 */
363 * Bit1: Current当前目录 '.'
364 * Bit2: Parent父目录 '..'
369 /* 后面跟着具体的名称,如果Flag的Bit1 2 5置为则后面就没有了 */
371 }BISO_ROCK_RIDGE_ENTRY_NM_S
;
374 /* 后面的CL PL RE用来扩展超过8级目录的情况 */
377 typedef struct tagBISO_ROCK_RIDGE_ENTRY_CL
380 CHAR cSignature1
; /* 必须为 'C' */
381 CHAR cSignature2
; /* 必须为 'L' */
383 /* 长度,包括控制字, 必须为12 */
389 BISO_DEF_733(uiChildDirLoc
)
390 }BISO_ROCK_RIDGE_ENTRY_CL_S
;
393 typedef struct tagBISO_ROCK_RIDGE_ENTRY_PL
396 CHAR cSignature1
; /* 必须为 'P' */
397 CHAR cSignature2
; /* 必须为 'L' */
399 /* 长度,包括控制字, 必须为12 */
405 BISO_DEF_733(uiParentDirLoc
)
406 }BISO_ROCK_RIDGE_ENTRY_PL_S
;
408 /* Relocated Directory */
409 typedef struct tagBISO_ROCK_RIDGE_ENTRY_RE
412 CHAR cSignature1
; /* 必须为 'R' */
413 CHAR cSignature2
; /* 必须为 'E' */
420 }BISO_ROCK_RIDGE_ENTRY_RE_S
;
422 /* Time Stamps For File */
423 typedef struct tagBISO_ROCK_RIDGE_ENTRY_TF
426 CHAR cSignature1
; /* 必须为 'T' */
427 CHAR cSignature2
; /* 必须为 'F' */
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)
450 /* 具体的每一个时间戳,每个时间戳7字节或者17字节,取决于ucFlags的Bit7 */
451 UCHAR aucTimeStamp
[1];
452 }BISO_ROCK_RIDGE_ENTRY_TF_S
;
454 /* File Data in sparse format 稀疏文件 */
455 typedef struct tagBISO_ROCK_RIDGE_ENTRY_SF
458 CHAR cSignature1
; /* 必须为 'S' */
459 CHAR cSignature2
; /* 必须为 'F' */
461 /* 长度,包括控制字, 必须为21 */
467 BISO_DEF_733(uiVirFileSizeHigh
)
468 BISO_DEF_733(uiVirFileSizeLow
)
481 }BISO_ROCK_RIDGE_ENTRY_SF_S
;
485 ULONG
BISO_RRIP_ReadIndicator(INOUT BISO_PARSER_S
*pstParser
);
486 ULONG BISO_RRIP_ReadExtInfo
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
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
);
499 #endif /* __BISO_ROCKRIDGE_H__ */