1 /*
2  * This file has been modified for the cdrkit suite.
3  *
4  * The behaviour and appearence of the program code below can differ to a major
5  * extent from the version distributed by the original author(s).
6  *
7  * For details, see Changelog file distributed with the cdrkit package. If you
8  * received this file from another source then ask the distributing person for
9  * a log of modifications.
10  *
11  */
12 
13 /* @(#)iso9660.h	1.19 04/03/02 joerg */
14 /*
15  * Header file iso9660.h - assorted structure definitions and typecasts.
16  * specific to iso9660 filesystem.
17  *
18  * Written by Eric Youngdale (1993).
19  *
20  * Copyright 1993 Yggdrasil Computing, Incorporated
21  * Copyright (c) 1999,2000-2004 J. Schilling
22  *
23  * This program is free software; you can redistribute it and/or modify
24  * it under the terms of the GNU General Public License as published by
25  * the Free Software Foundation; either version 2, or (at your option)
26  * any later version.
27  *
28  * This program is distributed in the hope that it will be useful,
29  * but WITHOUT ANY WARRANTY; without even the implied warranty of
30  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
31  * GNU General Public License for more details.
32  *
33  * You should have received a copy of the GNU General Public License
34  * along with this program; if not, write to the Free Software
35  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
36  */
37 #ifndef	_ISOFS_FS_H
38 #define	_ISOFS_FS_H
39 
40 /*
41  * The isofs filesystem constants/structures
42  */
43 
44 /* This part borrowed from the bsd386 isofs */
45 #define	ISODCL(from, to) (to - from + 1)
46 
47 struct iso_volume_descriptor {
48 	char type	[ISODCL(1, 1)]; /* 711 */
49 	char id		[ISODCL(2, 6)];
50 	char version	[ISODCL(7, 7)];
51 	char data	[ISODCL(8, 2048)];
52 };
53 
54 /* volume descriptor types */
55 #define	ISO_VD_PRIMARY		1
56 #define	ISO_VD_SUPPLEMENTARY	2	/* Used by Joliet */
57 #define	ISO_VD_END		255
58 
59 #define	ISO_STANDARD_ID		"CD001"
60 
61 #define	EL_TORITO_ID		"EL TORITO SPECIFICATION"
62 #define	EL_TORITO_ARCH_x86	0
63 #define	EL_TORITO_ARCH_PPC	1
64 #define	EL_TORITO_ARCH_MAC	2
65 
66 #define	EL_TORITO_BOOTABLE	0x88
67 #define	EL_TORITO_NOT_BOOTABLE	0
68 
69 #define	EL_TORITO_MEDIA_NOEMUL	0
70 #define	EL_TORITO_MEDIA_12FLOP	1
71 #define	EL_TORITO_MEDIA_144FLOP	2
72 #define	EL_TORITO_MEDIA_288FLOP	3
73 #define	EL_TORITO_MEDIA_HD	4
74 
75 struct iso_primary_descriptor {
76 	char type			[ISODCL(1,    1)]; /* 711 */
77 	char id				[ISODCL(2,    6)];
78 	char version			[ISODCL(7,    7)]; /* 711 */
79 	char unused1			[ISODCL(8,    8)];
80 	char system_id			[ISODCL(9,   40)]; /* achars */
81 	char volume_id			[ISODCL(41,  72)]; /* dchars */
82 	char unused2			[ISODCL(73,  80)];
83 	char volume_space_size		[ISODCL(81,  88)]; /* 733 */
84 	char escape_sequences		[ISODCL(89, 120)];
85 	char volume_set_size		[ISODCL(121, 124)]; /* 723 */
86 	char volume_sequence_number	[ISODCL(125, 128)]; /* 723 */
87 	char logical_block_size		[ISODCL(129, 132)]; /* 723 */
88 	char path_table_size		[ISODCL(133, 140)]; /* 733 */
89 	char type_l_path_table		[ISODCL(141, 144)]; /* 731 */
90 	char opt_type_l_path_table	[ISODCL(145, 148)]; /* 731 */
91 	char type_m_path_table		[ISODCL(149, 152)]; /* 732 */
92 	char opt_type_m_path_table	[ISODCL(153, 156)]; /* 732 */
93 	char root_directory_record	[ISODCL(157, 190)]; /* 9.1 */
94 	char volume_set_id		[ISODCL(191, 318)]; /* dchars */
95 	char publisher_id		[ISODCL(319, 446)]; /* achars */
96 	char preparer_id		[ISODCL(447, 574)]; /* achars */
97 	char application_id		[ISODCL(575, 702)]; /* achars */
98 	char copyright_file_id		[ISODCL(703, 739)]; /* 7.5 dchars */
99 	char abstract_file_id		[ISODCL(740, 776)]; /* 7.5 dchars */
100 	char bibliographic_file_id	[ISODCL(777, 813)]; /* 7.5 dchars */
101 	char creation_date		[ISODCL(814, 830)]; /* 8.4.26.1 */
102 	char modification_date		[ISODCL(831, 847)]; /* 8.4.26.1 */
103 	char expiration_date		[ISODCL(848, 864)]; /* 8.4.26.1 */
104 	char effective_date		[ISODCL(865, 881)]; /* 8.4.26.1 */
105 	char file_structure_version	[ISODCL(882, 882)]; /* 711 */
106 	char unused4			[ISODCL(883, 883)];
107 	char application_data		[ISODCL(884, 1395)];
108 	char unused5			[ISODCL(1396, 2048)];
109 };
110 
111 /*
112  * Supplementary or enhanced volume descriptor
113  */
114 struct iso_enhanced_descriptor {
115 	char type			[ISODCL(1,    1)]; /* 711 */
116 	char id				[ISODCL(2,    6)];
117 	char version			[ISODCL(7,    7)]; /* 711 */
118 	char flags			[ISODCL(8,    8)];
119 	char system_id			[ISODCL(9,   40)]; /* achars */
120 	char volume_id			[ISODCL(41,  72)]; /* dchars */
121 	char unused2			[ISODCL(73,  80)];
122 	char volume_space_size		[ISODCL(81,  88)]; /* 733 */
123 	char escape_sequences		[ISODCL(89, 120)];
124 	char volume_set_size		[ISODCL(121, 124)]; /* 723 */
125 	char volume_sequence_number	[ISODCL(125, 128)]; /* 723 */
126 	char logical_block_size		[ISODCL(129, 132)]; /* 723 */
127 	char path_table_size		[ISODCL(133, 140)]; /* 733 */
128 	char type_l_path_table		[ISODCL(141, 144)]; /* 731 */
129 	char opt_type_l_path_table	[ISODCL(145, 148)]; /* 731 */
130 	char type_m_path_table		[ISODCL(149, 152)]; /* 732 */
131 	char opt_type_m_path_table	[ISODCL(153, 156)]; /* 732 */
132 	char root_directory_record	[ISODCL(157, 190)]; /* 9.1 */
133 	char volume_set_id		[ISODCL(191, 318)]; /* dchars */
134 	char publisher_id		[ISODCL(319, 446)]; /* achars */
135 	char preparer_id		[ISODCL(447, 574)]; /* achars */
136 	char application_id		[ISODCL(575, 702)]; /* achars */
137 	char copyright_file_id		[ISODCL(703, 739)]; /* 7.5 dchars */
138 	char abstract_file_id		[ISODCL(740, 776)]; /* 7.5 dchars */
139 	char bibliographic_file_id	[ISODCL(777, 813)]; /* 7.5 dchars */
140 	char creation_date		[ISODCL(814, 830)]; /* 8.4.26.1 */
141 	char modification_date		[ISODCL(831, 847)]; /* 8.4.26.1 */
142 	char expiration_date		[ISODCL(848, 864)]; /* 8.4.26.1 */
143 	char effective_date		[ISODCL(865, 881)]; /* 8.4.26.1 */
144 	char file_structure_version	[ISODCL(882, 882)]; /* 711 */
145 	char unused4			[ISODCL(883, 883)];
146 	char application_data		[ISODCL(884, 1395)];
147 	char unused5			[ISODCL(1396, 2048)];
148 };
149 
150 /* El Torito Boot Record Volume Descriptor */
151 struct eltorito_boot_descriptor {
152 	char type			[ISODCL(1,    1)]; /* 711 */
153 	char id				[ISODCL(2,    6)];
154 	char version			[ISODCL(7,    7)]; /* 711 */
155 	char system_id			[ISODCL(8,   39)];
156 	char unused2			[ISODCL(40,  71)];
157 	char bootcat_ptr		[ISODCL(72,  75)];
158 	char unused5			[ISODCL(76, 2048)];
159 };
160 
161 /* Validation entry for El Torito */
162 struct eltorito_validation_entry {
163 	char headerid			[ISODCL(1,    1)]; /* 711 */
164 	char arch			[ISODCL(2,    2)];
165 	char pad1			[ISODCL(3,    4)]; /* 711 */
166 	char id				[ISODCL(5,   28)]; /* CD devel/man*/
167 	char cksum			[ISODCL(29,  30)];
168 	char key1			[ISODCL(31,  31)];
169 	char key2			[ISODCL(32,  32)];
170 };
171 
172 /* El Torito initial/default entry in boot catalog */
173 struct eltorito_defaultboot_entry {
174 	char boot_id			[ISODCL(1,    1)]; /* 711 */
175 	char boot_media			[ISODCL(2,    2)];
176 	char loadseg			[ISODCL(3,    4)]; /* 711 */
177 	char sys_type			[ISODCL(5,    5)];
178 	char pad1			[ISODCL(6,    6)];
179 	char nsect			[ISODCL(7,    8)];
180 	char bootoff			[ISODCL(9,   12)];
181 	char pad2			[ISODCL(13,  32)];
182 };
183 
184 /*
185  * XXX JS: The next two structures have odd lengths!
186  * Some compilers (e.g. on Sun3/mc68020) padd the structures to even length.
187  * For this reason, we cannot use sizeof (struct iso_path_table) or
188  * sizeof (struct iso_directory_record) to compute on disk sizes.
189  * Instead, we use offsetof(..., name) and add the name size.
190  * See genisoimage.h
191  */
192 
193 /* We use this to help us look up the parent inode numbers. */
194 
195 struct iso_path_table {
196 	unsigned char  name_len[2];	/* 721 */
197 	char extent[4];			/* 731 */
198 	char  parent[2];		/* 721 */
199 	char name[1];
200 };
201 
202 /*
203  * A ISO filename is: "abcde.eee;1" -> <filename> '.' <ext> ';' <version #>
204  *
205  * The maximum needed string length is:
206  *	30 chars (filename + ext)
207  * +	 2 chars ('.' + ';')
208  * +	   strlen("32767")
209  * +	   null byte
210  * ================================
211  * =	38 chars
212  *
213  * We currently do not support CD-ROM-XA entension records, but we must honor
214  * the needed space for ISO-9660:1999 (Version 2).
215  *
216  * XXX If we ever will start to support XA records, we will need to take care
217  * XXX that the the maximum ISO-9660 name length will be reduced by another
218  * XXX 14 bytes resulting in a new total of 179 Bytes.
219  */
220 #define	LEN_ISONAME		31
221 #define	MAX_ISONAME_V1		37
222 #define	MAX_ISONAME_V2		207		/* 254 - 33 - 14 (XA Record) */
223 #define	MAX_ISONAME_V2_RR	193		/* 254 - 33 - 28 (CE Record) */
224 #define	MAX_ISONAME_V2_RR_XA	179		/* 254 - 33 - 14 - 28	    */
225 #define	MAX_ISONAME		MAX_ISONAME_V2	/* Used for array space defs */
226 #define	MAX_ISODIR		254		/* Must be even and <= 255   */
227 
228 struct iso_directory_record {
229 	unsigned char length		[ISODCL(1,  1)];  /* 711 */
230 	char ext_attr_length		[ISODCL(2,  2)];  /* 711 */
231 	char extent			[ISODCL(3,  10)]; /* 733 */
232 	char size			[ISODCL(11, 18)]; /* 733 */
233 	char date			[ISODCL(19, 25)]; /* 7 by 711 */
234 	char flags			[ISODCL(26, 26)];
235 	char file_unit_size		[ISODCL(27, 27)]; /* 711 */
236 	char interleave			[ISODCL(28, 28)]; /* 711 */
237 	char volume_sequence_number	[ISODCL(29, 32)]; /* 723 */
238 	unsigned char name_len		[ISODCL(33, 33)]; /* 711 */
239 	char name			[MAX_ISONAME+1]; /* Not really, but we need something here */
240 };
241 
242 
243 /*
244  * Iso directory flags.
245  */
246 #define	ISO_FILE	0	/* Not really a flag...			*/
247 #define	ISO_EXISTENCE	1	/* Do not make existence known (hidden)	*/
248 #define	ISO_DIRECTORY	2	/* This file is a directory		*/
249 #define	ISO_ASSOCIATED	4	/* This file is an assiciated file	*/
250 #define	ISO_RECORD	8	/* Record format in extended attr. != 0	*/
251 #define	ISO_PROTECTION	16	/* No read/execute perm. in ext. attr.	*/
252 #define	ISO_DRESERVED1	32	/* Reserved bit 5			*/
253 #define	ISO_DRESERVED2	64	/* Reserved bit 6			*/
254 #define	ISO_MULTIEXTENT	128	/* Not final entry of a mult. ext. file	*/
255 
256 
257 struct iso_ext_attr_record {
258 	char owner			[ISODCL(1, 4)];	    /* 723 */
259 	char group			[ISODCL(5, 8)];	    /* 723 */
260 	char permissions		[ISODCL(9, 10)];    /* 16 bits */
261 	char creation_date		[ISODCL(11, 27)];   /* 8.4.26.1 */
262 	char modification_date		[ISODCL(28, 44)];   /* 8.4.26.1 */
263 	char expiration_date		[ISODCL(45, 61)];   /* 8.4.26.1 */
264 	char effective_date		[ISODCL(62, 78)];   /* 8.4.26.1 */
265 	char record_format		[ISODCL(79, 79)];   /* 711 */
266 	char record_attributes		[ISODCL(80, 80)];   /* 711 */
267 	char record_length		[ISODCL(81, 84)];   /* 723 */
268 	char system_id			[ISODCL(85, 116)];  /* achars */
269 	char system_use			[ISODCL(117, 180)];
270 	char ext_attr_version		[ISODCL(181, 181)]; /* 711 */
271 	char esc_seq_len		[ISODCL(182, 182)]; /* 711 */
272 	char reserved			[ISODCL(183, 246)]; /* for future use */
273 	char appl_use_len		[ISODCL(247, 250)]; /* 723 */
274 	char appl_use[1];		/* really more */
275 /*	char esc_seq[];			escape sequences recorded after appl_use */
276 };
277 
278 /*
279  * Iso extended attribute permissions.
280  */
281 #define	ISO_GS_READ		0x0001	/* System Group Read */
282 #define	ISO_BIT_1		0x0002
283 #define	ISO_GS_EXEC		0x0004	/* System Group Execute */
284 #define	ISO_BIT_3		0x0008
285 
286 #define	ISO_O_READ		0x0010	/* Owner Read */
287 #define	ISO_BIT_5		0x0020
288 #define	ISO_O_EXEC		0x0040	/* Owner Exexute */
289 #define	ISO_BIT_7		0x0080
290 
291 #define	ISO_G_READ		0x0100	/* Group Read */
292 #define	ISO_BIT_9		0x0200
293 #define	ISO_G_EXEC		0x0400	/* Group Execute */
294 #define	ISO_BIT_11		0x0800
295 
296 #define	ISO_W_READ		0x1000	/* World (other) Read */
297 #define	ISO_BIT_13		0x2000
298 #define	ISO_W_EXEC		0x4000	/* World (other) Execute */
299 #define	ISO_BIT_15		0x8000
300 
301 #define	ISO_MB_ONE		(ISO_BIT_1|ISO_BIT_3|ISO_BIT_5|ISO_BIT_7| \
302 				ISO_BIT_9|ISO_BIT_11|ISO_BIT_13|ISO_BIT_15)
303 
304 /*
305  * Extended Attributes record according to Yellow Book.
306  */
307 struct iso_xa_dir_record {
308 	char group_id			[ISODCL(1, 2)];
309 	char user_id			[ISODCL(3, 4)];
310 	char attributes			[ISODCL(5, 6)];
311 	char signature			[ISODCL(7, 8)];
312 	char file_number		[ISODCL(9, 9)];
313 	char reserved			[ISODCL(10, 14)];
314 };
315 
316 /*
317  * Definitions for XA attributes
318  */
319 #define	XA_O_READ	0x0001	/* Owner Read				*/
320 #define	XA_O_RES	0x0002	/* Owner Reserved (write ?)		*/
321 #define	XA_O_EXEC	0x0004	/* Owner Execute			*/
322 #define	XA_O_RES2	0x0008	/* Owner Reserved			*/
323 #define	XA_G_READ	0x0010	/* Group Read				*/
324 #define	XA_G_RES	0x0020	/* Group Reserved (write ?)		*/
325 #define	XA_G_EXEC	0x0040	/* Group Execute			*/
326 #define	XA_G_RES2	0x0080	/* Group Reserved			*/
327 #define	XA_W_READ	0x0100	/* World Read				*/
328 #define	XA_W_RES	0x0200	/* World Reserved (write ?)		*/
329 #define	XA_W_EXEC	0x0400	/* World Execute			*/
330 
331 #define	XA_FORM1	0x0800	/* File contains Form 1 sector		*/
332 #define	XA_FORM2	0x1000	/* File contains Form 2 sector		*/
333 #define	XA_INTERLEAVED	0x2000	/* File contains interleaved sectors	*/
334 #define	XA_CDDA		0x4000	/* File contains audio data		*/
335 #define	XA_DIR		0x8000	/* This is a directory			*/
336 
337 /*
338  * Definitions for CD-ROM XA-Mode-2-form-1/2 sector sub-headers
339  */
340 struct xa_subhdr {
341 	Uchar	file_number;		/* Identifies file for block	*/
342 	Uchar	channel_number;		/* Playback channel selection	*/
343 	Uchar	sub_mode;		/* See bit definitions below	*/
344 	Uchar	coding;			/* Coding information		*/
345 };
346 
347 /*
348  * Sub mode bit definitions
349  */
350 #define	XA_SUBH_EOR		0x01	/* End-Of-Record		*/
351 #define	XA_SUBH_VIDEO		0x02	/* Video Block			*/
352 #define	XA_SUBH_AUDIO		0x04	/* Audio Block (not CD-DA)	*/
353 #define	XA_SUBH_DATA		0x08	/* Data Block			*/
354 #define	XA_SUBH_TRIGGER		0x10	/* Trigger Block		*/
355 #define	XA_SUBH_FORM2		0x20	/* 0 == Form1, 1 == Form2	*/
356 #define	XA_SUBH_REALTIME	0x40	/* Real Time Block		*/
357 #define	XA_SUBH_EOF		0x80	/* End-Of-File			*/
358 
359 #endif	/* _ISOFS_FS_H */
360