1 
2 /*
3   Class struct of libisoburn.
4 
5   Copyright 2007 - 2017 Vreixo Formoso Lopes <metalpain2002@yahoo.es>
6                     and Thomas Schmitt <scdbackup@gmx.net>
7   Provided under GPL version 2 or later.
8 */
9 
10 #ifndef Isoburn_includeD
11 #define Isoburn_includeD
12 
13 
14 /* for uint8_t */
15 #ifdef HAVE_STDINT_H
16 #include <stdint.h>
17 #else
18 #ifdef HAVE_INTTYPES_H
19 #include <inttypes.h>
20 #endif
21 #endif
22 
23 /* For emulated TOC of overwriteable media.
24    Provides minimal info for faking a struct burn_toc_entry.
25 */
26 struct isoburn_toc_entry {
27  int session;
28  int track_no; /* point */
29  int start_lba;
30  int track_blocks;
31  char *volid; /* For caching a volume id from emulated toc on overwriteables */
32 
33  struct isoburn_toc_entry *next;
34 };
35 
36 int isoburn_toc_entry_new(struct isoburn_toc_entry **objpt,
37                           struct isoburn_toc_entry *boss, int flag);
38 
39 /* @param flag bit0= delete all subordinates too
40 */
41 int isoburn_toc_entry_destroy(struct isoburn_toc_entry **o, int flag);
42 
43 
44 /* Minimal size of target_iso_head which is to be written during
45    isoburn_activate_session().
46    Within this size there is everything that is needed for image access with
47    no partition offset. The actual target_iso_head buffer must be larger by
48    the evential partition offset.
49 */
50 #define Libisoburn_target_head_sizE (32*2048)
51 
52 
53 /* Maximum number of appended partitions. Effectively usable number depends
54    on system area type.
55 */
56 #define Libisoburn_max_appended_partitionS 8
57 
58 /*
59   Maximum length of a disc label text plus 1.
60 */
61 #define Libisoburn_disc_label_sizE 129
62 
63 
64 struct isoburn {
65 
66 
67  /* The libburn drive to which this isoburn object is related
68     Most isoburn calls will use a burn_drive as object handle */
69  struct burn_drive *drive;
70 
71  /* -1= inappropriate medium state detected
72     0= libburn multi-session medium, resp. undecided yet
73     1= random access medium */
74  int emulation_mode;
75 
76  /* Although rarely used, libburn can operate on several
77     drives simultaneously. */
78  struct isoburn *prev;
79  struct isoburn *next;
80 
81 
82  /* If >= 0, this address is used as reply for isoburn_disc_get_msc1()
83  */
84  int fabricated_msc1;
85 
86  /* If >= 0, this address is used in isoburn_disc_track_lba_nwa()
87     as reply parameter nwa.
88     (The other nwa parameters below apply only to the effective write address
89      on random access media. msc2 is handed to libisofs but not to libburn.)
90  */
91  int fabricated_msc2;
92 
93 
94  /* The nwa to be used for a first session on the present kind of overwriteable
95     media (usually Libisoburn_overwriteable_starT, but might be forced to 0)
96  */
97  int zero_nwa;
98 
99  /* Start address as given by image examination (bytes, not blocks) */
100  off_t min_start_byte;
101 
102  /* Aligned start address to be used for processing (counted in blocks) */
103  int nwa;
104 
105 
106  /* Truncate to .nwa an eventual regular file serving as output drive */
107  int truncate;
108 
109  /* Eventual freely fabricated isoburn_disc_get_status().
110     BURN_DISC_UNREADY means that this variable is disabled
111     and normally emulated status is in effect.
112  */
113  enum burn_disc_status fabricated_disc_status;
114 
115  /* To be set if read errors occurred during media evaluation.
116  */
117  int media_read_error;
118 
119  /* Eventual emulated table of content read from the chain of ISO headers
120     on overwriteable media.
121  */
122  struct isoburn_toc_entry *toc;
123 
124  /* Indicator wether the most recent burn run worked :
125     -1 = undetermined, ask libburn , 0 = failure , 1 = success
126     To be inquired by isoburn_drive_wrote_well()
127  */
128  int wrote_well;
129 
130 
131  /* ISO head buffer to be filled by write run */
132  int target_iso_head_size;
133  uint8_t *target_iso_head;
134 
135  /* The 2k offset which was read from a loaded image.
136  */
137  uint32_t loaded_partition_offset;
138 
139 
140  /* Libisofs image context */
141  IsoImage *image;
142 
143  /* The start LBA of the image */
144  int image_start_lba;
145 
146  /* The block data source from which the existing image is read.
147  */
148  IsoDataSource *iso_data_source;
149 
150  /* The burn source which transfers data from libisofs to libburn.
151     It has its own fifo.
152  */
153  struct burn_source *iso_source;
154 
155  /* For iso_tree_set_report_callback() */
156  int (*read_pacifier)(IsoImage*, IsoFileSource*);
157 
158  /* For iso_image_attach_data() */
159  void *read_pacifier_handle;
160 
161  /* An application provided method to immediately deliver messages */
162  int (*msgs_submit)(void *handle, int error_code, char msg_text[],
163                     int os_errno, char severity[], int flag);
164  void *msgs_submit_handle;  /* specific to application method */
165  int msgs_submit_flag;      /* specific to application method */
166 
167  /* Forwarding an image generation option to the burn wrapper */
168  int do_tao;
169 
170  /* Forwarding an image generation option to the burn wrapper */
171  int do_fsync;
172 
173 };
174 
175 
176 /* Creation and disposal function */
177 int isoburn_new(struct isoburn **objpt, int flag);
178 int isoburn_destroy(struct isoburn **objpt, int flag);
179 
180 /* Eventual readers for public attributes */
181 /* ( put into separate .h file then ) */
182 int isoburn_get_emulation_mode(struct isoburn *o, int *pt, int flag);
183 int isoburn_get_target_volset(struct isoburn *o, IsoImage **pt, int flag);
184 
185 /* List management */
186 int isoburn_get_prev(struct isoburn *o, struct isoburn **pt, int flag);
187 int isoburn_get_next(struct isoburn *o, struct isoburn **pt, int flag);
188 int isoburn_destroy_all(struct isoburn **objpt, int flag);
189 int isoburn_link(struct isoburn *o, struct isoburn *link, int flag);
190 int isoburn_count(struct isoburn *o, int flag);
191 int isoburn_by_idx(struct isoburn *o, int idx, struct isoburn **pt, int flag);
192 int isoburn_find_by_drive(struct isoburn **pt, struct burn_drive *d, int flag);
193 
194 
195 /* Non API inner interfaces */
196 
197 /* Submit a libisofs error to the libburn messenger. An application message
198    reader shall recognize the error code range and attribute it to the
199    libisofs message channel to which one cannot submit via API.
200    @param iso_error_code   return value <= 0 from a libisofs API call.
201    @param default_msg_text is to be put out if iso_error_code leads to no
202                            error message
203    @param os_errno         operating system errno, submit 0 if none is known
204    @param min_severity     minimum severity, might be be increased if libisofs
205                            error severity surpasses min_severity.
206    @param flag             Bitfield, submit 0 for now
207 */
208 int isoburn_report_iso_error(int iso_error_code, char default_msg_text[],
209                              int os_errno, char min_severity[], int flag);
210 
211 /* Calls from burn_wrap.c into isofs_wrap.c */
212 
213 int isoburn_start_emulation(struct isoburn *o, int flag);
214 int isoburn_invalidate_iso(struct isoburn *o, int flag);
215 
216 
217 /* Calls from isofs_wrap.c into burn_wrap.c */
218 
219 /** Get an eventual isoburn object which is wrapped around the drive.
220     @param pt    Eventually returns a pointer to the found object.
221                  It is allowed to become NULL if return value is -1 or 0.
222                  In this case, the drive is a genuine libburn drive
223                  with no emulation activated by isoburn.
224     @param drive The drive to be searched for
225     @param flag  unused yet
226     @return -1 unsuitable medium, 0 generic medium, 1 emulated medium.
227 */
228 int isoburn_find_emulator(struct isoburn **pt,
229                           struct burn_drive *drive, int flag);
230 
231 /* Deliver an event message. Either via a non-NULL o->msgs_submit() method
232    or via burn_msgs_submit() of libburn.
233 */
234 int isoburn_msgs_submit(struct isoburn *o, int error_code, char msg_text[],
235                         int os_errno, char severity[], int flag);
236 
237 /** Set the start address for an emulated add-on session. The value will
238     be rounded up to the alignment necessary for the medium. The aligned
239     value will be divided by 2048 and then put into  o->nwa .
240     @param o     The isoburn object to be programmed.
241     @param value The start address in bytes
242     @param flag  unused yet
243     @return <=0 is failure , >0 success
244 */
245 int isoburn_set_start_byte(struct isoburn *o, off_t value, int flag);
246 
247 /** Obtains the image address offset to be used with image generation.
248     This is either the (emulated) drive nwa or a value set by
249     isoburn_prepare_blind_grow().
250     In any case this is the address to tell to iso_write_opts_set_ms_block().
251     @param o     The isoburn object to be inquired
252     @param opts  If not NULL: write parameters to be set on drive before query
253     @param msc2  The value to be used with iso_write_opts_set_ms_block()
254     @param flag  unused yet
255     @return <=0 is failure , >0 success
256 */
257 int isoburn_get_msc2(struct isoburn *o,
258                      struct burn_write_opts *opts, int *msc2, int flag);
259 
260 /** Get a data source suitable for read from a drive using burn_read_data()
261     function.
262     @param d drive to read from. Must be grabbed.
263     @param displacement will be added or subtracted to any block address
264     @param displacement_sign  +1 = add , -1= subtract , else keep unaltered
265     @return the data source, NULL on error. Must be freed with libisofs
266             iso_data_source_unref() function. Note: this doesn't release
267             the drive.
268 */
269 IsoDataSource *
270 isoburn_data_source_new(struct burn_drive *d,
271                          uint32_t displacement, int displacement_sign,
272                          int cache_tiles, int tile_blocks);
273 
274 /** Default settings for above cache_tiles, tile_blocks in newly created
275     struct isoburn_read_opts.
276 */
277 #define Libisoburn_default_cache_tileS 32
278 #define Libisoburn_default_tile_blockS 32
279 
280 /** Maximum size of the cache in 2 kB blocks (1 GB)
281 */
282 #define Libisoburn_cache_max_sizE (1024 * 512)
283 
284 
285 /** Disable read capabilities of a data source which was originally created
286     by isoburn_data_source_new(). After this any attempt to read will yield
287     a FATAL programming error event.
288     This is usually done to allow libburn to release the drive while libisofs
289     still holds a reference to the data source object. libisofs is not supposed
290     to use this object for reading any more, nevertheless. The disabled state
291     of the data source is a safety fence around this daring situation.
292     @param src The data source to be disabled
293     @param flag  unused yet
294     @return <=0 is failure , >0 success
295 */
296 int isoburn_data_source_shutdown(IsoDataSource *src, int flag);
297 
298 
299 /** Check whether the size of target_iso_head matches the given partition
300     offset. Eventually adjust size.
301 */
302 int isoburn_adjust_target_iso_head(struct isoburn *o,
303                                    uint32_t offst, int flag);
304 
305 
306 /** Initialize the root directory attributes of a freshly created image.
307 */
308 int isoburn_root_defaults(IsoImage *image, int flag);
309 
310 
311 /**
312  * Options for image reading.
313    (Comments here may be outdated. API getter/setter function descriptions
314     may override the descriptions here. Any difference is supposed to be a
315     minor correction only.)
316  */
317 struct isoburn_read_opts {
318     int cache_tiles; /* number of cache tiles */
319     int cache_tile_blocks;
320 
321     unsigned int norock:1; /*< Do not read Rock Ridge extensions */
322     unsigned int nojoliet:1; /*< Do not read Joliet extensions */
323     unsigned int noiso1999:1; /*< Do not read ISO 9660:1999 enhanced tree */
324 
325     unsigned int do_ecma119_map:1; /* call iso_read_opts_set_ecma119_map() */
326     unsigned int map_mode:2;       /* argument for do_ecma119_map */
327 
328     /* ts A90121 */
329     unsigned int noaaip:1;   /* Do not read AAIP for ACL and EA */
330     unsigned int noacl:1;    /* Do not read ACL from external file objects */
331     unsigned int noea:1;     /* Do not read XFS-style EA from externals */
332 
333     /* ts A90508 */
334     unsigned int noino:1;    /* Discard eventual PX inode numbers */
335 
336     /* ts A90810 */
337     unsigned int nomd5:2;    /* Do not read eventual MD5 array */
338 
339     unsigned int preferjoliet:1;
340                 /*< When both Joliet and RR extensions are present, the RR
341                  *  tree is used. If you prefer using Joliet, set this to 1. */
342     uid_t uid; /**< Default uid when no RR */
343     gid_t gid; /**< Default uid when no RR */
344     mode_t mode; /**< Default mode when no RR (only permissions) */
345     mode_t dirmode; /**< Default mode for directories
346                          when no RR (only permissions) */
347 
348     /**
349      * Input charset for RR file names. NULL to use default locale charset.
350      */
351     char *input_charset;
352 
353     /**
354      * Enable or disable methods to automatically choose an input charset.
355      * This eventually overrides input_charset.
356      *
357      * bit0= set the input character set automatically from
358      *       attribute "isofs.cs" of root directory
359      */
360     int auto_input_charset;
361 
362     /**
363      * What to do in case of name longer than truncate_length:
364      *  0= throw FAILURE
365      *  1= truncate to truncate_length with MD5 of whole name at end
366      */
367     int truncate_mode;
368     int truncate_length;
369 
370     /* modified by the function isoburn_read_image */
371     unsigned int hasRR:1; /*< It will be set to 1 if RR extensions are present,
372                              to 0 if not. */
373     unsigned int hasJoliet:1; /*< It will be set to 1 if Joliet extensions are
374                                   present, to 0 if not. */
375 
376     /**
377      * It will be set to 1 if the image is an ISO 9660:1999, i.e. it has
378      * a version 2 Enhanced Volume Descriptor.
379      */
380     unsigned int hasIso1999:1;
381 
382     /** It will be set to 1 if El-Torito boot record is present, to 0 if not.*/
383     unsigned int hasElTorito:1;
384 
385     uint32_t size; /**< Will be filled with the size (in 2048 byte block) of
386                     *   the image, as reported in the PVM. */
387     unsigned int pretend_blank:1; /* always create empty image */
388 
389     uint32_t displacement;
390     int displacement_sign;
391 };
392 
393 
394 /**
395  * Options for image generation by libisofs and image transport to libburn.
396    (Comments here may be outdated. API getter/setter function descriptions
397     may override the descriptions here. Any difference is supposed to be a
398     minor correction only.)
399  */
400 struct isoburn_imgen_opts {
401 
402     /* Options for image generation */
403 
404     int will_cancel :1;
405 
406     int level;  /**< ISO level to write at. */
407 
408     /** Which extensions to support. */
409     unsigned int rockridge :1;
410     unsigned int joliet :1;
411     unsigned int iso1999 :1;
412     unsigned int hfsplus :1;
413     unsigned int fat :1;
414 
415     /* Whether to mark suitable IsoNode as hardlinks in RRIP PX */
416     unsigned int hardlinks :1;
417 
418     /* Write eventual AAIP info containing ACL and EA */
419     unsigned int aaip :1;
420 
421     /* Produce and write a MD5 checksum of the whole session stream. */
422     unsigned int session_md5 :1;
423 
424     /* Produce and write MD5 checksums for each single IsoFile.
425        See parameter "files" of iso_write_opts_set_record_md5().
426      */
427     unsigned int file_md5 :2;
428 
429     /* On overwriteable media or random access files do not write the first
430        session to LBA 32, but rather to LBA 0 directly.
431      */
432     unsigned int no_emul_toc :1;
433 
434     /* For empty files, symbolic links, and devices use the old ECMA-119 block
435        addresses in the range [0,31] rather than the address of the dedicated
436        empty block.
437     */
438     unsigned int old_empty :1;
439 
440 
441     /* relaxed constraints */
442 
443     /*
444      * Relaxed constraints. Setting any of these to 1 break the specifications,
445      * but it is supposed to work on most moderns systems. Use with caution.
446      */
447 
448     /*
449      * Extra Caution: This option breaks any assumptions about names that
450      *                are supported by ECMA-119 specifications.
451      * Omit any translation which would make a file name compliant to the
452      * ECMA-119 rules. This includes and exceeds omit_version_numbers,
453      * max_37_char_filenames, no_force_dots bit0, allow_lowercase.
454      */
455     unsigned int untranslated_name_len;
456 
457     /*
458      * Convert directory names for ECMA-119 similar to other file names, but do
459      * not force a dot or add a version number.
460      * This violates ECMA-119 by allowing one "." and especially ISO level 1
461      * by allowing DOS style 8.3 names rather than only 8 characters.
462      * (mkisofs and its clones seem to do this violation.)
463      */
464     unsigned int allow_dir_id_ext :1;
465 
466     /**
467      * Omit the version number (";1") at the end of the ISO-9660 identifiers.
468      * Version numbers are usually not used.
469      *      bit0= omit version number with ECMA-119 and Joliet
470      *      bit1= omit version number with Joliet alone
471      */
472     unsigned int omit_version_numbers :2;
473 
474     /**
475      * Allow ISO-9660 directory hierarchy to be deeper than 8 levels.
476      */
477     unsigned int allow_deep_paths :1;
478 
479     /**
480      * If not allow_deep_paths is in effect, then it may become
481      * necessary to relocate directories so that no ECMA-119 file path
482      * has more than 8 components. These directories are grafted into either
483      * the root directory of the ISO image or into a dedicated relocation
484      * directory. For details see libisofs.h, iso_write_opts_set_rr_reloc().
485      */
486     char *rr_reloc_dir;       /* IsoNode name in root directory. NULL or
487                                  empty text means root itself. */
488     int rr_reloc_flags;       /* bit0= mark auto-created rr_reloc_dir by RE
489                                  bit1= not settable via API (used internally)
490                               */
491 
492 
493 
494     /**
495      * Allow path in the ISO-9660 tree to have more than 255 characters.
496      */
497     unsigned int allow_longer_paths :1;
498 
499     /**
500      * Allow a single file or directory hierarchy to have up to 37 characters.
501      * This is larger than the 31 characters allowed by ISO level 2, and the
502      * extra space is taken from the version number, so this also forces
503      * omit_version_numbers.
504      */
505     unsigned int max_37_char_filenames :1;
506 
507     /**
508      * ISO-9660 forces filenames to have a ".", that separates file name from
509      * extension. libisofs adds it if original filename doesn't has one. Set
510      * this to 1 to prevent this behavior
511      *      bit0= no forced dot with ECMA-119
512      *      bit1= no forced dot with Joliet
513      */
514     unsigned int no_force_dots :2;
515 
516     /**
517      * Allow lowercase characters in ISO-9660 filenames. By default, only
518      * uppercase characters, numbers and a few other characters are allowed.
519      */
520     unsigned int allow_lowercase :1;
521 
522     /**
523      * Allow all ASCII characters to be appear on an ISO-9660 filename. Note
524      * that "/" and "\0" characters are never allowed, even in RR names.
525      */
526     unsigned int allow_full_ascii :1;
527 
528     /**
529      * Like allow_full_ascii, but only allowing 7-bit characters.
530      * Lowercase letters get mapped to uppercase if not allow_lowercase is set.
531      * Gets overridden if allow_full_ascii is enabled.
532      */
533     unsigned int allow_7bit_ascii :1;
534 
535     /**
536      * Allow paths in the Joliet tree to have more than 240 characters.
537      */
538     unsigned int joliet_longer_paths :1;
539 
540     /**
541      * Allow leaf names in the Joliet tree to have up to 103 characters
542      * rather than 64.
543      */
544     unsigned int joliet_long_names :1;
545 
546     /**
547      * Use UTF-16BE rather than its subset UCS-2
548      */
549     unsigned int joliet_utf16 :1;
550 
551     /**
552      * Store timestamps as GMT rather than in local time.
553      */
554     unsigned int always_gmt :1;
555 
556     /**
557      * Write Rock Ridge info as of specification RRIP-1.10 rather than
558      * RRIP-1.12: signature "RRIP_1991A" rather than "IEEE_1282",
559      *            field PX without file serial number
560      */
561     unsigned int rrip_version_1_10 :1;
562 
563     /**
564      * Store as ECMA-119 Directory Record timestamp the mtime
565      * of the source rather than the image creation time.
566      * The same can be ordered for Joliet and ISO 9660:1999
567      */
568     unsigned int dir_rec_mtime :1;
569     unsigned int joliet_rec_mtime :1;
570     unsigned int iso1999_rec_mtime :1;
571 
572     /**
573      * Write AAIP as extension according to SUSP 1.10 rather than SUSP 1.12.
574      * I.e. without announcing it by an ER field and thus without the need
575      * to precede the RRIP fields by an ES and to precede the AA field by ES.
576      */
577     unsigned int aaip_susp_1_10 :1;
578 
579     unsigned int sort_files:1;
580                 /**< If files should be sorted based on their weight. */
581 
582     /**
583      * The following options set the default values for files and directory
584      * permissions, gid and uid. All these take one of three values: 0, 1 or 2.
585      * If 0, the corresponding attribute will be kept as set in the IsoNode.
586      * Unless you have changed it, it corresponds to the value on disc, so it
587      * is suitable for backup purposes. If set to 1, the corresponding attrib.
588      * will be changed by a default suitable value. Finally, if you set it to
589      * 2, the attrib. will be changed with the value specified in the options
590      * below. Note that for mode attributes, only the permissions are set, the
591      * file type remains unchanged.
592      */
593     unsigned int replace_dir_mode :2;
594     unsigned int replace_file_mode :2;
595     unsigned int replace_uid :2;
596     unsigned int replace_gid :2;
597 
598     mode_t dir_mode; /** Mode to use on dirs when replace_dir_mode == 2. */
599     mode_t file_mode; /** Mode to use on files when replace_file_mode == 2. */
600     uid_t uid; /** uid to use when replace_uid == 2. */
601     gid_t gid; /** gid to use when replace_gid == 2. */
602 
603     char *output_charset; /**< NULL to use default charset */
604 
605 
606     /* Options for image transport */
607 
608     /** The number of bytes to be used for the fifo which decouples libisofs
609         and libburn for better throughput and for reducing the risk of
610         interrupting signals hitting the libburn thread which operates the
611         MMC drive.
612         The size will be rounded up to the next full 2048.
613         Minimum is 64kiB, maximum is 1 GiB (but that is too much anyway).
614     */
615     int fifo_size;
616 
617 
618     /** Output value: Block address of session start as evaluated from medium
619                       and other options by libisoburn and libburn.
620         If <0 : Invalid
621         If >=0: Valid block number. Block size is always 2 KiB.
622     */
623     int effective_lba;
624 
625     /** Output value: Block address of data section start as predicted by
626                       libisofs.
627         If < 16: Invalid
628         If >=16: Valid block number. Block size is always 2 KiB.
629     */
630     int data_start_lba;
631 
632     /**
633      * If not empty: Parameters "name" and "timestamp" for a scdbackup stream
634      * checksum tag. See scdbackup/README appendix VERIFY.
635      * It makes sense only for single session images which start at LBA 0.
636      * Such a tag may be part of a libisofs checksum tag block after the
637      * session tag line. It then covers the whole session up to its own start
638      * position.
639      * If scdbackup_tag_written is not NULL then it is a pointer to an
640      * application provided array with at least 512 characters. The effectively
641      * written scdbackup tag will be copied to this memory location.
642      */
643     char scdbackup_tag_name[81];
644     char scdbackup_tag_time[19];
645     char *scdbackup_tag_written;
646 
647 
648     /* Content of an embedded boot image. Valid if not NULL.
649      * In that case it must point to a memory buffer at least 32 kB.
650      */
651     char *system_area_data;
652     /*
653      * bit0= make bytes 446 - 512 of the system area a partition
654      *       table which reserves partition 1 from byte 63*512 to the
655      *       end of the ISO image. Assumed are 63 secs/hed, 255 head/cyl.
656      *       (GRUB protective msdos label.)
657      *       This works with and without system_area_data.
658      */
659     int system_area_options;
660 
661     /* User settable PVD time stamps */
662     time_t vol_creation_time;
663     time_t vol_modification_time;
664     time_t vol_expiration_time;
665     time_t vol_effective_time;
666     /* To eventually override vol_modification_time by unconverted string
667        and timezone 0 */
668     char vol_uuid[17];
669 
670     /* The number of unclaimed 2K blocks before start of partition 1 as of
671        the MBR in system area. If not 0 this will cause double volume
672        descriptor sets and double tree.
673     */
674     uint32_t partition_offset;
675     /* Partition table parameter: 1 to 63, 0= disabled/default */
676     int partition_secs_per_head;
677     /* 1 to 255, 0= disabled/default */
678     int partition_heads_per_cyl;
679 
680     /* Parameters and state of Jigdo Template Export environment.
681     */
682     void *libjte_handle;
683 
684     /* A trailing padding of zero bytes which belongs to the image
685     */
686     uint32_t tail_blocks;
687 
688     /* Disk file paths of content of PreP partition and EFI system partition */
689     char *prep_partition;
690     int prep_part_flag;
691     char *efi_boot_partition;
692     int efi_boot_part_flag;
693 
694     /* Eventual disk file paths of prepared images which shall be appended
695        after the ISO image and described by partiton table entries in a MBR.
696     */
697     char *appended_partitions[Libisoburn_max_appended_partitionS];
698     uint8_t appended_part_types[Libisoburn_max_appended_partitionS];
699     int appended_part_flags[Libisoburn_max_appended_partitionS];
700 
701     /* If 1: With appended partitions: create protective MBR and mark by GPT
702     */
703     int appended_as_gpt;
704 
705     /* If 1: With appended partitions: mark by APM
706     */
707     int appended_as_apm;
708 
709     /* If 1: Apply isohybrid gestures to non-isohybrid situations
710     */
711     int part_like_isohybrid;
712 
713     /* isoburn_igopt_set_iso_mbr_part_type()
714     */
715     int iso_mbr_part_type;
716 
717     /* See libisoburn.h isoburn_igopt_set_gpt_guid()
718     */
719     uint8_t gpt_guid[16];
720     int gpt_guid_mode;
721 
722     /* Eventual name of the non-ISO aspect of the image. E.g. SUN ASCII label.
723      */
724     char ascii_disc_label[Libisoburn_disc_label_sizE];
725 
726     /* HFS+ image serial number.
727      * 00...00 means that it shall be generated by libisofs.
728      */
729     uint8_t hfsp_serial_number[8];
730 
731     /* Allocation block size of HFS+ : 0= auto , 512, or 2048
732      */
733     int hfsp_block_size;
734 
735     /* Block size of and in APM : 0= auto , 512, or 2048
736      */
737     int apm_block_size;
738 
739     /* Write mode for optical media:
740      *   0 = auto
741      *   1 = TAO, Incremental, no RESERVE TRACK
742      *  -1 = SAO, DAO, RESERVE TRACK
743      */
744     int do_tao;
745 
746     /* Whether to fsync() stdio_drives after isoburn_activate_session() */
747     int do_fsync;
748 
749 };
750 
751 
752 /* Alignment for session starts on overwriteable media.
753    (Increased from 16 to 32 blocks for aligning to BD-RE clusters.)
754 */
755 #define Libisoburn_nwa_alignemenT 32
756 
757 
758 /* Alignment for outer session scanning with -ROM drives.
759    (E.g. my DVD-ROM drive shows any DVD type as 0x10 "DVD-ROM" with
760     more or less false capacity and TOC.)
761 */
762 #define Libisoburn_toc_scan_alignemenT 16
763 
764 /* Maximum gap to be bridged during a outer TOC scan. Gaps appear between the
765    end of a session and the start of the next session.
766    The longest gap found so far was about 38100 after the first session of a
767    DVD-R.
768 */
769 #define Libisoburn_toc_scan_max_gaP 65536
770 
771 
772 /* Creating a chain of image headers which form a TOC:
773 
774    The header of the first session is written after the LBA 0 header.
775    So it persists and can give the end of its session. By help of
776    Libisoburn_nwa_alignemenT it should be possible to predict the start
777    of the next session header.
778    The LBA 0 header is written by isoburn_activate_session() already
779    with the first session. So the medium is mountable.
780    A problem arises with DVD-RW in Intermediate State. They cannot be
781    written by random access before they were written sequentially.
782    In this case, no copy of the session  1 header is maintained and no TOC
783    will be possible. Thus writing begins sequentially at LBA 0.
784 
785    IMPORTANT: This macro gives the minimal size of an image header.
786               It has to be enlarged by the eventual partition offset.
787 */
788 #define Libisoburn_overwriteable_starT \
789                                    ((off_t) (Libisoburn_target_head_sizE/2048))
790 
791 
792 /* Wrappers for emulation of TOC on overwriteable media */
793 
794 struct isoburn_toc_track {
795  /* Either track or toc_entry are supposed to be NULL */
796  struct burn_track *track;
797  struct isoburn_toc_entry *toc_entry;
798 };
799 
800 struct isoburn_toc_session {
801  /* Either session or tracks and toc_entry are supposed to be NULL */
802  struct burn_session *session;
803  struct isoburn_toc_track **track_pointers;
804  int track_count;
805  struct isoburn_toc_entry *toc_entry;
806 };
807 
808 struct isoburn_toc_disc {
809  /* Either disc or sessions and toc are supposed to be NULL */
810  struct burn_disc *disc;
811  struct isoburn_toc_session *sessions;           /* storage array */
812  struct isoburn_toc_session **session_pointers;  /* storage array */
813  struct isoburn_toc_track *tracks;               /* storage array */
814  struct isoburn_toc_track **track_pointers;      /* storage array */
815  int session_count;
816  int incomplete_session_count;
817  int track_count;
818  struct isoburn_toc_entry *toc;
819 };
820 
821 #endif /* Isoburn_includeD */
822 
823