master
1/* $NetBSD: ecma167-udf.h,v 1.17 2022/03/18 16:06:18 reinoud Exp $ */
2
3/*-
4 * Copyright (c) 2003, 2004, 2005, 2006, 2008, 2009, 2017, 2018
5 * Reinoud Zandijk <reinoud@NetBSD.org>
6 * Copyright (c) 2001, 2002 Scott Long <scottl@freebsd.org>
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 *
31 * Extended and adapted for UDFv2.50+ bij Reinoud Zandijk based on the
32 * original by Scott Long.
33 *
34 * 20030508 Made some small typo and explanatory comments
35 * 20030510 Added UDF 2.01 structures
36 * 20030519 Added/correct comments on multi-partitioned logical volume space
37 * 20050616 Added pseudo overwrite
38 * 20050624 Added the missing extended attribute types and `magic values'.
39 * 20051106 Reworked some implementation use parts
40 *
41 */
42
43
44#ifndef _FS_UDF_ECMA167_UDF_H_
45#define _FS_UDF_ECMA167_UDF_H_
46
47
48/*
49 * in case of an older gcc versions, define the __packed as explicit
50 * attribute
51 */
52
53/*
54 * You may specify the `aligned' and `transparent_union' attributes either in
55 * a `typedef' declaration or just past the closing curly brace of a complete
56 * enum, struct or union type _definition_ and the `packed' attribute only
57 * past the closing brace of a definition. You may also specify attributes
58 * between the enum, struct or union tag and the name of the type rather than
59 * after the closing brace.
60*/
61
62#ifndef __packed
63#define __packed __attribute__((packed))
64#endif
65
66
67/* ecma167-udf.h */
68
69/* Volume recognition sequence ECMA 167 rev. 3 16.1 */
70struct vrs_desc {
71 uint8_t struct_type;
72 uint8_t identifier[5];
73 uint8_t version;
74 uint8_t data[2041];
75} __packed;
76
77
78#define VRS_NSR02 "NSR02"
79#define VRS_NSR03 "NSR03"
80#define VRS_BEA01 "BEA01"
81#define VRS_TEA01 "TEA01"
82#define VRS_CD001 "CD001"
83#define VRS_CDW02 "CDW02"
84
85
86/* Structure/definitions/constants a la ECMA 167 rev. 3 */
87
88
89#define MAX_TAGID_VOLUMES 9
90/* Tag identifiers */
91enum {
92 TAGID_SPARING_TABLE = 0,
93 TAGID_PRI_VOL = 1,
94 TAGID_ANCHOR = 2,
95 TAGID_VOL = 3,
96 TAGID_IMP_VOL = 4,
97 TAGID_PARTITION = 5,
98 TAGID_LOGVOL = 6,
99 TAGID_UNALLOC_SPACE = 7,
100 TAGID_TERM = 8,
101 TAGID_LOGVOL_INTEGRITY= 9,
102 TAGID_FSD = 256,
103 TAGID_FID = 257,
104 TAGID_ALLOCEXTENT = 258,
105 TAGID_INDIRECTENTRY = 259,
106 TAGID_ICB_TERM = 260,
107 TAGID_FENTRY = 261,
108 TAGID_EXTATTR_HDR = 262,
109 TAGID_UNALL_SP_ENTRY = 263,
110 TAGID_SPACE_BITMAP = 264,
111 TAGID_PART_INTEGRITY = 265,
112 TAGID_EXTFENTRY = 266,
113 TAGID_MAX = 266
114};
115
116
117enum {
118 UDF_DOMAIN_FLAG_HARD_WRITE_PROTECT = 1,
119 UDF_DOMAIN_FLAG_SOFT_WRITE_PROTECT = 2
120};
121
122
123enum {
124 UDF_ACCESSTYPE_NOT_SPECIFIED = 0, /* unknown */
125 UDF_ACCESSTYPE_PSEUDO_OVERWITE = 0, /* pseudo overwritable, e.g. BD-R's LOW */
126 UDF_ACCESSTYPE_READ_ONLY = 1, /* really only readable */
127 UDF_ACCESSTYPE_WRITE_ONCE = 2, /* write once and you're done */
128 UDF_ACCESSTYPE_REWRITEABLE = 3, /* may need extra work to rewrite */
129 UDF_ACCESSTYPE_OVERWRITABLE = 4 /* no limits on rewriting; e.g. harddisc*/
130};
131
132
133/* Descriptor tag [3/7.2] */
134struct desc_tag {
135 uint16_t id;
136 uint16_t descriptor_ver;
137 uint8_t cksum;
138 uint8_t reserved;
139 uint16_t serial_num;
140 uint16_t desc_crc;
141 uint16_t desc_crc_len;
142 uint32_t tag_loc;
143} __packed;
144#define UDF_DESC_TAG_LENGTH 16
145
146
147/* Recorded Address [4/7.1] */
148struct lb_addr { /* within partition space */
149 uint32_t lb_num;
150 uint16_t part_num;
151} __packed;
152
153
154/* Extent Descriptor [3/7.1] */
155struct extent_ad {
156 uint32_t len;
157 uint32_t loc;
158} __packed;
159
160
161/* Short Allocation Descriptor [4/14.14.1] */
162struct short_ad {
163 uint32_t len;
164 uint32_t lb_num;
165} __packed;
166
167
168/* Long Allocation Descriptor [4/14.14.2] */
169struct UDF_ADImp_use {
170 uint16_t flags;
171 uint32_t unique_id;
172} __packed;
173#define UDF_ADIMP_FLAGS_EXTENT_ERASED 1
174
175
176struct long_ad {
177 uint32_t len;
178 struct lb_addr loc; /* within a logical volume mapped partition space !! */
179 union {
180 uint8_t bytes[6];
181 struct UDF_ADImp_use im_used;
182 } impl;
183} __packed;
184#define longad_uniqueid impl.im_used.unique_id
185
186
187/* Extended Allocation Descriptor [4/14.14.3] ; identifies an extent of allocation descriptors ; also in UDF ? */
188struct ext_ad {
189 uint32_t ex_len;
190 uint32_t rec_len;
191 uint32_t inf_len;
192 struct lb_addr ex_loc;
193 uint8_t reserved[2];
194} __packed;
195
196
197/* ICB : Information Control Block; positioning */
198union icb {
199 struct short_ad s_ad;
200 struct long_ad l_ad;
201 struct ext_ad e_ad;
202};
203
204
205/* short/long/ext extent have flags encoded in length */
206#define UDF_EXT_ALLOCATED (0U<<30)
207#define UDF_EXT_FREED (1U<<30)
208#define UDF_EXT_ALLOCATED_BUT_NOT_USED (1U<<30)
209#define UDF_EXT_FREE (2U<<30)
210#define UDF_EXT_REDIRECT (3U<<30)
211#define UDF_EXT_FLAGS(len) ((len) & (3U<<30))
212#define UDF_EXT_LEN(len) ((len) & ((1U<<30)-1))
213#define UDF_EXT_MAXLEN ((1U<<30)-1)
214
215
216/* Character set spec [1/7.2.1] */
217struct charspec {
218 uint8_t type;
219 uint8_t inf[63];
220} __packed;
221
222
223struct pathcomp {
224 uint8_t type;
225 uint8_t l_ci;
226 uint16_t comp_filever;
227 uint8_t ident[256];
228} __packed;
229#define UDF_PATH_COMP_SIZE 4
230#define UDF_PATH_COMP_RESERVED 0
231#define UDF_PATH_COMP_ROOT 1
232#define UDF_PATH_COMP_MOUNTROOT 2
233#define UDF_PATH_COMP_PARENTDIR 3
234#define UDF_PATH_COMP_CURDIR 4
235#define UDF_PATH_COMP_NAME 5
236
237
238/* Timestamp [1/7.3] */
239struct timestamp {
240 uint16_t type_tz;
241 uint16_t year;
242 uint8_t month;
243 uint8_t day;
244 uint8_t hour;
245 uint8_t minute;
246 uint8_t second;
247 uint8_t centisec;
248 uint8_t hund_usec;
249 uint8_t usec;
250} __packed;
251#define UDF_TIMESTAMP_SIZE 12
252
253
254/* Entity Identifier [1/7.4] */
255#define UDF_REGID_ID_SIZE 23
256struct regid {
257 uint8_t flags;
258 uint8_t id[UDF_REGID_ID_SIZE];
259 uint8_t id_suffix[8];
260} __packed;
261
262
263/* ICB Tag [4/14.6] */
264struct icb_tag {
265 uint32_t prev_num_dirs;
266 uint16_t strat_type;
267 union {
268 uint8_t strat_param[2];
269 uint16_t strat_param16;
270 };
271 uint16_t max_num_entries;
272 uint8_t reserved;
273 uint8_t file_type;
274 struct lb_addr parent_icb;
275 uint16_t flags;
276} __packed;
277#define UDF_ICB_TAG_FLAGS_ALLOC_MASK 0x03
278#define UDF_ICB_SHORT_ALLOC 0x00
279#define UDF_ICB_LONG_ALLOC 0x01
280#define UDF_ICB_EXT_ALLOC 0x02
281#define UDF_ICB_INTERN_ALLOC 0x03
282
283#define UDF_ICB_TAG_FLAGS_DIRORDERED (1<< 3)
284#define UDF_ICB_TAG_FLAGS_NONRELOC (1<< 4)
285#define UDF_ICB_TAG_FLAGS_CONTIGUES (1<< 9)
286#define UDF_ICB_TAG_FLAGS_MULTIPLEVERS (1<<12)
287
288#define UDF_ICB_TAG_FLAGS_SETUID (1<< 6)
289#define UDF_ICB_TAG_FLAGS_SETGID (1<< 7)
290#define UDF_ICB_TAG_FLAGS_STICKY (1<< 8)
291
292#define UDF_ICB_FILETYPE_UNKNOWN 0
293#define UDF_ICB_FILETYPE_UNALLOCSPACE 1
294#define UDF_ICB_FILETYPE_PARTINTEGRITY 2
295#define UDF_ICB_FILETYPE_INDIRECTENTRY 3
296#define UDF_ICB_FILETYPE_DIRECTORY 4
297#define UDF_ICB_FILETYPE_RANDOMACCESS 5
298#define UDF_ICB_FILETYPE_BLOCKDEVICE 6
299#define UDF_ICB_FILETYPE_CHARDEVICE 7
300#define UDF_ICB_FILETYPE_EXTATTRREC 8
301#define UDF_ICB_FILETYPE_FIFO 9
302#define UDF_ICB_FILETYPE_SOCKET 10
303#define UDF_ICB_FILETYPE_TERM 11
304#define UDF_ICB_FILETYPE_SYMLINK 12
305#define UDF_ICB_FILETYPE_STREAMDIR 13
306#define UDF_ICB_FILETYPE_VAT 248
307#define UDF_ICB_FILETYPE_REALTIME 249
308#define UDF_ICB_FILETYPE_META_MAIN 250
309#define UDF_ICB_FILETYPE_META_MIRROR 251
310#define UDF_ICB_FILETYPE_META_BITMAP 252
311
312
313/* Anchor Volume Descriptor Pointer [3/10.2] */
314struct anchor_vdp {
315 struct desc_tag tag;
316 struct extent_ad main_vds_ex; /* to main volume descriptor set ; 16 sectors min */
317 struct extent_ad reserve_vds_ex; /* copy of main volume descriptor set ; 16 sectors min */
318} __packed;
319
320
321/* Volume Descriptor Pointer [3/10.3] */
322struct vol_desc_ptr {
323 struct desc_tag tag; /* use for extending the volume descriptor space */
324 uint32_t vds_number;
325 struct extent_ad next_vds_ex; /* points to the next block for volume descriptor space */
326} __packed;
327
328
329/* Primary Volume Descriptor [3/10.1] */
330struct pri_vol_desc {
331 struct desc_tag tag;
332 uint32_t seq_num; /* MAX prevail */
333 uint32_t pvd_num; /* assigned by author; 0 is special as in it may only occur once */
334 char vol_id[32]; /* KEY ; main identifier of this disc */
335 uint16_t vds_num; /* volume descriptor number; i.e. what volume number is it */
336 uint16_t max_vol_seq; /* maximum volume descriptor number known */
337 uint16_t ichg_lvl;
338 uint16_t max_ichg_lvl;
339 uint32_t charset_list;
340 uint32_t max_charset_list;
341 char volset_id[128]; /* KEY ; if part of a multi-disc set or a band of volumes */
342 struct charspec desc_charset; /* KEY according to ECMA 167 */
343 struct charspec explanatory_charset;
344 struct extent_ad vol_abstract;
345 struct extent_ad vol_copyright;
346 struct regid app_id;
347 struct timestamp time;
348 struct regid imp_id;
349 uint8_t imp_use[64];
350 uint32_t prev_vds_loc; /* location of predecessor _lov ? */
351 uint16_t flags; /* bit 0 : if set indicates volume set name is meaningful */
352 uint8_t reserved[22];
353} __packed;
354
355
356/* UDF specific implementation use part of the implementation use volume descriptor */
357struct udf_lv_info {
358 struct charspec lvi_charset;
359 char logvol_id[128];
360
361 char lvinfo1[36];
362 char lvinfo2[36];
363 char lvinfo3[36];
364
365 struct regid impl_id;
366 uint8_t impl_use[128];
367} __packed;
368
369
370/* Implementation use Volume Descriptor */
371struct impvol_desc {
372 struct desc_tag tag;
373 uint32_t seq_num;
374 struct regid impl_id;
375 union {
376 struct udf_lv_info lv_info;
377 char impl_use[460];
378 } _impl_use;
379} __packed;
380
381
382/* Logical Volume Descriptor [3/10.6] */
383struct logvol_desc {
384 struct desc_tag tag;
385 uint32_t seq_num; /* MAX prevail */
386 struct charspec desc_charset; /* KEY */
387 char logvol_id[128]; /* KEY */
388 uint32_t lb_size;
389 struct regid domain_id;
390 union {
391 struct long_ad fsd_loc; /* to fileset descriptor SEQUENCE */
392 uint8_t logvol_content_use[16];
393 } _lvd_use;
394 uint32_t mt_l; /* Partition map length */
395 uint32_t n_pm; /* Number of partition maps */
396 struct regid imp_id;
397 uint8_t imp_use[128];
398 struct extent_ad integrity_seq_loc;
399 uint8_t maps[1];
400} __packed;
401#define lv_fsd_loc _lvd_use.fsd_loc
402
403#define UDF_INTEGRITY_OPEN 0
404#define UDF_INTEGRITY_CLOSED 1
405
406
407#define UDF_PMAP_SIZE 64
408
409/* Type 1 Partition Map [3/10.7.2] */
410struct part_map_1 {
411 uint8_t type;
412 uint8_t len;
413 uint16_t vol_seq_num;
414 uint16_t part_num;
415} __packed;
416
417
418/* Type 2 Partition Map [3/10.7.3] */
419struct part_map_2 {
420 uint8_t type;
421 uint8_t len;
422 uint8_t reserved[2];
423 struct regid part_id;
424 uint16_t vol_seq_num;
425 uint16_t part_num;
426 uint8_t reserved2[24];
427} __packed;
428
429
430/* Virtual Partition Map [UDF 2.01/2.2.8] */
431struct part_map_virt {
432 uint8_t type;
433 uint8_t len;
434 uint8_t reserved[2];
435 struct regid id;
436 uint16_t vol_seq_num;
437 uint16_t part_num;
438 uint8_t reserved1[24];
439} __packed;
440
441
442/* Sparable Partition Map [UDF 2.01/2.2.9] */
443struct part_map_spare {
444 uint8_t type;
445 uint8_t len;
446 uint8_t reserved[2];
447 struct regid id;
448 uint16_t vol_seq_num;
449 uint16_t part_num;
450 uint16_t packet_len;
451 uint8_t n_st; /* Number of redundant sparing tables range 1-4 */
452 uint8_t reserved1;
453 uint32_t st_size; /* size of EACH sparing table */
454 uint32_t st_loc[1]; /* locations of sparing tables */
455} __packed;
456
457
458/* Metadata Partition Map [UDF 2.50/2.2.10] */
459struct part_map_meta {
460 uint8_t type;
461 uint8_t len;
462 uint8_t reserved[2];
463 struct regid id;
464 uint16_t vol_seq_num;
465 uint16_t part_num;
466 uint32_t meta_file_lbn; /* logical block number for file entry within part_num */
467 uint32_t meta_mirror_file_lbn;
468 uint32_t meta_bitmap_file_lbn;
469 uint32_t alloc_unit_size; /* allocation unit size in blocks */
470 uint16_t alignment_unit_size; /* alignment necessary in blocks */
471 uint8_t flags;
472 uint8_t reserved1[5];
473} __packed;
474#define METADATA_DUPLICATED 1
475
476
477union udf_pmap {
478 uint8_t data[UDF_PMAP_SIZE];
479 struct part_map_1 pm1;
480 struct part_map_2 pm2;
481 struct part_map_virt pmv;
482 struct part_map_spare pms;
483 struct part_map_meta pmm;
484};
485
486
487/* Sparing Map Entry [UDF 2.01/2.2.11] */
488struct spare_map_entry {
489 uint32_t org; /* partition relative address */
490 uint32_t map; /* absolute disc address (!) can be in partition, but doesn't have to be */
491} __packed;
492
493
494/* Sparing Table [UDF 2.01/2.2.11] */
495struct udf_sparing_table {
496 struct desc_tag tag;
497 struct regid id;
498 uint16_t rt_l; /* Relocation Table len */
499 uint8_t reserved[2];
500 uint32_t seq_num;
501 struct spare_map_entry entries[1];
502} __packed;
503
504
505#define UDF_NO_PREV_VAT 0xffffffff
506/* UDF 1.50 VAT suffix [UDF 2.2.10 (UDF 1.50 spec)] */
507struct udf_oldvat_tail {
508 struct regid id; /* "*UDF Virtual Alloc Tbl" */
509 uint32_t prev_vat;
510} __packed;
511
512
513/* VAT table [UDF 2.0.1/2.2.10] */
514struct udf_vat {
515 uint16_t header_len;
516 uint16_t impl_use_len;
517 char logvol_id[128]; /* newer version of the LVD one */
518 uint32_t prev_vat;
519 uint32_t num_files;
520 uint32_t num_directories;
521 uint16_t min_udf_readver;
522 uint16_t min_udf_writever;
523 uint16_t max_udf_writever;
524 uint16_t reserved;
525 uint8_t data[1]; /* impl.use followed by VAT entries (uint32_t) */
526} __packed;
527
528
529/* Space bitmap descriptor as found in the partition header descriptor */
530struct space_bitmap_desc {
531 struct desc_tag tag; /* TagId 264 */
532 uint32_t num_bits; /* number of bits */
533 uint32_t num_bytes; /* bytes that contain it */
534 uint8_t data[1];
535} __packed;
536
537
538/* Unalloc space entry as found in the partition header descriptor */
539struct space_entry_desc {
540 struct desc_tag tag; /* TagId 263 */
541 struct icb_tag icbtag; /* type 1 */
542 uint32_t l_ad; /* in bytes */
543 uint8_t entry[1];
544} __packed;
545
546
547/* Partition header descriptor; in the contents_use of part_desc */
548struct part_hdr_desc {
549 struct short_ad unalloc_space_table;
550 struct short_ad unalloc_space_bitmap;
551 struct short_ad part_integrity_table; /* has to be ZERO for UDF */
552 struct short_ad freed_space_table;
553 struct short_ad freed_space_bitmap;
554 uint8_t reserved[88];
555} __packed;
556
557
558/* Partition Descriptor [3/10.5] */
559struct part_desc {
560 struct desc_tag tag;
561 uint32_t seq_num; /* MAX prevailing */
562 uint16_t flags; /* bit 0 : if set the space is allocated */
563 uint16_t part_num; /* KEY */
564 struct regid contents;
565 union {
566 struct part_hdr_desc part_hdr;
567 uint8_t contents_use[128];
568 } _impl_use;
569 uint32_t access_type; /* R/W, WORM etc. */
570 uint32_t start_loc; /* start of partition with given length */
571 uint32_t part_len;
572 struct regid imp_id;
573 uint8_t imp_use[128];
574 uint8_t reserved[156];
575} __packed;
576#define pd_part_hdr _impl_use.part_hdr
577#define UDF_PART_FLAG_ALLOCATED 1
578
579
580/* Unallocated Space Descriptor (UDF 2.01/2.2.5) */
581struct unalloc_sp_desc {
582 struct desc_tag tag;
583 uint32_t seq_num; /* MAX prevailing */
584 uint32_t alloc_desc_num;
585 struct extent_ad alloc_desc[1];
586} __packed;
587
588
589/* Logical Volume Integrity Descriptor [3/30.10] */
590struct logvolhdr {
591 uint64_t next_unique_id;
592 /* rest reserved */
593} __packed;
594
595
596struct udf_logvol_info {
597 struct regid impl_id;
598 uint32_t num_files;
599 uint32_t num_directories;
600 uint16_t min_udf_readver;
601 uint16_t min_udf_writever;
602 uint16_t max_udf_writever;
603} __packed;
604
605
606struct logvol_int_desc {
607 struct desc_tag tag;
608 struct timestamp time;
609 uint32_t integrity_type;
610 struct extent_ad next_extent;
611 union {
612 struct logvolhdr logvolhdr;
613 int8_t reserved[32];
614 } _impl_use;
615 uint32_t num_part;
616 uint32_t l_iu;
617 uint32_t tables[1]; /* Freespace table, Sizetable, Implementation use */
618} __packed;
619#define lvint_next_unique_id _impl_use.logvolhdr.next_unique_id
620
621
622/* File Set Descriptor [4/14.1] */
623struct fileset_desc {
624 struct desc_tag tag;
625 struct timestamp time;
626 uint16_t ichg_lvl;
627 uint16_t max_ichg_lvl;
628 uint32_t charset_list;
629 uint32_t max_charset_list;
630 uint32_t fileset_num; /* key! */
631 uint32_t fileset_desc_num;
632 struct charspec logvol_id_charset;
633 char logvol_id[128]; /* for recovery */
634 struct charspec fileset_charset;
635 char fileset_id[32]; /* Mountpoint !! */
636 char copyright_file_id[32];
637 char abstract_file_id[32];
638 struct long_ad rootdir_icb; /* to rootdir; icb->virtual ? */
639 struct regid domain_id;
640 struct long_ad next_ex; /* to the next fileset_desc extent */
641 struct long_ad streamdir_icb; /* streamdir; needed? */
642 uint8_t reserved[32];
643} __packed;
644
645
646/* File Identifier Descriptor [4/14.4] */
647struct fileid_desc {
648 struct desc_tag tag;
649 uint16_t file_version_num;
650 uint8_t file_char;
651 uint8_t l_fi; /* Length of file identifier area */
652 struct long_ad icb;
653 uint16_t l_iu; /* Length of implementation use area */
654 uint8_t data[1];
655} __packed;
656#define UDF_FID_SIZE 38
657#define UDF_FILE_CHAR_VIS (1 << 0) /* Invisible */
658#define UDF_FILE_CHAR_DIR (1 << 1) /* Directory */
659#define UDF_FILE_CHAR_DEL (1 << 2) /* Deleted */
660#define UDF_FILE_CHAR_PAR (1 << 3) /* Parent Directory */
661#define UDF_FILE_CHAR_META (1 << 4) /* Stream metadata */
662
663
664/* Extended attributes [4/14.10.1] */
665struct extattrhdr_desc {
666 struct desc_tag tag;
667 uint32_t impl_attr_loc; /* offsets within this descriptor */
668 uint32_t appl_attr_loc; /* ditto */
669} __packed;
670#define UDF_IMPL_ATTR_LOC_NOT_PRESENT 0xffffffff
671#define UDF_APPL_ATTR_LOC_NOT_PRESENT 0xffffffff
672
673
674/* Extended attribute entry [4/48.10.2] */
675struct extattr_entry {
676 uint32_t type;
677 uint8_t subtype;
678 uint8_t reserved[3];
679 uint32_t a_l;
680} __packed;
681
682
683/* Extended attribute entry; type 2048 [4/48.10.8] */
684struct impl_extattr_entry {
685 struct extattr_entry hdr;
686 uint32_t iu_l;
687 struct regid imp_id;
688 union {
689 uint8_t data[1];
690 uint16_t data16;
691 };
692} __packed;
693
694
695/* Extended attribute entry; type 65 536 [4/48.10.9] */
696struct appl_extattr_entry {
697 struct extattr_entry hdr;
698 uint32_t au_l;
699 struct regid appl_id;
700 uint8_t data[1];
701} __packed;
702
703
704/* File Times attribute entry; type 5 or type 6 [4/48.10.5], [4/48.10.6] */
705struct filetimes_extattr_entry {
706 struct extattr_entry hdr;
707 uint32_t d_l; /* length of times[] data following */
708 uint32_t existence; /* bitmask */
709 struct timestamp times[1]; /* in order of ascending bits */
710} __packed;
711#define UDF_FILETIMES_ATTR_NO 5
712#define UDF_FILETIMES_FILE_CREATION 1
713#define UDF_FILETIMES_FILE_DELETION 4
714#define UDF_FILETIMES_FILE_EFFECTIVE 8
715#define UDF_FILETIMES_FILE_BACKUPED 16
716#define UDF_FILETIMES_ATTR_SIZE(no) (20 + (no)*sizeof(struct timestamp))
717
718
719/* Device Specification Extended Attribute [4/4.10.7] */
720struct device_extattr_entry {
721 struct extattr_entry hdr;
722 uint32_t iu_l; /* length of implementation use */
723 uint32_t major;
724 uint32_t minor;
725 uint8_t data[1]; /* UDF: if nonzero length, contain developer ID regid */
726} __packed;
727#define UDF_DEVICESPEC_ATTR_NO 12
728
729
730/* VAT LV extension Extended Attribute [UDF 3.3.4.5.1.3] 1.50 errata */
731struct vatlvext_extattr_entry {
732 uint64_t unique_id_chk; /* needs to be copy of ICB's */
733 uint32_t num_files;
734 uint32_t num_directories;
735 char logvol_id[128]; /* replaces logvol name */
736} __packed;
737
738
739/* File Entry [4/14.9] */
740struct file_entry {
741 struct desc_tag tag;
742 struct icb_tag icbtag;
743 uint32_t uid;
744 uint32_t gid;
745 uint32_t perm;
746 uint16_t link_cnt;
747 uint8_t rec_format;
748 uint8_t rec_disp_attr;
749 uint32_t rec_len;
750 uint64_t inf_len;
751 uint64_t logblks_rec;
752 struct timestamp atime;
753 struct timestamp mtime;
754 struct timestamp attrtime;
755 uint32_t ckpoint;
756 struct long_ad ex_attr_icb;
757 struct regid imp_id;
758 uint64_t unique_id;
759 uint32_t l_ea; /* Length of extended attribute area */
760 uint32_t l_ad; /* Length of allocation descriptors */
761 uint8_t data[1];
762} __packed;
763#define UDF_FENTRY_SIZE 176
764#define UDF_FENTRY_PERM_USER_MASK 0x07
765#define UDF_FENTRY_PERM_GRP_MASK 0xE0
766#define UDF_FENTRY_PERM_OWNER_MASK 0x1C00
767
768
769/* Extended File Entry [4/48.17] */
770struct extfile_entry {
771 struct desc_tag tag;
772 struct icb_tag icbtag;
773 uint32_t uid;
774 uint32_t gid;
775 uint32_t perm;
776 uint16_t link_cnt;
777 uint8_t rec_format;
778 uint8_t rec_disp_attr;
779 uint32_t rec_len;
780 uint64_t inf_len;
781 uint64_t obj_size;
782 uint64_t logblks_rec;
783 struct timestamp atime;
784 struct timestamp mtime;
785 struct timestamp ctime;
786 struct timestamp attrtime;
787 uint32_t ckpoint;
788 uint32_t reserved1;
789 struct long_ad ex_attr_icb;
790 struct long_ad streamdir_icb;
791 struct regid imp_id;
792 uint64_t unique_id;
793 uint32_t l_ea; /* Length of extended attribute area */
794 uint32_t l_ad; /* Length of allocation descriptors */
795 uint8_t data[1];
796} __packed;
797#define UDF_EXTFENTRY_SIZE 216
798
799
800/* Indirect entry [ecma 48.7] */
801struct indirect_entry {
802 struct desc_tag tag;
803 struct icb_tag icbtag;
804 struct long_ad indirect_icb;
805} __packed;
806
807
808/* Allocation extent descriptor [ecma 48.5] */
809struct alloc_ext_entry {
810 struct desc_tag tag;
811 uint32_t prev_entry;
812 uint32_t l_ad;
813 uint8_t data[1];
814} __packed;
815
816
817union dscrptr {
818 struct desc_tag tag;
819 struct anchor_vdp avdp;
820 struct vol_desc_ptr vdp;
821 struct pri_vol_desc pvd;
822 struct logvol_desc lvd;
823 struct unalloc_sp_desc usd;
824 struct logvol_int_desc lvid;
825 struct impvol_desc ivd;
826 struct part_desc pd;
827 struct fileset_desc fsd;
828 struct fileid_desc fid;
829 struct file_entry fe;
830 struct extfile_entry efe;
831 struct extattrhdr_desc eahd;
832 struct indirect_entry inde;
833 struct alloc_ext_entry aee;
834 struct udf_sparing_table spt;
835 struct space_bitmap_desc sbd;
836 struct space_entry_desc sed;
837};
838
839
840#endif /* !_FS_UDF_ECMA167_UDF_H_ */