patch genisoimage multi extent
[platform/upstream/cdrkit.git] / genisoimage / udf_fs.h
1 /*
2  * This file has been modified for the cdrkit suite.
3  *
4  * The behaviour and appearence of the program code below can differ to a major
5  * extent from the version distributed by the original author(s).
6  *
7  * For details, see Changelog file distributed with the cdrkit package. If you
8  * received this file from another source then ask the distributing person for
9  * a log of modifications.
10  *
11  */
12
13 /* @(#)udf_fs.h 1.2 04/03/01 Copyright 2001-2004 J. Schilling */
14 /*
15  * udf_fs.h - UDF structure definitions for genisoimage
16  *
17  * Written by Ben Rudiak-Gould (2001).
18  *
19  * Copyright 2001-2004 J. Schilling.
20  */
21 /*
22  * This program is free software; you can redistribute it and/or modify
23  * it under the terms of the GNU General Public License version 2
24  * as published by the Free Software Foundation.
25  *
26  * This program is distributed in the hope that it will be useful,
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29  * GNU General Public License for more details.
30  *
31  * You should have received a copy of the GNU General Public License along with
32  * this program; see the file COPYING.  If not, write to the Free Software
33  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
34  */
35
36 #ifndef _UDF_FS_H
37 #define _UDF_FS_H
38
39 /*
40  * Abbreviations:
41  *
42  * ad           allocation descriptor
43  * desc         descriptor
44  * ext          extended
45  * ident        identifier
46  * impl         implementation
47  * info         information
48  * ptr          pointer
49  * seq          sequence
50  */
51
52 typedef char udf_Uint8;
53 typedef char udf_dchar;
54 typedef char udf_dstring;
55 typedef char udf_byte;
56 typedef char udf_zerobyte;
57
58 /* Is this safe? Are there compilers so perverse as to pad these structs? */
59 typedef struct udf_Uint16_ {
60         char    l;
61         char    h;
62 } udf_Uint16;
63
64 typedef struct udf_Uint32_ {
65         char    l;
66         char    ml;
67         char    mh;
68         char    h;
69 } udf_Uint32;
70 typedef struct udf_Uint64_ {
71         udf_Uint32      l;
72         udf_Uint32      h;
73 } udf_Uint64;
74
75 typedef struct udf_tag_ {                       /* ECMA-167 3/7.2 */
76 /* 0*/  udf_Uint16      tag_ident;
77 /* 2*/  udf_Uint16      desc_version;
78 /* 4*/  udf_Uint8       tag_checksum;
79 /* 5*/  udf_zerobyte    reserved;
80 /* 6*/  udf_Uint16      tag_serial_number;
81 /* 8*/  udf_Uint16      desc_crc;
82 /*10*/  udf_Uint16      desc_crc_length;
83 /*12*/  udf_Uint32      tag_location;
84 /*16*/
85 } udf_tag;
86
87 #define UDF_TAGID_PRIMARY_VOLUME_DESC           1
88 #define UDF_TAGID_ANCHOR_VOLUME_DESC_PTR        2
89 #define UDF_TAGID_IMPL_USE_VOLUME_DESC          4
90 #define UDF_TAGID_PARTITION_DESC                5
91 #define UDF_TAGID_LOGICAL_VOLUME_DESC           6
92 #define UDF_TAGID_UNALLOCATED_SPACE_DESC        7
93 #define UDF_TAGID_TERMINATING_DESC              8
94 #define UDF_TAGID_LOGICAL_VOLUME_INTEGRITY_DESC 9
95 #define UDF_TAGID_FILE_SET_DESC                 256
96 #define UDF_TAGID_FILE_IDENT_DESC               257
97 #define UDF_TAGID_FILE_ENTRY                    261
98 #define UDF_TAGID_EXT_ATTRIBUTE_HEADER_DESC     262
99
100 typedef struct udf_extent_ad_ {                 /* ECMA-167 3/7.1 */
101 /*0*/   udf_Uint32      extent_length;
102 /*4*/   udf_Uint32      extent_location;
103 /*8*/
104 } udf_extent_ad;
105
106 typedef struct udf_charspec_ {                  /* ECMA-167 1/7.2.1 */
107 /* 0*/  udf_Uint8       character_set_type;
108 /* 1*/  udf_byte        character_set_info[63];
109 /*64*/
110 } udf_charspec;
111
112 typedef struct udf_EntityID_ {                  /* ECMA-167 1/7.4 */
113 /* 0*/  udf_Uint8       flags;
114 /* 1*/  udf_byte        ident[23];
115 /*24*/  udf_byte        ident_suffix[8];
116 /*32*/
117 } udf_EntityID;
118
119 #define UDF_ENTITYID_FLAG_PROTECTED     2       /* ECMA-167 1/7.4.1 */
120
121 typedef struct udf_lb_addr_ {                   /* ECMA-167 4/7.1 */
122 /*0*/   udf_Uint32      logical_block_number;
123 /*4*/   udf_Uint16      partition_reference_number;
124 /*6*/
125 } udf_lb_addr;
126
127 typedef struct udf_short_ad_ {                  /* ECMA-167 4/14.14.1 */
128 /*0*/   udf_Uint32      extent_length;
129 /*4*/   udf_Uint32      extent_position;
130 /*8*/
131 } udf_short_ad;
132
133 typedef struct udf_long_ad_impl_use_field_ {    /* UDF 2.01 2.3.4.3 */
134 /*0*/   udf_Uint16      flags;
135 /*2*/   udf_Uint32      unique_id;
136 /*6*/
137 } udf_long_ad_impl_use_field;
138
139 typedef struct udf_long_ad_ {                   /* ECMA-167 4/14.14.2 */
140 /* 0*/  udf_Uint32      extent_length;
141 /* 4*/  udf_lb_addr     extent_location;
142 /*10*/  udf_long_ad_impl_use_field      impl_use;
143 /*16*/
144 } udf_long_ad;
145
146 typedef struct udf_timestamp_ {                 /* TR/71 1.5.4 */
147 /* 0*/  udf_Uint16      type_and_time_zone;
148 /* 2*/  udf_Uint16      year;
149 /* 4*/  udf_Uint8       month;
150 /* 5*/  udf_Uint8       day;
151 /* 6*/  udf_Uint8       hour;
152 /* 7*/  udf_Uint8       minute;
153 /* 8*/  udf_Uint8       second;
154 /* 9*/  udf_Uint8       centiseconds;
155 /*10*/  udf_Uint8       hundreds_of_microseconds;
156 /*11*/  udf_Uint8       microseconds;
157 /*12*/
158 } udf_timestamp;
159
160 typedef struct udf_volume_recognition_desc_ {   /* TR/71 2.4.{1,2,3} */
161         udf_Uint8       structure_type;
162         udf_byte        standard_identifier[5];
163         udf_Uint8       structure_version;
164         udf_zerobyte    structure_data[2041];
165 } udf_volume_recognition_desc;
166
167 typedef struct udf_anchor_volume_desc_ptr_ {    /* TR/71 2.5.1 */
168 /*  0*/ udf_tag         desc_tag;
169 /* 16*/ udf_extent_ad   main_volume_desc_seq_extent;
170 /* 24*/ udf_extent_ad   reserve_volume_desc_seq_extent;
171 /* 32*/ udf_zerobyte    reserved[480];
172 /*512*/
173 } udf_anchor_volume_desc_ptr;
174
175 typedef struct udf_primary_volume_desc_ {       /* TR/71 2.6.1 */
176 /*  0*/ udf_tag         desc_tag;
177 /* 16*/ udf_Uint32      volume_desc_seq_number;
178 /* 20*/ udf_Uint32      primary_volume_desc_number;
179 /* 24*/ udf_dstring     volume_ident[32];
180 /* 56*/ udf_Uint16      volume_seq_number;
181 /* 58*/ udf_Uint16      maximum_volume_seq_number;
182 /* 60*/ udf_Uint16      interchange_level;
183 /* 62*/ udf_Uint16      maximum_interchange_level;
184 /* 64*/ udf_Uint32      character_set_list;
185 /* 68*/ udf_Uint32      maximum_character_set_list;
186 /* 72*/ udf_dstring     volume_set_ident[128];
187 /*200*/ udf_charspec    desc_character_set;
188 /*264*/ udf_charspec    explanatory_character_set;
189 /*328*/ udf_extent_ad   volume_abstract;
190 /*336*/ udf_extent_ad   volume_copyright_notice;
191 /*344*/ udf_EntityID    application_ident;
192 /*376*/ udf_timestamp   recording_date_and_time;
193 /*388*/ udf_EntityID    impl_ident;
194 /*420*/ udf_byte        impl_use[64];
195 /*484*/ udf_Uint32      predecessor_volume_desc_seq_location;
196 /*488*/ udf_Uint16      flags;
197 /*490*/ udf_zerobyte    reserved[22];
198 /*512*/
199 } udf_primary_volume_desc;
200
201 typedef struct udf_impl_use_volume_desc_impl_use_field_ {       /* TR/71 2.6.3 */
202 /*  0*/ udf_charspec    lvi_charset;
203 /* 64*/ udf_dstring     logical_volume_ident[128];
204 /*192*/ udf_dstring     lv_info1[36];
205 /*228*/ udf_dstring     lv_info2[36];
206 /*264*/ udf_dstring     lv_info3[36];
207 /*300*/ udf_EntityID    impl_id;
208 /*332*/ udf_byte        impl_use[128];
209 /*460*/
210 } udf_impl_use_volume_desc_impl_use_field;
211
212 typedef struct udf_impl_use_volume_desc_ {      /* TR/71 2.6.2 */
213 /*  0*/ udf_tag         desc_tag;
214 /* 16*/ udf_Uint32      volume_desc_seq_number;
215 /* 20*/ udf_EntityID    impl_ident;
216 /* 52*/ udf_impl_use_volume_desc_impl_use_field impl_use;
217 /*512*/
218 } udf_impl_use_volume_desc;
219
220 typedef struct udf_partition_desc_ {            /* TR/71 2.6.4 */
221 /*  0*/ udf_tag         desc_tag;
222 /* 16*/ udf_Uint32      volume_desc_seq_number;
223 /* 20*/ udf_Uint16      partition_flags;
224 /* 22*/ udf_Uint16      partition_number;
225 /* 24*/ udf_EntityID    partition_contents;
226 /* 56*/ udf_byte        partition_contents_use[128];
227 /*184*/ udf_Uint32      access_type;
228 /*188*/ udf_Uint32      partition_starting_location;
229 /*192*/ udf_Uint32      partition_length;
230 /*196*/ udf_EntityID    impl_ident;
231 /*228*/ udf_byte        impl_use[128];
232 /*356*/ udf_zerobyte    reserved[156];
233 /*512*/
234 } udf_partition_desc;
235
236 #define UDF_PARTITION_FLAG_ALLOCATED    1       /* ECMA-167 3/10.5.3 */
237 #define UDF_ACCESSTYPE_READONLY         1       /* ECMA-167 3/10.5.7 */
238
239 typedef struct udf_type_1_partition_map_ {      /* TR/71 2.6.8 */
240 /*0*/   udf_Uint8       partition_map_type;
241 /*1*/   udf_Uint8       partition_map_length;
242 /*2*/   udf_Uint16      volume_seq_number;
243 /*4*/   udf_Uint16      partition_number;
244 /*6*/
245 } udf_type_1_partition_map;
246
247 #define UDF_PARTITION_MAP_TYPE_1        1
248
249 typedef struct udf_logical_volume_desc_ {       /* TR/71 2.6.7 */
250 /*  0*/ udf_tag         desc_tag;
251 /* 16*/ udf_Uint32      volume_desc_seq_number;
252 /* 20*/ udf_charspec    desc_character_set;
253 /* 84*/ udf_dstring     logical_volume_ident[128];
254 /*212*/ udf_Uint32      logical_block_size;
255 /*216*/ udf_EntityID    domain_ident;
256 /*248*/ udf_long_ad     logical_volume_contents_use;
257 /*264*/ udf_Uint32      map_table_length;
258 /*268*/ udf_Uint32      number_of_partition_maps;
259 /*272*/ udf_EntityID    impl_ident;
260 /*304*/ udf_byte        impl_use[128];
261 /*432*/ udf_extent_ad   integrity_seq_extent;
262 /*440*/ udf_type_1_partition_map        partition_map[1];
263 /*446*/
264 } udf_logical_volume_desc;
265
266 typedef struct udf_unallocated_space_desc_ {    /* TR/71 2.6.9 */
267 /* 0*/  udf_tag         desc_tag;
268 /*16*/  udf_Uint32      volume_desc_seq_number;
269 /*20*/  udf_Uint32      number_of_allocation_descs;
270 /*24*/  /*udf_extent_ad allocation_descs[0];*/
271 } udf_unallocated_space_desc;
272
273 typedef struct udf_terminating_desc_ {          /* TR/71 2.6.10 */
274 /*  0*/ udf_tag         desc_tag;
275 /* 16*/ udf_zerobyte    reserved[496];
276 /*512*/
277 } udf_terminating_desc;
278
279 typedef struct udf_logical_volume_integrity_desc_impl_use_field_ {      /* TR/71 2.7.3 */
280 /* 0*/  udf_EntityID    impl_id;
281 /*32*/  udf_Uint32      number_of_files;
282 /*36*/  udf_Uint32      number_of_directories;
283 /*40*/  udf_Uint16      minimum_udf_read_revision;
284 /*42*/  udf_Uint16      minimum_udf_write_revision;
285 /*44*/  udf_Uint16      maximum_udf_write_revision;
286 /*46*/  /*udf_byte      impl_use[0];*/
287 } udf_logical_volume_integrity_desc_impl_use_field;
288
289 typedef struct udf_logical_volume_integrity_desc_contents_use_field_ {  /* TR/71 2.7.2 */
290         udf_Uint64      unique_id;
291         udf_zerobyte    reserved[24];
292 } udf_logical_volume_integrity_desc_contents_use_field;
293
294 typedef struct udf_logical_volume_integrity_desc_ {     /* TR/71 2.7.1 */
295 /* 0*/  udf_tag         desc_tag;
296 /*16*/  udf_timestamp   recording_date;
297 /*28*/  udf_Uint32      integrity_type;
298 /*32*/  udf_extent_ad   next_integrity_extent;
299 /*40*/  udf_logical_volume_integrity_desc_contents_use_field    logical_volume_contents_use;
300 /*72*/  udf_Uint32      number_of_partitions;
301 /*76*/  udf_Uint32      length_of_impl_use;
302 /*80*/  udf_Uint32      free_space_table;
303 /*84*/  udf_Uint32      size_table;
304 /*88*/  udf_logical_volume_integrity_desc_impl_use_field        impl_use;
305 } udf_logical_volume_integrity_desc;
306
307 #define UDF_INTEGRITY_TYPE_CLOSE        1       /* ECMA-167 3/10.10.3 */
308
309 typedef struct udf_file_set_desc_ {             /* TR/71 3.3.1 */
310 /* 0*/  udf_tag         desc_tag;
311 /*16*/  udf_timestamp   recording_date_and_time;
312 /*28*/  udf_Uint16      interchange_level;
313 /*30*/  udf_Uint16      maximum_interchange_level;
314 /*32*/  udf_Uint32      character_set_list;
315 /*36*/  udf_Uint32      maximum_character_set_list;
316 /*40*/  udf_Uint32      file_set_number;
317 /*44*/  udf_Uint32      file_set_desc_number;
318 /*48*/  udf_charspec    logical_volume_ident_character_set;
319 /*112*/ udf_dstring     logical_volume_ident[128];
320 /*240*/ udf_charspec    file_set_character_set;
321 /*304*/ udf_dstring     file_set_ident[32];
322 /*336*/ udf_dstring     copyright_file_ident[32];
323 /*368*/ udf_dstring     abstract_file_ident[32];
324 /*400*/ udf_long_ad     root_directory_icb;
325 /*416*/ udf_EntityID    domain_ident;
326 /*448*/ udf_long_ad     next_extent;
327 /*464*/ udf_zerobyte    reserved[48];
328 /*512*/
329 } udf_file_set_desc;
330
331 typedef struct udf_file_ident_desc_ {           /* TR/71 3.4.1 */
332 /* 0*/  udf_tag         desc_tag;
333 /*16*/  udf_Uint16      file_version_number;
334 /*18*/  udf_Uint8       file_characteristics;
335 /*19*/  udf_Uint8       length_of_file_ident;
336 /*20*/  udf_long_ad     icb;
337 /*36*/  udf_Uint16      length_of_impl_use;
338 /*38*/  /*udf_EntityID  impl_use;*/
339 /*38*/  udf_dchar       file_ident[1];
340         /*udf_zerobyte  padding[0/1/2/3];*/
341 } udf_file_ident_desc;
342
343 #define UDF_FILE_CHARACTERISTIC_HIDDEN          1       /* ECMA-167 4/14.4.3 */
344 #define UDF_FILE_CHARACTERISTIC_DIRECTORY       2
345 #define UDF_FILE_CHARACTERISTIC_DELETED         4
346 #define UDF_FILE_CHARACTERISTIC_PARENT          8
347
348 typedef struct udf_icbtag_ {                    /* TR/71 3.5.2 */
349 /* 0*/  udf_Uint32      prior_recorded_number_of_direct_entries;
350 /* 4*/  udf_Uint16      strategy_type;
351 /* 6*/  udf_Uint16      strategy_parameter;
352 /* 8*/  udf_Uint16      maximum_number_of_entries;
353 /*10*/  udf_zerobyte    reserved;
354 /*11*/  udf_Uint8       file_type;
355 /*12*/  udf_lb_addr     parent_icb_location;
356 /*18*/  udf_Uint16      flags;
357 /*20*/
358 } udf_icbtag;
359
360 #define UDF_ICBTAG_FILETYPE_DIRECTORY   4       /* ECMA-167 4/14.6.6 */
361 #define UDF_ICBTAG_FILETYPE_BYTESEQ     5
362
363 #define UDF_ICBTAG_FLAG_MASK_AD_TYPE    7       /* TR/71 3.5.3 */
364 #define UDF_ICBTAG_FLAG_SHORT_AD        0
365 #define UDF_ICBTAG_FLAG_DIRECTORY_SORT  8
366 #define UDF_ICBTAG_FLAG_NONRELOCATABLE  16
367 #define UDF_ICBTAG_FLAG_ARCHIVE         32
368 #define UDF_ICBTAG_FLAG_SETUID          64
369 #define UDF_ICBTAG_FLAG_SETGID          128
370 #define UDF_ICBTAG_FLAG_STICKY          256
371 #define UDF_ICBTAG_FLAG_CONTIGUOUS      512
372 #define UDF_ICBTAG_FLAG_SYSTEM          1024
373 #define UDF_ICBTAG_FLAG_TRANSFORMED     2048
374 #define UDF_ICBTAG_FLAG_MULTI_VERSIONS  4096
375
376 typedef struct udf_ext_attribute_header_desc_ { /* TR/71 3.6.1 */
377 /* 0*/  udf_tag         desc_tag;
378 /*16*/  udf_Uint32      impl_attributes_location;
379 /*20*/  udf_Uint32      application_attributes_location;
380 /*24*/
381 } udf_ext_attribute_header_desc;
382
383 typedef struct udf_ext_attribute_free_ea_space_ {       /* TR/71 3.6.{2,3} */
384 /* 0*/  udf_Uint32      attribute_type;         /* = 2048 */
385 /* 4*/  udf_Uint8       attribute_subtype;      /* = 1 */
386 /* 5*/  udf_zerobyte    reserved[3];
387 /* 8*/  udf_Uint32      attribute_length;       /* = 52 */
388 /*12*/  udf_Uint32      impl_use_length;        /* = 4 */
389 /*16*/  udf_EntityID    impl_ident;             /* "*UDF FreeEASpace" */
390 /*48*/  udf_Uint16      header_checksum;
391 /*50*/  udf_Uint16      free_ea_space;          /* = 0 */
392 /*52*/
393 } udf_ext_attribute_free_ea_space;
394
395 typedef struct udf_ext_attribute_dvd_cgms_info_ {       /* TR/71 3.6.{2,4} */
396 /* 0*/  udf_Uint32      attribute_type;         /* = 2048 */
397 /* 4*/  udf_Uint8       attribute_subtype;      /* = 1 */
398 /* 5*/  udf_zerobyte    reserved[3];
399 /* 8*/  udf_Uint32      attribute_length;       /* = 56 */
400 /*12*/  udf_Uint32      impl_use_length;        /* = 8 */
401 /*16*/  udf_EntityID    impl_ident;             /* "*UDF DVD CGMS Info" */
402 /*48*/  udf_Uint16      header_checksum;
403 /*50*/  udf_byte        cgms_info;
404 /*51*/  udf_Uint8       data_structure_type;
405 /*52*/  udf_byte        protection_system_info[4];
406 /*56*/
407 } udf_ext_attribute_dvd_cgms_info;
408
409 #define UDF_CGMSINFO_NO_COPIES                  48      /* TR/71 3.6.4 */
410 #define UDF_CGMSINFO_ONE_GENERATION             32
411 #define UDF_CGMSINFO_UNLIMITED_COPIES           0
412 #define UDF_CGMSINFO_FLAG_COPYRIGHTED_MATERIAL  128
413
414 typedef struct udf_file_entry_ {                /* TR/71 3.5.1 */
415 /* 0*/  udf_tag         desc_tag;
416 /*16*/  udf_icbtag      icb_tag;
417 /*36*/  udf_Uint32      uid;
418 /*40*/  udf_Uint32      gid;
419 /*44*/  udf_Uint32      permissions;
420 /*48*/  udf_Uint16      file_link_count;
421 /*50*/  udf_Uint8       record_format;
422 /*51*/  udf_Uint8       record_display_attributes;
423 /*52*/  udf_Uint32      record_length;
424 /*56*/  udf_Uint64      info_length;
425 /*64*/  udf_Uint64      logical_blocks_recorded;
426 /*72*/  udf_timestamp   access_time;
427 /*84*/  udf_timestamp   modification_time;
428 /*96*/  udf_timestamp   attribute_time;
429 /*108*/ udf_Uint32      checkpoint;
430 /*112*/ udf_long_ad     ext_attribute_icb;
431 /*128*/ udf_EntityID    impl_ident;
432 /*160*/ udf_Uint64      unique_id;
433 /*168*/ udf_Uint32      length_of_ext_attributes;
434 /*172*/ udf_Uint32      length_of_allocation_descs;
435 #if 0
436 /*176*/ udf_ext_attribute_header_desc   ext_attribute_header;
437 /*200*/ udf_ext_attribute_free_ea_space ext_attribute_free_ea_space;
438 /*252*/ udf_ext_attribute_dvd_cgms_info ext_attribute_dvd_cgms_info;
439 /*308*/ udf_short_ad    allocation_desc;
440 /*316*/
441 #else
442 /*176*/ udf_short_ad    allocation_desc;
443 /*184*/
444 #endif
445 } udf_file_entry;
446
447 /*
448  * (U,G,O) = (owner, group, other)
449  * (X,R) = (execute, read)
450  *
451  * There are Write, Change Attribute and Delete permissions also,
452  * but it is not permitted to set them on DVD Read-Only media.
453  */
454 #define UDF_FILEENTRY_PERMISSION_OX     1       /* TR/71 3.5.4 */
455 #define UDF_FILEENTRY_PERMISSION_OR     4
456 #define UDF_FILEENTRY_PERMISSION_GX     32
457 #define UDF_FILEENTRY_PERMISSION_GR     128
458 #define UDF_FILEENTRY_PERMISSION_UX     1024
459 #define UDF_FILEENTRY_PERMISSION_UR     4096
460
461
462 #endif  /* _UDF_FS_H */