[MKISOFS]
[reactos.git] / reactos / sdk / tools / mkisofs / schilytools / mkisofs / mkisofs.h
1 /* @(#)mkisofs.h 1.150 16/10/10 joerg */
2 /*
3 * Header file mkisofs.h - assorted structure definitions and typecasts.
4 *
5 * Written by Eric Youngdale (1993).
6 *
7 * Copyright 1993 Yggdrasil Computing, Incorporated
8 * Copyright (c) 1999,2000-2016 J. Schilling
9 *
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 2, or (at your option)
13 * any later version.
14 *
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.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 */
24
25 /* APPLE_HYB James Pearson j.pearson@ge.ucl.ac.uk 23/2/2000 */
26
27 #include <schily/mconfig.h> /* Must be before stdio.h for LARGEFILE support */
28 #include <schily/stdio.h>
29 #include <schily/types.h>
30 #include <schily/time.h>
31 #include <schily/stat.h>
32 #include <schily/stdlib.h>
33 #include <schily/unistd.h> /* Needed for for LARGEFILE support */
34 #include <schily/string.h>
35 #include <schily/dirent.h>
36 #include <schily/utypes.h>
37 #include <schily/standard.h>
38 #include <schily/nlsdefs.h>
39 #include <schily/ctype.h>
40 #include <schily/libport.h> /* Define missing prototypes */
41 #include "scsi.h"
42
43 #ifdef DVD_AUD_VID
44 #ifndef UDF
45 #define UDF
46 #endif
47 #endif
48
49 #ifdef USE_LARGEFILES
50 /*
51 * XXX Hack until fseeko()/ftello() are available everywhere or until
52 * XXX we know a secure way to let autoconf ckeck for fseeko()/ftello()
53 * XXX without defining FILE_OFFSETBITS to 64 in confdefs.h
54 */
55 # define fseek fseeko
56 # define ftell ftello
57 #endif
58
59 #ifndef HAVE_LSTAT
60 #ifndef VMS
61 #define lstat stat
62 #endif
63 #endif
64
65 #include "iso9660.h"
66 #include "defaults.h"
67 #include <schily/siconv.h>
68
69 extern siconvt_t *in_nls; /* input UNICODE conversion table */
70 extern siconvt_t *out_nls; /* output UNICODE conversion table */
71 extern siconvt_t *hfs_inls; /* input HFS UNICODE conversion table */
72 extern siconvt_t *hfs_onls; /* output HFS UNICODE conversion table */
73
74 /*
75 * Structure used to pass arguments via trewalk() to walkfun().
76 */
77 struct wargs {
78 void *dir; /* Pointer to struct directory *root */
79 char *name; /* NULL or alternative short name */
80 };
81
82 #ifdef APPLE_HYB
83 #include "mactypes.h"
84 #include "hfs.h"
85
86 struct hfs_info {
87 unsigned char finderinfo[32];
88 char name[HFS_MAX_FLEN + 1];
89 /* should have fields for dates here as well */
90 char *keyname;
91 struct hfs_info *next;
92 };
93
94 #endif /* APPLE_HYB */
95
96 /*
97 * Our version of "struct timespec".
98 * Currently only used with UDF.
99 */
100 typedef struct timesp {
101 time_t tv_sec;
102 Int32_t tv_nsec;
103 } timesp;
104
105 struct directory_entry {
106 struct directory_entry *next;
107 struct directory_entry *jnext;
108 struct iso_directory_record isorec;
109 unsigned int starting_block;
110 off_t size;
111 int mxpart; /* Extent number */
112 unsigned short priority;
113 unsigned char jreclen; /* Joliet record len */
114 char *name;
115 char *table;
116 char *whole_name;
117 struct directory *filedir;
118 struct directory_entry *parent_rec;
119 struct directory_entry *mxroot; /* Pointer to orig entry */
120 unsigned int de_flags;
121 #ifdef UDF
122 mode_t mode; /* used for udf */
123 dev_t rdev; /* used for udf devices */
124 uid_t uid; /* used for udf */
125 gid_t gid; /* used for udf */
126 timesp atime; /* timespec for atime */
127 timesp mtime; /* timespec for mtime */
128 timesp ctime; /* timespec for ctime */
129 #endif
130 ino_t inode; /* Used in the hash table */
131 dev_t dev; /* Used in the hash table */
132 unsigned char *rr_attributes;
133 unsigned int rr_attr_size;
134 unsigned int total_rr_attr_size;
135 unsigned int got_rr_name;
136 #ifdef APPLE_HYB
137 struct directory_entry *assoc; /* entry has a resource fork */
138 hfsdirent *hfs_ent; /* HFS parameters */
139 off_t hfs_off; /* offset to real start of fork */
140 int hfs_type; /* type of HFS Unix file */
141 #endif /* APPLE_HYB */
142 #ifdef SORTING
143 int sort; /* sort weight for entry */
144 #endif /* SORTING */
145 #ifdef UDF
146 int udf_file_entry_sector; /* also used as UDF unique ID */
147 #endif
148 };
149
150 struct file_hash {
151 struct file_hash *next;
152 ino_t inode; /* Used in the hash table */
153 dev_t dev; /* Used in the hash table */
154 nlink_t nlink; /* Used to compute new link count */
155 unsigned int starting_block;
156 off_t size;
157 #ifdef SORTING
158 struct directory_entry *de;
159 #endif /* SORTING */
160 };
161
162
163 /*
164 * This structure is used to control the output of fragments to the cdrom
165 * image. Everything that will be written to the output image will eventually
166 * go through this structure. There are two pieces - first is the sizing where
167 * we establish extent numbers for everything, and the second is when we actually
168 * generate the contents and write it to the output image.
169 *
170 * This makes it trivial to extend mkisofs to write special things in the image.
171 * All you need to do is hook an additional structure in the list, and the rest
172 * works like magic.
173 *
174 * The three passes each do the following:
175 *
176 * The 'size' pass determines the size of each component and assigns the extent number
177 * for that component.
178 *
179 * The 'generate' pass will adjust the contents and pointers as required now that extent
180 * numbers are assigned. In some cases, the contents of the record are also generated.
181 *
182 * The 'write' pass actually writes the data to the disc.
183 */
184 struct output_fragment {
185 struct output_fragment *of_next;
186 int (*of_size) __PR((UInt32_t));
187 int (*of_generate) __PR((void));
188 int (*of_write) __PR((FILE *));
189 char *of_name; /* Textual description */
190 unsigned int of_start_extent; /* For consist check */
191 };
192
193 extern struct output_fragment *out_list;
194 extern struct output_fragment *out_tail;
195
196 extern struct output_fragment startpad_desc;
197 extern struct output_fragment voldesc_desc;
198 extern struct output_fragment xvoldesc_desc;
199 extern struct output_fragment joliet_desc;
200 extern struct output_fragment torito_desc;
201 extern struct output_fragment end_vol;
202 extern struct output_fragment version_desc;
203 extern struct output_fragment pathtable_desc;
204 extern struct output_fragment jpathtable_desc;
205 extern struct output_fragment dirtree_desc;
206 extern struct output_fragment dirtree_clean;
207 extern struct output_fragment jdirtree_desc;
208 extern struct output_fragment extension_desc;
209 extern struct output_fragment files_desc;
210 extern struct output_fragment interpad_desc;
211 extern struct output_fragment endpad_desc;
212 extern struct output_fragment sunboot_desc;
213 extern struct output_fragment sunlabel_desc;
214 extern struct output_fragment genboot_desc;
215 extern struct output_fragment strfile_desc;
216 extern struct output_fragment strdir_desc;
217 extern struct output_fragment strpath_desc;
218
219 #ifdef APPLE_HYB
220 extern struct output_fragment hfs_desc;
221
222 #endif /* APPLE_HYB */
223 #ifdef DVD_AUD_VID
224 /*
225 * This structure holds the information necessary to create a valid
226 * DVD-Video image. Basically it's how much to pad the files so the
227 * file offsets described in the video_ts.ifo and vts_xx_0.ifo are
228 * the correct one in the image that we create.
229 */
230 typedef struct {
231 int realsize_ifo;
232 int realsize_menu;
233 int realsize_bup;
234 int size_ifo;
235 int size_menu;
236 int size_title;
237 int size_bup;
238 int pad_ifo;
239 int pad_menu;
240 int pad_title;
241 int pad_bup;
242 int number_of_vob_files;
243 int realsize_vob[10];
244 } title_set_t;
245
246 typedef struct {
247 int num_titles;
248 title_set_t *title_set;
249 } title_set_info_t;
250 #endif /* DVD_AUD_VID */
251
252 /*
253 * This structure describes one complete directory. It has pointers
254 * to other directories in the overall tree so that it is clear where
255 * this directory lives in the tree, and it also must contain pointers
256 * to the contents of the directory. Note that subdirectories of this
257 * directory exist twice in this stucture. Once in the subdir chain,
258 * and again in the contents chain.
259 */
260 struct directory {
261 struct directory *next; /* Next directory at same level as this one */
262 struct directory *subdir; /* First subdirectory in this directory */
263 struct directory *parent;
264 struct directory_entry *contents;
265 struct directory_entry *jcontents;
266 struct directory_entry *self;
267 char *whole_name; /* Entire source path */
268 char *de_path; /* Entire path iside ISO-9660 */
269 char *de_name; /* Last path name component */
270 unsigned int ce_bytes; /* Number of bytes of CE entries read */
271 /* for this dir */
272 unsigned int depth;
273 unsigned int size;
274 unsigned int extent;
275 unsigned int jsize;
276 unsigned int jextent;
277 unsigned int path_index;
278 unsigned int jpath_index;
279 unsigned short dir_flags;
280 unsigned short dir_nlink;
281 #ifdef APPLE_HYB
282 hfsdirent *hfs_ent; /* HFS parameters */
283 struct hfs_info *hfs_info; /* list of info for all entries in dir */
284 #endif /* APPLE_HYB */
285 #ifdef SORTING
286 int sort; /* sort weight for child files */
287 #endif /* SORTING */
288 };
289
290 struct deferred_write {
291 struct deferred_write *next;
292 char *table;
293 unsigned int extent;
294 off_t size;
295 char *name;
296 struct directory_entry *s_entry;
297 unsigned int pad;
298 off_t off;
299 unsigned int dw_flags;
300 #ifdef APPLE_HYB
301 int hfstype;
302 #endif
303 };
304
305 struct eltorito_boot_entry_info {
306 struct eltorito_boot_entry_info *next;
307 char *boot_image;
308 int not_bootable;
309 int no_emul_boot;
310 int hard_disk_boot;
311 int boot_info_table;
312 int load_size;
313 int load_addr;
314
315 #define ELTORITO_BOOT_ID 1
316 #define ELTORITO_SECTION_HEADER 2
317 int type;
318 /*
319 * Valid if (type & ELTORITO_BOOT_ID) != 0
320 */
321 int boot_platform;
322
323 };
324
325 typedef struct ldate {
326 time_t l_sec;
327 int l_usec;
328 int l_gmtoff;
329 } ldate;
330
331 extern int goof;
332 extern struct directory *root;
333 extern struct directory *reloc_dir;
334 extern UInt32_t next_extent;
335 extern UInt32_t last_extent;
336 extern UInt32_t last_extent_written;
337 extern UInt32_t session_start;
338
339 extern unsigned int path_table_size;
340 extern unsigned int path_table[4];
341 extern unsigned int path_blocks;
342 extern char *path_table_l;
343 extern char *path_table_m;
344
345 extern unsigned int jpath_table_size;
346 extern unsigned int jpath_table[4];
347 extern unsigned int jpath_blocks;
348 extern char *jpath_table_l;
349 extern char *jpath_table_m;
350
351 extern struct iso_directory_record root_record;
352 extern struct iso_directory_record jroot_record;
353
354 extern int check_oldnames;
355 extern int check_session;
356 extern int use_eltorito;
357 extern int hard_disk_boot;
358 extern int not_bootable;
359 extern int no_emul_boot;
360 extern int load_addr;
361 extern int load_size;
362 extern int boot_info_table;
363 extern int use_RockRidge;
364 extern int osecsize;
365 extern int use_XA;
366 extern int use_Joliet;
367 extern int rationalize;
368 extern int rationalize_uid;
369 extern int rationalize_gid;
370 extern int rationalize_filemode;
371 extern int rationalize_dirmode;
372 extern uid_t uid_to_use;
373 extern gid_t gid_to_use;
374 extern int filemode_to_use;
375 extern int dirmode_to_use;
376 extern int new_dir_mode;
377 extern int follow_links;
378 extern int cache_inodes;
379 extern int verbose;
380 extern int debug;
381 extern int gui;
382 extern int all_files;
383 extern int generate_tables;
384 extern int print_size;
385 extern int split_output;
386 extern int use_graft_ptrs;
387 extern int jhide_trans_tbl;
388 extern int hide_rr_moved;
389 extern int omit_period;
390 extern int omit_version_number;
391 extern int no_rr;
392 extern int transparent_compression;
393 extern Uint RR_relocation_depth;
394 extern int do_largefiles;
395 extern off_t maxnonlarge;
396 extern int iso9660_level;
397 extern int iso9660_namelen;
398 extern int full_iso9660_filenames;
399 extern int nolimitpathtables;
400 extern int relaxed_filenames;
401 extern int allow_lowercase;
402 extern int allow_multidot;
403 extern int iso_translate;
404 extern int allow_leading_dots;
405 extern int use_fileversion;
406 extern int split_SL_component;
407 extern int split_SL_field;
408 extern char *trans_tbl;
409
410 #define JMAX 64 /* maximum Joliet file name length (spec) */
411 #define JLONGMAX 103 /* out of spec Joliet file name length */
412 extern int jlen; /* selected maximum Joliet file name length */
413
414 #ifdef DVD_AUD_VID
415
416 #define DVD_SPEC_NONE 0x0
417 #define DVD_SPEC_VIDEO 0x1
418 #define DVD_SPEC_AUDIO 0x2
419 #define DVD_SPEC_HYBRD (DVD_SPEC_VIDEO | DVD_SPEC_AUDIO)
420 extern int dvd_audio;
421 extern int dvd_hybrid;
422 extern int dvd_video;
423 extern int dvd_aud_vid_flag;
424 #endif /* DVD_AUD_VID */
425
426
427 extern int donotwrite_macpart;
428
429 #ifdef APPLE_HYB
430 extern int apple_hyb; /* create HFS hybrid */
431 extern int apple_ext; /* use Apple extensions */
432 extern int apple_both; /* common flag (for above) */
433 extern int hfs_extra; /* extra ISO extents (hfs_ce_size) */
434 extern hce_mem *hce; /* libhfs/mkisofs extras */
435 extern int use_mac_name; /* use Mac name for ISO9660/Joliet/RR */
436 extern int create_dt; /* create the Desktp files */
437 extern char *hfs_boot_file; /* name of HFS boot file */
438 extern char *magic_file; /* magic file for CREATOR/TYPE matching */
439 extern int hfs_last; /* order in which to process map/magic files */
440 extern char *deftype; /* default Apple TYPE */
441 extern char *defcreator; /* default Apple CREATOR */
442 extern int gen_pt; /* generate HFS partition table */
443 extern char *autoname; /* Autostart filename */
444 extern int afe_size; /* Apple File Exchange block size */
445 extern char *hfs_volume_id; /* HFS volume ID */
446 extern int icon_pos; /* Keep Icon position */
447 extern int hfs_lock; /* lock HFS volume (read-only) */
448 extern char *hfs_bless; /* name of folder to 'bless' (System Folder) */
449 extern char *hfs_parms; /* low level HFS parameters */
450
451 #define MAP_LAST 1 /* process magic then map file */
452 #define MAG_LAST 2 /* process map then magic file */
453
454 #ifndef PREP_BOOT
455 #define PREP_BOOT
456 #endif /* PREP_BOOT */
457
458 #ifdef PREP_BOOT
459 extern char *prep_boot_image[4];
460 extern int use_prep_boot;
461 extern int use_chrp_boot;
462
463 #endif /* PREP_BOOT */
464 #endif /* APPLE_HYB */
465
466 #ifdef SORTING
467 extern int do_sort;
468 #endif /* SORTING */
469
470 /* tree.c */
471 extern int stat_filter __PR((char *, struct stat *));
472 extern int lstat_filter __PR((char *, struct stat *));
473 extern int sort_tree __PR((struct directory *));
474 extern void attach_dot_entries __PR((struct directory * dirnode,
475 struct stat * this_stat,
476 struct stat * parent_stat));
477 extern struct directory *
478 find_or_create_directory __PR((struct directory *,
479 char *,
480 struct directory_entry * self, int));
481 extern void finish_cl_pl_entries __PR((void));
482 extern int scan_directory_tree __PR((struct directory * this_dir,
483 char *path,
484 struct directory_entry * self));
485
486 extern int insert_file_entry __PR((struct directory *, char *,
487 char *, struct stat *, int));
488
489 extern struct directory_entry *
490 dup_directory_entry __PR((struct directory_entry *s_entry));
491 extern void generate_iso9660_directories __PR((struct directory *, FILE *));
492 extern void dump_tree __PR((struct directory * node));
493 extern struct directory_entry *search_tree_file __PR((struct
494 directory * node, char *filename));
495 extern void init_fstatbuf __PR((void));
496 extern struct stat root_statbuf;
497 extern struct stat fstatbuf;
498
499 /* eltorito.c */
500 extern void init_boot_catalog __PR((const char *path));
501 extern void insert_boot_cat __PR((void));
502 extern void get_boot_entry __PR((void));
503 extern int new_boot_entry __PR((void));
504 extern void ex_boot_enoent __PR((char *msg, char *pname));
505
506 /* boot.c */
507 extern int sparc_boot_label __PR((char *label));
508 extern int sunx86_boot_label __PR((char *label));
509 extern int scan_sparc_boot __PR((char *files));
510 extern int scan_sunx86_boot __PR((char *files));
511 extern int make_sun_label __PR((void));
512 extern int make_sunx86_label __PR((void));
513
514 /* isonum.c */
515 extern void set_721 __PR((void *, UInt32_t));
516 extern void set_722 __PR((void *, UInt32_t));
517 extern void set_723 __PR((void *, UInt32_t));
518 extern void set_731 __PR((void *, UInt32_t));
519 extern void set_732 __PR((void *, UInt32_t));
520 extern void set_733 __PR((void *, UInt32_t));
521
522 extern UInt32_t get_711 __PR((void *));
523 extern UInt32_t get_721 __PR((void *));
524 extern UInt32_t get_723 __PR((void *));
525 extern UInt32_t get_731 __PR((void *));
526 extern UInt32_t get_732 __PR((void *));
527 extern UInt32_t get_733 __PR((void *));
528
529 /* write.c */
530 extern int sort_directory __PR((struct directory_entry **, int));
531 extern void generate_one_directory __PR((struct directory *, FILE *));
532 extern void memcpy_max __PR((char *, char *, int));
533 extern int oneblock_size __PR((UInt32_t starting_extent));
534 extern struct iso_primary_descriptor vol_desc;
535 extern void xfwrite __PR((void *buffer, int size, int count, FILE * file, int submode, BOOL islast));
536 extern void outputlist_insert __PR((struct output_fragment * frag));
537
538 #ifdef APPLE_HYB
539 extern Ulong get_adj_size __PR((int Csize));
540 extern int adj_size __PR((int Csize, UInt32_t start_extent, int extra));
541 extern void adj_size_other __PR((struct directory * dpnt));
542 extern int insert_padding_file __PR((int size));
543 extern int gen_mac_label __PR((struct deferred_write *));
544
545 #ifdef PREP_BOOT
546 extern void gen_prepboot_label __PR((unsigned char *));
547
548 #endif /* PREP_BOOT */
549 #endif /* APPLE_HYB */
550
551 /* multi.c */
552
553 extern FILE *in_image;
554 extern BOOL ignerr;
555 extern int open_merge_image __PR((char *path));
556 extern int close_merge_image __PR((void));
557 extern struct iso_directory_record *
558 merge_isofs __PR((char *path));
559 extern unsigned char *parse_xa __PR((unsigned char *pnt, int *lenp,
560 struct directory_entry * dpnt));
561 extern int rr_flags __PR((struct iso_directory_record *idr));
562 extern int merge_previous_session __PR((struct directory *,
563 struct iso_directory_record *, char *, char *));
564 extern int get_session_start __PR((int *));
565
566 /* joliet.c */
567 #ifdef UDF
568 extern void convert_to_unicode __PR((unsigned char *buffer,
569 int size, char *source, siconvt_t *inls));
570 extern int joliet_strlen __PR((const char *string, size_t maxlen,
571 siconvt_t *inls));
572 #endif
573 extern void conv_charset __PR((unsigned char *to, size_t *tosizep,
574 unsigned char *from, size_t *fromsizep,
575 siconvt_t *,
576 siconvt_t *));
577 extern int joliet_sort_tree __PR((struct directory * node));
578
579 /* match.c */
580 extern int matches __PR((char *));
581 extern int add_match __PR((char *));
582
583 /* files.c */
584 struct dirent *readdir_add_files __PR((char **, char *, DIR *));
585
586 /* name.c */
587
588 extern void iso9660_check __PR((struct iso_directory_record *idr, struct directory_entry *ndr));
589 extern int iso9660_file_length __PR((const char *name,
590 struct directory_entry * sresult, int flag));
591
592 /* various */
593 extern int iso9660_date __PR((char *, time_t));
594 extern int iso9660_ldate __PR((char *, time_t, int, int));
595 extern void add_hash __PR((struct directory_entry *));
596 extern struct file_hash *find_hash __PR((dev_t, ino_t));
597
598 extern void flush_hash __PR((void));
599 extern void add_directory_hash __PR((dev_t, ino_t));
600 extern struct file_hash *find_directory_hash __PR((dev_t, ino_t));
601 extern void flush_file_hash __PR((void));
602 extern int delete_file_hash __PR((struct directory_entry *));
603 extern struct directory_entry *find_file_hash __PR((char *));
604 extern void add_file_hash __PR((struct directory_entry *));
605
606 extern int generate_xa_rr_attributes __PR((char *, char *,
607 struct directory_entry *,
608 struct stat *, struct stat *,
609 int deep_flag));
610 extern char *generate_rr_extension_record __PR((char *id,
611 char *descriptor,
612 char *source, int *size));
613
614 extern int check_prev_session __PR((struct directory_entry **, int len,
615 struct directory_entry *,
616 struct stat *,
617 struct stat *,
618 struct directory_entry **));
619
620 extern void match_cl_re_entries __PR((void));
621 extern void finish_cl_pl_for_prev_session __PR((void));
622 extern char *find_rr_attribute __PR((unsigned char *pnt, int len, char *attr_type));
623
624 extern void udf_set_extattr_macresfork __PR((unsigned char *buf, off_t size, unsigned rba));
625 extern void udf_set_extattr_freespace __PR((unsigned char *buf, off_t size, unsigned rba));
626 extern int udf_get_symlinkcontents __PR((char *, char *, off_t *));
627
628 /* inode.c */
629 extern void do_inode __PR((struct directory *dpnt));
630 extern void do_dir_nlink __PR((struct directory *dpnt));
631
632 #ifdef APPLE_HYB
633 /* volume.c */
634 extern int make_mac_volume __PR((struct directory * dpnt, UInt32_t start_extent));
635 extern int write_fork __PR((hfsfile * hfp, long tot));
636
637 /* apple.c */
638
639 extern void del_hfs_info __PR((struct hfs_info *));
640 extern int get_hfs_dir __PR((char *, char *, struct directory_entry *));
641 extern int get_hfs_info __PR((char *, char *, struct directory_entry *));
642 extern int get_hfs_rname __PR((char *, char *, char *));
643 extern int hfs_exclude __PR((char *));
644 extern void print_hfs_info __PR((struct directory_entry *));
645 extern void hfs_init __PR((char *, unsigned short, unsigned int));
646 extern void delete_rsrc_ent __PR((struct directory_entry *));
647 extern void clean_hfs __PR((void));
648 extern void perr __PR((char *));
649 extern void set_root_info __PR((char *));
650 extern int file_is_resource __PR((char *fname, int hfstype));
651 extern int hfs_excludepath __PR((char *));
652
653 /* desktop.c */
654
655 extern int make_desktop __PR((hfsvol *, int));
656
657 /* mac_label.c */
658
659 #ifdef _MAC_LABEL_H
660 #ifdef PREP_BOOT
661 extern void gen_prepboot_label __PR((MacLabel * mac_label));
662 #endif
663 extern int gen_mac_label __PR((defer *));
664 #endif
665 extern int autostart __PR((void));
666
667 /* libfile */
668
669 extern char *get_magic_match __PR((const char *));
670 extern void clean_magic __PR((void));
671
672 #endif /* APPLE_HYB */
673
674 #ifdef USE_FIND
675 /*
676 * The callback function for treewalk() from walk.c
677 */
678 #ifdef _SCHILY_WALK_H
679 EXPORT int walkfunc __PR((char *nm, struct stat *fs, int type,
680 struct WALK *state));
681 #endif
682 #endif
683
684 extern char *extension_record;
685 extern UInt32_t extension_record_extent;
686 /*extern int n_data_extents;*/
687 extern BOOL archive_isreg;
688 extern dev_t archive_dev;
689 extern ino_t archive_ino;
690
691 /*
692 * These are a few goodies that can be specified on the command line, and are
693 * filled into the root record
694 */
695 extern char *preparer;
696 extern char *publisher;
697 extern char *copyright;
698 extern char *biblio;
699 extern char *abstract;
700 extern char *appid;
701 extern char *volset_id;
702 extern char *system_id;
703 extern char *volume_id;
704 extern char *boot_catalog;
705 extern char *boot_image;
706 extern char *genboot_image;
707 extern int ucs_level;
708 extern int volume_set_size;
709 extern int volume_sequence_number;
710
711 extern struct eltorito_boot_entry_info *first_boot_entry;
712 extern struct eltorito_boot_entry_info *last_boot_entry;
713 extern struct eltorito_boot_entry_info *current_boot_entry;
714
715 extern UInt32_t null_inodes;
716 extern BOOL correct_inodes;
717 extern BOOL rrip112;
718 extern BOOL long_rr_time; /* TRUE: use long (17 Byte) time format */
719
720 extern char *findgequal __PR((char *));
721 extern void *e_malloc __PR((size_t));
722 extern char *e_strdup __PR((const char *));
723
724 /*
725 * Note: always use these macros to avoid problems.
726 *
727 * ISO_ROUND_UP(X) may cause an integer overflow and thus give
728 * incorrect results. So avoid it if possible.
729 *
730 * ISO_BLOCKS(X) is overflow safe. Prefer this when ever it is possible.
731 */
732 #define SECTOR_SIZE (2048)
733 #define ISO_ROUND_UP(X) (((X) + (SECTOR_SIZE - 1)) & ~(SECTOR_SIZE - 1))
734 #define ISO_BLOCKS(X) (((X) / SECTOR_SIZE) + (((X)%SECTOR_SIZE)?1:0))
735
736 #define ROUND_UP(X, Y) (((X + (Y - 1)) / Y) * Y)
737
738 #ifdef APPLE_HYB
739 /*
740 * ISO blocks == 2048, HFS blocks == 512
741 */
742 #define HFS_BLK_CONV (SECTOR_SIZE/HFS_BLOCKSZ)
743
744 #define HFS_ROUND_UP(X) ISO_ROUND_UP(((X)*HFS_BLOCKSZ)) /* XXX ??? */
745 #define HFS_BLOCKS(X) (ISO_BLOCKS(X) * HFS_BLK_CONV)
746
747 #define USE_MAC_NAME(E) (use_mac_name && ((E)->hfs_ent != NULL) && (E)->hfs_type)
748 #endif /* APPLE_HYB */
749
750 /*
751 * Inode and device values for special purposes.
752 */
753 #define PREV_SESS_DEV ((dev_t)-2)
754 #define TABLE_INODE ((ino_t)-2)
755 #define UNCACHED_INODE ((ino_t)-1)
756 #define UNCACHED_DEVICE ((dev_t)-1)
757
758 /*
759 * The highest value used for the inodes we assign to files that do not have
760 * a starting block address (zero length files, symlinks, dev nodes, pipes,
761 * socket).
762 * We need to make sure that these numbers are valid ISO-9660 block addresses,
763 * this is why we use unsigned 32-bit integer values.
764 * We need to make sure that the inode numbers assigned for zero sized files
765 * is in a proper range, this is why we use numbers above the range of block
766 * addresses we use in the image. We start counting backwards from 0xFFFFFFF0
767 * to leave enough space for special numbers from the range listed above.
768 */
769 #define NULL_INO_MAX ((UInt32_t)0xFFFFFFF0)
770
771 #ifdef VMS
772 #define STAT_INODE(X) (X.st_ino[0])
773 #define PATH_SEPARATOR ']'
774 #define SPATH_SEPARATOR ""
775 #else
776 #define STAT_INODE(X) (X.st_ino)
777 #define PATH_SEPARATOR '/'
778 #define SPATH_SEPARATOR "/"
779 #endif
780
781 /*
782 * When using multi-session, indicates that we can reuse the
783 * TRANS.TBL information for this directory entry. If this flag
784 * is set for all entries in a directory, it means we can just
785 * reuse the TRANS.TBL and not generate a new one.
786 */
787 #define SAFE_TO_REUSE_TABLE_ENTRY 0x01 /* de_flags only */
788 #define DIR_HAS_DOT 0x02 /* dir_flags only */
789 #define DIR_HAS_DOTDOT 0x04 /* dir_flags only */
790 #define INHIBIT_JOLIET_ENTRY 0x08
791 #define INHIBIT_RR_ENTRY 0x10 /* not used */
792 #define RELOCATED_DIRECTORY 0x20 /* de_flags only */
793 #define INHIBIT_ISO9660_ENTRY 0x40
794 #define MEMORY_FILE 0x80 /* de_flags only */
795 #define HIDDEN_FILE 0x100 /* de_flags only */
796 #define DIR_WAS_SCANNED 0x200 /* dir_flags only */
797 #define RESOURCE_FORK 0x400 /* de_flags only */
798 #define IS_SYMLINK 0x800 /* de_flags only */
799 #define MULTI_EXTENT 0x1000 /* de_flags only */
800 #define INHIBIT_UDF_ENTRY 0x2000
801
802 /*
803 * Volume sequence number to use in all of the iso directory records.
804 */
805 #define DEF_VSN 1
806
807 /*
808 * Make sure we have a definition for this. If not, take a very conservative
809 * guess.
810 * POSIX requires the max pathname component lenght to be defined in limits.h
811 * If variable, it may be undefined. If undefined, there should be
812 * a definition for _POSIX_NAME_MAX in limits.h or in unistd.h
813 * As _POSIX_NAME_MAX is defined to 14, we cannot use it.
814 * XXX Eric's wrong comment:
815 * XXX From what I can tell SunOS is the only one with this trouble.
816 */
817 #include <schily/limits.h>
818
819 #ifndef NAME_MAX
820 #ifdef FILENAME_MAX
821 #define NAME_MAX FILENAME_MAX
822 #else
823 #define NAME_MAX 256
824 #endif
825 #endif
826
827 #ifndef PATH_MAX
828 #ifdef FILENAME_MAX
829 #define PATH_MAX FILENAME_MAX
830 #else
831 #define PATH_MAX 1024
832 #endif
833 #endif
834
835 /*
836 * Cygwin seems to have PATH_MAX == 260 which is less than the usable
837 * path length. We raise PATH_MAX to at least 1024 for now for all platforms
838 * unless someone reports problems with mkisofs memory size.
839 */
840 #if PATH_MAX < 1024
841 #undef PATH_MAX
842 #define PATH_MAX 1024
843 #endif
844
845 /*
846 * XXX JS: Some structures have odd lengths!
847 * Some compilers (e.g. on Sun3/mc68020) padd the structures to even length.
848 * For this reason, we cannot use sizeof (struct iso_path_table) or
849 * sizeof (struct iso_directory_record) to compute on disk sizes.
850 * Instead, we use offsetof(..., name) and add the name size.
851 * See iso9660.h
852 */
853 #ifndef offsetof
854 #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
855 #endif
856
857 #ifdef UDF
858 extern int use_udf;
859 #endif
860 extern int create_udfsymlinks;
861
862 #if !defined(HAVE_MEMSET) && !defined(memset)
863 #define memset(s, c, n) fillbytes(s, n, c)
864 #endif
865 #if !defined(HAVE_MEMCHR) && !defined(memchr)
866 #define memchr(s, c, n) findbytes(s, n, c)
867 #endif
868 #if !defined(HAVE_MEMCPY) && !defined(memcpy)
869 #define memcpy(s1, s2, n) movebytes(s2, s1, n)
870 #endif
871 #if !defined(HAVE_MEMMOVE) && !defined(memmove)
872 #define memmove(s1, s2, n) movebytes(s2, s1, n)
873 #endif