xref: /minix3/usr.sbin/makefs/cd9660.h (revision 9f988b79349f9b89ecc822458c30ec8897558560)
1*9f988b79SJean-Baptiste Boric /*	$NetBSD: cd9660.h,v 1.20 2013/01/29 15:52:25 christos Exp $	*/
2*9f988b79SJean-Baptiste Boric 
3*9f988b79SJean-Baptiste Boric /*
4*9f988b79SJean-Baptiste Boric  * Copyright (c) 2005 Daniel Watt, Walter Deignan, Ryan Gabrys, Alan
5*9f988b79SJean-Baptiste Boric  * Perez-Rathke and Ram Vedam.  All rights reserved.
6*9f988b79SJean-Baptiste Boric  *
7*9f988b79SJean-Baptiste Boric  * This code was written by Daniel Watt, Walter Deignan, Ryan Gabrys,
8*9f988b79SJean-Baptiste Boric  * Alan Perez-Rathke and Ram Vedam.
9*9f988b79SJean-Baptiste Boric  *
10*9f988b79SJean-Baptiste Boric  * Redistribution and use in source and binary forms, with or
11*9f988b79SJean-Baptiste Boric  * without modification, are permitted provided that the following
12*9f988b79SJean-Baptiste Boric  * conditions are met:
13*9f988b79SJean-Baptiste Boric  * 1. Redistributions of source code must retain the above copyright
14*9f988b79SJean-Baptiste Boric  *    notice, this list of conditions and the following disclaimer.
15*9f988b79SJean-Baptiste Boric  * 2. Redistributions in binary form must reproduce the above
16*9f988b79SJean-Baptiste Boric  *    copyright notice, this list of conditions and the following
17*9f988b79SJean-Baptiste Boric  *    disclaimer in the documentation and/or other materials provided
18*9f988b79SJean-Baptiste Boric  *    with the distribution.
19*9f988b79SJean-Baptiste Boric  *
20*9f988b79SJean-Baptiste Boric  * THIS SOFTWARE IS PROVIDED BY DANIEL WATT, WALTER DEIGNAN, RYAN
21*9f988b79SJean-Baptiste Boric  * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM ``AS IS'' AND ANY EXPRESS OR
22*9f988b79SJean-Baptiste Boric  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23*9f988b79SJean-Baptiste Boric  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24*9f988b79SJean-Baptiste Boric  * DISCLAIMED.  IN NO EVENT SHALL DANIEL WATT, WALTER DEIGNAN, RYAN
25*9f988b79SJean-Baptiste Boric  * GABRYS, ALAN PEREZ-RATHKE AND RAM VEDAM BE LIABLE FOR ANY DIRECT, INDIRECT,
26*9f988b79SJean-Baptiste Boric  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27*9f988b79SJean-Baptiste Boric  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
28*9f988b79SJean-Baptiste Boric  * USE,DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
29*9f988b79SJean-Baptiste Boric  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30*9f988b79SJean-Baptiste Boric  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31*9f988b79SJean-Baptiste Boric  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
32*9f988b79SJean-Baptiste Boric  * OF SUCH DAMAGE.
33*9f988b79SJean-Baptiste Boric  */
34*9f988b79SJean-Baptiste Boric 
35*9f988b79SJean-Baptiste Boric #ifndef _MAKEFS_CD9660_H
36*9f988b79SJean-Baptiste Boric #define _MAKEFS_CD9660_H
37*9f988b79SJean-Baptiste Boric 
38*9f988b79SJean-Baptiste Boric #if HAVE_NBTOOL_CONFIG_H
39*9f988b79SJean-Baptiste Boric #include "nbtool_config.h"
40*9f988b79SJean-Baptiste Boric #endif
41*9f988b79SJean-Baptiste Boric 
42*9f988b79SJean-Baptiste Boric #include <assert.h>
43*9f988b79SJean-Baptiste Boric #include <errno.h>
44*9f988b79SJean-Baptiste Boric #include <fcntl.h>
45*9f988b79SJean-Baptiste Boric #include <stdarg.h>
46*9f988b79SJean-Baptiste Boric #include <stdio.h>
47*9f988b79SJean-Baptiste Boric #include <stdlib.h>
48*9f988b79SJean-Baptiste Boric #include <string.h>
49*9f988b79SJean-Baptiste Boric #include <unistd.h>
50*9f988b79SJean-Baptiste Boric #include <time.h>
51*9f988b79SJean-Baptiste Boric #include <limits.h>
52*9f988b79SJean-Baptiste Boric #include <sys/queue.h>
53*9f988b79SJean-Baptiste Boric #include <sys/param.h>
54*9f988b79SJean-Baptiste Boric #include <sys/endian.h>
55*9f988b79SJean-Baptiste Boric 
56*9f988b79SJean-Baptiste Boric #include "makefs.h"
57*9f988b79SJean-Baptiste Boric #include "iso.h"
58*9f988b79SJean-Baptiste Boric #include "iso_rrip.h"
59*9f988b79SJean-Baptiste Boric #include "cd9660/cd9660_eltorito.h"
60*9f988b79SJean-Baptiste Boric 
61*9f988b79SJean-Baptiste Boric #ifdef DEBUG
62*9f988b79SJean-Baptiste Boric #define	INODE_WARNX(__x)	warnx __x
63*9f988b79SJean-Baptiste Boric #else /* DEBUG */
64*9f988b79SJean-Baptiste Boric #define	INODE_WARNX(__x)
65*9f988b79SJean-Baptiste Boric #endif /* DEBUG */
66*9f988b79SJean-Baptiste Boric 
67*9f988b79SJean-Baptiste Boric #define CD9660MAXPATH 4096
68*9f988b79SJean-Baptiste Boric 
69*9f988b79SJean-Baptiste Boric #define ISO_STRING_FILTER_NONE = 0x00
70*9f988b79SJean-Baptiste Boric #define ISO_STRING_FILTER_DCHARS = 0x01
71*9f988b79SJean-Baptiste Boric #define ISO_STRING_FILTER_ACHARS = 0x02
72*9f988b79SJean-Baptiste Boric 
73*9f988b79SJean-Baptiste Boric /*
74*9f988b79SJean-Baptiste Boric Extended preferences type, in the spirit of what makefs gives us (only ints)
75*9f988b79SJean-Baptiste Boric */
76*9f988b79SJean-Baptiste Boric typedef struct {
77*9f988b79SJean-Baptiste Boric 	const char  *shortName;		/* Short option */
78*9f988b79SJean-Baptiste Boric 	const char	*name;		/* option name */
79*9f988b79SJean-Baptiste Boric 	char		*value;		/* where to stuff the value */
80*9f988b79SJean-Baptiste Boric 	int		minLength;	/* minimum for value */
81*9f988b79SJean-Baptiste Boric 	int		maxLength;	/* maximum for value */
82*9f988b79SJean-Baptiste Boric 	const char	*desc;		/* option description */
83*9f988b79SJean-Baptiste Boric 	int		filterFlags;
84*9f988b79SJean-Baptiste Boric } string_option_t;
85*9f988b79SJean-Baptiste Boric 
86*9f988b79SJean-Baptiste Boric /******** STRUCTURES **********/
87*9f988b79SJean-Baptiste Boric 
88*9f988b79SJean-Baptiste Boric /*Defaults*/
89*9f988b79SJean-Baptiste Boric #define ISO_DEFAULT_VOLUMEID "MAKEFS_CD9660_IMAGE"
90*9f988b79SJean-Baptiste Boric #define ISO_DEFAULT_APPID "MAKEFS"
91*9f988b79SJean-Baptiste Boric #define ISO_DEFAULT_PUBLISHER "MAKEFS"
92*9f988b79SJean-Baptiste Boric #define ISO_DEFAULT_PREPARER "MAKEFS"
93*9f988b79SJean-Baptiste Boric 
94*9f988b79SJean-Baptiste Boric #define ISO_VOLUME_DESCRIPTOR_STANDARD_ID "CD001"
95*9f988b79SJean-Baptiste Boric #define ISO_VOLUME_DESCRIPTOR_BOOT 0
96*9f988b79SJean-Baptiste Boric #define ISO_VOLUME_DESCRIPTOR_PVD 1
97*9f988b79SJean-Baptiste Boric #define ISO_VOLUME_DESCRIPTOR_TERMINATOR 255
98*9f988b79SJean-Baptiste Boric 
99*9f988b79SJean-Baptiste Boric /*30 for name and extension, as well as version number and padding bit*/
100*9f988b79SJean-Baptiste Boric #define ISO_FILENAME_MAXLENGTH_BEFORE_VERSION 30
101*9f988b79SJean-Baptiste Boric #define ISO_FILENAME_MAXLENGTH	36
102*9f988b79SJean-Baptiste Boric #define ISO_FILENAME_MAXLENGTH_WITH_PADDING 37
103*9f988b79SJean-Baptiste Boric 
104*9f988b79SJean-Baptiste Boric #define ISO_FLAG_CLEAR 0x00
105*9f988b79SJean-Baptiste Boric #define ISO_FLAG_HIDDEN 0x01
106*9f988b79SJean-Baptiste Boric #define ISO_FLAG_DIRECTORY 0x02
107*9f988b79SJean-Baptiste Boric #define ISO_FLAG_ASSOCIATED 0x04
108*9f988b79SJean-Baptiste Boric #define ISO_FLAG_PERMISSIONS 0x08
109*9f988b79SJean-Baptiste Boric #define ISO_FLAG_RESERVED5 0x10
110*9f988b79SJean-Baptiste Boric #define ISO_FLAG_RESERVED6 0x20
111*9f988b79SJean-Baptiste Boric #define ISO_FLAG_FINAL_RECORD 0x40
112*9f988b79SJean-Baptiste Boric 
113*9f988b79SJean-Baptiste Boric #define ISO_PATHTABLE_ENTRY_BASESIZE 8
114*9f988b79SJean-Baptiste Boric 
115*9f988b79SJean-Baptiste Boric #define ISO_RRIP_DEFAULT_MOVE_DIR_NAME "RR_MOVED"
116*9f988b79SJean-Baptiste Boric #define RRIP_DEFAULT_MOVE_DIR_NAME ".rr_moved"
117*9f988b79SJean-Baptiste Boric 
118*9f988b79SJean-Baptiste Boric #define	CD9660_BLOCKS(__sector_size, __bytes)	\
119*9f988b79SJean-Baptiste Boric 	howmany((__bytes), (__sector_size))
120*9f988b79SJean-Baptiste Boric 
121*9f988b79SJean-Baptiste Boric #define CD9660_MEM_ALLOC_ERROR(_F)	\
122*9f988b79SJean-Baptiste Boric     err(EXIT_FAILURE, "%s, %s l. %d", _F, __FILE__, __LINE__)
123*9f988b79SJean-Baptiste Boric 
124*9f988b79SJean-Baptiste Boric #define CD9660_TYPE_FILE	0x01
125*9f988b79SJean-Baptiste Boric #define CD9660_TYPE_DIR		0x02
126*9f988b79SJean-Baptiste Boric #define CD9660_TYPE_DOT		0x04
127*9f988b79SJean-Baptiste Boric #define CD9660_TYPE_DOTDOT	0x08
128*9f988b79SJean-Baptiste Boric #define CD9660_TYPE_VIRTUAL	0x80
129*9f988b79SJean-Baptiste Boric 
130*9f988b79SJean-Baptiste Boric #define CD9660_INODE_HASH_SIZE	1024
131*9f988b79SJean-Baptiste Boric #define CD9660_SECTOR_SIZE	2048
132*9f988b79SJean-Baptiste Boric 
133*9f988b79SJean-Baptiste Boric #define CD9660_END_PADDING	150
134*9f988b79SJean-Baptiste Boric 
135*9f988b79SJean-Baptiste Boric /* Slight modification of the ISO structure in iso.h */
136*9f988b79SJean-Baptiste Boric typedef struct _iso_directory_record_cd9660 {
137*9f988b79SJean-Baptiste Boric 	u_char length			[ISODCL (1, 1)];	/* 711 */
138*9f988b79SJean-Baptiste Boric 	u_char ext_attr_length		[ISODCL (2, 2)];	/* 711 */
139*9f988b79SJean-Baptiste Boric 	u_char extent			[ISODCL (3, 10)];	/* 733 */
140*9f988b79SJean-Baptiste Boric 	u_char size			[ISODCL (11, 18)];	/* 733 */
141*9f988b79SJean-Baptiste Boric 	u_char date			[ISODCL (19, 25)];	/* 7 by 711 */
142*9f988b79SJean-Baptiste Boric 	u_char flags			[ISODCL (26, 26)];
143*9f988b79SJean-Baptiste Boric 	u_char file_unit_size		[ISODCL (27, 27)];	/* 711 */
144*9f988b79SJean-Baptiste Boric 	u_char interleave		[ISODCL (28, 28)];	/* 711 */
145*9f988b79SJean-Baptiste Boric 	u_char volume_sequence_number	[ISODCL (29, 32)];	/* 723 */
146*9f988b79SJean-Baptiste Boric 	u_char name_len			[ISODCL (33, 33)];	/* 711 */
147*9f988b79SJean-Baptiste Boric 	char name			[ISO_FILENAME_MAXLENGTH_WITH_PADDING];
148*9f988b79SJean-Baptiste Boric } iso_directory_record_cd9660;
149*9f988b79SJean-Baptiste Boric 
150*9f988b79SJean-Baptiste Boric /* TODO: Lots of optimization of this structure */
151*9f988b79SJean-Baptiste Boric typedef struct _cd9660node {
152*9f988b79SJean-Baptiste Boric 	u_char	type;/* Used internally */
153*9f988b79SJean-Baptiste Boric 	/* Tree structure */
154*9f988b79SJean-Baptiste Boric 	struct _cd9660node	*parent;	/* parent (NULL if root) */
155*9f988b79SJean-Baptiste Boric 	TAILQ_HEAD(cd9660_children_head, _cd9660node)	cn_children;
156*9f988b79SJean-Baptiste Boric 	TAILQ_ENTRY(_cd9660node)		cn_next_child;
157*9f988b79SJean-Baptiste Boric 
158*9f988b79SJean-Baptiste Boric 	struct _cd9660node *dot_record; /* For directories, used mainly in RRIP */
159*9f988b79SJean-Baptiste Boric 	struct _cd9660node *dot_dot_record;
160*9f988b79SJean-Baptiste Boric 
161*9f988b79SJean-Baptiste Boric 	fsnode		*node;		/* pointer to fsnode */
162*9f988b79SJean-Baptiste Boric 	struct _iso_directory_record_cd9660	*isoDirRecord;
163*9f988b79SJean-Baptiste Boric 	struct iso_extended_attributes	*isoExtAttributes;
164*9f988b79SJean-Baptiste Boric 
165*9f988b79SJean-Baptiste Boric 	/***** SIZE CALCULATION *****/
166*9f988b79SJean-Baptiste Boric 	/*already stored in isoDirRecord, but this is an int version, and will be
167*9f988b79SJean-Baptiste Boric 		copied to isoDirRecord on writing*/
168*9f988b79SJean-Baptiste Boric 	uint32_t fileDataSector;
169*9f988b79SJean-Baptiste Boric 
170*9f988b79SJean-Baptiste Boric 	/*
171*9f988b79SJean-Baptiste Boric 	 * same thing, though some notes:
172*9f988b79SJean-Baptiste Boric 	 * If a file, this is the file size
173*9f988b79SJean-Baptiste Boric 	 * If a directory, this is the size of all its children's
174*9f988b79SJean-Baptiste Boric 	 *	directory records
175*9f988b79SJean-Baptiste Boric 	 * plus necessary padding
176*9f988b79SJean-Baptiste Boric 	 */
177*9f988b79SJean-Baptiste Boric 	int64_t fileDataLength;
178*9f988b79SJean-Baptiste Boric 
179*9f988b79SJean-Baptiste Boric 	int64_t fileSectorsUsed;
180*9f988b79SJean-Baptiste Boric 	int fileRecordSize;/*copy of a variable, int for quicker calculations*/
181*9f988b79SJean-Baptiste Boric 
182*9f988b79SJean-Baptiste Boric 	/* Old name, used for renaming - needs to be optimized but low priority */
183*9f988b79SJean-Baptiste Boric 	char o_name [ISO_FILENAME_MAXLENGTH_WITH_PADDING];
184*9f988b79SJean-Baptiste Boric 
185*9f988b79SJean-Baptiste Boric 	/***** SPACE RESERVED FOR EXTENSIONS *****/
186*9f988b79SJean-Baptiste Boric 	/* For memory efficiency's sake - we should move this to a separate struct
187*9f988b79SJean-Baptiste Boric 		and point to null if not needed */
188*9f988b79SJean-Baptiste Boric 	/* For Rock Ridge */
189*9f988b79SJean-Baptiste Boric 	struct _cd9660node *rr_real_parent, *rr_relocated;
190*9f988b79SJean-Baptiste Boric 
191*9f988b79SJean-Baptiste Boric 	int64_t susp_entry_size;
192*9f988b79SJean-Baptiste Boric 	int64_t susp_dot_entry_size;
193*9f988b79SJean-Baptiste Boric 	int64_t susp_dot_dot_entry_size;
194*9f988b79SJean-Baptiste Boric 
195*9f988b79SJean-Baptiste Boric 	/* Continuation area stuff */
196*9f988b79SJean-Baptiste Boric 	int64_t susp_entry_ce_start;
197*9f988b79SJean-Baptiste Boric 	int64_t susp_dot_ce_start;
198*9f988b79SJean-Baptiste Boric 	int64_t susp_dot_dot_ce_start;
199*9f988b79SJean-Baptiste Boric 
200*9f988b79SJean-Baptiste Boric 	int64_t susp_entry_ce_length;
201*9f988b79SJean-Baptiste Boric 	int64_t susp_dot_ce_length;
202*9f988b79SJean-Baptiste Boric 	int64_t susp_dot_dot_ce_length;
203*9f988b79SJean-Baptiste Boric 
204*9f988b79SJean-Baptiste Boric 	/* Data to put at the end of the System Use field */
205*9f988b79SJean-Baptiste Boric 	int64_t su_tail_size;
206*9f988b79SJean-Baptiste Boric 	char *su_tail_data;
207*9f988b79SJean-Baptiste Boric 
208*9f988b79SJean-Baptiste Boric 	/*** PATH TABLE STUFF ***/
209*9f988b79SJean-Baptiste Boric 	int level;			/*depth*/
210*9f988b79SJean-Baptiste Boric 	int ptnumber;
211*9f988b79SJean-Baptiste Boric 	struct _cd9660node *ptnext, *ptprev, *ptlast;
212*9f988b79SJean-Baptiste Boric 
213*9f988b79SJean-Baptiste Boric 	/* SUSP entries */
214*9f988b79SJean-Baptiste Boric 	TAILQ_HEAD(susp_linked_list, ISO_SUSP_ATTRIBUTES) head;
215*9f988b79SJean-Baptiste Boric } cd9660node;
216*9f988b79SJean-Baptiste Boric 
217*9f988b79SJean-Baptiste Boric typedef struct _path_table_entry
218*9f988b79SJean-Baptiste Boric {
219*9f988b79SJean-Baptiste Boric 	u_char length[ISODCL (1, 1)];
220*9f988b79SJean-Baptiste Boric 	u_char extended_attribute_length[ISODCL (2, 2)];
221*9f988b79SJean-Baptiste Boric 	u_char first_sector[ISODCL (3, 6)];
222*9f988b79SJean-Baptiste Boric 	u_char parent_number[ISODCL (7, 8)];
223*9f988b79SJean-Baptiste Boric 	u_char name[ISO_FILENAME_MAXLENGTH_WITH_PADDING];
224*9f988b79SJean-Baptiste Boric } path_table_entry;
225*9f988b79SJean-Baptiste Boric 
226*9f988b79SJean-Baptiste Boric typedef struct _volume_descriptor
227*9f988b79SJean-Baptiste Boric {
228*9f988b79SJean-Baptiste Boric 	u_char *volumeDescriptorData; /*ALWAYS 2048 bytes long*/
229*9f988b79SJean-Baptiste Boric 	int64_t sector;
230*9f988b79SJean-Baptiste Boric 	struct _volume_descriptor *next;
231*9f988b79SJean-Baptiste Boric } volume_descriptor;
232*9f988b79SJean-Baptiste Boric 
233*9f988b79SJean-Baptiste Boric typedef struct _iso9660_disk {
234*9f988b79SJean-Baptiste Boric 	int sectorSize;
235*9f988b79SJean-Baptiste Boric 	struct iso_primary_descriptor		primaryDescriptor;
236*9f988b79SJean-Baptiste Boric 	struct iso_supplementary_descriptor	supplementaryDescriptor;
237*9f988b79SJean-Baptiste Boric 
238*9f988b79SJean-Baptiste Boric 	volume_descriptor *firstVolumeDescriptor;
239*9f988b79SJean-Baptiste Boric 
240*9f988b79SJean-Baptiste Boric 	cd9660node *rootNode;
241*9f988b79SJean-Baptiste Boric 
242*9f988b79SJean-Baptiste Boric 	/* Important sector numbers here */
243*9f988b79SJean-Baptiste Boric 	/* primaryDescriptor.type_l_path_table*/
244*9f988b79SJean-Baptiste Boric 	int64_t primaryBigEndianTableSector;
245*9f988b79SJean-Baptiste Boric 
246*9f988b79SJean-Baptiste Boric 	/* primaryDescriptor.type_m_path_table*/
247*9f988b79SJean-Baptiste Boric 	int64_t primaryLittleEndianTableSector;
248*9f988b79SJean-Baptiste Boric 
249*9f988b79SJean-Baptiste Boric 	/* primaryDescriptor.opt_type_l_path_table*/
250*9f988b79SJean-Baptiste Boric 	int64_t secondaryBigEndianTableSector;
251*9f988b79SJean-Baptiste Boric 
252*9f988b79SJean-Baptiste Boric 	/* primaryDescriptor.opt_type_m_path_table*/
253*9f988b79SJean-Baptiste Boric 	int64_t secondaryLittleEndianTableSector;
254*9f988b79SJean-Baptiste Boric 
255*9f988b79SJean-Baptiste Boric 	/* primaryDescriptor.path_table_size*/
256*9f988b79SJean-Baptiste Boric 	int pathTableLength;
257*9f988b79SJean-Baptiste Boric 	int64_t dataFirstSector;
258*9f988b79SJean-Baptiste Boric 
259*9f988b79SJean-Baptiste Boric 	int64_t totalSectors;
260*9f988b79SJean-Baptiste Boric 	/* OPTIONS GO HERE */
261*9f988b79SJean-Baptiste Boric 	int	isoLevel;
262*9f988b79SJean-Baptiste Boric 
263*9f988b79SJean-Baptiste Boric 	int include_padding_areas;
264*9f988b79SJean-Baptiste Boric 
265*9f988b79SJean-Baptiste Boric 	int follow_sym_links;
266*9f988b79SJean-Baptiste Boric 	int verbose_level;
267*9f988b79SJean-Baptiste Boric 	int displayHelp;
268*9f988b79SJean-Baptiste Boric 	int keep_bad_images;
269*9f988b79SJean-Baptiste Boric 
270*9f988b79SJean-Baptiste Boric 	/* SUSP options and variables */
271*9f988b79SJean-Baptiste Boric 	int64_t susp_continuation_area_start_sector;
272*9f988b79SJean-Baptiste Boric 	int64_t susp_continuation_area_size;
273*9f988b79SJean-Baptiste Boric 	int64_t susp_continuation_area_current_free;
274*9f988b79SJean-Baptiste Boric 
275*9f988b79SJean-Baptiste Boric 	int rock_ridge_enabled;
276*9f988b79SJean-Baptiste Boric 	/* Other Rock Ridge Variables */
277*9f988b79SJean-Baptiste Boric 	char *rock_ridge_renamed_dir_name;
278*9f988b79SJean-Baptiste Boric 	int rock_ridge_move_count;
279*9f988b79SJean-Baptiste Boric 	cd9660node *rr_moved_dir;
280*9f988b79SJean-Baptiste Boric 
281*9f988b79SJean-Baptiste Boric 	int archimedes_enabled;
282*9f988b79SJean-Baptiste Boric 	int chrp_boot;
283*9f988b79SJean-Baptiste Boric 
284*9f988b79SJean-Baptiste Boric 	/* Spec breaking options */
285*9f988b79SJean-Baptiste Boric 	u_char allow_deep_trees;
286*9f988b79SJean-Baptiste Boric 	u_char allow_start_dot;
287*9f988b79SJean-Baptiste Boric 	u_char allow_max_name; /* Allow 37 char filenames*/
288*9f988b79SJean-Baptiste Boric 	u_char allow_illegal_chars; /* ~, !, # */
289*9f988b79SJean-Baptiste Boric 	u_char allow_lowercase;
290*9f988b79SJean-Baptiste Boric 	u_char allow_multidot;
291*9f988b79SJean-Baptiste Boric 	u_char omit_trailing_period;
292*9f988b79SJean-Baptiste Boric 
293*9f988b79SJean-Baptiste Boric 	/* BOOT INFORMATION HERE */
294*9f988b79SJean-Baptiste Boric 	int has_generic_bootimage; /* Default to 0 */
295*9f988b79SJean-Baptiste Boric 	char *generic_bootimage;
296*9f988b79SJean-Baptiste Boric 
297*9f988b79SJean-Baptiste Boric 	int is_bootable;/* Default to 0 */
298*9f988b79SJean-Baptiste Boric 	int64_t boot_catalog_sector;
299*9f988b79SJean-Baptiste Boric 	boot_volume_descriptor *boot_descriptor;
300*9f988b79SJean-Baptiste Boric 	char * boot_image_directory;
301*9f988b79SJean-Baptiste Boric 
302*9f988b79SJean-Baptiste Boric 	TAILQ_HEAD(boot_image_list,cd9660_boot_image) boot_images;
303*9f988b79SJean-Baptiste Boric 	int image_serialno;
304*9f988b79SJean-Baptiste Boric 	LIST_HEAD(boot_catalog_entries,boot_catalog_entry) boot_entries;
305*9f988b79SJean-Baptiste Boric 
306*9f988b79SJean-Baptiste Boric } iso9660_disk;
307*9f988b79SJean-Baptiste Boric 
308*9f988b79SJean-Baptiste Boric /************ FUNCTIONS **************/
309*9f988b79SJean-Baptiste Boric int			cd9660_valid_a_chars(const char *);
310*9f988b79SJean-Baptiste Boric int			cd9660_valid_d_chars(const char *);
311*9f988b79SJean-Baptiste Boric void			cd9660_uppercase_characters(char *, int);
312*9f988b79SJean-Baptiste Boric 
313*9f988b79SJean-Baptiste Boric /* ISO Data Types */
314*9f988b79SJean-Baptiste Boric void			cd9660_721(uint16_t, unsigned char *);
315*9f988b79SJean-Baptiste Boric void			cd9660_731(uint32_t, unsigned char *);
316*9f988b79SJean-Baptiste Boric void			cd9660_722(uint16_t, unsigned char *);
317*9f988b79SJean-Baptiste Boric void			cd9660_732(uint32_t, unsigned char *);
318*9f988b79SJean-Baptiste Boric void 			cd9660_bothendian_dword(uint32_t dw, unsigned char *);
319*9f988b79SJean-Baptiste Boric void 			cd9660_bothendian_word(uint16_t dw, unsigned char *);
320*9f988b79SJean-Baptiste Boric void			cd9660_set_date(char *, time_t);
321*9f988b79SJean-Baptiste Boric void			cd9660_time_8426(unsigned char *, time_t);
322*9f988b79SJean-Baptiste Boric void			cd9660_time_915(unsigned char *, time_t);
323*9f988b79SJean-Baptiste Boric 
324*9f988b79SJean-Baptiste Boric /*** Boot Functions ***/
325*9f988b79SJean-Baptiste Boric int	cd9660_write_generic_bootimage(FILE *);
326*9f988b79SJean-Baptiste Boric int	cd9660_write_boot(iso9660_disk *, FILE *);
327*9f988b79SJean-Baptiste Boric int	cd9660_add_boot_disk(iso9660_disk *, const char *);
328*9f988b79SJean-Baptiste Boric int	cd9660_eltorito_add_boot_option(iso9660_disk *, const char *,
329*9f988b79SJean-Baptiste Boric     const char *);
330*9f988b79SJean-Baptiste Boric int	cd9660_setup_boot(iso9660_disk *, int);
331*9f988b79SJean-Baptiste Boric int	cd9660_setup_boot_volume_descriptor(iso9660_disk *,
332*9f988b79SJean-Baptiste Boric     volume_descriptor *);
333*9f988b79SJean-Baptiste Boric 
334*9f988b79SJean-Baptiste Boric 
335*9f988b79SJean-Baptiste Boric /*** Write Functions ***/
336*9f988b79SJean-Baptiste Boric int	cd9660_write_image(iso9660_disk *, const char *image);
337*9f988b79SJean-Baptiste Boric int	cd9660_copy_file(iso9660_disk *, FILE *, off_t, const char *);
338*9f988b79SJean-Baptiste Boric 
339*9f988b79SJean-Baptiste Boric void	cd9660_compute_full_filename(cd9660node *, char *);
340*9f988b79SJean-Baptiste Boric int	cd9660_compute_record_size(iso9660_disk *, cd9660node *);
341*9f988b79SJean-Baptiste Boric 
342*9f988b79SJean-Baptiste Boric /* Debugging functions */
343*9f988b79SJean-Baptiste Boric void	debug_print_tree(iso9660_disk *, cd9660node *,int);
344*9f988b79SJean-Baptiste Boric void	debug_print_path_tree(cd9660node *);
345*9f988b79SJean-Baptiste Boric void	debug_print_volume_descriptor_information(iso9660_disk *);
346*9f988b79SJean-Baptiste Boric void	debug_dump_to_xml_ptentry(path_table_entry *,int, int);
347*9f988b79SJean-Baptiste Boric void	debug_dump_to_xml_path_table(FILE *, off_t, int, int);
348*9f988b79SJean-Baptiste Boric void	debug_dump_to_xml(FILE *);
349*9f988b79SJean-Baptiste Boric int	debug_get_encoded_number(unsigned char *, int);
350*9f988b79SJean-Baptiste Boric void	debug_dump_integer(const char *, char *,int);
351*9f988b79SJean-Baptiste Boric void	debug_dump_string(const char *,unsigned char *,int);
352*9f988b79SJean-Baptiste Boric void	debug_dump_directory_record_9_1(unsigned char *);
353*9f988b79SJean-Baptiste Boric void	debug_dump_to_xml_volume_descriptor(unsigned char *,int);
354*9f988b79SJean-Baptiste Boric 
355*9f988b79SJean-Baptiste Boric void	cd9660_pad_string_spaces(char *, int);
356*9f988b79SJean-Baptiste Boric 
357*9f988b79SJean-Baptiste Boric #endif
358