xref: /netbsd-src/sys/fs/udf/ecma167-udf.h (revision fad4c9f71477ae11cea2ee75ec82151ac770a534)
1 /* $NetBSD: ecma167-udf.h,v 1.2 2006/02/02 16:14:26 reinoud Exp $ */
2 
3 /*-
4  * Copyright (c) 2003, 2004, 2005, 2006 Reinoud Zandijk <reinoud@netbsd.org>
5  * Copyright (c) 2001, 2002 Scott Long <scottl@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 
184 
185 /* Extended Allocation Descriptor [4/14.14.3] ; identifies an extent of allocation descriptors ; also in UDF ? */
186 struct ext_ad {
187 	uint32_t	ex_len;
188 	uint32_t	rec_len;
189 	uint32_t	inf_len;
190 	struct lb_addr	ex_loc;
191 	uint8_t		reserved[2];
192 } __packed;
193 
194 
195 /* ICB : Information Control Block; positioning */
196 union icb {
197 	struct short_ad	s_ad;
198 	struct long_ad	l_ad;
199 	struct ext_ad	e_ad;
200 } __packed;
201 
202 
203 /* short/long/ext extent have flags encoded in length */
204 #define UDF_EXT_ALLOCATED              (0<<30)
205 #define UDF_EXT_FREED                  (1<<30)
206 #define UDF_EXT_ALLOCATED_BUT_NOT_USED (1<<30)
207 #define UDF_EXT_FREE                   (2<<30)
208 #define UDF_EXT_REDIRECT               (3<<30)
209 #define UDF_EXT_FLAGS(len) ((len) & (3<<30))
210 #define UDF_EXT_LEN(len)   ((len) & ((1<<30)-1))
211 
212 
213 /* Character set spec [1/7.2.1] */
214 struct charspec {
215 	uint8_t		type;
216 	uint8_t		inf[63];
217 } __packed;
218 
219 
220 /* Timestamp [1/7.3] */
221 struct timestamp {
222 	uint16_t	type_tz;
223 	uint16_t	year;
224 	uint8_t		month;
225 	uint8_t		day;
226 	uint8_t		hour;
227 	uint8_t		minute;
228 	uint8_t		second;
229 	uint8_t		centisec;
230 	uint8_t		hund_usec;
231 	uint8_t		usec;
232 } __packed;
233 
234 
235 /* Entity Identifier [1/7.4] */
236 #define	UDF_REGID_ID_SIZE	23
237 struct regid {
238 	uint8_t		flags;
239 	uint8_t		id[UDF_REGID_ID_SIZE];
240 	uint8_t		id_suffix[8];
241 } __packed;
242 
243 
244 /* ICB Tag [4/14.6] */
245 struct icb_tag {
246 	uint32_t	prev_num_dirs;
247 	uint16_t	strat_type;
248 	uint8_t		strat_param[2];
249 	uint16_t	max_num_entries;
250 	uint8_t		reserved;
251 	uint8_t		file_type;
252 	struct lb_addr	parent_icb;
253 	uint16_t	flags;
254 } __packed;
255 #define UDF_ICB_TAG_FLAGS_ALLOC_MASK	0x03
256 #define UDF_ICB_SHORT_ALLOC		0x00
257 #define UDF_ICB_LONG_ALLOC		0x01
258 #define UDF_ICB_EXT_ALLOC		0x02
259 #define UDF_ICB_INTERN_ALLOC		0x03
260 
261 #define UDF_ICB_TAG_FLAGS_DIRORDERED	(1<< 3)
262 #define UDF_ICB_TAG_FLAGS_NONRELOC	(1<< 4)
263 #define UDF_ICB_TAG_FLAGS_CONTIGUES	(1<< 9)
264 #define UDF_ICB_TAG_FLAGS_MULTIPLEVERS	(1<<12)
265 
266 #define	UDF_ICB_TAG_FLAGS_SETUID	(1<< 6)
267 #define	UDF_ICB_TAG_FLAGS_SETGID	(1<< 7)
268 #define	UDF_ICB_TAG_FLAGS_STICKY	(1<< 8)
269 
270 #define UDF_ICB_FILETYPE_UNKNOWN	  0
271 #define UDF_ICB_FILETYPE_UNALLOCSPACE	  1
272 #define UDF_ICB_FILETYPE_PARTINTEGRITY    2
273 #define UDF_ICB_FILETYPE_INDIRECTENTRY	  3
274 #define UDF_ICB_FILETYPE_DIRECTORY	  4
275 #define UDF_ICB_FILETYPE_RANDOMACCESS	  5
276 #define UDF_ICB_FILETYPE_BLOCKDEVICE	  6
277 #define UDF_ICB_FILETYPE_CHARDEVICE	  7
278 #define UDF_ICB_FILETYPE_EXTATTRREC	  8
279 #define UDF_ICB_FILETYPE_FIFO		  9
280 #define UDF_ICB_FILETYPE_SOCKET		 10
281 #define UDF_ICB_FILETYPE_TERM		 11
282 #define UDF_ICB_FILETYPE_SYMLINK	 12
283 #define UDF_ICB_FILETYPE_STREAMDIR	 13
284 #define UDF_ICB_FILETYPE_VAT		248
285 #define UDF_ICB_FILETYPE_META_MAIN	250
286 #define UDF_ICB_FILETYPE_META_MIRROR	251
287 
288 
289 /* Anchor Volume Descriptor Pointer [3/10.2] */
290 struct anchor_vdp {
291 	struct desc_tag		tag;
292 	struct extent_ad	main_vds_ex;		/* to main volume descriptor set      ; 16 sectors min */
293 	struct extent_ad	reserve_vds_ex;		/* copy of main volume descriptor set ; 16 sectors min */
294 } __packed;
295 
296 
297 /* Volume Descriptor Pointer [3/10.3] */
298 struct vol_desc_ptr {
299 	struct desc_tag		tag;			/* use for extending the volume descriptor space */
300 	uint32_t		vds_number;
301 	struct extent_ad	next_vds_ex;		/* points to the next block for volume descriptor space */
302 } __packed;
303 
304 
305 /* Primary Volume Descriptor [3/10.1] */
306 struct pri_vol_desc {
307 	struct desc_tag		tag;
308 	uint32_t		seq_num;		/* MAX prevail */
309 	uint32_t		pvd_num;		/* assigned by author; 0 is special as in it may only occure once */
310 	char			vol_id[32];		/* KEY ; main identifier of this disc */
311 	uint16_t		vds_num;		/* volume descriptor number; i.e. what volume number is it */
312 	uint16_t		max_vol_seq;		/* maximum volume descriptor number known */
313 	uint16_t		ichg_lvl;
314 	uint16_t		max_ichg_lvl;
315 	uint32_t		charset_list;
316 	uint32_t		max_charset_list;
317 	char			volset_id[128];		/* KEY ; if part of a multi-disc set or a band of volumes */
318 	struct charspec		desc_charset;		/* KEY according to ECMA 167 */
319 	struct charspec		explanatory_charset;
320 	struct extent_ad	vol_abstract;
321 	struct extent_ad	vol_copyright;
322 	struct regid		app_id;
323 	struct timestamp	time;
324 	struct regid		imp_id;
325 	uint8_t			imp_use[64];
326 	uint32_t		prev_vds_loc;		/* location of predecessor _lov ? */
327 	uint16_t		flags;			/* bit 0 : if set indicates volume set name is meaningfull */
328 	uint8_t			reserved[22];
329 } __packed;
330 
331 
332 /* UDF specific implementation use part of the implementation use volume descriptor */
333 struct udf_lv_info {
334 	struct charspec		lvi_charset;
335 	char			logvol_id[128];
336 
337 	char			lvinfo1[36];
338 	char			lvinfo2[36];
339 	char			lvinfo3[36];
340 
341 	struct regid		impl_id;
342 	uint8_t			impl_use[128];
343 } __packed;
344 
345 
346 /* Implementation use Volume Descriptor */
347 struct impvol_desc {
348 	struct desc_tag		tag;
349 	uint32_t		seq_num;
350 	struct regid		impl_id;
351 	union {
352 		struct udf_lv_info	lv_info;
353 		char			impl_use[460];
354 	} __packed _impl_use;
355 } __packed;
356 
357 
358 /* Logical Volume Descriptor [3/10.6] */
359 struct logvol_desc {
360 	struct desc_tag		tag;
361 	uint32_t		seq_num;		/* MAX prevail */
362 	struct charspec		desc_charset;		/* KEY */
363 	char			logvol_id[128];		/* KEY */
364 	uint32_t		lb_size;
365 	struct regid		domain_id;
366 	union {
367 		struct long_ad	fsd_loc;		/* to fileset descriptor SEQUENCE */
368 		uint8_t		logvol_content_use[16];
369 	} __packed _lvd_use;
370 	uint32_t		mt_l;			/* Partition map length */
371 	uint32_t		n_pm;			/* Number of partition maps */
372 	struct regid		imp_id;
373 	uint8_t			imp_use[128];
374 	struct extent_ad	integrity_seq_loc;
375 	uint8_t			maps[1];
376 } __packed;
377 #define lv_fsd_loc _lvd_use.fsd_loc
378 
379 #define UDF_INTEGRITY_OPEN	0
380 #define UDF_INTEGRITY_CLOSED	1
381 
382 
383 #define	UDF_PMAP_SIZE	64
384 
385 /* Type 1 Partition Map [3/10.7.2] */
386 struct part_map_1 {
387 	uint8_t			type;
388 	uint8_t			len;
389 	uint16_t		vol_seq_num;
390 	uint16_t		part_num;
391 } __packed;
392 
393 
394 /* Type 2 Partition Map [3/10.7.3] */
395 struct part_map_2 {
396 	uint8_t			type;
397 	uint8_t			len;
398 	uint8_t			reserved[2];
399 	struct regid		part_id;
400 	uint16_t		vol_seq_num;
401 	uint16_t		part_num;
402 	uint8_t			reserved2[24];
403 } __packed;
404 
405 
406 /* Virtual Partition Map [UDF 2.01/2.2.8] */
407 struct part_map_virt {
408 	uint8_t			type;
409 	uint8_t			len;
410 	uint8_t			reserved[2];
411 	struct regid		id;
412 	uint16_t		vol_seq_num;
413 	uint16_t		part_num;
414 	uint8_t			reserved1[24];
415 } __packed;
416 
417 
418 /* Sparable Partition Map [UDF 2.01/2.2.9] */
419 struct part_map_spare {
420 	uint8_t			type;
421 	uint8_t			len;
422 	uint8_t			reserved[2];
423 	struct regid		id;
424 	uint16_t		vol_seq_num;
425 	uint16_t		part_num;
426 	uint16_t		packet_len;
427 	uint8_t			n_st;		/* Number of redundant sparing tables range 1-4 */
428 	uint8_t			reserved1;
429 	uint32_t		st_size;	/* size of EACH sparing table  */
430 	uint32_t		st_loc[1];	/* locations of sparing tables */
431 } __packed;
432 
433 
434 /* Metadata Partition Map [UDF 2.50/2.2.10] */
435 struct part_map_meta {
436 	uint8_t			type;
437 	uint8_t			len;
438 	uint8_t			reserved[2];
439 	struct regid		id;
440 	uint16_t		vol_seq_num;
441 	uint16_t		part_num;
442 	uint32_t		meta_file_lbn;		/* logical block number for file entry within part_num */
443 	uint32_t		meta_mirror_file_lbn;
444 	uint32_t		meta_bitmap_file_lbn;
445 	uint32_t		alloc_unit_size;	/* allocation unit size in blocks */
446 	uint16_t		alignment_unit_size;	/* alignment nessisary in blocks  */
447 	uint8_t			flags;
448 	uint8_t			reserved1[5];
449 } __packed;
450 #define METADATA_DUPLICATED	1
451 
452 
453 union udf_pmap {
454 	uint8_t			data[UDF_PMAP_SIZE];
455 	struct part_map_1	pm1;
456 	struct part_map_2	pm2;
457 	struct part_map_virt	pmv;
458 	struct part_map_spare	pms;
459 	struct part_map_meta	pmm;
460 } __packed;
461 
462 
463 /* Sparing Map Entry [UDF 2.01/2.2.11] */
464 struct spare_map_entry {
465 	uint32_t		org;			/* partion relative address  */
466 	uint32_t		map;			/* absolute disc address (!) can be in partion, but doesn't have to be */
467 } __packed;
468 
469 
470 /* Sparing Table [UDF 2.01/2.2.11] */
471 struct udf_sparing_table {
472 	struct desc_tag		tag;
473 	struct regid		id;
474 	uint16_t		rt_l;			/* Relocation Table len */
475 	uint8_t			reserved[2];
476 	uint32_t		seq_num;
477 	struct spare_map_entry	entries[1];
478 } __packed;
479 
480 
481 /* VAT table [UDF 2.0.1/2.2.10] */
482 struct udf_vat {
483 	uint16_t		header_len;
484 	uint16_t		impl_use_len;
485 	char			logvol_id[128];		/* newer version of the LVD one */
486 	uint32_t		prev_vat;
487 	uint32_t		num_files;
488 	uint32_t		num_directories;
489 	uint16_t		min_udf_readver;
490 	uint16_t		min_udf_writever;
491 	uint16_t		max_udf_writever;
492 	uint16_t		reserved;
493 	uint8_t			data[1];		/* impl.use followed by VAT entries (uint32_t) */
494 } __packed;
495 
496 
497 /* Space bitmap descriptor as found in the partition header descriptor */
498 struct space_bitmap_desc {
499 	struct desc_tag		tag;			/* TagId 264			*/
500 	uint32_t		num_bits;		/* number of bits		*/
501 	uint32_t		num_bytes;		/* bytes that contain it	*/
502 	uint8_t			data[1];
503 } __packed;
504 
505 
506 /* Unalloc space entry as found in the partition header descriptor */
507 struct space_entry_desc {
508 	struct desc_tag		tag;			/* TagId 263			*/
509 	struct icb_tag		icbtag;			/* type 1			*/
510 	uint32_t		l_ad;			/* in bytes			*/
511 	uint8_t			entry[1];
512 } __packed;
513 
514 
515 /* Partition header descriptor; in the contents_use of part_desc */
516 struct part_hdr_desc {
517 	struct short_ad		unalloc_space_table;
518 	struct short_ad		unalloc_space_bitmap;
519 	struct short_ad		part_integrety_table;	/* has to be ZERO for UDF */
520 	struct short_ad		freed_space_table;
521 	struct short_ad		freed_space_bitmap;
522 	uint8_t			reserved[88];
523 } __packed;
524 
525 
526 /* Partition Descriptor [3/10.5] */
527 struct part_desc {
528 	struct desc_tag		tag;
529 	uint32_t		seq_num;		/* MAX prevailing */
530 	uint16_t		flags;			/* bit 0 : if set the space is allocated */
531 	uint16_t		part_num;		/* KEY */
532 	struct regid		contents;
533 	union {
534 		struct part_hdr_desc	part_hdr;
535 		uint8_t			contents_use[128];
536 	} _impl_use;
537 	uint32_t		access_type;		/* R/W, WORM etc. */
538 	uint32_t		start_loc;		/* start of partion with given length */
539 	uint32_t		part_len;
540 	struct regid		imp_id;
541 	uint8_t			imp_use[128];
542 	uint8_t			reserved[156];
543 } __packed;
544 #define pd_part_hdr _impl_use.part_hdr
545 #define UDF_PART_FLAG_ALLOCATED		1
546 
547 
548 /* Unallocated Space Descriptor (UDF 2.01/2.2.5) */
549 struct unalloc_sp_desc {
550 	struct desc_tag		tag;
551 	uint32_t		seq_num;	/* MAX prevailing */
552 	uint32_t		alloc_desc_num;
553 	struct extent_ad	alloc_desc[1];
554 } __packed;
555 
556 
557 /* Logical Volume Integrity Descriptor [3/30.10] */
558 struct logvolhdr {
559 	uint64_t		next_unique_id;
560 	/* rest reserved */
561 } __packed;
562 
563 
564 struct udf_logvol_info {
565 	struct regid		impl_id;
566 	uint32_t		num_files;
567 	uint32_t		num_directories;
568 	uint16_t		min_udf_readver;
569 	uint16_t		min_udf_writever;
570 	uint16_t		max_udf_writever;
571 } __packed;
572 
573 
574 struct logvol_int_desc {
575 	struct desc_tag		tag;
576 	struct timestamp	time;
577 	uint32_t		integrity_type;
578 	struct extent_ad	next_extent;
579 	union {
580 		struct logvolhdr  logvolhdr;
581 		int8_t		  reserved[32];
582 	} __packed _impl_use;
583 	uint32_t		num_part;
584 	uint32_t		l_iu;
585 	uint32_t		tables[1];	/* Freespace table, Sizetable, Implementation use */
586 } __packed;
587 #define lvint_next_unique_id _impl_use.logvolhdr.next_unique_id
588 
589 
590 /* File Set Descriptor [4/14.1] */
591 struct fileset_desc {
592 	struct desc_tag		tag;
593 	struct timestamp	time;
594 	uint16_t		ichg_lvl;
595 	uint16_t		max_ichg_lvl;
596 	uint32_t		charset_list;
597 	uint32_t		max_charset_list;
598 	uint32_t		fileset_num;			/* key! */
599 	uint32_t		fileset_desc_num;
600 	struct charspec		logvol_id_charset;
601 	char			logvol_id[128];			/* for recovery			*/
602 	struct charspec		fileset_charset;
603 	char			fileset_id[32];			/* Mountpoint !!		*/
604 	char			copyright_file_id[32];
605 	char			abstract_file_id[32];
606 	struct long_ad		rootdir_icb;			/* to rootdir; icb->virtual ?	*/
607 	struct regid		domain_id;
608 	struct long_ad		next_ex;			/* to the next fileset_desc extent */
609 	struct long_ad		streamdir_icb;			/* streamdir; needed?		*/
610 	uint8_t			reserved[32];
611 } __packed;
612 
613 
614 /* File Identifier Descriptor [4/14.4] */
615 struct fileid_desc {
616 	struct desc_tag		tag;
617 	uint16_t		file_version_num;
618 	uint8_t			file_char;
619 	uint8_t			l_fi;	/* Length of file identifier area */
620 	struct long_ad		icb;
621 	uint16_t		l_iu;	/* Length of implementation use area */
622 	uint8_t			data[1];
623 } __packed;
624 #define	UDF_FID_SIZE	38
625 #define	UDF_FILE_CHAR_VIS	(1 << 0) /* Invisible */
626 #define	UDF_FILE_CHAR_DIR	(1 << 1) /* Directory */
627 #define	UDF_FILE_CHAR_DEL	(1 << 2) /* Deleted */
628 #define	UDF_FILE_CHAR_PAR	(1 << 3) /* Parent Directory */
629 #define	UDF_FILE_CHAR_META	(1 << 4) /* Stream metadata */
630 
631 
632 /* Extended attributes [4/14.10.1] */
633 struct extattrhdr_desc {
634 	struct desc_tag		tag;
635 	uint32_t		impl_attr_loc;	/* offsets within this descriptor */
636 	uint32_t		appl_attr_loc;	/* ditto */
637 } __packed;
638 #define UDF_IMPL_ATTR_LOC_NOT_PRESENT 0xffffffff
639 #define UDF_APPL_ATTR_LOC_NOT_PRESENT 0xffffffff
640 
641 
642 /* Extended attribute entry [4/48.10.2] */
643 struct extattr_entry {
644 	uint32_t		type;
645 	uint8_t			subtype;
646 	uint8_t			reserved[3];
647 	uint32_t		a_l;
648 } __packed;
649 
650 
651 /* Extended attribute entry; type 2048 [4/48.10.8] */
652 struct impl_extattr_entry {
653 	struct extattr_entry    hdr;
654 	uint32_t		iu_l;
655 	struct regid		imp_id;
656 	uint16_t		cksum;		/* UDF: of header */
657 	uint8_t			data[1];
658 } __packed;
659 
660 
661 /* Extended attribute entry; type 65 536 [4/48.10.9] */
662 struct appl_extattr_entry {
663 	struct extattr_entry    hdr;
664 	uint32_t		au_l;
665 	struct regid		appl_id;
666 	uint8_t			data[1];
667 } __packed;
668 
669 
670 /* File Times attribute entry; type 5 or type 6 [4/48.10.5], [4/48.10.6] */
671 struct filetimes_extattr_entry {
672 	struct extattr_entry    hdr;
673 	uint32_t		d_l;		/* length of times[] data following */
674 	uint32_t		existence;	/* bitmask */
675 	struct timestamp	times[1];	/* in order of assending bits */
676 } __packed;
677 
678 
679 /* Device Specification Extended Attribute [4/4.10.7] */
680 struct device_extattr_entry {
681 	struct extattr_entry	hdr;
682 	uint32_t		iu_l;		/* length of implementation use */
683 	uint32_t		major;
684 	uint32_t		minor;
685 	uint8_t			data[1];	/* UDF: if nonzero length, contain developer ID regid */
686 } __packed;
687 
688 
689 /* File Entry [4/14.9] */
690 struct file_entry {
691 	struct desc_tag		tag;
692 	struct icb_tag		icbtag;
693 	uint32_t		uid;
694 	uint32_t		gid;
695 	uint32_t		perm;
696 	uint16_t		link_cnt;
697 	uint8_t			rec_format;
698 	uint8_t			rec_disp_attr;
699 	uint32_t		rec_len;
700 	uint64_t		inf_len;
701 	uint64_t		logblks_rec;
702 	struct timestamp	atime;
703 	struct timestamp	mtime;
704 	struct timestamp	attrtime;
705 	uint32_t		ckpoint;
706 	struct long_ad		ex_attr_icb;
707 	struct regid		imp_id;
708 	uint64_t		unique_id;
709 	uint32_t		l_ea;	/* Length of extended attribute area */
710 	uint32_t		l_ad;	/* Length of allocation descriptors */
711 	uint8_t			data[1];
712 } __packed;
713 #define	UDF_FENTRY_SIZE	176
714 #define	UDF_FENTRY_PERM_USER_MASK	0x07
715 #define	UDF_FENTRY_PERM_GRP_MASK	0xE0
716 #define	UDF_FENTRY_PERM_OWNER_MASK	0x1C00
717 
718 
719 /* Extended File Entry [4/48.17] */
720 struct extfile_entry {
721 	struct desc_tag		tag;
722 	struct icb_tag		icbtag;
723 	uint32_t		uid;
724 	uint32_t		gid;
725 	uint32_t		perm;
726 	uint16_t		link_cnt;
727 	uint8_t			rec_format;
728 	uint8_t			rec_disp_attr;
729 	uint32_t		rec_len;
730 	uint64_t		inf_len;
731 	uint64_t		obj_size;
732 	uint64_t		logblks_rec;
733 	struct timestamp	atime;
734 	struct timestamp	mtime;
735 	struct timestamp	ctime;
736 	struct timestamp	attrtime;
737 	uint32_t		ckpoint;
738 	uint32_t		reserved1;
739 	struct long_ad		ex_attr_icb;
740 	struct long_ad		streamdir_icb;
741 	struct regid		imp_id;
742 	uint64_t		unique_id;
743 	uint32_t		l_ea;	/* Length of extended attribute area */
744 	uint32_t		l_ad;	/* Length of allocation descriptors */
745 	uint8_t			data[1];
746 } __packed;
747 
748 
749 /* Indirect entry [ecma 48.7] */
750 struct indirect_entry {
751 	struct desc_tag		tag;
752 	struct icb_tag		icbtag;
753 	struct long_ad		indirect_icb;
754 } __packed;
755 
756 
757 /* Allocation extent descritor [ecma 48.5] */
758 struct alloc_ext_entry {
759 	struct desc_tag		tag;
760 	uint32_t		prev_entry;
761 	uint32_t		l_ad;
762 	uint8_t			data[1];
763 } __packed;
764 
765 
766 union dscrptr {
767 	struct desc_tag		 tag;
768 	struct anchor_vdp	 avdp;
769 	struct vol_desc_ptr	 vdp;
770 	struct pri_vol_desc	 pvd;
771 	struct logvol_desc	 lvd;
772 	struct unalloc_sp_desc	 usd;
773 	struct logvol_int_desc	 lvid;
774 	struct impvol_desc	 ivd;
775 	struct part_desc	 pd;
776 	struct fileset_desc	 fsd;
777 	struct fileid_desc	 fid;
778 	struct file_entry	 fe;
779 	struct extfile_entry	 efe;
780 	struct extattrhdr_desc	 eahd;
781 	struct indirect_entry	 inde;
782 	struct alloc_ext_entry	 aee;
783 	struct udf_sparing_table spt;
784 	struct space_bitmap_desc sbd;
785 	struct space_entry_desc	 sed;
786 } __packed;
787 
788 
789 /* Useful defines */
790 
791 #define	GETICB(ad_type, fentry, offset)	\
792 	(struct ad_type *)&fentry->data[offset]
793 
794 #define	GETICBLEN(ad_type, icb)	((struct ad_type *)(icb))->len
795 
796 
797 #endif /* !_FS_UDF_ECMA167_UDF_H_ */
798 
799