2 * This file contains support for System Use Sharing Protocol (SUSP) extension
9 #ifdef ISO9660_OPTION_ROCKRIDGE
11 int parse_susp(struct rrii_dir_record
*dir
, char *buffer
)
13 /* Parse fundamental SUSP entries */
14 char susp_signature
[2];
23 susp_signature
[0] = buffer
[0];
24 susp_signature
[1] = buffer
[1];
25 susp_length
= *((u8_t
*)buffer
+ 2);
26 susp_version
= *((u8_t
*)buffer
+ 3);
28 if ((susp_signature
[0] == 'C') && (susp_signature
[1] == 'E') &&
29 (susp_length
>= 28) && (susp_version
>= 1)) {
31 * Continuation area, perform a recursion.
33 * FIXME: Currently we're parsing only first logical block of a
34 * continuation area, and infinite recursion is not checked.
37 ca_block_nr
= *((u32_t
*)(buffer
+ 4));
38 ca_offset
= *((u32_t
*)(buffer
+ 12));
39 ca_length
= *((u32_t
*)(buffer
+ 20));
41 /* Truncate continuation area to fit one logical block. */
42 if (ca_offset
>= v_pri
.logical_block_size_l
) {
45 if (ca_offset
+ ca_length
> v_pri
.logical_block_size_l
) {
46 ca_length
= v_pri
.logical_block_size_l
- ca_offset
;
49 r
= lmfs_get_block(&ca_bp
, fs_dev
, ca_block_nr
, NORMAL
);
53 parse_susp_buffer(dir
, b_data(ca_bp
) + ca_offset
, ca_length
);
54 lmfs_put_block(ca_bp
);
58 else if ((susp_signature
[0] == 'P') && (susp_signature
[1] == 'D')) {
62 else if ((susp_signature
[0] == 'S') && (susp_signature
[1] == 'P')) {
66 else if ((susp_signature
[0] == 'S') && (susp_signature
[1] == 'T')) {
67 /* Terminator entry, stop processing. */
70 else if ((susp_signature
[0] == 'E') && (susp_signature
[1] == 'R')) {
74 else if ((susp_signature
[0] == 'E') && (susp_signature
[1] == 'S')) {
79 /* Not a SUSP fundamental entry. */
83 void parse_susp_buffer(struct rrii_dir_record
*dir
, char *buffer
, u32_t size
)
86 * Parse a SUSP system use entry for the ISO 9660.
87 * This is the main entry point for parsing SUSP data : SUSP entries are
88 * routed from here to the relevant handling functions.
90 char susp_signature
[2];
96 /* A SUSP entry can't be smaller than 4 bytes. */
100 susp_signature
[0] = buffer
[0];
101 susp_signature
[1] = buffer
[1];
102 susp_length
= *((u8_t
*)buffer
+ 2);
104 /* Check if SUSP entry is present. */
105 if (((susp_signature
[0] == 0) && (susp_signature
[1] == 0)) ||
106 (susp_length
> size
) || (susp_length
< 4))
109 /* Check for SUSP fundamental entry. */
110 parser_return
= parse_susp(dir
, buffer
);
111 if (parser_return
== ECANCELED
)
113 else if (parser_return
== OK
)
116 /* Check for Rock Ridge entry. */
117 if (opt
.norock
== FALSE
) {
118 parser_return
= parse_susp_rock_ridge(dir
, buffer
);
119 if (parser_return
== ECANCELED
)
121 else if (parser_return
== OK
)
125 /* Parse next SUSP entry. */
127 buffer
+= susp_length
;