xref: /titanic_52/usr/src/uts/common/sys/fs/udf_volume.h (revision 3db86aab554edbb4244c8d1a1c90f152eee768af)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 #ifndef	_SYS_FS_UDF_VOLUME_H
28 #define	_SYS_FS_UDF_VOLUME_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/isa_defs.h>
33 
34 #ifdef	__cplusplus
35 extern "C" {
36 #endif
37 
38 #define	UDF_102	0x102
39 #define	UDF_150	0x150
40 #define	UDF_200	0x200
41 
42 /* fid_idlen include compression id */
43 #define	FID_LEN(fid)	(((sizeof (struct file_id) +	\
44 		SWAP_16((fid)->fid_iulen) + (fid)->fid_idlen - 2) + 3) & ~3)
45 
46 /*
47  * #define	ID_LEN(fid)	\
48  *		(((SWAP_16((fid)->fid_iulen) + (fid)->fid_idlen - 2) + 3) & ~3)
49  */
50 
51 #define	F_LEN		(sizeof (struct file_id) - 2)
52 
53 #define	UDF_DOMAIN_NAME		"*OSTA UDF Compliant\0\0\0\0"
54 #define	UDF_LV_INFO		"*UDF LV Info\0\0\0\0\0\0\0\0\0\0\0\0"
55 #define	UDF_FREEEASPACE		"*UDF FreeEASpace\0\0\0\0\0\0\0\0"
56 #define	UDF_FREEAEASPACE	"*UDF FreeAppEASpace\0\0\0\0"
57 #define	UDF_CGMS_INFO		"*UDF DVD CGMS Info\0\0\0\0"
58 #define	UDF_OS2_EA		"*UDF OS/2 EA\0\0\0\0\0\0\0\0\0\0\0"
59 #define	UDF_OS2_EA_LEN		"*UDF OS/2 EALength\0\0\0\0\0\0"
60 #define	UDF_MAC_VOLINFO		"*UDF Mac VolumeInfo\0\0\0\0"
61 #define	UDF_MAC_UNIQID		"*UDF Mac UniqueIDTable\0"
62 #define	UDF_MAC_RESFRK		"*UDF Mac ResourceFork\0\0"
63 #define	UDF_VIRT_PART		"*UDF Virtual Partition\0"
64 #define	UDF_SPAR_PART		"*UDF Sparable Partition"
65 #define	UDF_VAT			"*UDF Virtual Alloc Tbl\0"
66 #define	UDF_SPAR_TBL		"*UDF Sparing Table\0\0\0\0\0"
67 
68 
69 #if defined(_BIG_ENDIAN)
70 #define	SWAP_16(a)	(((ushort_t)((a) & 0xff) << 8) | \
71 					((ushort_t)((a) & 0xff00) >> 8))
72 #define	SWAP_32(a)	((((a) & 0xff) << 24) |	\
73 				(((a) & 0xff00) << 8) |	\
74 				(((a) & 0xff0000) >> 8) |	\
75 				(((a) & 0xff000000) >> 24))
76 #define	SWAP_64(a)	((((a) & 0xffULL) << 56)	| \
77 				(((a) & 0xff00ULL) << 40) | \
78 				(((a) & 0xff0000ULL) << 24) | \
79 				(((a) & 0xff000000ULL) << 8) | \
80 				(((a) & 0xff00000000ULL) >> 8) | \
81 				(((a) & 0xff0000000000ULL) >> 24) | \
82 				(((a) & 0xff000000000000ULL) >> 40) | \
83 				(((a) & 0xff00000000000000ULL) >> 56))
84 
85 #define	GET_32(a)	((uint32_t)(*((uint8_t *)a)) | \
86 				(((uint32_t)(*(((uint8_t *)a) + 1))) << 8) | \
87 				(((uint32_t)(*(((uint8_t *)a) + 2))) << 16) | \
88 				(((uint32_t)(*(((uint8_t *)a) + 3))) << 24))
89 #else
90 #define	SWAP_16(a)	(a)
91 #define	SWAP_32(a)	(a)
92 #define	SWAP_64(a)	(a)
93 
94 #define	GET_32(a)	(*((uint32_t *)a))
95 #endif	/* _BIG_ENDIAN */
96 
97 
98 #define	BCD2HEX_16(a)	(((a) & 0xf) + \
99 			(((ushort_t)((a) & 0xf0) >> 4) * 10) + \
100 			(((ushort_t)((a) & 0xf00) >> 8) * 100) + \
101 			(((ushort_t)((a) & 0xf000) >> 12) * 1000))
102 
103 #define	HEX2BCD_16(a)	((((ushort_t)a) % 10) | \
104 			(((ushort_t)((ushort_t)(a) / 10) % 10) << 4) | \
105 			(((ushort_t)((ushort_t)(a) / 100) % 10) << 8) | \
106 			(((ushort_t)((ushort_t)(a) / 1000) % 10) << 12))
107 
108 #define	ANCHOR_VOL_DESC_LOC	(256)
109 #define	ANCHOR_VOL_DESC_LEN	0x200
110 
111 
112 
113 /* Basic data structures */
114 
115 
116 typedef char dstring_t;
117 
118 
119 /*
120  * recorded at the start of the descriptor
121  * used to distinguish between different
122  * descriptors
123  */
124 struct tag {
125 	uint16_t	tag_id;		/* 00 Tag Identifier */
126 	uint16_t	tag_desc_ver;	/* 02 Descriptor Version */
127 	uint8_t		tag_cksum;	/* 04 Tag Checksum */
128 	uint8_t		tag_res;	/* 05 Reserved */
129 	uint16_t	tag_sno;	/* 06 Tag Serial Number */
130 	uint16_t	tag_crc;	/* 08 Descriptor CRC */
131 	uint16_t	tag_crc_len;	/* 0A Descriptor CRC length */
132 	uint32_t	tag_loc;	/* 0C Tag Location */
133 };
134 typedef struct tag tag_t;
135 
136 /*
137  * descriptor tag id values
138  */
139 
140 #define	UD_PRI_VOL_DESC		0x0001
141 #define	UD_ANCH_VOL_DESC	0x0002
142 #define	UD_VOL_DESC_PTR		0x0003
143 #define	UD_IMPL_USE_DESC	0x0004
144 #define	UD_PART_DESC		0x0005
145 #define	UD_LOG_VOL_DESC		0x0006
146 #define	UD_UNALL_SPA_DESC	0x0007
147 #define	UD_TERM_DESC		0x0008
148 #define	UD_LOG_VOL_INT		0x0009
149 
150 #define	UD_FILE_SET_DESC	0x0100
151 #define	UD_FILE_ID_DESC		0x0101
152 #define	UD_ALLOC_EXT_DESC	0x0102
153 #define	UD_INDIRECT_ENT		0x0103
154 #define	UD_TERMINAL_ENT		0x0104
155 #define	UD_FILE_ENTRY		0x0105
156 #define	UD_EXT_ATTR_HDR		0x0106
157 #define	UD_UNALL_SPA_ENT	0x0107
158 #define	UD_SPA_BMAP_DESC	0x0108
159 #define	UD_PART_INT_DESC	0x0109
160 #define	UD_EXT_FILE_ENT		0x010A
161 
162 
163 
164 
165 /*
166  * Character set's allowed in descriptor fields
167  * shall be specified
168  */
169 struct charspec {
170 	uint8_t		cs_type;	/* 00 Character Set Type */
171 	char		cs_info[63];	/* 01 Character Set Information */
172 };
173 typedef struct charspec charspec_t;
174 
175 #define	CS_TYPE0	0x00
176 #define	CS_TYPE1	0x01
177 #define	CS_TYPE2	0x02
178 #define	CS_TYPE3	0x03
179 #define	CS_TYPE4	0x04
180 #define	CS_TYPE5	0x05
181 #define	CS_TYPE6	0x06
182 #define	CS_TYPE7	0x07
183 #define	CS_TYPE8	0x08
184 
185 
186 
187 /*
188  * Entity Identification
189  */
190 struct regid {
191 	uint8_t		reg_flags;	/* 00 Flags */
192 	char		reg_id[23];	/* 01 Identifier */
193 	char		reg_ids[8];	/* 18 Identifier Suffix */
194 };
195 typedef struct regid regid_t;
196 
197 #define	EI_FLAG_DIRTY		0x00
198 #define	EI_FLAG_PROT		0x01
199 
200 struct lb_addr {
201 	/* uint32_t	lba_number;	00 Logical Block Number */
202 	/* uint8_t	lba_prn[2];	04 Partition Reference Number */
203 	char		lba_aaa[6];
204 };
205 typedef	struct lb_addr lb_addr_t;
206 #define	lba_number(x)(((x)->lba_aaa[0]) | \
207 			((x)->lba_aaa[1] << 8) | \
208 			((x)->lba_aaa[2] << 16) | \
209 			((x)->lba_aaa[3] << 24))
210 
211 #define	lba_prn(x)	((x)->lba_aaa[4] | ((x)->lba_aaa[5] << 8))
212 
213 
214 /*
215  * Extend Descriptor
216  */
217 struct extent_ad {
218 	uint32_t	ext_len;	/* 00 Extent Length */
219 	uint32_t	ext_loc;	/* 04 Extent Location */
220 };
221 typedef struct extent_ad extent_ad_t;
222 
223 /*
224  * Short Allocation Descriptor
225  */
226 struct short_ad {
227 	uint32_t	sad_ext_len;	/* 00 Extent Length */
228 	uint32_t	sad_ext_loc;	/* 04 extent Position */
229 };
230 typedef struct short_ad short_ad_t;
231 
232 /*
233  * Long Allocation Descriptor
234  */
235 struct long_ad {
236 	uint32_t	lad_ext_len;	/* 00 Extent Length */
237 	uint32_t	lad_ext_loc;	/* 04 Extent Location */
238 	uint16_t	lad_ext_prn;	/* 08 Extent part ref no */
239 	/* lb_addr_t	lad_ext_loc;	 04 Extent Location */
240 	char		lad_iu[6];	/* 0A Implementation Use */
241 };
242 typedef struct long_ad long_ad_t;
243 
244 
245 
246 
247 /*
248  * Format to record date and time
249  * If zero date & time is not specified
250  */
251 struct tstamp {
252 	uint16_t	ts_tzone;	/* 00 Type and Time Zone */
253 	uint16_t	ts_year;	/* 02 Year */
254 	uint8_t		ts_month;	/* 04 Month */
255 	uint8_t		ts_day;		/* 05 Day */
256 	uint8_t		ts_hour;	/* 06 Hour */
257 	uint8_t		ts_min;		/* 07 Minute */
258 	uint8_t		ts_sec;		/* 08 Second */
259 	uint8_t		ts_csec;	/* 09 Centi-seconds */
260 	uint8_t		ts_husec;	/* 0A Hundreds of Micro sec's */
261 	uint8_t		ts_usec;	/* 0B Micro-seconds */
262 };
263 typedef struct tstamp tstamp_t;
264 
265 
266 /*
267  * ts_tzone
268  */
269 #define	TMODE		0xF000
270 #define	TSIGN		0x0800
271 #define	TOFFSET		0x07FF
272 #define	TINVALID	(TSIGN|TOFFSET)
273 
274 
275 /*
276  * Format of the ICB tag which specifies
277  * most of the infomation of the file
278  */
279 struct icb_tag {
280 	uint32_t	itag_prnde;	/* 00 Prior Recorded No of Dir Entry */
281 	uint16_t	itag_strategy;	/* 04 Strategy Type */
282 	uint16_t	itag_param;	/* 06 Strategy parameter */
283 	uint16_t	itag_max_ent;	/* 08 Maximum No of Entries */
284 	uint8_t		itag_rsvd;	/* 0A Reserved */
285 	uint8_t		itag_ftype;	/* 0B File Type */
286 	/* lb_addr_t	itag_lb_addr;	0C parent ICB Location */
287 	uint32_t	itag_lb_loc;	/* 0C */
288 	uint16_t	itag_lb_prn;	/* 10 */
289 	uint16_t	itag_flags;	/* 12 Flags */
290 };
291 typedef struct icb_tag icb_tag_t;
292 
293 /*
294  * Different strategy types for the file
295  * For DVD_ROM we use onlt type4
296  */
297 #define	STRAT_TYPE1		0x0001
298 #define	STRAT_TYPE2		0x0002
299 #define	STRAT_TYPE3		0x0003
300 #define	STRAT_TYPE4		0x0004
301 #define	STRAT_TYPE4096		0x1000
302 
303 /*
304  * File types
305  */
306 #define	FTYPE_UNALL_SPACE	0x01
307 #define	FTYPE_PART_INTEG	0x02
308 #define	FTYPE_INDIRECT		0x03
309 #define	FTYPE_DIRECTORY		0x04
310 #define	FTYPE_FILE		0x05
311 #define	FTYPE_BLOCK_DEV		0x06
312 #define	FTYPE_CHAR_DEV		0x07
313 #define	FTYPE_EAR		0x08
314 #define	FTYPE_FIFO		0x09
315 #define	FTYPE_C_ISSOCK		0x0A
316 #define	FTYPE_T_ENTRY		0x0B
317 #define	FTYPE_SYMLINK		0x0C
318 
319 /*
320  * Flags
321  */
322 #define	ICB_FLAG_SHORT_AD	0x0000
323 #define	ICB_FLAG_LONG_AD	0x0001
324 #define	ICB_FLAG_EXT_AD		0x0002
325 #define	ICB_FLAG_ONE_AD		0x0003
326 #define	ICB_FLAG_SORTED		0x0008
327 #define	ICB_FLAG_NON_RELOC	0x0010
328 #define	ICB_FLAG_ARCHIVE	0x0020
329 #define	ICB_FLAG_SETUID		0x0040
330 #define	ICB_FLAG_SETGID		0x0080
331 #define	ICB_FLAG_STICKY		0x0100
332 #define	ICB_FLAG_CONTIG		0x0200
333 #define	ICB_FLAG_SYSTEM		0x0400
334 #define	ICB_FLAG_TRNSFRMED	0x0800
335 #define	ICB_FLAG_MVERS		0x1000
336 
337 
338 
339 
340 /* Volume recognition descriptors */
341 
342 
343 
344 
345 /*
346  * Primary volume descriptor identifis the
347  * volume and certain attributes of the volume
348  */
349 struct pri_vol_desc {
350 	tag_t		pvd_tag;	/* 00 Descriptor Tag */
351 	uint32_t	pvd_vdsn;	/* 10 Volume Descriptor Seq Num */
352 	uint32_t	pvd_pvdn;	/* 14 Primary Vol Desc Num */
353 	dstring_t	pvd_vol_id[32];	/* 18 Volume Identifier */
354 	uint16_t	pvd_vsn;	/* 38 Volume Sequence Num */
355 	uint16_t	pvd_mvsn;	/* 3A Max Volume Sequence Num */
356 	uint16_t	pvd_il;		/* 3C Interchange Level */
357 	uint16_t	pvd_mil;	/* 3E Max Interchange Level */
358 	uint32_t	pvd_csl;	/* 40 Character Set List */
359 	uint32_t	pvd_mcsl;	/* 44 Max Character Set List */
360 	dstring_t	pvd_vsi[128];	/* 48 Volume Set Identifier */
361 	charspec_t	pvd_desc_cs;	/* C8 Descriptor Character Set */
362 	charspec_t	pvd_exp_cs;	/* 108 Explanatory Char Set */
363 	extent_ad_t	pvd_vol_abs;	/* 148 Volume Abstract */
364 	extent_ad_t	pvd_vcn;	/* 150 Volume Copyright Notice */
365 	regid_t		pvd_appl_id;	/* 158 Application Identifier */
366 	tstamp_t	pvd_time;	/* 178 Recording Data & Time */
367 	regid_t		pvd_ii;		/* 184 Implementation Identifier */
368 	char		pvd_iu[64];	/* 1A4 Implementation Use */
369 	uint32_t	pvd_pvdsl;	/* 1E4 Pred Vol Desc Seq Loc */
370 	uint16_t	pvd_flags;	/* 1E8 Flags */
371 	uint8_t		pvd_res[22];	/* 1EA Reserved */
372 };
373 
374 
375 
376 
377 /*
378  * Anchor Volume Descriptor Pointer specifies
379  * the extent of Main & Reserve volume descriptor
380  */
381 struct anch_vol_desc_ptr {
382 	tag_t		avd_tag;	/* 00 Descriptor Tag */
383 	extent_ad_t	avd_main_vdse;	/* 10 Main Vol Desc Seq Extent */
384 	extent_ad_t	avd_res_vdse;	/* 18 Reserve Vol Desc Seq Ext */
385 	char		avd_res[480];	/* 20 Reserved */
386 };
387 typedef struct anch_vol_desc_ptr anch_vol_desc_ptr_t;
388 
389 
390 
391 
392 /*
393  * Volume Descriptor Pointer
394  */
395 struct vol_desc_ptr {
396 	tag_t		vdp_tag;	/* 00 Descriptor Tag */
397 	uint32_t	vdp_vdsn;	/* 10 Volume Descriptor Seq Num */
398 	extent_ad_t	vdp_nvdse;	/* 14 Next Vol Desc Seq Extent */
399 	uint8_t		vdp_res[484];	/* 1A Reserved */
400 };
401 typedef struct vol_desc_ptr vol_desc_ptr_t;
402 
403 
404 
405 
406 /*
407  * Implementation Use Volume Descriptor
408  * This is taken from udf1.02/1.50 documents
409  * the fields after iuvd_ii are defined only
410  * for the udf domain
411  */
412 struct iuvd_desc {
413 	tag_t		iuvd_tag;	/* 00 Descriptor Tag */
414 	uint32_t	iuvd_vdsn;	/* 10 Volume Desc Seq Num */
415 	regid_t		iuvd_ii;	/* 14 Domain Identifier */
416 	charspec_t	iuvd_cset;	/* 34 LVI Charset */
417 	dstring_t	iuvd_lvi[128];	/* 74 Logical Vol Identifier */
418 	dstring_t	iuvd_ifo1[36];	/* F4 LV Info1 */
419 	dstring_t	iuvd_ifo2[36];	/* 118 LV Info2 */
420 	dstring_t	iuvd_ifo3[36];	/* 13C LV Info3 */
421 	regid_t		iuvd_iid;	/* 160 Implementation ID */
422 	uint8_t		iuvd_iu[128];	/* 180 Implementation Use */
423 };
424 typedef struct iuvd_desc iuvd_desc_t;
425 
426 
427 
428 
429 
430 /*
431  * Partition Descriptor
432  * specifies the size and location of the partition
433  */
434 struct part_desc {
435 	tag_t		pd_tag;		/* 00 Descriptor Tag */
436 	uint32_t	pd_vdsn;	/* 10 Volume Desc Seq Num */
437 	uint16_t	pd_pflags;	/* 14 Partition Flags */
438 	uint16_t	pd_pnum;	/* 16 partition Number */
439 	regid_t		pd_pcontents;	/* 18 Partition Contents */
440 	uint8_t		pd_pc_use[128];	/* 38 Partition Contents Use */
441 	uint32_t	pd_acc_type;	/* B8 Access Type */
442 	uint32_t	pd_part_start;	/* BC Part Start Location */
443 	uint32_t	pd_part_length;	/* C0 partition Length */
444 	regid_t		pd_ii;		/* C4 Implementation Identifier */
445 	uint8_t		pd_iu[128];	/* E4 Implementation Use */
446 	uint8_t		pd_res[156];	/* 164 Reserved */
447 };
448 typedef struct part_desc part_desc_t;
449 
450 
451 /*
452  * pd_acc_type
453  */
454 #define	PART_ACC_RO	0x01
455 #define	PART_ACC_WO	0x02
456 #define	PART_ACC_RW	0x03
457 #define	PART_ACC_OW	0x04
458 
459 
460 /*
461  * Partition Header Descriptor
462  * Overloads pd_pc_use
463  */
464 struct phdr_desc {
465 	struct short_ad	phdr_ust;		/* Unallocated Space Table */
466 	struct short_ad	phdr_usb;		/* Unallocated Space Bitmap */
467 	struct short_ad	phdr_it;		/* Partition Integrity Table */
468 	struct short_ad	phdr_fst;		/* Freed Space Table */
469 	struct short_ad	phdr_fsb;		/* Freed Space Bitmap */
470 };
471 typedef struct phdr_desc phdr_desc_t;
472 
473 
474 
475 
476 
477 
478 /*
479  * Logical Volume Descriptor
480  */
481 struct log_vol_desc {
482 	tag_t		lvd_tag;	/* 00 Descriptor Tag */
483 	uint32_t	lvd_vdsn;	/* 10 Volume Desc Seq Num */
484 	charspec_t	lvd_desc_cs;	/* 14 Descriptor Char Set */
485 	dstring_t	lvd_lvid[128];	/* 54 Logical Vol Identifier */
486 	uint32_t	lvd_log_bsize;	/* D4 Logical Block Size */
487 	regid_t		lvd_dom_id;	/* D8 Domain Identifier */
488 	long_ad_t	lvd_lvcu;	/* F8 Logical Vol Contents Use */
489 	uint32_t	lvd_mtbl_len;	/* 108 Map Table Length */
490 	uint32_t	lvd_num_pmaps;	/* 10C Number of Partition Maps */
491 	regid_t		lvd_ii;		/* 110 Implementation Identifier */
492 	uint8_t		lvd_iu[128];	/* 130 Implementation Use */
493 	extent_ad_t	lvd_int_seq_ext; /* 1B0 Integrity Sequence Extent */
494 	uint8_t		lvd_pmaps[72];	/* 1B8 Partition Maps */
495 };
496 typedef struct log_vol_desc log_vol_desc_t;
497 
498 
499 
500 
501 
502 /*
503  * Unallocated Space Descriptor
504  * Contains information about the space
505  * that does not belong to any of the
506  * partition
507  */
508 struct unall_spc_desc {
509 	tag_t		ua_tag;		/* 00 Descriptor Tag */
510 	uint32_t	ua_vdsn;	/* 10 Volume Desc Seq Num */
511 	uint32_t	ua_nad;		/* 14 Number of Allocation Desc */
512 	uint8_t		ua_al_dsc[488];	/* 18 Allocation Desc */
513 };
514 typedef struct unall_spc_desc unall_spc_desc_t;
515 
516 
517 
518 
519 /*
520  * Terminating Descriptor
521  * this will be the last in a Volume Descriptor Sequence
522  */
523 struct term_desc {
524 	tag_t		td_tag;		/* 00 Descriptor Tag */
525 	uint8_t		td_res[496];	/* 10 Reserved */
526 };
527 typedef struct term_desc term_desc_t;
528 
529 
530 /*
531  * Logical Volume Header Descriptor
532  * This will be overlaid on lvid_lvcu
533  * and will contain the maximum value of
534  * unique id on the media
535  */
536 struct log_vol_hdr_desc {
537 	uint64_t	lvhd_uniqid;	/* 00 Unique Id */
538 	uint8_t		lvhd_pad[24];	/* 08 reserved */
539 };
540 typedef struct log_vol_hdr_desc log_vol_hdr_desc_t;
541 
542 /*
543  * Logical Volume Integrity Sequence
544  * This will contain the integrity of the
545  * file system
546  */
547 struct log_vol_int_desc {
548 	tag_t		lvid_tag;	/* 00 Descriptor Tag */
549 	tstamp_t	lvid_tstamp;	/* 10 Recording Date and Time */
550 	uint32_t	lvid_int_type;	/* 1C Integrity Type */
551 	extent_ad_t	lvid_nie;	/* 20 Next Integrity Extent */
552 	/* uint8_t	lvid_lvcu[32]; */
553 	log_vol_hdr_desc_t lvid_lvcu;	/* 28 Logical Volume Contents Use */
554 	uint32_t	lvid_npart;	/* 48 Number of Partitions */
555 	uint32_t	lvid_liu;	/* 4C Length of Implementation Use */
556 	uint32_t	lvid_fst[2];	/* 50 Free Space Table */
557 					/* Size Table */
558 					/* Implementation Use */
559 };
560 typedef struct log_vol_int_desc log_vol_int_desc_t;
561 
562 #define	lvid_uniqid	lvid_lvcu.lvhd_uniqid
563 
564 
565 #define	LOG_VOL_OPEN_INT	0x00
566 #define	LOG_VOL_CLOSE_INT	0x01
567 
568 
569 /*
570  * Logical Volume integrity Implementation Use
571  * This is defined in udf spec
572  */
573 struct lvid_iu {
574 	regid_t		lvidiu_regid;	/* 00 Implementation ID */
575 	uint32_t	lvidiu_nfiles;	/* 20 Number of Files */
576 	uint32_t	lvidiu_ndirs;	/* 24 Number of Directories */
577 	uint16_t	lvidiu_mread;	/* 28 Minimum UDF read revision */
578 	uint16_t	lvidiu_mwrite;	/* 2A Minimum UDF write revision */
579 	uint16_t	lvidiu_maxwr;	/* 2C Maximum UDF write revision */
580 };
581 
582 
583 
584 
585 
586 
587 
588 /*
589  * File Set Descriptor
590  * This will point to the root directory.
591  */
592 struct file_set_desc {
593 	tag_t		fsd_tag;	/* 00 Descriptor Tag */
594 	tstamp_t	fsd_time;	/* 10 Recording Date and Time */
595 	uint16_t	fsd_ilevel;	/* 1C Interchange Level */
596 	uint16_t	fsd_mi_level;	/* 1E Max Interchange Level */
597 	uint32_t	fsd_cs_list;	/* 20 Character Set List */
598 	uint32_t	fsd_mcs_list;	/* 24 Max Character Set List */
599 	uint32_t	fsd_fs_no;	/* 28 File Set Number */
600 	uint32_t	fsd_fsd_no;	/* 2C File Set Desc Number */
601 	charspec_t	fsd_lvidcs;	/* 30 Log Vol Id Char Set */
602 	char		fsd_lvid[128];	/* 70 Log Vol Identifier */
603 	charspec_t	fsd_fscs;	/* F0 File Set Character Set */
604 	char		fsd_fsi[32];	/* 130 File Set Identifier */
605 	char		fsd_cfi[32];	/* 150 Copyright File Identifier */
606 	char		fsd_afi[32];	/* 170 Abstract File identifier */
607 	long_ad_t	fsd_root_icb;	/* 190 Root Directory ICB */
608 	regid_t		fsd_did;	/* 1A0 Domain Identifier */
609 	long_ad_t	fsd_next;	/* 1C0 Next Extent */
610 	uint8_t		fsd_res[48];	/* 1D0 Reserved */
611 };
612 typedef struct file_set_desc file_set_desc_t;
613 
614 
615 
616 
617 
618 
619 
620 /*
621  * File Identifier Descriptor
622  * Directory entries
623  */
624 struct file_id {
625 	tag_t		fid_tag;	/* 00 Descriptor Tag */
626 	uint16_t	fid_ver;	/* 10 File Version Number */
627 	uint8_t		fid_flags;	/* 12 File characteristics */
628 	uint8_t		fid_idlen;	/* 13 Length File Identifier */
629 	long_ad_t	fid_icb;	/* 14 ICB */
630 	uint16_t	fid_iulen;	/* 24 Length of Implmentation use */
631 	uint8_t		fid_spec[2];	/* iulen for iu name and padding */
632 };
633 typedef struct file_id file_id_t;
634 
635 #define	FID_EXIST	0x01
636 #define	FID_DIR		0x02
637 #define	FID_DELETED	0x04
638 #define	FID_PARENT	0x08
639 
640 
641 
642 
643 
644 
645 
646 /*
647  * Allocation Extent Descriptor
648  */
649 struct alloc_ext_desc {
650 	tag_t		aed_tag;	/* 00 Descriptor Tag */
651 	uint32_t	aed_rev_ael;	/* 10 Previous Alloc Extent Location */
652 	uint32_t	aed_len_aed;	/* 14 Length of Allocation Desc */
653 };
654 typedef struct alloc_ext_desc alloc_ext_desc_t;
655 
656 
657 
658 
659 
660 /*
661  * Indirect Entry
662  * used to specify the address of another ICB
663  */
664 struct indirect_entry {
665 	tag_t		ie_tag;		/* 00 Descriptor Tag */
666 	icb_tag_t	ie_icb_tag;	/* 10 ICB tag */
667 	long_ad_t	ie_indirecticb;	/* 24 Indirect ICB */
668 };
669 typedef struct indirect_entry indirect_entry_t;
670 
671 
672 
673 
674 /*
675  * Terminal Entry
676  */
677 struct term_entry {
678 	tag_t		te_tag;		/* 00 Descriptor Tag */
679 	icb_tag_t	te_icb_tag;	/* 10 ICB tag */
680 };
681 typedef struct term_entry term_entry_t;
682 
683 
684 
685 
686 /*
687  * File entry describes the
688  * file attributes and location it is recorded on the media
689  */
690 struct file_entry {
691 	tag_t		fe_tag;		/* 00 Descriptor Tag */
692 	icb_tag_t	fe_icb_tag;	/* 10 ICB tag */
693 	uint32_t	fe_uid;		/* 24 Uid */
694 	uint32_t	fe_gid;		/* 28 Gid */
695 	uint32_t	fe_perms;	/* 2C Permissions */
696 	uint16_t	fe_lcount;	/* 30 File Link Count */
697 	uint8_t		fe_rec_for;	/* 32 Record Format */
698 	uint8_t		fe_rec_dis;	/* 33 Record Display Attributes */
699 	uint32_t	fe_rec_len;	/* 34 Record Length */
700 	uint64_t	fe_info_len;	/* 38 Information Length */
701 	uint64_t	fe_lbr;		/* 40 Logical Blocks recorded */
702 	tstamp_t	fe_acc_time;	/* 48 Access Data and Time */
703 	tstamp_t	fe_mod_time;	/* 54 Modification Data and Time */
704 	tstamp_t	fe_attr_time;	/* 60 Attribute Data and Time */
705 	uint32_t	fe_ckpoint;	/* 6C Checkpoint */
706 	long_ad_t	fe_ea_icb;	/* 70 Extended Attr ICB */
707 	regid_t		fe_impl_id;	/* 80 Implementation Identifier */
708 	uint64_t	fe_uniq_id;	/* A0 Unique Id */
709 	uint32_t	fe_len_ear;	/* A8 Length of Extended Attr */
710 	uint32_t	fe_len_adesc;	/* AC Length of Alloc Desc */
711 	char		fe_spec[336];	/* B0 used for EA and AD's */
712 };
713 typedef struct file_entry file_entry_t;
714 
715 
716 
717 
718 
719 /*
720  * Extended Attribute Header
721  */
722 struct ext_attr_hdr {
723 	tag_t		eah_tag;	/* 00 Descriptor Tag */
724 	uint32_t	eah_ial;	/* 10 Implementation Attr Location */
725 	uint32_t	eah_aal;	/* 14 Application Attr Location */
726 };
727 typedef struct ext_attr_hdr ext_attr_hdr_t;
728 
729 
730 
731 
732 
733 
734 
735 /*
736  * Unallocated Space Entry
737  */
738 struct unall_space_ent {
739 	tag_t		use_tag;	/* 00 Descriptor Tag */
740 	icb_tag_t	use_icb_tag;	/* 10 ICB tag */
741 	uint32_t	use_len_ad;	/* 24 Lenght of Allocation desc */
742 	uint8_t		use_ad[484];	/* 28 Allocation Descriptors */
743 };
744 typedef struct unall_space_ent unall_space_ent_t;
745 
746 
747 
748 
749 
750 /*
751  * Space Bitmap Descriptor
752  */
753 struct space_bmap_desc {
754 	tag_t		sbd_tag;	/* 00 Descriptor Tag */
755 	uint32_t	sbd_nbits;	/* 10 Number of Bits */
756 	uint32_t	sbd_nbytes;	/* 14 Number of Bytes */
757 	uint8_t		sbd_bmap[500];	/* 18 Bitmap */
758 };
759 typedef struct space_bmap_desc space_bmap_desc_t;
760 
761 
762 
763 
764 
765 /*
766  * Partition Integrity entry
767  */
768 struct part_int_desc {
769 	tag_t		pid_tag;	/* 00 Descriptor Tag */
770 	icb_tag_t	pid_idb_tag;	/* 10 ICB tag */
771 	tstamp_t	pid_rtime;	/* 24 Recording Data and Time */
772 	uint8_t		pid_integ;	/* 30 Integrity type */
773 	uint8_t		pid_res[175];	/* 31 Reserved */
774 	regid_t		pid_ii;		/* E0 Implementation Identifier */
775 	uint8_t		pid_iu[256];	/* 100 Implementation Use */
776 };
777 typedef struct part_int_desc part_int_desc_t;
778 
779 
780 #define	PART_OPEN_INT		0x00
781 #define	PART_CLOSE_INT		0x01
782 #define	PART_STABLE_INT		0x02
783 
784 
785 
786 
787 struct attr_hdr {
788 	uint32_t	ahdr_atype;	/* Attribute Type */
789 	uint8_t		ahdr_astype;	/* Attribute Subtype */
790 	uint8_t		ahdr_res[3];	/* Reserved */
791 	uint32_t	ahdr_length;	/* Attribute Length */
792 	uint8_t		ahdr_data[4];	/* Attribute Data */
793 };
794 
795 /*
796  * We will support and use the
797  * following Extended Attributes
798  * we will ignore others while reading
799  * and will preserve then when updating
800  * the EAR's
801  * In all the EA's we allocate the last member
802  * as 4 bytes. This is a sort of hack
803  * since the structure has to be
804  * properly alined to 4 bytes.
805  */
806 
807 struct dev_spec_ear {
808 	uint32_t	ds_atype;	/* 00 Attribute Type */
809 	uint8_t		ds_astype;	/* 04 Attribute Subtype */
810 	uint8_t		ds_res[3];	/* 05 Reserved */
811 	uint32_t	ds_attr_len;	/* 08 Attrbute Length */
812 	uint32_t	ds_iu_len;	/* 0C Impl Use Length */
813 	uint32_t	ds_major_id;	/* 10 Major Device ID */
814 	uint32_t	ds_minor_id;	/* 14 Minor Device ID */
815 	uint8_t		ds_iu[4];	/* 18 Implementation Use */
816 };
817 
818 
819 struct ftimes_ear {
820 	uint32_t	ft_atype;	/* 00 Attribute Type */
821 	uint8_t		ft_astype;	/* 04 Attribute Subtype */
822 	uint8_t		ft_res[3];	/* 05 Reserved */
823 	uint32_t	ft_attr_len;	/* 08 Attrbute Length */
824 	uint32_t	ft_data_len;	/* 0C Data Length */
825 	uint32_t	ft_exist;	/* 10 File Time Existence */
826 	uint8_t		ft_ft[4];	/* 14 File Times */
827 };
828 
829 /* ft_exit */
830 #define	FT_EXIST	0x0
831 #define	FT_DELETE	0x2
832 #define	FT_FEDT		0x3
833 #define	FT_BACKUP	0x5
834 
835 struct iu_ea {
836 	uint32_t	iuea_atype;	/* 00 Attribute Type */
837 	uint8_t		iuea_astype;	/* 04 Attribute Subtype */
838 	uint8_t		iuea_res[3];	/* 05 Reserved */
839 	uint32_t	iuea_attr_len;	/* 08 Attrbute Length */
840 	uint32_t	iuea_iu_len;	/* 0C Implementation Use Length */
841 	regid_t		iuea_ii;		/* 10 Implementation ID */
842 	uint8_t		iuea_iu[4];	/* 30 Impl Use */
843 };
844 
845 
846 /*
847  * CGMS & FREE_SPACE will be
848  * over laid on iu_iu field
849  */
850 
851 struct copy_mgt_info {
852 	uint16_t	cgms_cksum;	/* Header Checksum */
853 	uint8_t		cgms_info;	/* CGMS Information */
854 	uint8_t		cgms_dstype;	/* Data Structure Type */
855 	uint32_t	cgms_psi;	/* Protection System Info */
856 };
857 
858 #define	COPY_PROTECTED	0x80
859 
860 struct FREE_SPACE {
861 	uint16_t	fs_cksum;	/* Header Checksum */
862 	uint8_t		fs_freesp[2];	/* Free EA space */
863 };
864 
865 
866 
867 
868 struct nsr_desc {
869 	uint8_t		nsr_str_type;
870 	uint8_t		nsr_id[5];
871 	uint8_t		nsr_ver;
872 	uint8_t		nsr_res;
873 	uint8_t		nsr_data[2040];
874 };
875 
876 
877 
878 /*
879  * Partition Map
880  */
881 struct pmap_hdr {
882 	uint8_t		maph_type;	/* Partition Map Type */
883 	uint8_t		maph_length;	/* Partition Map Length */
884 };
885 
886 #define	MAP_TYPE1	1
887 #define	MAP_TYPE2	2
888 
889 #define	MAP_TYPE1_LEN	6
890 #define	MAP_TYPE2_LEN	64
891 
892 struct pmap_typ1 {
893 	uint8_t		map1_type;	/* Map type == 1 */
894 	uint8_t		map1_length;	/* Map length == 6 */
895 	uint16_t	map1_vsn;	/* Volume Sequence Number */
896 	uint16_t	map1_pn;	/* Partition Number */
897 };
898 
899 
900 /*
901  * Only two types of type2 maps
902  * are supported they are
903  * *UDF Virtual Partition
904  * *UDF Sparable Partition
905  * For vpm fields till map2_pn
906  * are valid and the entire structure is
907  * valid for spm
908  */
909 struct pmap_typ2 {
910 	uint8_t		map2_type;	/* 00 Map type == 2 */
911 	uint8_t		map2_length;	/* 01 Map length == 64 */
912 	uint16_t	map2_pad1;	/* 02 Reserved */
913 	regid_t		map2_pti;	/* 04 Entiry ID */
914 	uint16_t	map2_vsn;	/* 24 Volume Sequence Number */
915 	uint16_t	map2_pn;	/* 26 Partition Number */
916 	uint16_t	map2_pl;	/* 28 Packet Length == 32 */
917 	uint8_t		map2_nst;	/* 2A Number of sparing tables */
918 	uint8_t		map2_pad2;	/* 2B Reserved */
919 	uint32_t	map2_sest;	/* 2C Size of each sparing table */
920 	uint32_t	map2_st[4];	/* 30 sparing Tables */
921 };
922 
923 
924 struct stbl_entry {
925 	uint32_t	sent_ol;	/* Original Location */
926 	uint32_t	sent_ml;	/* Mapped Location */
927 };
928 
929 typedef struct stbl_entry stbl_entry_t;
930 
931 struct stbl {
932 	tag_t		stbl_tag;	/* 00 Tag */
933 	regid_t		stbl_si;	/* 10 Sparing Identifier */
934 	uint16_t	stbl_len;	/* 30 Reallocation Table Len */
935 	uint16_t	stbl_res1;	/* 32 Reserved */
936 	uint32_t	stbl_seqno;	/* 34 Sequence Number */
937 	stbl_entry_t	stbl_entry;	/* 38 Sparing Table Entries */
938 };
939 
940 struct path_comp {
941 	uint8_t		pc_type;	/* Component Type */
942 	uint8_t		pc_len;		/* Length of Component ID */
943 	uint16_t	pc_ver;		/* Component File Version Number */
944 	uint8_t		pc_id[4];	/* Component ID */
945 };
946 
947 #ifdef	__cplusplus
948 }
949 #endif
950 
951 #endif	/* _SYS_FS_UDF_VOLUME_H */
952