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