2 * Header file mkisofs.h - assorted structure definitions and typecasts.
4 Written by Eric Youngdale (1993).
6 Copyright 1993 Yggdrasil Computing, Incorporated
8 Copyright (C) 2009 Free Software Foundation, Inc.
10 This program is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3, or (at your option)
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, see <http://www.gnu.org/licenses/>.
22 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
25 * $Id: mkisofs.h,v 1.20 1999/03/02 04:16:41 eric Exp $
33 /* This symbol is used to indicate that we do not have things like
34 symlinks, devices, and so forth available. Just files and dirs */
79 lstat (const char *filename
, struct stat
*buf
)
81 return stat (filename
, buf
);
86 #include <sys/types.h>
89 #if defined(HAVE_DIRENT_H)
91 # define NAMLEN(dirent) strlen((dirent)->d_name)
93 # define dirent direct
94 # define NAMLEN(dirent) (dirent)->d_namlen
95 # if defined(HAVE_SYS_NDIR_H)
96 # include <sys/ndir.h>
98 # if defined(HAVE_SYS_DIR_H)
101 # if defined(HAVE_NDIR_H)
106 #if defined(HAVE_STRING_H)
109 #if defined(HAVE_STRINGS_H)
115 extern char *strdup();
119 #define DECL(NAME,ARGS) NAME ARGS
120 #define FDECL1(NAME,TYPE0, ARG0) \
122 #define FDECL2(NAME,TYPE0, ARG0,TYPE1, ARG1) \
123 NAME(TYPE0 ARG0, TYPE1 ARG1)
124 #define FDECL3(NAME,TYPE0, ARG0,TYPE1, ARG1, TYPE2, ARG2) \
125 NAME(TYPE0 ARG0, TYPE1 ARG1, TYPE2 ARG2)
126 #define FDECL4(NAME,TYPE0, ARG0,TYPE1, ARG1, TYPE2, ARG2, TYPE3, ARG3) \
127 NAME(TYPE0 ARG0, TYPE1 ARG1, TYPE2 ARG2, TYPE3 ARG3)
128 #define FDECL5(NAME,TYPE0, ARG0,TYPE1, ARG1, TYPE2, ARG2, TYPE3, ARG3, TYPE4, ARG4) \
129 NAME(TYPE0 ARG0, TYPE1 ARG1, TYPE2 ARG2, TYPE3 ARG3, TYPE4 ARG4)
130 #define FDECL6(NAME,TYPE0, ARG0,TYPE1, ARG1, TYPE2, ARG2, TYPE3, ARG3, TYPE4, ARG4, TYPE5, ARG5) \
131 NAME(TYPE0 ARG0, TYPE1 ARG1, TYPE2 ARG2, TYPE3 ARG3, TYPE4 ARG4, TYPE5 ARG5)
133 #define DECL(NAME,ARGS) NAME()
134 #define FDECL1(NAME,TYPE0, ARG0) NAME(ARG0) TYPE0 ARG0;
135 #define FDECL2(NAME,TYPE0, ARG0,TYPE1, ARG1) NAME(ARG0, ARG1) TYPE0 ARG0; TYPE1 ARG1;
136 #define FDECL3(NAME,TYPE0, ARG0,TYPE1, ARG1, TYPE2, ARG2) \
137 NAME(ARG0, ARG1, ARG2) TYPE0 ARG0; TYPE1 ARG1; TYPE2 ARG2;
138 #define FDECL4(NAME,TYPE0, ARG0,TYPE1, ARG1, TYPE2, ARG2, TYPE3, ARG3) \
139 NAME(ARG0, ARG1, ARG2, ARG3, ARG4) TYPE0 ARG0; TYPE1 ARG1; TYPE2 ARG2; TYPE3 ARG3;
140 #define FDECL5(NAME,TYPE0, ARG0,TYPE1, ARG1, TYPE2, ARG2, TYPE3, ARG3, TYPE4, ARG4) \
141 NAME(ARG0, ARG1, ARG2, ARG3, ARG4) TYPE0 ARG0; TYPE1 ARG1; TYPE2 ARG2; TYPE3 ARG3; TYPE4 ARG4;
142 #define FDECL6(NAME,TYPE0, ARG0,TYPE1, ARG1, TYPE2, ARG2, TYPE3, ARG3, TYPE4, ARG4, TYPE5, ARG5) \
143 NAME(ARG0, ARG1, ARG2, ARG3, ARG4, ARG5) TYPE0 ARG0; TYPE1 ARG1; TYPE2 ARG2; TYPE3 ARG3; TYPE4 ARG4; TYPE5 ARG5;
153 /* extern int getopt (int __argc, char **__argv, char *__optstring); */
157 #include "defaults.h"
159 struct directory_entry
{
160 struct directory_entry
* next
;
161 struct directory_entry
* jnext
;
162 struct iso_directory_record isorec
;
163 uint64_t starting_block
;
165 unsigned short priority
;
166 unsigned char jreclen
; /* Joliet record len */
170 struct directory
* filedir
;
171 struct directory_entry
* parent_rec
;
172 unsigned int de_flags
;
173 ino_t inode
; /* Used in the hash table */
174 dev_t dev
; /* Used in the hash table */
175 unsigned char * rr_attributes
;
176 unsigned int rr_attr_size
;
177 unsigned int total_rr_attr_size
;
178 unsigned int got_rr_name
;
182 struct file_hash
* next
;
183 ino_t inode
; /* Used in the hash table */
184 dev_t dev
; /* Used in the hash table */
185 unsigned int starting_block
;
191 * This structure is used to control the output of fragments to the cdrom
192 * image. Everything that will be written to the output image will eventually
193 * go through this structure. There are two pieces - first is the sizing where
194 * we establish extent numbers for everything, and the second is when we actually
195 * generate the contents and write it to the output image.
197 * This makes it trivial to extend mkisofs to write special things in the image.
198 * All you need to do is hook an additional structure in the list, and the rest
201 * The three passes each do the following:
203 * The 'size' pass determines the size of each component and assigns the extent number
204 * for that component.
206 * The 'generate' pass will adjust the contents and pointers as required now that extent
207 * numbers are assigned. In some cases, the contents of the record are also generated.
209 * The 'write' pass actually writes the data to the disc.
211 struct output_fragment
213 struct output_fragment
* of_next
;
216 int (*of_generate
)(void);
217 int (*of_write
)(FILE *);
220 int (*of_generate
)();
225 extern struct output_fragment
* out_list
;
226 extern struct output_fragment
* out_tail
;
228 extern struct output_fragment padblock_desc
;
229 extern struct output_fragment voldesc_desc
;
230 extern struct output_fragment joliet_desc
;
231 extern struct output_fragment torito_desc
;
232 extern struct output_fragment end_vol
;
233 extern struct output_fragment pathtable_desc
;
234 extern struct output_fragment jpathtable_desc
;
235 extern struct output_fragment dirtree_desc
;
236 extern struct output_fragment dirtree_clean
;
237 extern struct output_fragment jdirtree_desc
;
238 extern struct output_fragment extension_desc
;
239 extern struct output_fragment files_desc
;
242 * This structure describes one complete directory. It has pointers
243 * to other directories in the overall tree so that it is clear where
244 * this directory lives in the tree, and it also must contain pointers
245 * to the contents of the directory. Note that subdirectories of this
246 * directory exist twice in this stucture. Once in the subdir chain,
247 * and again in the contents chain.
250 struct directory
* next
; /* Next directory at same level as this one */
251 struct directory
* subdir
; /* First subdirectory in this directory */
252 struct directory
* parent
;
253 struct directory_entry
* contents
;
254 struct directory_entry
* jcontents
;
255 struct directory_entry
* self
;
256 char * whole_name
; /* Entire path */
257 char * de_name
; /* Entire path */
258 unsigned int ce_bytes
; /* Number of bytes of CE entries reqd for this dir */
263 unsigned int jextent
;
264 unsigned short path_index
;
265 unsigned short jpath_index
;
266 unsigned short dir_flags
;
267 unsigned short dir_nlink
;
271 extern struct directory
* root
;
272 extern struct directory
* reloc_dir
;
273 extern uint64_t next_extent
;
274 extern uint64_t last_extent
;
275 extern uint64_t last_extent_written
;
276 extern uint64_t session_start
;
278 extern unsigned int path_table_size
;
279 extern unsigned int path_table
[4];
280 extern unsigned int path_blocks
;
281 extern char * path_table_l
;
282 extern char * path_table_m
;
284 extern unsigned int jpath_table_size
;
285 extern unsigned int jpath_table
[4];
286 extern unsigned int jpath_blocks
;
287 extern char * jpath_table_l
;
288 extern char * jpath_table_m
;
290 extern struct iso_directory_record root_record
;
291 extern struct iso_directory_record jroot_record
;
293 extern int use_eltorito
;
294 extern int use_eltorito_emul_floppy
;
295 extern int use_boot_info_table
;
296 extern int use_RockRidge
;
297 extern int use_Joliet
;
298 extern int rationalize
;
299 extern int follow_links
;
301 extern int all_files
;
302 extern int generate_tables
;
303 extern int print_size
;
304 extern int split_output
;
305 extern int omit_period
;
306 extern int omit_version_number
;
307 extern int transparent_compression
;
308 extern unsigned int RR_relocation_depth
;
309 extern int full_iso9660_filenames
;
310 extern int split_SL_component
;
311 extern int split_SL_field
;
314 extern int DECL(stat_filter
, (char *, struct stat
*));
315 extern int DECL(lstat_filter
, (char *, struct stat
*));
316 extern int DECL(sort_tree
,(struct directory
*));
317 extern struct directory
*
318 DECL(find_or_create_directory
,(struct directory
*, const char *,
319 struct directory_entry
* self
, int));
320 extern void DECL (finish_cl_pl_entries
, (void));
321 extern int DECL(scan_directory_tree
,(struct directory
* this_dir
,
323 struct directory_entry
* self
));
324 extern int DECL(insert_file_entry
,(struct directory
*, char *,
327 extern void DECL(generate_iso9660_directories
,(struct directory
*, FILE*));
328 extern void DECL(dump_tree
,(struct directory
* node
));
329 extern struct directory_entry
* DECL(search_tree_file
, (struct
330 directory
* node
,char * filename
));
331 extern void DECL(update_nlink_field
,(struct directory
* node
));
332 extern void DECL (init_fstatbuf
, (void));
333 extern struct stat root_statbuf
;
336 extern void DECL(init_boot_catalog
, (const char * path
));
337 extern void DECL(get_torito_desc
, (struct eltorito_boot_descriptor
* path
));
340 extern int DECL(get_731
,(char *));
341 extern int DECL(get_733
,(char *));
342 extern int DECL(isonum_733
,(unsigned char *));
343 extern void DECL(set_723
,(char *, unsigned int));
344 extern void DECL(set_731
,(char *, unsigned int));
345 extern void DECL(set_721
,(char *, unsigned int));
346 extern void DECL(set_733
,(char *, unsigned int));
347 extern int DECL(sort_directory
,(struct directory_entry
**));
348 extern void DECL(generate_one_directory
,(struct directory
*, FILE*));
349 extern void DECL(memcpy_max
, (char *, char *, int));
350 extern int DECL(oneblock_size
, (int starting_extent
));
351 extern struct iso_primary_descriptor vol_desc
;
352 extern void DECL(xfwrite
, (void * buffer
, uint64_t count
, uint64_t size
, FILE * file
));
353 extern void DECL(set_732
, (char * pnt
, unsigned int i
));
354 extern void DECL(set_722
, (char * pnt
, unsigned int i
));
355 extern void DECL(outputlist_insert
, (struct output_fragment
* frag
));
358 * Set by user command-line to override default date values
361 extern char *creation_date
;
362 extern char *modification_date
;
363 extern char *expiration_date
;
364 extern char *effective_date
;
368 extern FILE * in_image
;
369 extern struct iso_directory_record
*
370 DECL(merge_isofs
,(char * path
));
372 extern int DECL(free_mdinfo
, (struct directory_entry
**, int len
));
374 extern struct directory_entry
**
375 DECL(read_merging_directory
,(struct iso_directory_record
*, int*));
377 DECL(merge_remaining_entries
, (struct directory
*,
378 struct directory_entry
**, int));
380 DECL(merge_previous_session
, (struct directory
*,
381 struct iso_directory_record
*));
383 extern int DECL(get_session_start
, (int *));
386 int DECL(joliet_sort_tree
, (struct directory
* node
));
389 extern int DECL(matches
, (char *));
390 extern void DECL(add_match
, (char *));
393 struct dirent
* DECL(readdir_add_files
, (char **, char *, DIR *));
397 extern int DECL(iso9660_file_length
,(const char* name
,
398 struct directory_entry
* sresult
, int flag
));
399 extern int DECL(iso9660_date
,(char *, time_t));
400 extern void DECL(add_hash
,(struct directory_entry
*));
401 extern struct file_hash
* DECL(find_hash
,(dev_t
, ino_t
));
402 extern void DECL(add_directory_hash
,(dev_t
, ino_t
));
403 extern struct file_hash
* DECL(find_directory_hash
,(dev_t
, ino_t
));
404 extern void DECL (flush_file_hash
, (void));
405 extern int DECL(delete_file_hash
,(struct directory_entry
*));
406 extern struct directory_entry
* DECL(find_file_hash
,(char *));
407 extern void DECL(add_file_hash
,(struct directory_entry
*));
408 extern int DECL(generate_rock_ridge_attributes
,(char *, char *,
409 struct directory_entry
*,
410 struct stat
*, struct stat
*,
412 extern char * DECL(generate_rr_extension_record
,(char * id
, char * descriptor
,
413 char * source
, int * size
));
415 extern int DECL(check_prev_session
, (struct directory_entry
**, int len
,
416 struct directory_entry
*,
419 struct directory_entry
**));
424 extern int readsecs(int startsecno
, void *buffer
, int sectorcount
);
425 extern int scsidev_open(char *path
);
427 extern int readsecs();
428 extern int scsidev_open();
432 extern char * extension_record
;
433 extern int extension_record_extent
;
434 extern int n_data_extents
;
436 /* These are a few goodies that can be specified on the command line, and are
437 filled into the root record */
439 extern char * preparer
;
440 extern char * publisher
;
441 extern char * copyright
;
442 extern char * biblio
;
443 extern char * abstract
;
445 extern char * volset_id
;
446 extern char * system_id
;
447 extern char * volume_id
;
448 extern char * boot_catalog
;
449 extern char * boot_image
;
450 extern int volume_set_size
;
451 extern int volume_sequence_number
;
453 extern void * DECL(e_malloc
,(size_t));
456 #define SECTOR_SIZE (2048)
457 #define ROUND_UP(X) ((X + (SECTOR_SIZE - 1)) & ~(SECTOR_SIZE - 1))
465 #define PREV_SESS_DEV (sizeof(dev_t) >= 4 ? 0x7ffffffd : 0x7ffd)
466 #define TABLE_INODE (sizeof(ino_t) >= 4 ? 0x7ffffffe : 0x7ffe)
467 #define UNCACHED_INODE (sizeof(ino_t) >= 4 ? 0x7fffffff : 0x7fff)
468 #define UNCACHED_DEVICE (sizeof(dev_t) >= 4 ? 0x7fffffff : 0x7fff)
471 #define STAT_INODE(X) (X.st_ino[0])
472 #define PATH_SEPARATOR ']'
473 #define SPATH_SEPARATOR ""
475 #define STAT_INODE(X) (X.st_ino)
476 #define PATH_SEPARATOR '/'
477 #define SPATH_SEPARATOR "/"
481 * When using multi-session, indicates that we can reuse the
482 * TRANS.TBL information for this directory entry. If this flag
483 * is set for all entries in a directory, it means we can just
484 * reuse the TRANS.TBL and not generate a new one.
486 #define SAFE_TO_REUSE_TABLE_ENTRY 0x01
487 #define DIR_HAS_DOT 0x02
488 #define DIR_HAS_DOTDOT 0x04
489 #define INHIBIT_JOLIET_ENTRY 0x08
490 #define INHIBIT_RR_ENTRY 0x10
491 #define RELOCATED_DIRECTORY 0x20
492 #define INHIBIT_ISO9660_ENTRY 0x40
495 * Volume sequence number to use in all of the iso directory records.
500 * Make sure we have a definition for this. If not, take a very conservative
501 * guess. From what I can tell SunOS is the only one with this trouble.
505 #define NAME_MAX FILENAME_MAX