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