libisofs  1.3.6
libisofs.h
Go to the documentation of this file.
1 
2 #ifndef LIBISO_LIBISOFS_H_
3 #define LIBISO_LIBISOFS_H_
4 
5 /*
6  * Copyright (c) 2007-2008 Vreixo Formoso, Mario Danic
7  * Copyright (c) 2009-2014 Thomas Schmitt
8  *
9  * This file is part of the libisofs project; you can redistribute it and/or
10  * modify it under the terms of the GNU General Public License version 2
11  * or later as published by the Free Software Foundation.
12  * See COPYING file for details.
13  */
14 
15 /* Important: If you add a public API function then add its name to file
16  libisofs/libisofs.ver
17 */
18 
19 /*
20  *
21  * Applications must use 64 bit off_t.
22  * E.g. on 32-bit GNU/Linux by defining
23  * #define _LARGEFILE_SOURCE
24  * #define _FILE_OFFSET_BITS 64
25  * The minimum requirement is to interface with the library by 64 bit signed
26  * integers where libisofs.h or libisoburn.h prescribe off_t.
27  * Failure to do so may result in surprising malfunction or memory faults.
28  *
29  * Application files which include libisofs/libisofs.h must provide
30  * definitions for uint32_t and uint8_t.
31  * This can be achieved either:
32  * - by using autotools which will define HAVE_STDINT_H or HAVE_INTTYPES_H
33  * according to its ./configure tests,
34  * - or by defining the macros HAVE_STDINT_H resp. HAVE_INTTYPES_H according
35  * to the local situation,
36  * - or by appropriately defining uint32_t and uint8_t by other means,
37  * e.g. by including inttypes.h before including libisofs.h
38  */
39 #ifdef HAVE_STDINT_H
40 #include <stdint.h>
41 #else
42 #ifdef HAVE_INTTYPES_H
43 #include <inttypes.h>
44 #endif
45 #endif
46 
47 
48 /*
49  * Normally this API is operated via public functions and opaque object
50  * handles. But it also exposes several C structures which may be used to
51  * provide custom functionality for the objects of the API. The same
52  * structures are used for internal objects of libisofs, too.
53  * You are not supposed to manipulate the entrails of such objects if they
54  * are not your own custom extensions.
55  *
56  * See for an example IsoStream = struct iso_stream below.
57  */
58 
59 
60 #include <sys/stat.h>
61 
62 #include <stdlib.h>
63 
64 
65 /**
66  * The following two functions and three macros are utilities to help ensuring
67  * version match of application, compile time header, and runtime library.
68  */
69 /**
70  * These three release version numbers tell the revision of this header file
71  * and of the API it describes. They are memorized by applications at
72  * compile time.
73  * They must show the same values as these symbols in ./configure.ac
74  * LIBISOFS_MAJOR_VERSION=...
75  * LIBISOFS_MINOR_VERSION=...
76  * LIBISOFS_MICRO_VERSION=...
77  * Note to anybody who does own work inside libisofs:
78  * Any change of configure.ac or libisofs.h has to keep up this equality !
79  *
80  * Before usage of these macros on your code, please read the usage discussion
81  * below.
82  *
83  * @since 0.6.2
84  */
85 #define iso_lib_header_version_major 1
86 #define iso_lib_header_version_minor 3
87 #define iso_lib_header_version_micro 6
88 
89 /**
90  * Get version of the libisofs library at runtime.
91  * NOTE: This function may be called before iso_init().
92  *
93  * @since 0.6.2
94  */
95 void iso_lib_version(int *major, int *minor, int *micro);
96 
97 /**
98  * Check at runtime if the library is ABI compatible with the given version.
99  * NOTE: This function may be called before iso_init().
100  *
101  * @return
102  * 1 lib is compatible, 0 is not.
103  *
104  * @since 0.6.2
105  */
106 int iso_lib_is_compatible(int major, int minor, int micro);
107 
108 /**
109  * Usage discussion:
110  *
111  * Some developers of the libburnia project have differing opinions how to
112  * ensure the compatibility of libaries and applications.
113  *
114  * It is about whether to use at compile time and at runtime the version
115  * numbers provided here. Thomas Schmitt advises to use them. Vreixo Formoso
116  * advises to use other means.
117  *
118  * At compile time:
119  *
120  * Vreixo Formoso advises to leave proper version matching to properly
121  * programmed checks in the the application's build system, which will
122  * eventually refuse compilation.
123  *
124  * Thomas Schmitt advises to use the macros defined here for comparison with
125  * the application's requirements of library revisions and to eventually
126  * break compilation.
127  *
128  * Both advises are combinable. I.e. be master of your build system and have
129  * #if checks in the source code of your application, nevertheless.
130  *
131  * At runtime (via iso_lib_is_compatible()):
132  *
133  * Vreixo Formoso advises to compare the application's requirements of
134  * library revisions with the runtime library. This is to allow runtime
135  * libraries which are young enough for the application but too old for
136  * the lib*.h files seen at compile time.
137  *
138  * Thomas Schmitt advises to compare the header revisions defined here with
139  * the runtime library. This is to enforce a strictly monotonous chain of
140  * revisions from app to header to library, at the cost of excluding some older
141  * libraries.
142  *
143  * These two advises are mutually exclusive.
144  */
145 
146 struct burn_source;
147 
148 /**
149  * Context for image creation. It holds the files that will be added to image,
150  * and several options to control libisofs behavior.
151  *
152  * @since 0.6.2
153  */
154 typedef struct Iso_Image IsoImage;
155 
156 /*
157  * A node in the iso tree, i.e. a file that will be written to image.
158  *
159  * It can represent any kind of files. When needed, you can get the type with
160  * iso_node_get_type() and cast it to the appropiate subtype. Useful macros
161  * are provided, see below.
162  *
163  * @since 0.6.2
164  */
165 typedef struct Iso_Node IsoNode;
166 
167 /**
168  * A directory in the iso tree. It is an special type of IsoNode and can be
169  * casted to it in any case.
170  *
171  * @since 0.6.2
172  */
173 typedef struct Iso_Dir IsoDir;
174 
175 /**
176  * A symbolic link in the iso tree. It is an special type of IsoNode and can be
177  * casted to it in any case.
178  *
179  * @since 0.6.2
180  */
181 typedef struct Iso_Symlink IsoSymlink;
182 
183 /**
184  * A regular file in the iso tree. It is an special type of IsoNode and can be
185  * casted to it in any case.
186  *
187  * @since 0.6.2
188  */
189 typedef struct Iso_File IsoFile;
190 
191 /**
192  * An special file in the iso tree. This is used to represent any POSIX file
193  * other that regular files, directories or symlinks, i.e.: socket, block and
194  * character devices, and fifos.
195  * It is an special type of IsoNode and can be casted to it in any case.
196  *
197  * @since 0.6.2
198  */
199 typedef struct Iso_Special IsoSpecial;
200 
201 /**
202  * The type of an IsoNode.
203  *
204  * When an user gets an IsoNode from an image, (s)he can use
205  * iso_node_get_type() to get the current type of the node, and then
206  * cast to the appropriate subtype. For example:
207  *
208  * ...
209  * IsoNode *node;
210  * res = iso_dir_iter_next(iter, &node);
211  * if (res == 1 && iso_node_get_type(node) == LIBISO_DIR) {
212  * IsoDir *dir = (IsoDir *)node;
213  * ...
214  * }
215  *
216  * @since 0.6.2
217  */
224 };
225 
226 /* macros to check node type */
227 #define ISO_NODE_IS_DIR(n) (iso_node_get_type(n) == LIBISO_DIR)
228 #define ISO_NODE_IS_FILE(n) (iso_node_get_type(n) == LIBISO_FILE)
229 #define ISO_NODE_IS_SYMLINK(n) (iso_node_get_type(n) == LIBISO_SYMLINK)
230 #define ISO_NODE_IS_SPECIAL(n) (iso_node_get_type(n) == LIBISO_SPECIAL)
231 #define ISO_NODE_IS_BOOTCAT(n) (iso_node_get_type(n) == LIBISO_BOOT)
232 
233 /* macros for safe downcasting */
234 #define ISO_DIR(n) ((IsoDir*)(ISO_NODE_IS_DIR(n) ? n : NULL))
235 #define ISO_FILE(n) ((IsoFile*)(ISO_NODE_IS_FILE(n) ? n : NULL))
236 #define ISO_SYMLINK(n) ((IsoSymlink*)(ISO_NODE_IS_SYMLINK(n) ? n : NULL))
237 #define ISO_SPECIAL(n) ((IsoSpecial*)(ISO_NODE_IS_SPECIAL(n) ? n : NULL))
238 
239 #define ISO_NODE(n) ((IsoNode*)n)
240 
241 /**
242  * File section in an old image.
243  *
244  * @since 0.6.8
245  */
247 {
248  uint32_t block;
249  uint32_t size;
250 };
251 
252 /* If you get here because of a compilation error like
253 
254  /usr/include/libisofs/libisofs.h:166: error:
255  expected specifier-qualifier-list before 'uint32_t'
256 
257  then see the paragraph above about the definition of uint32_t.
258 */
259 
260 
261 /**
262  * Context for iterate on directory children.
263  * @see iso_dir_get_children()
264  *
265  * @since 0.6.2
266  */
267 typedef struct Iso_Dir_Iter IsoDirIter;
268 
269 /**
270  * It represents an El-Torito boot image.
271  *
272  * @since 0.6.2
273  */
274 typedef struct el_torito_boot_image ElToritoBootImage;
275 
276 /**
277  * An special type of IsoNode that acts as a placeholder for an El-Torito
278  * boot catalog. Once written, it will appear as a regular file.
279  *
280  * @since 0.6.2
281  */
282 typedef struct Iso_Boot IsoBoot;
283 
284 /**
285  * Flag used to hide a file in the RR/ISO or Joliet tree.
286  *
287  * @see iso_node_set_hidden
288  * @since 0.6.2
289  */
291  /** Hide the node in the ECMA-119 / RR tree */
293  /** Hide the node in the Joliet tree, if Joliet extension are enabled */
295  /** Hide the node in the ISO-9660:1999 tree, if that format is enabled */
297 
298  /** Hide the node in the HFS+ tree, if that format is enabled.
299  @since 1.2.4
300  */
302 
303  /** Hide the node in the FAT tree, if that format is enabled.
304  @since 1.2.4
305  */
307 
308  /** With IsoNode and IsoBoot: Write data content even if the node is
309  * not visible in any tree.
310  * With directory nodes : Write data content of IsoNode and IsoBoot
311  * in the directory's tree unless they are
312  * explicitely marked LIBISO_HIDE_ON_RR
313  * without LIBISO_HIDE_BUT_WRITE.
314  * @since 0.6.34
315  */
317 };
318 
319 /**
320  * El-Torito bootable image type.
321  *
322  * @since 0.6.2
323  */
328 };
329 
330 /**
331  * Replace mode used when addding a node to a directory.
332  * This controls how libisofs will act when you tried to add to a dir a file
333  * with the same name that an existing file.
334  *
335  * @since 0.6.2
336  */
338  /**
339  * Never replace an existing node, and instead fail with
340  * ISO_NODE_NAME_NOT_UNIQUE.
341  */
343  /**
344  * Always replace the old node with the new.
345  */
347  /**
348  * Replace with the new node if it is the same file type
349  */
351  /**
352  * Replace with the new node if it is the same file type and its ctime
353  * is newer than the old one.
354  */
356  /**
357  * Replace with the new node if its ctime is newer than the old one.
358  */
360  /*
361  * TODO #00006 define more values
362  * -if both are dirs, add contents (and what to do with conflicts?)
363  */
364 };
365 
366 /**
367  * Options for image written.
368  * @see iso_write_opts_new()
369  * @since 0.6.2
370  */
371 typedef struct iso_write_opts IsoWriteOpts;
372 
373 /**
374  * Options for image reading or import.
375  * @see iso_read_opts_new()
376  * @since 0.6.2
377  */
378 typedef struct iso_read_opts IsoReadOpts;
379 
380 /**
381  * Source for image reading.
382  *
383  * @see struct iso_data_source
384  * @since 0.6.2
385  */
387 
388 /**
389  * Data source used by libisofs for reading an existing image.
390  *
391  * It offers homogeneous read access to arbitrary blocks to different sources
392  * for images, such as .iso files, CD/DVD drives, etc...
393  *
394  * To create a multisession image, libisofs needs a IsoDataSource, that the
395  * user must provide. The function iso_data_source_new_from_file() constructs
396  * an IsoDataSource that uses POSIX I/O functions to access data. You can use
397  * it with regular .iso images, and also with block devices that represent a
398  * drive.
399  *
400  * @since 0.6.2
401  */
403 {
404 
405  /* reserved for future usage, set to 0 */
406  int version;
407 
408  /**
409  * Reference count for the data source. Should be 1 when a new source
410  * is created. Don't access it directly, but with iso_data_source_ref()
411  * and iso_data_source_unref() functions.
412  */
413  unsigned int refcount;
414 
415  /**
416  * Opens the given source. You must open() the source before any attempt
417  * to read data from it. The open is the right place for grabbing the
418  * underlying resources.
419  *
420  * @return
421  * 1 if success, < 0 on error (has to be a valid libisofs error code)
422  */
423  int (*open)(IsoDataSource *src);
424 
425  /**
426  * Close a given source, freeing all system resources previously grabbed in
427  * open().
428  *
429  * @return
430  * 1 if success, < 0 on error (has to be a valid libisofs error code)
431  */
432  int (*close)(IsoDataSource *src);
433 
434  /**
435  * Read an arbitrary block (2048 bytes) of data from the source.
436  *
437  * @param lba
438  * Block to be read.
439  * @param buffer
440  * Buffer where the data will be written. It should have at least
441  * 2048 bytes.
442  * @return
443  * 1 if success,
444  * < 0 if error. This function has to emit a valid libisofs error code.
445  * Predifined (but not mandatory) for this purpose are:
446  * ISO_DATA_SOURCE_SORRY , ISO_DATA_SOURCE_MISHAP,
447  * ISO_DATA_SOURCE_FAILURE , ISO_DATA_SOURCE_FATAL
448  */
449  int (*read_block)(IsoDataSource *src, uint32_t lba, uint8_t *buffer);
450 
451  /**
452  * Clean up the source specific data. Never call this directly, it is
453  * automatically called by iso_data_source_unref() when refcount reach
454  * 0.
455  */
456  void (*free_data)(IsoDataSource *src);
457 
458  /** Source specific data */
459  void *data;
460 };
461 
462 /**
463  * Return information for image. This is optionally allocated by libisofs,
464  * as a way to inform user about the features of an existing image, such as
465  * extensions present, size, ...
466  *
467  * @see iso_image_import()
468  * @since 0.6.2
469  */
470 typedef struct iso_read_image_features IsoReadImageFeatures;
471 
472 /**
473  * POSIX abstraction for source files.
474  *
475  * @see struct iso_file_source
476  * @since 0.6.2
477  */
479 
480 /**
481  * Abstract for source filesystems.
482  *
483  * @see struct iso_filesystem
484  * @since 0.6.2
485  */
487 
488 /**
489  * Interface that defines the operations (methods) available for an
490  * IsoFileSource.
491  *
492  * @see struct IsoFileSource_Iface
493  * @since 0.6.2
494  */
496 
497 /**
498  * IsoFilesystem implementation to deal with ISO images, and to offer a way to
499  * access specific information of the image, such as several volume attributes,
500  * extensions being used, El-Torito artifacts...
501  *
502  * @since 0.6.2
503  */
505 
506 /**
507  * See IsoFilesystem->get_id() for info about this.
508  * @since 0.6.2
509  */
510 extern unsigned int iso_fs_global_id;
511 
512 /**
513  * An IsoFilesystem is a handler for a source of files, or a "filesystem".
514  * That is defined as a set of files that are organized in a hierarchical
515  * structure.
516  *
517  * A filesystem allows libisofs to access files from several sources in
518  * an homogeneous way, thus abstracting the underlying operations needed to
519  * access and read file contents. Note that this doesn't need to be tied
520  * to the disc filesystem used in the partition being accessed. For example,
521  * we have an IsoFilesystem implementation to access any mounted filesystem,
522  * using standard POSIX functions. It is also legal, of course, to implement
523  * an IsoFilesystem to deal with a specific filesystem over raw partitions.
524  * That is what we do, for example, to access an ISO Image.
525  *
526  * Each file inside an IsoFilesystem is represented as an IsoFileSource object,
527  * that defines POSIX-like interface for accessing files.
528  *
529  * @since 0.6.2
530  */
532 {
533  /**
534  * Type of filesystem.
535  * "file" -> local filesystem
536  * "iso " -> iso image filesystem
537  */
538  char type[4];
539 
540  /* reserved for future usage, set to 0 */
541  int version;
542 
543  /**
544  * Get the root of a filesystem.
545  *
546  * @return
547  * 1 on success, < 0 on error (has to be a valid libisofs error code)
548  */
549  int (*get_root)(IsoFilesystem *fs, IsoFileSource **root);
550 
551  /**
552  * Retrieve a file from its absolute path inside the filesystem.
553  * @param file
554  * Returns a pointer to a IsoFileSource object representing the
555  * file. It has to be disposed by iso_file_source_unref() when
556  * no longer needed.
557  * @return
558  * 1 success, < 0 error (has to be a valid libisofs error code)
559  * Error codes:
560  * ISO_FILE_ACCESS_DENIED
561  * ISO_FILE_BAD_PATH
562  * ISO_FILE_DOESNT_EXIST
563  * ISO_OUT_OF_MEM
564  * ISO_FILE_ERROR
565  * ISO_NULL_POINTER
566  */
567  int (*get_by_path)(IsoFilesystem *fs, const char *path,
568  IsoFileSource **file);
569 
570  /**
571  * Get filesystem identifier.
572  *
573  * If the filesystem is able to generate correct values of the st_dev
574  * and st_ino fields for the struct stat of each file, this should
575  * return an unique number, greater than 0.
576  *
577  * To get a identifier for your filesystem implementation you should
578  * use iso_fs_global_id, incrementing it by one each time.
579  *
580  * Otherwise, if you can't ensure values in the struct stat are valid,
581  * this should return 0.
582  */
583  unsigned int (*get_id)(IsoFilesystem *fs);
584 
585  /**
586  * Opens the filesystem for several read operations. Calling this funcion
587  * is not needed at all, each time that the underlying system resource
588  * needs to be accessed, it is openned propertly.
589  * However, if you plan to execute several operations on the filesystem,
590  * it is a good idea to open it previously, to prevent several open/close
591  * operations to occur.
592  *
593  * @return 1 on success, < 0 on error (has to be a valid libisofs error code)
594  */
595  int (*open)(IsoFilesystem *fs);
596 
597  /**
598  * Close the filesystem, thus freeing all system resources. You should
599  * call this function if you have previously open() it.
600  * Note that you can open()/close() a filesystem several times.
601  *
602  * @return 1 on success, < 0 on error (has to be a valid libisofs error code)
603  */
604  int (*close)(IsoFilesystem *fs);
605 
606  /**
607  * Free implementation specific data. Should never be called by user.
608  * Use iso_filesystem_unref() instead.
609  */
610  void (*free)(IsoFilesystem *fs);
611 
612  /* internal usage, do never access them directly */
613  unsigned int refcount;
614  void *data;
615 };
616 
617 /**
618  * Interface definition for an IsoFileSource. Defines the POSIX-like function
619  * to access files and abstract underlying source.
620  *
621  * @since 0.6.2
622  */
624 {
625  /**
626  * Tells the version of the interface:
627  * Version 0 provides functions up to (*lseek)().
628  * @since 0.6.2
629  * Version 1 additionally provides function *(get_aa_string)().
630  * @since 0.6.14
631  * Version 2 additionally provides function *(clone_src)().
632  * @since 1.0.2
633  */
634  int version;
635 
636  /**
637  * Get the absolute path in the filesystem this file source belongs to.
638  *
639  * @return
640  * the path of the FileSource inside the filesystem, it should be
641  * freed when no more needed.
642  */
643  char* (*get_path)(IsoFileSource *src);
644 
645  /**
646  * Get the name of the file, with the dir component of the path.
647  *
648  * @return
649  * the name of the file, it should be freed when no more needed.
650  */
651  char* (*get_name)(IsoFileSource *src);
652 
653  /**
654  * Get information about the file. It is equivalent to lstat(2).
655  *
656  * @return
657  * 1 success, < 0 error (has to be a valid libisofs error code)
658  * Error codes:
659  * ISO_FILE_ACCESS_DENIED
660  * ISO_FILE_BAD_PATH
661  * ISO_FILE_DOESNT_EXIST
662  * ISO_OUT_OF_MEM
663  * ISO_FILE_ERROR
664  * ISO_NULL_POINTER
665  */
666  int (*lstat)(IsoFileSource *src, struct stat *info);
667 
668  /**
669  * Get information about the file. If the file is a symlink, the info
670  * returned refers to the destination. It is equivalent to stat(2).
671  *
672  * @return
673  * 1 success, < 0 error
674  * Error codes:
675  * ISO_FILE_ACCESS_DENIED
676  * ISO_FILE_BAD_PATH
677  * ISO_FILE_DOESNT_EXIST
678  * ISO_OUT_OF_MEM
679  * ISO_FILE_ERROR
680  * ISO_NULL_POINTER
681  */
682  int (*stat)(IsoFileSource *src, struct stat *info);
683 
684  /**
685  * Check if the process has access to read file contents. Note that this
686  * is not necessarily related with (l)stat functions. For example, in a
687  * filesystem implementation to deal with an ISO image, if the user has
688  * read access to the image it will be able to read all files inside it,
689  * despite of the particular permission of each file in the RR tree, that
690  * are what the above functions return.
691  *
692  * @return
693  * 1 if process has read access, < 0 on error (has to be a valid
694  * libisofs error code)
695  * Error codes:
696  * ISO_FILE_ACCESS_DENIED
697  * ISO_FILE_BAD_PATH
698  * ISO_FILE_DOESNT_EXIST
699  * ISO_OUT_OF_MEM
700  * ISO_FILE_ERROR
701  * ISO_NULL_POINTER
702  */
703  int (*access)(IsoFileSource *src);
704 
705  /**
706  * Opens the source.
707  * @return 1 on success, < 0 on error (has to be a valid libisofs error code)
708  * Error codes:
709  * ISO_FILE_ALREADY_OPENED
710  * ISO_FILE_ACCESS_DENIED
711  * ISO_FILE_BAD_PATH
712  * ISO_FILE_DOESNT_EXIST
713  * ISO_OUT_OF_MEM
714  * ISO_FILE_ERROR
715  * ISO_NULL_POINTER
716  */
717  int (*open)(IsoFileSource *src);
718 
719  /**
720  * Close a previuously openned file
721  * @return 1 on success, < 0 on error
722  * Error codes:
723  * ISO_FILE_ERROR
724  * ISO_NULL_POINTER
725  * ISO_FILE_NOT_OPENED
726  */
727  int (*close)(IsoFileSource *src);
728 
729  /**
730  * Attempts to read up to count bytes from the given source into
731  * the buffer starting at buf.
732  *
733  * The file src must be open() before calling this, and close() when no
734  * more needed. Not valid for dirs. On symlinks it reads the destination
735  * file.
736  *
737  * @return
738  * number of bytes read, 0 if EOF, < 0 on error (has to be a valid
739  * libisofs error code)
740  * Error codes:
741  * ISO_FILE_ERROR
742  * ISO_NULL_POINTER
743  * ISO_FILE_NOT_OPENED
744  * ISO_WRONG_ARG_VALUE -> if count == 0
745  * ISO_FILE_IS_DIR
746  * ISO_OUT_OF_MEM
747  * ISO_INTERRUPTED
748  */
749  int (*read)(IsoFileSource *src, void *buf, size_t count);
750 
751  /**
752  * Read a directory.
753  *
754  * Each call to this function will return a new children, until we reach
755  * the end of file (i.e, no more children), in that case it returns 0.
756  *
757  * The dir must be open() before calling this, and close() when no more
758  * needed. Only valid for dirs.
759  *
760  * Note that "." and ".." children MUST NOT BE returned.
761  *
762  * @param child
763  * pointer to be filled with the given child. Undefined on error or OEF
764  * @return
765  * 1 on success, 0 if EOF (no more children), < 0 on error (has to be
766  * a valid libisofs error code)
767  * Error codes:
768  * ISO_FILE_ERROR
769  * ISO_NULL_POINTER
770  * ISO_FILE_NOT_OPENED
771  * ISO_FILE_IS_NOT_DIR
772  * ISO_OUT_OF_MEM
773  */
774  int (*readdir)(IsoFileSource *src, IsoFileSource **child);
775 
776  /**
777  * Read the destination of a symlink. You don't need to open the file
778  * to call this.
779  *
780  * @param buf
781  * allocated buffer of at least bufsiz bytes.
782  * The dest. will be copied there, and it will be NULL-terminated
783  * @param bufsiz
784  * characters to be copied. Destination link will be truncated if
785  * it is larger than given size. This include the 0x0 character.
786  * @return
787  * 1 on success, < 0 on error (has to be a valid libisofs error code)
788  * Error codes:
789  * ISO_FILE_ERROR
790  * ISO_NULL_POINTER
791  * ISO_WRONG_ARG_VALUE -> if bufsiz <= 0
792  * ISO_FILE_IS_NOT_SYMLINK
793  * ISO_OUT_OF_MEM
794  * ISO_FILE_BAD_PATH
795  * ISO_FILE_DOESNT_EXIST
796  *
797  */
798  int (*readlink)(IsoFileSource *src, char *buf, size_t bufsiz);
799 
800  /**
801  * Get the filesystem for this source. No extra ref is added, so you
802  * musn't unref the IsoFilesystem.
803  *
804  * @return
805  * The filesystem, NULL on error
806  */
807  IsoFilesystem* (*get_filesystem)(IsoFileSource *src);
808 
809  /**
810  * Free implementation specific data. Should never be called by user.
811  * Use iso_file_source_unref() instead.
812  */
813  void (*free)(IsoFileSource *src);
814 
815  /**
816  * Repositions the offset of the IsoFileSource (must be opened) to the
817  * given offset according to the value of flag.
818  *
819  * @param offset
820  * in bytes
821  * @param flag
822  * 0 The offset is set to offset bytes (SEEK_SET)
823  * 1 The offset is set to its current location plus offset bytes
824  * (SEEK_CUR)
825  * 2 The offset is set to the size of the file plus offset bytes
826  * (SEEK_END).
827  * @return
828  * Absolute offset position of the file, or < 0 on error. Cast the
829  * returning value to int to get a valid libisofs error.
830  *
831  * @since 0.6.4
832  */
833  off_t (*lseek)(IsoFileSource *src, off_t offset, int flag);
834 
835  /* Add-ons of .version 1 begin here */
836 
837  /**
838  * Valid only if .version is > 0. See above.
839  * Get the AAIP string with encoded ACL and xattr.
840  * (Not to be confused with ECMA-119 Extended Attributes).
841  *
842  * bit1 and bit2 of flag should be implemented so that freshly fetched
843  * info does not include the undesired ACL or xattr. Nevertheless if the
844  * aa_string is cached, then it is permissible that ACL and xattr are still
845  * delivered.
846  *
847  * @param flag Bitfield for control purposes
848  * bit0= Transfer ownership of AAIP string data.
849  * src will free the eventual cached data and might
850  * not be able to produce it again.
851  * bit1= No need to get ACL (no guarantee of exclusion)
852  * bit2= No need to get xattr (no guarantee of exclusion)
853  * @param aa_string Returns a pointer to the AAIP string data. If no AAIP
854  * string is available, *aa_string becomes NULL.
855  * (See doc/susp_aaip_*_*.txt for the meaning of AAIP and
856  * libisofs/aaip_0_2.h for encoding and decoding.)
857  * The caller is responsible for finally calling free()
858  * on non-NULL results.
859  * @return 1 means success (*aa_string == NULL is possible)
860  * <0 means failure and must b a valid libisofs error code
861  * (e.g. ISO_FILE_ERROR if no better one can be found).
862  * @since 0.6.14
863  */
865  unsigned char **aa_string, int flag);
866 
867  /**
868  * Produce a copy of a source. It must be possible to operate both source
869  * objects concurrently.
870  *
871  * @param old_src
872  * The existing source object to be copied
873  * @param new_stream
874  * Will return a pointer to the copy
875  * @param flag
876  * Bitfield for control purposes. Submit 0 for now.
877  * The function shall return ISO_STREAM_NO_CLONE on unknown flag bits.
878  *
879  * @since 1.0.2
880  * Present if .version is 2 or higher.
881  */
882  int (*clone_src)(IsoFileSource *old_src, IsoFileSource **new_src,
883  int flag);
884 
885  /*
886  * TODO #00004 Add a get_mime_type() function.
887  * This can be useful for GUI apps, to choose the icon of the file
888  */
889 };
890 
891 #ifndef __cplusplus
892 #ifndef Libisofs_h_as_cpluspluS
893 
894 /**
895  * An IsoFile Source is a POSIX abstraction of a file.
896  *
897  * @since 0.6.2
898  */
900 {
901  const IsoFileSourceIface *class;
902  int refcount;
903  void *data;
904 };
905 
906 #endif /* ! Libisofs_h_as_cpluspluS */
907 #endif /* ! __cplusplus */
908 
909 
910 /* A class of IsoStream is implemented by a class description
911  * IsoStreamIface = struct IsoStream_Iface
912  * and a structure of data storage for each instance of IsoStream.
913  * This structure shall be known to the functions of the IsoStreamIface.
914  * To create a custom IsoStream class:
915  * - Define the structure of the custom instance data.
916  * - Implement the methods which are described by the definition of
917  * struct IsoStream_Iface (see below),
918  * - Create a static instance of IsoStreamIface which lists the methods as
919  * C function pointers. (Example in libisofs/stream.c : fsrc_stream_class)
920  * To create an instance of that class:
921  * - Allocate sizeof(IsoStream) bytes of memory and initialize it as
922  * struct iso_stream :
923  * - Point to the custom IsoStreamIface by member .class .
924  * - Set member .refcount to 1.
925  * - Let member .data point to the custom instance data.
926  *
927  * Regrettably the choice of the structure member name "class" makes it
928  * impossible to implement this generic interface in C++ language directly.
929  * If C++ is absolutely necessary then you will have to make own copies
930  * of the public API structures. Use other names but take care to maintain
931  * the same memory layout.
932  */
933 
934 /**
935  * Representation of file contents. It is an stream of bytes, functionally
936  * like a pipe.
937  *
938  * @since 0.6.4
939  */
940 typedef struct iso_stream IsoStream;
941 
942 /**
943  * Interface that defines the operations (methods) available for an
944  * IsoStream.
945  *
946  * @see struct IsoStream_Iface
947  * @since 0.6.4
948  */
950 
951 /**
952  * Serial number to be used when you can't get a valid id for a Stream by other
953  * means. If you use this, both fs_id and dev_id should be set to 0.
954  * This must be incremented each time you get a reference to it.
955  *
956  * @see IsoStreamIface->get_id()
957  * @since 0.6.4
958  */
959 extern ino_t serial_id;
960 
961 /**
962  * Interface definition for IsoStream methods. It is public to allow
963  * implementation of own stream types.
964  * The methods defined here typically make use of stream.data which points
965  * to the individual state data of stream instances.
966  *
967  * @since 0.6.4
968  */
969 
971 {
972  /*
973  * Current version of the interface.
974  * Version 0 (since 0.6.4)
975  * deprecated but still valid.
976  * Version 1 (since 0.6.8)
977  * update_size() added.
978  * Version 2 (since 0.6.18)
979  * get_input_stream() added.
980  * A filter stream must have version 2 at least.
981  * Version 3 (since 0.6.20)
982  * compare() added.
983  * A filter stream should have version 3 at least.
984  * Version 4 (since 1.0.2)
985  * clone_stream() added.
986  */
987  int version;
988 
989  /**
990  * Type of Stream.
991  * "fsrc" -> Read from file source
992  * "cout" -> Cut out interval from disk file
993  * "mem " -> Read from memory
994  * "boot" -> Boot catalog
995  * "extf" -> External filter program
996  * "ziso" -> zisofs compression
997  * "osiz" -> zisofs uncompression
998  * "gzip" -> gzip compression
999  * "pizg" -> gzip uncompression (gunzip)
1000  * "user" -> User supplied stream
1001  */
1002  char type[4];
1003 
1004  /**
1005  * Opens the stream.
1006  *
1007  * @return
1008  * 1 on success, 2 file greater than expected, 3 file smaller than
1009  * expected, < 0 on error (has to be a valid libisofs error code)
1010  */
1011  int (*open)(IsoStream *stream);
1012 
1013  /**
1014  * Close the Stream.
1015  * @return
1016  * 1 on success, < 0 on error (has to be a valid libisofs error code)
1017  */
1018  int (*close)(IsoStream *stream);
1019 
1020  /**
1021  * Get the size (in bytes) of the stream. This function should always
1022  * return the same size, even if the underlying source size changes,
1023  * unless you call update_size() method.
1024  */
1025  off_t (*get_size)(IsoStream *stream);
1026 
1027  /**
1028  * Attempt to read up to count bytes from the given stream into
1029  * the buffer starting at buf. The implementation has to make sure that
1030  * either the full desired count of bytes is delivered or that the
1031  * next call to this function will return EOF or error.
1032  * I.e. only the last read block may be shorter than parameter count.
1033  *
1034  * The stream must be open() before calling this, and close() when no
1035  * more needed.
1036  *
1037  * @return
1038  * number of bytes read, 0 if EOF, < 0 on error (has to be a valid
1039  * libisofs error code)
1040  */
1041  int (*read)(IsoStream *stream, void *buf, size_t count);
1042 
1043  /**
1044  * Tell whether this IsoStream can be read several times, with the same
1045  * results. For example, a regular file is repeatable, you can read it
1046  * as many times as you want. However, a pipe is not.
1047  *
1048  * @return
1049  * 1 if stream is repeatable, 0 if not,
1050  * < 0 on error (has to be a valid libisofs error code)
1051  */
1052  int (*is_repeatable)(IsoStream *stream);
1053 
1054  /**
1055  * Get an unique identifier for the IsoStream.
1056  */
1057  void (*get_id)(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
1058  ino_t *ino_id);
1059 
1060  /**
1061  * Free implementation specific data. Should never be called by user.
1062  * Use iso_stream_unref() instead.
1063  */
1064  void (*free)(IsoStream *stream);
1065 
1066  /**
1067  * Update the size of the IsoStream with the current size of the underlying
1068  * source, if the source is prone to size changes. After calling this,
1069  * get_size() shall eventually return the new size.
1070  * This will never be called after iso_image_create_burn_source() was
1071  * called and before the image was completely written.
1072  * (The API call to update the size of all files in the image is
1073  * iso_image_update_sizes()).
1074  *
1075  * @return
1076  * 1 if ok, < 0 on error (has to be a valid libisofs error code)
1077  *
1078  * @since 0.6.8
1079  * Present if .version is 1 or higher.
1080  */
1081  int (*update_size)(IsoStream *stream);
1082 
1083  /**
1084  * Retrieve the eventual input stream of a filter stream.
1085  *
1086  * @param stream
1087  * The eventual filter stream to be inquired.
1088  * @param flag
1089  * Bitfield for control purposes. 0 means normal behavior.
1090  * @return
1091  * The input stream, if one exists. Elsewise NULL.
1092  * No extra reference to the stream shall be taken by this call.
1093  *
1094  * @since 0.6.18
1095  * Present if .version is 2 or higher.
1096  */
1097  IsoStream *(*get_input_stream)(IsoStream *stream, int flag);
1098 
1099  /**
1100  * Compare two streams whether they are based on the same input and will
1101  * produce the same output. If in any doubt, then this comparison should
1102  * indicate no match. A match might allow hardlinking of IsoFile objects.
1103  *
1104  * If this function cannot accept one of the given stream types, then
1105  * the decision must be delegated to
1106  * iso_stream_cmp_ino(s1, s2, 1);
1107  * This is also appropriate if one has reason to implement stream.cmp_ino()
1108  * without having an own special comparison algorithm.
1109  *
1110  * With filter streams, the decision whether the underlying chains of
1111  * streams match, should be delegated to
1112  * iso_stream_cmp_ino(iso_stream_get_input_stream(s1, 0),
1113  * iso_stream_get_input_stream(s2, 0), 0);
1114  *
1115  * The stream.cmp_ino() function has to establish an equivalence and order
1116  * relation:
1117  * cmp_ino(A,A) == 0
1118  * cmp_ino(A,B) == -cmp_ino(B,A)
1119  * if cmp_ino(A,B) == 0 && cmp_ino(B,C) == 0 then cmp_ino(A,C) == 0
1120  * if cmp_ino(A,B) < 0 && cmp_ino(B,C) < 0 then cmp_ino(A,C) < 0
1121  *
1122  * A big hazard to the last constraint are tests which do not apply to some
1123  * types of streams.Thus it is mandatory to let iso_stream_cmp_ino(s1,s2,1)
1124  * decide in this case.
1125  *
1126  * A function s1.(*cmp_ino)() must only accept stream s2 if function
1127  * s2.(*cmp_ino)() would accept s1. Best is to accept only the own stream
1128  * type or to have the same function for a family of similar stream types.
1129  *
1130  * @param s1
1131  * The first stream to compare. Expect foreign stream types.
1132  * @param s2
1133  * The second stream to compare. Expect foreign stream types.
1134  * @return
1135  * -1 if s1 is smaller s2 , 0 if s1 matches s2 , 1 if s1 is larger s2
1136  *
1137  * @since 0.6.20
1138  * Present if .version is 3 or higher.
1139  */
1140  int (*cmp_ino)(IsoStream *s1, IsoStream *s2);
1141 
1142  /**
1143  * Produce a copy of a stream. It must be possible to operate both stream
1144  * objects concurrently.
1145  *
1146  * @param old_stream
1147  * The existing stream object to be copied
1148  * @param new_stream
1149  * Will return a pointer to the copy
1150  * @param flag
1151  * Bitfield for control purposes. 0 means normal behavior.
1152  * The function shall return ISO_STREAM_NO_CLONE on unknown flag bits.
1153  * @return
1154  * 1 in case of success, or an error code < 0
1155  *
1156  * @since 1.0.2
1157  * Present if .version is 4 or higher.
1158  */
1159  int (*clone_stream)(IsoStream *old_stream, IsoStream **new_stream,
1160  int flag);
1161 
1162 };
1163 
1164 #ifndef __cplusplus
1165 #ifndef Libisofs_h_as_cpluspluS
1166 
1167 /**
1168  * Representation of file contents as a stream of bytes.
1169  *
1170  * @since 0.6.4
1171  */
1173 {
1176  void *data;
1177 };
1178 
1179 #endif /* ! Libisofs_h_as_cpluspluS */
1180 #endif /* ! __cplusplus */
1181 
1182 
1183 /**
1184  * Initialize libisofs. Before any usage of the library you must either call
1185  * this function or iso_init_with_flag().
1186  * Only exception from this rule: iso_lib_version(), iso_lib_is_compatible().
1187  * @return 1 on success, < 0 on error
1188  *
1189  * @since 0.6.2
1190  */
1191 int iso_init();
1192 
1193 /**
1194  * Initialize libisofs. Before any usage of the library you must either call
1195  * this function or iso_init() which is equivalent to iso_init_with_flag(0).
1196  * Only exception from this rule: iso_lib_version(), iso_lib_is_compatible().
1197  * @param flag
1198  * Bitfield for control purposes
1199  * bit0= do not set up locale by LC_* environment variables
1200  * @return 1 on success, < 0 on error
1201  *
1202  * @since 0.6.18
1203  */
1204 int iso_init_with_flag(int flag);
1205 
1206 /**
1207  * Finalize libisofs.
1208  *
1209  * @since 0.6.2
1210  */
1211 void iso_finish();
1212 
1213 /**
1214  * Override the reply of libc function nl_langinfo(CODESET) which may or may
1215  * not give the name of the character set which is in effect for your
1216  * environment. So this call can compensate for inconsistent terminal setups.
1217  * Another use case is to choose UTF-8 as intermediate character set for a
1218  * conversion from an exotic input character set to an exotic output set.
1219  *
1220  * @param name
1221  * Name of the character set to be assumed as "local" one.
1222  * @param flag
1223  * Unused yet. Submit 0.
1224  * @return
1225  * 1 indicates success, <=0 failure
1226  *
1227  * @since 0.6.12
1228  */
1229 int iso_set_local_charset(char *name, int flag);
1230 
1231 /**
1232  * Obtain the local charset as currently assumed by libisofs.
1233  * The result points to internal memory. It is volatile and must not be
1234  * altered.
1235  *
1236  * @param flag
1237  * Unused yet. Submit 0.
1238  *
1239  * @since 0.6.12
1240  */
1241 char *iso_get_local_charset(int flag);
1242 
1243 /**
1244  * Create a new image, empty.
1245  *
1246  * The image will be owned by you and should be unref() when no more needed.
1247  *
1248  * @param name
1249  * Name of the image. This will be used as volset_id and volume_id.
1250  * @param image
1251  * Location where the image pointer will be stored.
1252  * @return
1253  * 1 sucess, < 0 error
1254  *
1255  * @since 0.6.2
1256  */
1257 int iso_image_new(const char *name, IsoImage **image);
1258 
1259 
1260 /**
1261  * Control whether ACL and xattr will be imported from external filesystems
1262  * (typically the local POSIX filesystem) when new nodes get inserted. If
1263  * enabled by iso_write_opts_set_aaip() they will later be written into the
1264  * image as AAIP extension fields.
1265  *
1266  * A change of this setting does neither affect existing IsoNode objects
1267  * nor the way how ACL and xattr are handled when loading an ISO image.
1268  * The latter is controlled by iso_read_opts_set_no_aaip().
1269  *
1270  * @param image
1271  * The image of which the behavior is to be controlled
1272  * @param what
1273  * A bit field which sets the behavior:
1274  * bit0= ignore ACLs if the external file object bears some
1275  * bit1= ignore xattr if the external file object bears some
1276  * all other bits are reserved
1277  *
1278  * @since 0.6.14
1279  */
1280 void iso_image_set_ignore_aclea(IsoImage *image, int what);
1281 
1282 
1283 /**
1284  * Creates an IsoWriteOpts for writing an image. You should set the options
1285  * desired with the correspondent setters.
1286  *
1287  * Options by default are determined by the selected profile. Fifo size is set
1288  * by default to 2 MB.
1289  *
1290  * @param opts
1291  * Pointer to the location where the newly created IsoWriteOpts will be
1292  * stored. You should free it with iso_write_opts_free() when no more
1293  * needed.
1294  * @param profile
1295  * Default profile for image creation. For now the following values are
1296  * defined:
1297  * ---> 0 [BASIC]
1298  * No extensions are enabled, and ISO level is set to 1. Only suitable
1299  * for usage for very old and limited systems (like MS-DOS), or by a
1300  * start point from which to set your custom options.
1301  * ---> 1 [BACKUP]
1302  * POSIX compatibility for backup. Simple settings, ISO level is set to
1303  * 3 and RR extensions are enabled. Useful for backup purposes.
1304  * Note that ACL and xattr are not enabled by default.
1305  * If you enable them, expect them not to show up in the mounted image.
1306  * They will have to be retrieved by libisofs applications like xorriso.
1307  * ---> 2 [DISTRIBUTION]
1308  * Setting for information distribution. Both RR and Joliet are enabled
1309  * to maximize compatibility with most systems. Permissions are set to
1310  * default values, and timestamps to the time of recording.
1311  * @return
1312  * 1 success, < 0 error
1313  *
1314  * @since 0.6.2
1315  */
1316 int iso_write_opts_new(IsoWriteOpts **opts, int profile);
1317 
1318 /**
1319  * Free an IsoWriteOpts previously allocated with iso_write_opts_new().
1320  *
1321  * @since 0.6.2
1322  */
1323 void iso_write_opts_free(IsoWriteOpts *opts);
1324 
1325 /**
1326  * Announce that only the image size is desired, that the struct burn_source
1327  * which is set to consume the image output stream will stay inactive,
1328  * and that the write thread will be cancelled anyway by the .cancel() method
1329  * of the struct burn_source.
1330  * This avoids to create a write thread which would begin production of the
1331  * image stream and would generate a MISHAP event when burn_source.cancel()
1332  * gets into effect.
1333  *
1334  * @param opts
1335  * The option set to be manipulated.
1336  * @param will_cancel
1337  * 0= normal image generation
1338  * 1= prepare for being canceled before image stream output is completed
1339  * @return
1340  * 1 success, < 0 error
1341  *
1342  * @since 0.6.40
1343  */
1344 int iso_write_opts_set_will_cancel(IsoWriteOpts *opts, int will_cancel);
1345 
1346 /**
1347  * Set the ISO-9960 level to write at.
1348  *
1349  * @param opts
1350  * The option set to be manipulated.
1351  * @param level
1352  * -> 1 for higher compatibility with old systems. With this level
1353  * filenames are restricted to 8.3 characters.
1354  * -> 2 to allow up to 31 filename characters.
1355  * -> 3 to allow files greater than 4GB
1356  * @return
1357  * 1 success, < 0 error
1358  *
1359  * @since 0.6.2
1360  */
1361 int iso_write_opts_set_iso_level(IsoWriteOpts *opts, int level);
1362 
1363 /**
1364  * Whether to use or not Rock Ridge extensions.
1365  *
1366  * This are standard extensions to ECMA-119, intended to add POSIX filesystem
1367  * features to ECMA-119 images. Thus, usage of this flag is highly recommended
1368  * for images used on GNU/Linux systems. With the usage of RR extension, the
1369  * resulting image will have long filenames (up to 255 characters), deeper
1370  * directory structure, POSIX permissions and owner info on files and
1371  * directories, support for symbolic links or special files... All that
1372  * attributes can be modified/setted with the appropiate function.
1373  *
1374  * @param opts
1375  * The option set to be manipulated.
1376  * @param enable
1377  * 1 to enable RR extension, 0 to not add them
1378  * @return
1379  * 1 success, < 0 error
1380  *
1381  * @since 0.6.2
1382  */
1383 int iso_write_opts_set_rockridge(IsoWriteOpts *opts, int enable);
1384 
1385 /**
1386  * Whether to add the non-standard Joliet extension to the image.
1387  *
1388  * This extensions are heavily used in Microsoft Windows systems, so if you
1389  * plan to use your disc on such a system you should add this extension.
1390  * Usage of Joliet supplies longer filesystem length (up to 64 unicode
1391  * characters), and deeper directory structure.
1392  *
1393  * @param opts
1394  * The option set to be manipulated.
1395  * @param enable
1396  * 1 to enable Joliet extension, 0 to not add them
1397  * @return
1398  * 1 success, < 0 error
1399  *
1400  * @since 0.6.2
1401  */
1402 int iso_write_opts_set_joliet(IsoWriteOpts *opts, int enable);
1403 
1404 /**
1405  * Whether to add a HFS+ filesystem to the image which points to the same
1406  * file content as the other directory trees.
1407  * It will get marked by an Apple Partition Map in the System Area of the ISO
1408  * image. This may collide with data submitted by
1409  * iso_write_opts_set_system_area()
1410  * and with settings made by
1411  * el_torito_set_isolinux_options()
1412  * The first 8 bytes of the System Area get overwritten by
1413  * {0x45, 0x52, 0x08 0x00, 0xeb, 0x02, 0xff, 0xff}
1414  * which can be executed as x86 machine code without negative effects.
1415  * So if an MBR gets combined with this feature, then its first 8 bytes
1416  * should contain no essential commands.
1417  * The next blocks of 2 KiB in the System Area will be occupied by APM entries.
1418  * The first one covers the part of the ISO image before the HFS+ filesystem
1419  * metadata. The second one marks the range from HFS+ metadata to the end
1420  * of file content data. If more ISO image data follow, then a third partition
1421  * entry gets produced. Other features of libisofs might cause the need for
1422  * more APM entries.
1423  *
1424  * @param opts
1425  * The option set to be manipulated.
1426  * @param enable
1427  * 1 to enable HFS+ extension, 0 to not add HFS+ metadata and APM
1428  * @return
1429  * 1 success, < 0 error
1430  *
1431  * @since 1.2.4
1432  */
1433 int iso_write_opts_set_hfsplus(IsoWriteOpts *opts, int enable);
1434 
1435 /**
1436  * >>> Production of FAT32 is not implemented yet.
1437  * >>> This call exists only as preparation for implementation.
1438  *
1439  * Whether to add a FAT32 filesystem to the image which points to the same
1440  * file content as the other directory trees.
1441  *
1442  * >>> FAT32 is planned to get implemented in co-existence with HFS+
1443  * >>> Describe impact on MBR
1444  *
1445  * @param opts
1446  * The option set to be manipulated.
1447  * @param enable
1448  * 1 to enable FAT32 extension, 0 to not add FAT metadata
1449  * @return
1450  * 1 success, < 0 error
1451  *
1452  * @since 1.2.4
1453  */
1454 int iso_write_opts_set_fat(IsoWriteOpts *opts, int enable);
1455 
1456 /**
1457  * Supply a serial number for the HFS+ extension of the emerging image.
1458  *
1459  * @param opts
1460  * The option set to be manipulated.
1461  * @param serial_number
1462  * 8 bytes which should be unique to the image.
1463  * If all bytes are 0, then the serial number will be generated as
1464  * random number by libisofs. This is the default setting.
1465  * @return
1466  * 1 success, < 0 error
1467  *
1468  * @since 1.2.4
1469  */
1471  uint8_t serial_number[8]);
1472 
1473 /**
1474  * Set the block size for Apple Partition Map and for HFS+.
1475  *
1476  * @param opts
1477  * The option set to be manipulated.
1478  * @param hfsp_block_size
1479  * The allocation block size to be used by the HFS+ fileystem.
1480  * 0, 512, or 2048
1481  * @param hfsp_block_size
1482  * The block size to be used for and within the Apple Partition Map.
1483  * 0, 512, or 2048.
1484  * Size 512 is not compatible with options which produce GPT.
1485  * @return
1486  * 1 success, < 0 error
1487  *
1488  * @since 1.2.4
1489  */
1491  int hfsp_block_size, int apm_block_size);
1492 
1493 
1494 /**
1495  * Whether to use newer ISO-9660:1999 version.
1496  *
1497  * This is the second version of ISO-9660. It allows longer filenames and has
1498  * less restrictions than old ISO-9660. However, nobody is using it so there
1499  * are no much reasons to enable this.
1500  *
1501  * @since 0.6.2
1502  */
1503 int iso_write_opts_set_iso1999(IsoWriteOpts *opts, int enable);
1504 
1505 /**
1506  * Control generation of non-unique inode numbers for the emerging image.
1507  * Inode numbers get written as "file serial number" with PX entries as of
1508  * RRIP-1.12. They may mark families of hardlinks.
1509  * RRIP-1.10 prescribes a PX entry without file serial number. If not overriden
1510  * by iso_write_opts_set_rrip_1_10_px_ino() there will be no file serial number
1511  * written into RRIP-1.10 images.
1512  *
1513  * Inode number generation does not affect IsoNode objects which imported their
1514  * inode numbers from the old ISO image (see iso_read_opts_set_new_inos())
1515  * and which have not been altered since import. It rather applies to IsoNode
1516  * objects which were newly added to the image, or to IsoNode which brought no
1517  * inode number from the old image, or to IsoNode where certain properties
1518  * have been altered since image import.
1519  *
1520  * If two IsoNode are found with same imported inode number but differing
1521  * properties, then one of them will get assigned a new unique inode number.
1522  * I.e. the hardlink relation between both IsoNode objects ends.
1523  *
1524  * @param opts
1525  * The option set to be manipulated.
1526  * @param enable
1527  * 1 = Collect IsoNode objects which have identical data sources and
1528  * properties.
1529  * 0 = Generate unique inode numbers for all IsoNode objects which do not
1530  * have a valid inode number from an imported ISO image.
1531  * All other values are reserved.
1532  *
1533  * @since 0.6.20
1534  */
1535 int iso_write_opts_set_hardlinks(IsoWriteOpts *opts, int enable);
1536 
1537 /**
1538  * Control writing of AAIP informations for ACL and xattr.
1539  * For importing ACL and xattr when inserting nodes from external filesystems
1540  * (e.g. the local POSIX filesystem) see iso_image_set_ignore_aclea().
1541  * For loading of this information from images see iso_read_opts_set_no_aaip().
1542  *
1543  * @param opts
1544  * The option set to be manipulated.
1545  * @param enable
1546  * 1 = write AAIP information from nodes into the image
1547  * 0 = do not write AAIP information into the image
1548  * All other values are reserved.
1549  *
1550  * @since 0.6.14
1551  */
1552 int iso_write_opts_set_aaip(IsoWriteOpts *opts, int enable);
1553 
1554 /**
1555  * Use this only if you need to reproduce a suboptimal behavior of older
1556  * versions of libisofs. They used address 0 for links and device files,
1557  * and the address of the Volume Descriptor Set Terminator for empty data
1558  * files.
1559  * New versions let symbolic links, device files, and empty data files point
1560  * to a dedicated block of zero-bytes after the end of the directory trees.
1561  * (Single-pass reader libarchive needs to see all directory info before
1562  * processing any data files.)
1563  *
1564  * @param opts
1565  * The option set to be manipulated.
1566  * @param enable
1567  * 1 = use the suboptimal block addresses in the range of 0 to 115.
1568  * 0 = use the address of a block after the directory tree. (Default)
1569  *
1570  * @since 1.0.2
1571  */
1572 int iso_write_opts_set_old_empty(IsoWriteOpts *opts, int enable);
1573 
1574 /**
1575  * Caution: This option breaks any assumptions about names that
1576  * are supported by ECMA-119 specifications.
1577  * Try to omit any translation which would make a file name compliant to the
1578  * ECMA-119 rules. This includes and exceeds omit_version_numbers,
1579  * max_37_char_filenames, no_force_dots bit0, allow_full_ascii. Further it
1580  * prevents the conversion from local character set to ASCII.
1581  * The maximum name length is given by this call. If a filename exceeds
1582  * this length or cannot be recorded untranslated for other reasons, then
1583  * image production is aborted with ISO_NAME_NEEDS_TRANSL.
1584  * Currently the length limit is 96 characters, because an ECMA-119 directory
1585  * record may at most have 254 bytes and up to 158 other bytes must fit into
1586  * the record. Probably 96 more bytes can be made free for the name in future.
1587  * @param opts
1588  * The option set to be manipulated.
1589  * @param len
1590  * 0 = disable this feature and perform name translation according to
1591  * other settings.
1592  * >0 = Omit any translation. Eventually abort image production
1593  * if a name is longer than the given value.
1594  * -1 = Like >0. Allow maximum possible length (currently 96)
1595  * @return >=0 success, <0 failure
1596  * In case of >=0 the return value tells the effectively set len.
1597  * E.g. 96 after using len == -1.
1598  * @since 1.0.0
1599  */
1601 
1602 /**
1603  * Convert directory names for ECMA-119 similar to other file names, but do
1604  * not force a dot or add a version number.
1605  * This violates ECMA-119 by allowing one "." and especially ISO level 1
1606  * by allowing DOS style 8.3 names rather than only 8 characters.
1607  * (mkisofs and its clones seem to do this violation.)
1608  * @param opts
1609  * The option set to be manipulated.
1610  * @param allow
1611  * 1= allow dots , 0= disallow dots and convert them
1612  * @return
1613  * 1 success, < 0 error
1614  * @since 1.0.0
1615  */
1617 
1618 /**
1619  * Omit the version number (";1") at the end of the ISO-9660 identifiers.
1620  * This breaks ECMA-119 specification, but version numbers are usually not
1621  * used, so it should work on most systems. Use with caution.
1622  * @param opts
1623  * The option set to be manipulated.
1624  * @param omit
1625  * bit0= omit version number with ECMA-119 and Joliet
1626  * bit1= omit version number with Joliet alone (@since 0.6.30)
1627  * @since 0.6.2
1628  */
1630 
1631 /**
1632  * Allow ISO-9660 directory hierarchy to be deeper than 8 levels.
1633  * This breaks ECMA-119 specification. Use with caution.
1634  *
1635  * @since 0.6.2
1636  */
1638 
1639 /**
1640  * This call describes the directory where to store Rock Ridge relocated
1641  * directories.
1642  * If not iso_write_opts_set_allow_deep_paths(,1) is in effect, then it may
1643  * become necessary to relocate directories so that no ECMA-119 file path
1644  * has more than 8 components. These directories are grafted into either
1645  * the root directory of the ISO image or into a dedicated relocation
1646  * directory.
1647  * For Rock Ridge, the relocated directories are linked forth and back to
1648  * placeholders at their original positions in path level 8. Directories
1649  * marked by Rock Ridge entry RE are to be considered artefacts of relocation
1650  * and shall not be read into a Rock Ridge tree. Instead they are to be read
1651  * via their placeholders and their links.
1652  * For plain ECMA-119, the relocation directory and the relocated directories
1653  * are just normal directories which contain normal files and directories.
1654  * @param opts
1655  * The option set to be manipulated.
1656  * @param name
1657  * The name of the relocation directory in the root directory. Do not
1658  * prepend "/". An empty name or NULL will direct relocated directories
1659  * into the root directory. This is the default.
1660  * If the given name does not exist in the root directory when
1661  * iso_image_create_burn_source() is called, and if there are directories
1662  * at path level 8, then directory /name will be created automatically.
1663  * The name given by this call will be compared with iso_node_get_name()
1664  * of the directories in the root directory, not with the final ECMA-119
1665  * names of those directories.
1666  * @parm flags
1667  * Bitfield for control purposes.
1668  * bit0= Mark the relocation directory by a Rock Ridge RE entry, if it
1669  * gets created during iso_image_create_burn_source(). This will
1670  * make it invisible for most Rock Ridge readers.
1671  * bit1= not settable via API (used internally)
1672  * @return
1673  * 1 success, < 0 error
1674  * @since 1.2.2
1675 */
1676 int iso_write_opts_set_rr_reloc(IsoWriteOpts *opts, char *name, int flags);
1677 
1678 /**
1679  * Allow path in the ISO-9660 tree to have more than 255 characters.
1680  * This breaks ECMA-119 specification. Use with caution.
1681  *
1682  * @since 0.6.2
1683  */
1685 
1686 /**
1687  * Allow a single file or directory identifier to have up to 37 characters.
1688  * This is larger than the 31 characters allowed by ISO level 2, and the
1689  * extra space is taken from the version number, so this also forces
1690  * omit_version_numbers.
1691  * This breaks ECMA-119 specification and could lead to buffer overflow
1692  * problems on old systems. Use with caution.
1693  *
1694  * @since 0.6.2
1695  */
1697 
1698 /**
1699  * ISO-9660 forces filenames to have a ".", that separates file name from
1700  * extension. libisofs adds it if original filename doesn't has one. Set
1701  * this to 1 to prevent this behavior.
1702  * This breaks ECMA-119 specification. Use with caution.
1703  *
1704  * @param opts
1705  * The option set to be manipulated.
1706  * @param no
1707  * bit0= no forced dot with ECMA-119
1708  * bit1= no forced dot with Joliet (@since 0.6.30)
1709  *
1710  * @since 0.6.2
1711  */
1713 
1714 /**
1715  * Allow lowercase characters in ISO-9660 filenames. By default, only
1716  * uppercase characters, numbers and a few other characters are allowed.
1717  * This breaks ECMA-119 specification. Use with caution.
1718  * If lowercase is not allowed then those letters get mapped to uppercase
1719  * letters.
1720  *
1721  * @since 0.6.2
1722  */
1723 int iso_write_opts_set_allow_lowercase(IsoWriteOpts *opts, int allow);
1724 
1725 /**
1726  * Allow all 8-bit characters to appear on an ISO-9660 filename. Note
1727  * that "/" and 0x0 characters are never allowed, even in RR names.
1728  * This breaks ECMA-119 specification. Use with caution.
1729  *
1730  * @since 0.6.2
1731  */
1733 
1734 /**
1735  * If not iso_write_opts_set_allow_full_ascii() is set to 1:
1736  * Allow all 7-bit characters that would be allowed by allow_full_ascii, but
1737  * map lowercase to uppercase if iso_write_opts_set_allow_lowercase()
1738  * is not set to 1.
1739  * @param opts
1740  * The option set to be manipulated.
1741  * @param allow
1742  * If not zero, then allow what is described above.
1743  *
1744  * @since 1.2.2
1745  */
1747 
1748 /**
1749  * Allow all characters to be part of Volume and Volset identifiers on
1750  * the Primary Volume Descriptor. This breaks ISO-9660 contraints, but
1751  * should work on modern systems.
1752  *
1753  * @since 0.6.2
1754  */
1756 
1757 /**
1758  * Allow paths in the Joliet tree to have more than 240 characters.
1759  * This breaks Joliet specification. Use with caution.
1760  *
1761  * @since 0.6.2
1762  */
1764 
1765 /**
1766  * Allow leaf names in the Joliet tree to have up to 103 characters.
1767  * Normal limit is 64.
1768  * This breaks Joliet specification. Use with caution.
1769  *
1770  * @since 1.0.6
1771  */
1773 
1774 /**
1775  * Use character set UTF-16BE with Joliet, which is a superset of the
1776  * actually prescribed character set UCS-2.
1777  * This breaks Joliet specification with exotic characters which would
1778  * elsewise be mapped to underscore '_'. Use with caution.
1779  *
1780  * @since 1.3.6
1781  */
1782 int iso_write_opts_set_joliet_utf16(IsoWriteOpts *opts, int allow);
1783 
1784 /**
1785  * Write Rock Ridge info as of specification RRIP-1.10 rather than RRIP-1.12:
1786  * signature "RRIP_1991A" rather than "IEEE_1282", field PX without file
1787  * serial number.
1788  *
1789  * @since 0.6.12
1790  */
1791 int iso_write_opts_set_rrip_version_1_10(IsoWriteOpts *opts, int oldvers);
1792 
1793 /**
1794  * Write field PX with file serial number (i.e. inode number) even if
1795  * iso_write_opts_set_rrip_version_1_10(,1) is in effect.
1796  * This clearly violates the RRIP-1.10 specs. But it is done by mkisofs since
1797  * a while and no widespread protest is visible in the web.
1798  * If this option is not enabled, then iso_write_opts_set_hardlinks() will
1799  * only have an effect with iso_write_opts_set_rrip_version_1_10(,0).
1800  *
1801  * @since 0.6.20
1802  */
1803 int iso_write_opts_set_rrip_1_10_px_ino(IsoWriteOpts *opts, int enable);
1804 
1805 /**
1806  * Write AAIP as extension according to SUSP 1.10 rather than SUSP 1.12.
1807  * I.e. without announcing it by an ER field and thus without the need
1808  * to preceed the RRIP fields and the AAIP field by ES fields.
1809  * This saves 5 to 10 bytes per file and might avoid problems with readers
1810  * which dislike ER fields other than the ones for RRIP.
1811  * On the other hand, SUSP 1.12 frowns on such unannounced extensions
1812  * and prescribes ER and ES. It does this since the year 1994.
1813  *
1814  * In effect only if above iso_write_opts_set_aaip() enables writing of AAIP.
1815  *
1816  * @since 0.6.14
1817  */
1818 int iso_write_opts_set_aaip_susp_1_10(IsoWriteOpts *opts, int oldvers);
1819 
1820 /**
1821  * Store as ECMA-119 Directory Record timestamp the mtime of the source node
1822  * rather than the image creation time.
1823  * If storing of mtime is enabled, then the settings of
1824  * iso_write_opts_set_replace_timestamps() apply. (replace==1 will revoke,
1825  * replace==2 will override mtime by iso_write_opts_set_default_timestamp().
1826  *
1827  * Since version 1.2.0 this may apply also to Joliet and ISO 9660:1999. To
1828  * reduce the probability of unwanted behavior changes between pre-1.2.0 and
1829  * post-1.2.0, the bits for Joliet and ISO 9660:1999 also enable ECMA-119.
1830  * The hopefully unlikely bit14 may then be used to disable mtime for ECMA-119.
1831  *
1832  * To enable mtime for all three directory trees, submit 7.
1833  * To disable this feature completely, submit 0.
1834  *
1835  * @param opts
1836  * The option set to be manipulated.
1837  * @param allow
1838  * If this parameter is negative, then mtime is enabled only for ECMA-119.
1839  * With positive numbers, the parameter is interpreted as bit field :
1840  * bit0= enable mtime for ECMA-119
1841  * bit1= enable mtime for Joliet and ECMA-119
1842  * bit2= enable mtime for ISO 9660:1999 and ECMA-119
1843  * bit14= disable mtime for ECMA-119 although some of the other bits
1844  * would enable it
1845  * @since 1.2.0
1846  * Before version 1.2.0 this applied only to ECMA-119 :
1847  * 0 stored image creation time in ECMA-119 tree.
1848  * Any other value caused storing of mtime.
1849  * Joliet and ISO 9660:1999 always stored the image creation time.
1850  * @since 0.6.12
1851  */
1852 int iso_write_opts_set_dir_rec_mtime(IsoWriteOpts *opts, int allow);
1853 
1854 /**
1855  * Whether to sort files based on their weight.
1856  *
1857  * @see iso_node_set_sort_weight
1858  * @since 0.6.2
1859  */
1860 int iso_write_opts_set_sort_files(IsoWriteOpts *opts, int sort);
1861 
1862 /**
1863  * Whether to compute and record MD5 checksums for the whole session and/or
1864  * for each single IsoFile object. The checksums represent the data as they
1865  * were written into the image output stream, not necessarily as they were
1866  * on hard disk at any point of time.
1867  * See also calls iso_image_get_session_md5() and iso_file_get_md5().
1868  * @param opts
1869  * The option set to be manipulated.
1870  * @param session
1871  * If bit0 set: Compute session checksum
1872  * @param files
1873  * If bit0 set: Compute a checksum for each single IsoFile object which
1874  * gets its data content written into the session. Copy
1875  * checksums from files which keep their data in older
1876  * sessions.
1877  * If bit1 set: Check content stability (only with bit0). I.e. before
1878  * writing the file content into to image stream, read it
1879  * once and compute a MD5. Do a second reading for writing
1880  * into the image stream. Afterwards compare both MD5 and
1881  * issue a MISHAP event ISO_MD5_STREAM_CHANGE if they do not
1882  * match.
1883  * Such a mismatch indicates content changes between the
1884  * time point when the first MD5 reading started and the
1885  * time point when the last block was read for writing.
1886  * So there is high risk that the image stream was fed from
1887  * changing and possibly inconsistent file content.
1888  *
1889  * @since 0.6.22
1890  */
1891 int iso_write_opts_set_record_md5(IsoWriteOpts *opts, int session, int files);
1892 
1893 /**
1894  * Set the parameters "name" and "timestamp" for a scdbackup checksum tag.
1895  * It will be appended to the libisofs session tag if the image starts at
1896  * LBA 0 (see iso_write_opts_set_ms_block()). The scdbackup tag can be used
1897  * to verify the image by command scdbackup_verify device -auto_end.
1898  * See scdbackup/README appendix VERIFY for its inner details.
1899  *
1900  * @param opts
1901  * The option set to be manipulated.
1902  * @param name
1903  * A word of up to 80 characters. Typically volno_totalno telling
1904  * that this is volume volno of a total of totalno volumes.
1905  * @param timestamp
1906  * A string of 13 characters YYMMDD.hhmmss (e.g. A90831.190324).
1907  * A9 = 2009, B0 = 2010, B1 = 2011, ... C0 = 2020, ...
1908  * @param tag_written
1909  * Either NULL or the address of an array with at least 512 characters.
1910  * In the latter case the eventually produced scdbackup tag will be
1911  * copied to this array when the image gets written. This call sets
1912  * scdbackup_tag_written[0] = 0 to mark its preliminary invalidity.
1913  * @return
1914  * 1 indicates success, <0 is error
1915  *
1916  * @since 0.6.24
1917  */
1919  char *name, char *timestamp,
1920  char *tag_written);
1921 
1922 /**
1923  * Whether to set default values for files and directory permissions, gid and
1924  * uid. All these take one of three values: 0, 1 or 2.
1925  *
1926  * If 0, the corresponding attribute will be kept as set in the IsoNode.
1927  * Unless you have changed it, it corresponds to the value on disc, so it
1928  * is suitable for backup purposes. If set to 1, the corresponding attrib.
1929  * will be changed by a default suitable value. Finally, if you set it to
1930  * 2, the attrib. will be changed with the value specified by the functioins
1931  * below. Note that for mode attributes, only the permissions are set, the
1932  * file type remains unchanged.
1933  *
1934  * @see iso_write_opts_set_default_dir_mode
1935  * @see iso_write_opts_set_default_file_mode
1936  * @see iso_write_opts_set_default_uid
1937  * @see iso_write_opts_set_default_gid
1938  * @since 0.6.2
1939  */
1940 int iso_write_opts_set_replace_mode(IsoWriteOpts *opts, int dir_mode,
1941  int file_mode, int uid, int gid);
1942 
1943 /**
1944  * Set the mode to use on dirs when you set the replace_mode of dirs to 2.
1945  *
1946  * @see iso_write_opts_set_replace_mode
1947  * @since 0.6.2
1948  */
1949 int iso_write_opts_set_default_dir_mode(IsoWriteOpts *opts, mode_t dir_mode);
1950 
1951 /**
1952  * Set the mode to use on files when you set the replace_mode of files to 2.
1953  *
1954  * @see iso_write_opts_set_replace_mode
1955  * @since 0.6.2
1956  */
1957 int iso_write_opts_set_default_file_mode(IsoWriteOpts *opts, mode_t file_mode);
1958 
1959 /**
1960  * Set the uid to use when you set the replace_uid to 2.
1961  *
1962  * @see iso_write_opts_set_replace_mode
1963  * @since 0.6.2
1964  */
1965 int iso_write_opts_set_default_uid(IsoWriteOpts *opts, uid_t uid);
1966 
1967 /**
1968  * Set the gid to use when you set the replace_gid to 2.
1969  *
1970  * @see iso_write_opts_set_replace_mode
1971  * @since 0.6.2
1972  */
1973 int iso_write_opts_set_default_gid(IsoWriteOpts *opts, gid_t gid);
1974 
1975 /**
1976  * 0 to use IsoNode timestamps, 1 to use recording time, 2 to use
1977  * values from timestamp field. This applies to the timestamps of Rock Ridge
1978  * and if the use of mtime is enabled by iso_write_opts_set_dir_rec_mtime().
1979  * In the latter case, value 1 will revoke the recording of mtime, value
1980  * 2 will override mtime by iso_write_opts_set_default_timestamp().
1981  *
1982  * @see iso_write_opts_set_default_timestamp
1983  * @since 0.6.2
1984  */
1985 int iso_write_opts_set_replace_timestamps(IsoWriteOpts *opts, int replace);
1986 
1987 /**
1988  * Set the timestamp to use when you set the replace_timestamps to 2.
1989  *
1990  * @see iso_write_opts_set_replace_timestamps
1991  * @since 0.6.2
1992  */
1993 int iso_write_opts_set_default_timestamp(IsoWriteOpts *opts, time_t timestamp);
1994 
1995 /**
1996  * Whether to always record timestamps in GMT.
1997  *
1998  * By default, libisofs stores local time information on image. You can set
1999  * this to always store timestamps converted to GMT. This prevents any
2000  * discrimination of the timezone of the image preparer by the image reader.
2001  *
2002  * It is useful if you want to hide your timezone, or you live in a timezone
2003  * that can't be represented in ECMA-119. These are timezones with an offset
2004  * from GMT greater than +13 hours, lower than -12 hours, or not a multiple
2005  * of 15 minutes.
2006  * Negative timezones (west of GMT) can trigger bugs in some operating systems
2007  * which typically appear in mounted ISO images as if the timezone shift from
2008  * GMT was applied twice (e.g. in New York 22:36 becomes 17:36).
2009  *
2010  * @since 0.6.2
2011  */
2012 int iso_write_opts_set_always_gmt(IsoWriteOpts *opts, int gmt);
2013 
2014 /**
2015  * Set the charset to use for the RR names of the files that will be created
2016  * on the image.
2017  * NULL to use default charset, that is the locale charset.
2018  * You can obtain the list of charsets supported on your system executing
2019  * "iconv -l" in a shell.
2020  *
2021  * @since 0.6.2
2022  */
2023 int iso_write_opts_set_output_charset(IsoWriteOpts *opts, const char *charset);
2024 
2025 /**
2026  * Set the type of image creation in case there was already an existing
2027  * image imported. Libisofs supports two types of creation:
2028  * stand-alone and appended.
2029  *
2030  * A stand-alone image is an image that does not need the old image any more
2031  * for being mounted by the operating system or imported by libisofs. It may
2032  * be written beginning with byte 0 of optical media or disk file objects.
2033  * There will be no distinction between files from the old image and those
2034  * which have been added by the new image generation.
2035  *
2036  * On the other side, an appended image is not self contained. It may refer
2037  * to files that stay stored in the imported existing image.
2038  * This usage model is inspired by CD multi-session. It demands that the
2039  * appended image is finally written to the same media resp. disk file
2040  * as the imported image at an address behind the end of that imported image.
2041  * The exact address may depend on media peculiarities and thus has to be
2042  * announced by the application via iso_write_opts_set_ms_block().
2043  * The real address where the data will be written is under control of the
2044  * consumer of the struct burn_source which takes the output of libisofs
2045  * image generation. It may be the one announced to libisofs or an intermediate
2046  * one. Nevertheless, the image will be readable only at the announced address.
2047  *
2048  * If you have not imported a previous image by iso_image_import(), then the
2049  * image will always be a stand-alone image, as there is no previous data to
2050  * refer to.
2051  *
2052  * @param opts
2053  * The option set to be manipulated.
2054  * @param append
2055  * 1 to create an appended image, 0 for an stand-alone one.
2056  *
2057  * @since 0.6.2
2058  */
2059 int iso_write_opts_set_appendable(IsoWriteOpts *opts, int append);
2060 
2061 /**
2062  * Set the start block of the image. It is supposed to be the lba where the
2063  * first block of the image will be written on disc. All references inside the
2064  * ISO image will take this into account, thus providing a mountable image.
2065  *
2066  * For appendable images, that are written to a new session, you should
2067  * pass here the lba of the next writable address on disc.
2068  *
2069  * In stand alone images this is usually 0. However, you may want to
2070  * provide a different ms_block if you don't plan to burn the image in the
2071  * first session on disc, such as in some CD-Extra disc whether the data
2072  * image is written in a new session after some audio tracks.
2073  *
2074  * @since 0.6.2
2075  */
2076 int iso_write_opts_set_ms_block(IsoWriteOpts *opts, uint32_t ms_block);
2077 
2078 /**
2079  * Sets the buffer where to store the descriptors which shall be written
2080  * at the beginning of an overwriteable media to point to the newly written
2081  * image.
2082  * This is needed if the write start address of the image is not 0.
2083  * In this case the first 64 KiB of the media have to be overwritten
2084  * by the buffer content after the session was written and the buffer
2085  * was updated by libisofs. Otherwise the new session would not be
2086  * found by operating system function mount() or by libisoburn.
2087  * (One could still mount that session if its start address is known.)
2088  *
2089  * If you do not need this information, for example because you are creating a
2090  * new image for LBA 0 or because you will create an image for a true
2091  * multisession media, just do not use this call or set buffer to NULL.
2092  *
2093  * Use cases:
2094  *
2095  * - Together with iso_write_opts_set_appendable(opts, 1) the buffer serves
2096  * for the growing of an image as done in growisofs by Andy Polyakov.
2097  * This allows appending of a new session to non-multisession media, such
2098  * as DVD+RW. The new session will refer to the data of previous sessions
2099  * on the same media.
2100  * libisoburn emulates multisession appendability on overwriteable media
2101  * and disk files by performing this use case.
2102  *
2103  * - Together with iso_write_opts_set_appendable(opts, 0) the buffer allows
2104  * to write the first session on overwriteable media to start addresses
2105  * other than 0.
2106  * This address must not be smaller than 32 blocks plus the eventual
2107  * partition offset as defined by iso_write_opts_set_part_offset().
2108  * libisoburn in most cases writes the first session on overwriteable media
2109  * and disk files to LBA (32 + partition_offset) in order to preserve its
2110  * descriptors from the subsequent overwriting by the descriptor buffer of
2111  * later sessions.
2112  *
2113  * @param opts
2114  * The option set to be manipulated.
2115  * @param overwrite
2116  * When not NULL, it should point to at least 64KiB of memory, where
2117  * libisofs will install the contents that shall be written at the
2118  * beginning of overwriteable media.
2119  * You should initialize the buffer either with 0s, or with the contents
2120  * of the first 32 blocks of the image you are growing. In most cases,
2121  * 0 is good enought.
2122  * IMPORTANT: If you use iso_write_opts_set_part_offset() then the
2123  * overwrite buffer must be larger by the offset defined there.
2124  *
2125  * @since 0.6.2
2126  */
2127 int iso_write_opts_set_overwrite_buf(IsoWriteOpts *opts, uint8_t *overwrite);
2128 
2129 /**
2130  * Set the size, in number of blocks, of the ring buffer used between the
2131  * writer thread and the burn_source. You have to provide at least a 32
2132  * blocks buffer. Default value is set to 2MB, if that is ok for you, you
2133  * don't need to call this function.
2134  *
2135  * @since 0.6.2
2136  */
2137 int iso_write_opts_set_fifo_size(IsoWriteOpts *opts, size_t fifo_size);
2138 
2139 /*
2140  * Release 1.3.6 contains an incomplete implementation of preparations for the
2141  * HP-PA bootloader PALO. Its header version 5 is not completely defined yet.
2142  * To enable the code for these preparations, you have to define the macro
2143  * Libisofs_enable_unreleased_hppa_palO
2144  * and to insert into libisofs/libisofs.ver the lines
2145  * iso_image_set_hppa_palo;
2146  * iso_image_get_hppa_palo;
2147  */
2148 /*
2149  * Attach 32 kB of binary data which shall get written to the first 32 kB
2150  * of the ISO image, the ECMA-119 System Area. This space is intended for
2151  * system dependent boot software, e.g. a Master Boot Record which allows to
2152  * boot from USB sticks or hard disks. ECMA-119 makes no own assumptions or
2153  * prescriptions about the byte content.
2154  *
2155  * If system area data are given or options bit0 is set, then bit1 of
2156  * el_torito_set_isolinux_options() is automatically disabled.
2157  *
2158  * @param opts
2159  * The option set to be manipulated.
2160  * @param data
2161  * Either NULL or 32 kB of data. Do not submit less bytes !
2162  * @param options
2163  * Can cause manipulations of submitted data before they get written:
2164  * bit0= Only with System area type 0 = MBR
2165  * Apply a --protective-msdos-label as of grub-mkisofs.
2166  * This means to patch bytes 446 to 512 of the system area so
2167  * that one partition is defined which begins at the second
2168  * 512-byte block of the image and ends where the image ends.
2169  * This works with and without system_area_data.
2170  * bit1= Only with System area type 0 = MBR
2171  * Apply isohybrid MBR patching to the system area.
2172  * This works only with system area data from SYSLINUX plus an
2173  * ISOLINUX boot image (see iso_image_set_boot_image()) and
2174  * only if not bit0 is set.
2175  * bit2-7= System area type
2176  * 0= with bit0 or bit1: MBR
2177  * else: unspecified type which will be used unaltered.
2178  * 1= MIPS Big Endian Volume Header
2179  * @since 0.6.38
2180  * Submit up to 15 MIPS Big Endian boot files by
2181  * iso_image_add_mips_boot_file().
2182  * This will overwrite the first 512 bytes of the submitted
2183  * data.
2184  * 2= DEC Boot Block for MIPS Little Endian
2185  * @since 0.6.38
2186  * The first boot file submitted by
2187  * iso_image_add_mips_boot_file() will be activated.
2188  * This will overwrite the first 512 bytes of the submitted
2189  * data.
2190  * 3= SUN Disk Label for SUN SPARC
2191  * @since 0.6.40
2192  * Submit up to 7 SPARC boot images by
2193  * iso_write_opts_set_partition_img() for partition numbers 2
2194  * to 8.
2195  * This will overwrite the first 512 bytes of the submitted
2196  * data.
2197  * 4= HP-PA PALO boot sector version 4 for HP PA-RISC
2198  * <<< only ifdef Libisofs_enable_unreleased_hppa_palO
2199  * @since 1.3.8
2200  * Suitable for older PALO of e.g. Debian 4 and 5.
2201  * Submit all five parameters of iso_image_set_hppa_palo():
2202  * cmdline, bootloader, kernel_32, kernel_64, ramdisk
2203  * 5= HP-PA PALO boot sector version 5 for HP PA-RISC
2204  * <<< only ifdef Libisofs_enable_unreleased_hppa_palO
2205  * @since 1.3.8
2206  * Suitable for newer PALO, where PALOHDRVERSION in
2207  * lib/common.h is defined as 5.
2208  * Submit all five parameters of iso_image_set_hppa_palo():
2209  * cmdline, bootloader, kernel_32, kernel_64, ramdisk
2210  * bit8-9= Only with System area type 0 = MBR
2211  * @since 1.0.4
2212  * Cylinder alignment mode eventually pads the image to make it
2213  * end at a cylinder boundary.
2214  * 0 = auto (align if bit1)
2215  * 1 = always align to cylinder boundary
2216  * 2 = never align to cylinder boundary
2217  * 3 = always align, additionally pad up and align partitions
2218  * which were appended by iso_write_opts_set_partition_img()
2219  * @since 1.2.6
2220  * bit10-13= System area sub type
2221  * @since 1.2.4
2222  * With type 0 = MBR:
2223  * Gets overridden by bit0 and bit1.
2224  * 0 = no particular sub type
2225  * 1 = CHRP: A single MBR partition of type 0x96 covers the
2226  * ISO image. Not compatible with any other feature
2227  * which needs to have own MBR partition entries.
2228  * bit14= Only with System area type 0 = MBR
2229  * GRUB2 boot provisions:
2230  * @since 1.3.0
2231  * Patch system area at byte 92 to 99 with 512-block address + 1
2232  * of the first boot image file. Little-endian 8-byte.
2233  * Should be combined with options bit0.
2234  * Will not be in effect if options bit1 is set.
2235  * @param flag
2236  * bit0 = invalidate any attached system area data. Same as data == NULL
2237  * (This re-activates eventually loaded image System Area data.
2238  * To erase those, submit 32 kB of zeros without flag bit0.)
2239  * bit1 = keep data unaltered
2240  * bit2 = keep options unaltered
2241  * @return
2242  * ISO_SUCCESS or error
2243  * @since 0.6.30
2244  */
2245 int iso_write_opts_set_system_area(IsoWriteOpts *opts, char data[32768],
2246  int options, int flag);
2247 
2248 /**
2249  * Set a name for the system area. This setting is ignored unless system area
2250  * type 3 "SUN Disk Label" is in effect by iso_write_opts_set_system_area().
2251  * In this case it will replace the default text at the start of the image:
2252  * "CD-ROM Disc with Sun sparc boot created by libisofs"
2253  *
2254  * @param opts
2255  * The option set to be manipulated.
2256  * @param label
2257  * A text of up to 128 characters.
2258  * @return
2259  * ISO_SUCCESS or error
2260  * @since 0.6.40
2261 */
2262 int iso_write_opts_set_disc_label(IsoWriteOpts *opts, char *label);
2263 
2264 /**
2265  * Explicitely set the four timestamps of the emerging Primary Volume
2266  * Descriptor and in the volume descriptors of Joliet and ISO 9660:1999,
2267  * if those are to be generated.
2268  * Default with all parameters is 0.
2269  *
2270  * ECMA-119 defines them as:
2271  * @param opts
2272  * The option set to be manipulated.
2273  * @param vol_creation_time
2274  * When "the information in the volume was created."
2275  * A value of 0 means that the timepoint of write start is to be used.
2276  * @param vol_modification_time
2277  * When "the information in the volume was last modified."
2278  * A value of 0 means that the timepoint of write start is to be used.
2279  * @param vol_expiration_time
2280  * When "the information in the volume may be regarded as obsolete."
2281  * A value of 0 means that the information never shall expire.
2282  * @param vol_effective_time
2283  * When "the information in the volume may be used."
2284  * A value of 0 means that not such retention is intended.
2285  * @param vol_uuid
2286  * If this text is not empty, then it overrides vol_creation_time and
2287  * vol_modification_time by copying the first 16 decimal digits from
2288  * uuid, eventually padding up with decimal '1', and writing a NUL-byte
2289  * as timezone.
2290  * Other than with vol_*_time the resulting string in the ISO image
2291  * is fully predictable and free of timezone pitfalls.
2292  * It should express a reasonable time in form YYYYMMDDhhmmsscc.
2293  * The timezone will always be recorded as GMT.
2294  * E.g.: "2010040711405800" = 7 Apr 2010 11:40:58 (+0 centiseconds)
2295  * @return
2296  * ISO_SUCCESS or error
2297  *
2298  * @since 0.6.30
2299  */
2301  time_t vol_creation_time, time_t vol_modification_time,
2302  time_t vol_expiration_time, time_t vol_effective_time,
2303  char *vol_uuid);
2304 
2305 
2306 /*
2307  * Control production of a second set of volume descriptors (superblock)
2308  * and directory trees, together with a partition table in the MBR where the
2309  * first partition has non-zero start address and the others are zeroed.
2310  * The first partition stretches to the end of the whole ISO image.
2311  * The additional volume descriptor set and trees will allow to mount the
2312  * ISO image at the start of the first partition, while it is still possible
2313  * to mount it via the normal first volume descriptor set and tree at the
2314  * start of the image resp. storage device.
2315  * This makes few sense on optical media. But on USB sticks it creates a
2316  * conventional partition table which makes it mountable on e.g. Linux via
2317  * /dev/sdb and /dev/sdb1 alike.
2318  * IMPORTANT: When submitting memory by iso_write_opts_set_overwrite_buf()
2319  * then its size must be at least 64 KiB + partition offset.
2320  *
2321  * @param opts
2322  * The option set to be manipulated.
2323  * @param block_offset_2k
2324  * The offset of the partition start relative to device start.
2325  * This is counted in 2 kB blocks. The partition table will show the
2326  * according number of 512 byte sectors.
2327  * Default is 0 which causes no special partition table preparations.
2328  * If it is not 0 then it must not be smaller than 16.
2329  * @param secs_512_per_head
2330  * Number of 512 byte sectors per head. 1 to 63. 0=automatic.
2331  * @param heads_per_cyl
2332  * Number of heads per cylinder. 1 to 255. 0=automatic.
2333  * @return
2334  * ISO_SUCCESS or error
2335  *
2336  * @since 0.6.36
2337  */
2339  uint32_t block_offset_2k,
2340  int secs_512_per_head, int heads_per_cyl);
2341 
2342 
2343 /** The minimum version of libjte to be used with this version of libisofs
2344  at compile time. The use of libjte is optional and depends on configure
2345  tests. It can be prevented by ./configure option --disable-libjte .
2346  @since 0.6.38
2347 */
2348 #define iso_libjte_req_major 1
2349 #define iso_libjte_req_minor 0
2350 #define iso_libjte_req_micro 0
2351 
2352 /**
2353  * Associate a libjte environment object to the upcomming write run.
2354  * libjte implements Jigdo Template Extraction as of Steve McIntyre and
2355  * Richard Atterer.
2356  * The call will fail if no libjte support was enabled at compile time.
2357  * @param opts
2358  * The option set to be manipulated.
2359  * @param libjte_handle
2360  * Pointer to a struct libjte_env e.g. created by libjte_new().
2361  * It must stay existent from the start of image generation by
2362  * iso_image_create_burn_source() until the write thread has ended.
2363  * This can be inquired by iso_image_generator_is_running().
2364  * In order to keep the libisofs API identical with and without
2365  * libjte support the parameter type is (void *).
2366  * @return
2367  * ISO_SUCCESS or error
2368  *
2369  * @since 0.6.38
2370 */
2371 int iso_write_opts_attach_jte(IsoWriteOpts *opts, void *libjte_handle);
2372 
2373 /**
2374  * Remove eventual association to a libjte environment handle.
2375  * The call will fail if no libjte support was enabled at compile time.
2376  * @param opts
2377  * The option set to be manipulated.
2378  * @param libjte_handle
2379  * If not submitted as NULL, this will return the previously set
2380  * libjte handle.
2381  * @return
2382  * ISO_SUCCESS or error
2383  *
2384  * @since 0.6.38
2385 */
2386 int iso_write_opts_detach_jte(IsoWriteOpts *opts, void **libjte_handle);
2387 
2388 
2389 /**
2390  * Cause a number of blocks with zero bytes to be written after the payload
2391  * data, but before the eventual checksum data. Unlike libburn tail padding,
2392  * these blocks are counted as part of the image and covered by eventual
2393  * image checksums.
2394  * A reason for such padding can be the wish to prevent the Linux read-ahead
2395  * bug by sacrificial data which still belong to image and Jigdo template.
2396  * Normally such padding would be the job of the burn program which should know
2397  * that it is needed with CD write type TAO if Linux read(2) shall be able
2398  * to read all payload blocks.
2399  * 150 blocks = 300 kB is the traditional sacrifice to the Linux kernel.
2400  * @param opts
2401  * The option set to be manipulated.
2402  * @param num_blocks
2403  * Number of extra 2 kB blocks to be written.
2404  * @return
2405  * ISO_SUCCESS or error
2406  *
2407  * @since 0.6.38
2408  */
2409 int iso_write_opts_set_tail_blocks(IsoWriteOpts *opts, uint32_t num_blocks);
2410 
2411 /**
2412  * Copy a data file from the local filesystem into the emerging ISO image.
2413  * Mark it by an MBR partition entry as PreP partition and also cause
2414  * protective MBR partition entries before and after this partition.
2415  * Vladimir Serbinenko stated aboy PreP = PowerPC Reference Platform :
2416  * "PreP [...] refers mainly to IBM hardware. PreP boot is a partition
2417  * containing only raw ELF and having type 0x41."
2418  *
2419  * This feature is only combinable with system area type 0
2420  * and currently not combinable with ISOLINUX isohybrid production.
2421  * It overrides --protective-msdos-label. See iso_write_opts_set_system_area().
2422  * Only partition 4 stays available for iso_write_opts_set_partition_img().
2423  * It is compatible with HFS+/FAT production by storing the PreP partition
2424  * before the start of the HFS+/FAT partition.
2425  *
2426  * @param opts
2427  * The option set to be manipulated.
2428  * @param image_path
2429  * File address in the local file system.
2430  * NULL revokes production of the PreP partition.
2431  * @param flag
2432  * Reserved for future usage, set to 0.
2433  * @return
2434  * ISO_SUCCESS or error
2435  *
2436  * @since 1.2.4
2437  */
2438 int iso_write_opts_set_prep_img(IsoWriteOpts *opts, char *image_path,
2439  int flag);
2440 
2441 /**
2442  * Copy a data file from the local filesystem into the emerging ISO image.
2443  * Mark it by an GPT partition entry as EFI System partition, and also cause
2444  * protective GPT partition entries before and after the partition.
2445  * GPT = Globally Unique Identifier Partition Table
2446  *
2447  * This feature may collide with data submitted by
2448  * iso_write_opts_set_system_area()
2449  * and with settings made by
2450  * el_torito_set_isolinux_options()
2451  * It is compatible with HFS+/FAT production by storing the EFI partition
2452  * before the start of the HFS+/FAT partition.
2453  * The GPT overwrites byte 0x0200 to 0x03ff of the system area and all
2454  * further bytes above 0x0800 which are not used by an Apple Partition Map.
2455  *
2456  * @param opts
2457  * The option set to be manipulated.
2458  * @param image_path
2459  * File address in the local file system.
2460  * NULL revokes production of the EFI boot partition.
2461  * @param flag
2462  * Reserved for future usage, set to 0.
2463  * @return
2464  * ISO_SUCCESS or error
2465  *
2466  * @since 1.2.4
2467  */
2468 int iso_write_opts_set_efi_bootp(IsoWriteOpts *opts, char *image_path,
2469  int flag);
2470 
2471 /**
2472  * Cause an arbitrary data file to be appended to the ISO image and to be
2473  * described by a partition table entry in an MBR or SUN Disk Label at the
2474  * start of the ISO image.
2475  * The partition entry will bear the size of the image file rounded up to
2476  * the next multiple of 2048 bytes.
2477  * MBR or SUN Disk Label are selected by iso_write_opts_set_system_area()
2478  * system area type: 0 selects MBR partition table. 3 selects a SUN partition
2479  * table with 320 kB start alignment.
2480  *
2481  * @param opts
2482  * The option set to be manipulated.
2483  * @param partition_number
2484  * Depicts the partition table entry which shall describe the
2485  * appended image.
2486  * Range with MBR: 1 to 4. 1 will cause the whole ISO image to be
2487  * unclaimable space before partition 1.
2488  * Range with SUN Disk Label: 2 to 8.
2489  * @param image_path
2490  * File address in the local file system.
2491  * With SUN Disk Label: an empty name causes the partition to become
2492  * a copy of the next lower partition.
2493  * @param image_type
2494  * The MBR partition type. E.g. FAT12 = 0x01 , FAT16 = 0x06,
2495  * Linux Native Partition = 0x83. See fdisk command L.
2496  * This parameter is ignored with SUN Disk Label.
2497  * @param flag
2498  * Reserved for future usage, set to 0.
2499  * @return
2500  * ISO_SUCCESS or error
2501  *
2502  * @since 0.6.38
2503  */
2504 int iso_write_opts_set_partition_img(IsoWriteOpts *opts, int partition_number,
2505  uint8_t partition_type, char *image_path, int flag);
2506 
2507 
2508 /**
2509  * Inquire the start address of the file data blocks after having used
2510  * IsoWriteOpts with iso_image_create_burn_source().
2511  * @param opts
2512  * The option set that was used when starting image creation
2513  * @param data_start
2514  * Returns the logical block address if it is already valid
2515  * @param flag
2516  * Reserved for future usage, set to 0.
2517  * @return
2518  * 1 indicates valid data_start, <0 indicates invalid data_start
2519  *
2520  * @since 0.6.16
2521  */
2522 int iso_write_opts_get_data_start(IsoWriteOpts *opts, uint32_t *data_start,
2523  int flag);
2524 
2525 /**
2526  * Update the sizes of all files added to image.
2527  *
2528  * This may be called just before iso_image_create_burn_source() to force
2529  * libisofs to check the file sizes again (they're already checked when added
2530  * to IsoImage). It is useful if you have changed some files after adding then
2531  * to the image.
2532  *
2533  * @return
2534  * 1 on success, < 0 on error
2535  * @since 0.6.8
2536  */
2537 int iso_image_update_sizes(IsoImage *image);
2538 
2539 /**
2540  * Create a burn_source and a thread which immediately begins to generate
2541  * the image. That burn_source can be used with libburn as a data source
2542  * for a track. A copy of its public declaration in libburn.h can be found
2543  * further below in this text.
2544  *
2545  * If image generation shall be aborted by the application program, then
2546  * the .cancel() method of the burn_source must be called to end the
2547  * generation thread: burn_src->cancel(burn_src);
2548  *
2549  * @param image
2550  * The image to write.
2551  * @param opts
2552  * The options for image generation. All needed data will be copied, so
2553  * you can free the given struct once this function returns.
2554  * @param burn_src
2555  * Location where the pointer to the burn_source will be stored
2556  * @return
2557  * 1 on success, < 0 on error
2558  *
2559  * @since 0.6.2
2560  */
2562  struct burn_source **burn_src);
2563 
2564 /**
2565  * Inquire whether the image generator thread is still at work. As soon as the
2566  * reply is 0, the caller of iso_image_create_burn_source() may assume that
2567  * the image generation has ended.
2568  * Nevertheless there may still be readily formatted output data pending in
2569  * the burn_source or its consumers. So the final delivery of the image has
2570  * also to be checked at the data consumer side,e.g. by burn_drive_get_status()
2571  * in case of libburn as consumer.
2572  * @param image
2573  * The image to inquire.
2574  * @return
2575  * 1 generating of image stream is still in progress
2576  * 0 generating of image stream has ended meanwhile
2577  *
2578  * @since 0.6.38
2579  */
2581 
2582 /**
2583  * Creates an IsoReadOpts for reading an existent image. You should set the
2584  * options desired with the correspondent setters. Note that you may want to
2585  * set the start block value.
2586  *
2587  * Options by default are determined by the selected profile.
2588  *
2589  * @param opts
2590  * Pointer to the location where the newly created IsoReadOpts will be
2591  * stored. You should free it with iso_read_opts_free() when no more
2592  * needed.
2593  * @param profile
2594  * Default profile for image reading. For now the following values are
2595  * defined:
2596  * ---> 0 [STANDARD]
2597  * Suitable for most situations. Most extension are read. When both
2598  * Joliet and RR extension are present, RR is used.
2599  * AAIP for ACL and xattr is not enabled by default.
2600  * @return
2601  * 1 success, < 0 error
2602  *
2603  * @since 0.6.2
2604  */
2605 int iso_read_opts_new(IsoReadOpts **opts, int profile);
2606 
2607 /**
2608  * Free an IsoReadOpts previously allocated with iso_read_opts_new().
2609  *
2610  * @since 0.6.2
2611  */
2612 void iso_read_opts_free(IsoReadOpts *opts);
2613 
2614 /**
2615  * Set the block where the image begins. It is usually 0, but may be different
2616  * on a multisession disc.
2617  *
2618  * @since 0.6.2
2619  */
2620 int iso_read_opts_set_start_block(IsoReadOpts *opts, uint32_t block);
2621 
2622 /**
2623  * Do not read Rock Ridge extensions.
2624  * In most cases you don't want to use this. It could be useful if RR info
2625  * is damaged, or if you want to use the Joliet tree.
2626  *
2627  * @since 0.6.2
2628  */
2629 int iso_read_opts_set_no_rockridge(IsoReadOpts *opts, int norr);
2630 
2631 /**
2632  * Do not read Joliet extensions.
2633  *
2634  * @since 0.6.2
2635  */
2636 int iso_read_opts_set_no_joliet(IsoReadOpts *opts, int nojoliet);
2637 
2638 /**
2639  * Do not read ISO 9660:1999 enhanced tree
2640  *
2641  * @since 0.6.2
2642  */
2643 int iso_read_opts_set_no_iso1999(IsoReadOpts *opts, int noiso1999);
2644 
2645 /**
2646  * Control reading of AAIP informations about ACL and xattr when loading
2647  * existing images.
2648  * For importing ACL and xattr when inserting nodes from external filesystems
2649  * (e.g. the local POSIX filesystem) see iso_image_set_ignore_aclea().
2650  * For eventual writing of this information see iso_write_opts_set_aaip().
2651  *
2652  * @param opts
2653  * The option set to be manipulated
2654  * @param noaaip
2655  * 1 = Do not read AAIP information
2656  * 0 = Read AAIP information if available
2657  * All other values are reserved.
2658  * @since 0.6.14
2659  */
2660 int iso_read_opts_set_no_aaip(IsoReadOpts *opts, int noaaip);
2661 
2662 /**
2663  * Control reading of an array of MD5 checksums which is eventually stored
2664  * at the end of a session. See also iso_write_opts_set_record_md5().
2665  * Important: Loading of the MD5 array will only work if AAIP is enabled
2666  * because its position and layout is recorded in xattr "isofs.ca".
2667  *
2668  * @param opts
2669  * The option set to be manipulated
2670  * @param no_md5
2671  * 0 = Read MD5 array if available, refuse on non-matching MD5 tags
2672  * 1 = Do not read MD5 checksum array
2673  * 2 = Read MD5 array, but do not check MD5 tags
2674  * @since 1.0.4
2675  * All other values are reserved.
2676  *
2677  * @since 0.6.22
2678  */
2679 int iso_read_opts_set_no_md5(IsoReadOpts *opts, int no_md5);
2680 
2681 
2682 /**
2683  * Control discarding of eventual inode numbers from existing images.
2684  * Such numbers may come from RRIP 1.12 entries PX. If not discarded they
2685  * get written unchanged when the file object gets written into an ISO image.
2686  * If this inode number is missing with a file in the imported image,
2687  * or if it has been discarded during image reading, then a unique inode number
2688  * will be generated at some time before the file gets written into an ISO
2689  * image.
2690  * Two image nodes which have the same inode number represent two hardlinks
2691  * of the same file object. So discarding the numbers splits hardlinks.
2692  *
2693  * @param opts
2694  * The option set to be manipulated
2695  * @param new_inos
2696  * 1 = Discard imported inode numbers and finally hand out a unique new
2697  * one to each single file before it gets written into an ISO image.
2698  * 0 = Keep eventual inode numbers from PX entries.
2699  * All other values are reserved.
2700  * @since 0.6.20
2701  */
2702 int iso_read_opts_set_new_inos(IsoReadOpts *opts, int new_inos);
2703 
2704 /**
2705  * Whether to prefer Joliet over RR. libisofs usually prefers RR over
2706  * Joliet, as it give us much more info about files. So, if both extensions
2707  * are present, RR is used. You can set this if you prefer Joliet, but
2708  * note that this is not very recommended. This doesn't mean than RR
2709  * extensions are not read: if no Joliet is present, libisofs will read
2710  * RR tree.
2711  *
2712  * @since 0.6.2
2713  */
2714 int iso_read_opts_set_preferjoliet(IsoReadOpts *opts, int preferjoliet);
2715 
2716 /**
2717  * Set default uid for files when RR extensions are not present.
2718  *
2719  * @since 0.6.2
2720  */
2721 int iso_read_opts_set_default_uid(IsoReadOpts *opts, uid_t uid);
2722 
2723 /**
2724  * Set default gid for files when RR extensions are not present.
2725  *
2726  * @since 0.6.2
2727  */
2728 int iso_read_opts_set_default_gid(IsoReadOpts *opts, gid_t gid);
2729 
2730 /**
2731  * Set default permissions for files when RR extensions are not present.
2732  *
2733  * @param opts
2734  * The option set to be manipulated
2735  * @param file_perm
2736  * Permissions for files.
2737  * @param dir_perm
2738  * Permissions for directories.
2739  *
2740  * @since 0.6.2
2741  */
2742 int iso_read_opts_set_default_permissions(IsoReadOpts *opts, mode_t file_perm,
2743  mode_t dir_perm);
2744 
2745 /**
2746  * Set the input charset of the file names on the image. NULL to use locale
2747  * charset. You have to specify a charset if the image filenames are encoded
2748  * in a charset different that the local one. This could happen, for example,
2749  * if the image was created on a system with different charset.
2750  *
2751  * @param opts
2752  * The option set to be manipulated
2753  * @param charset
2754  * The charset to use as input charset. You can obtain the list of
2755  * charsets supported on your system executing "iconv -l" in a shell.
2756  *
2757  * @since 0.6.2
2758  */
2759 int iso_read_opts_set_input_charset(IsoReadOpts *opts, const char *charset);
2760 
2761 /**
2762  * Enable or disable methods to automatically choose an input charset.
2763  * This eventually overrides the name set via iso_read_opts_set_input_charset()
2764  *
2765  * @param opts
2766  * The option set to be manipulated
2767  * @param mode
2768  * Bitfield for control purposes:
2769  * bit0= Allow to use the input character set name which is eventually
2770  * stored in attribute "isofs.cs" of the root directory.
2771  * Applications may attach this xattr by iso_node_set_attrs() to
2772  * the root node, call iso_write_opts_set_output_charset() with the
2773  * same name and enable iso_write_opts_set_aaip() when writing
2774  * an image.
2775  * Submit any other bits with value 0.
2776  *
2777  * @since 0.6.18
2778  *
2779  */
2780 int iso_read_opts_auto_input_charset(IsoReadOpts *opts, int mode);
2781 
2782 /**
2783  * Enable or disable loading of the first 32768 bytes of the session.
2784  *
2785  * @param opts
2786  * The option set to be manipulated
2787  * @param mode
2788  * Bitfield for control purposes:
2789  * bit0= Load System Area data and attach them to the image so that they
2790  * get written by the next session, if not overridden by
2791  * iso_write_opts_set_system_area().
2792  * Submit any other bits with value 0.
2793  *
2794  * @since 0.6.30
2795  *
2796  */
2797 int iso_read_opts_load_system_area(IsoReadOpts *opts, int mode);
2798 
2799 /**
2800  * Import a previous session or image, for growing or modify.
2801  *
2802  * @param image
2803  * The image context to which old image will be imported. Note that all
2804  * files added to image, and image attributes, will be replaced with the
2805  * contents of the old image.
2806  * TODO #00025 support for merging old image files
2807  * @param src
2808  * Data Source from which old image will be read. A extra reference is
2809  * added, so you still need to iso_data_source_unref() yours.
2810  * @param opts
2811  * Options for image import. All needed data will be copied, so you
2812  * can free the given struct once this function returns.
2813  * @param features
2814  * If not NULL, a new IsoReadImageFeatures will be allocated and filled
2815  * with the features of the old image. It should be freed with
2816  * iso_read_image_features_destroy() when no more needed. You can pass
2817  * NULL if you're not interested on them.
2818  * @return
2819  * 1 on success, < 0 on error
2820  *
2821  * @since 0.6.2
2822  */
2823 int iso_image_import(IsoImage *image, IsoDataSource *src, IsoReadOpts *opts,
2824  IsoReadImageFeatures **features);
2825 
2826 /**
2827  * Destroy an IsoReadImageFeatures object obtained with iso_image_import.
2828  *
2829  * @since 0.6.2
2830  */
2832 
2833 /**
2834  * Get the size (in 2048 byte block) of the image, as reported in the PVM.
2835  *
2836  * @since 0.6.2
2837  */
2839 
2840 /**
2841  * Whether RockRidge extensions are present in the image imported.
2842  *
2843  * @since 0.6.2
2844  */
2846 
2847 /**
2848  * Whether Joliet extensions are present in the image imported.
2849  *
2850  * @since 0.6.2
2851  */
2853 
2854 /**
2855  * Whether the image is recorded according to ISO 9660:1999, i.e. it has
2856  * a version 2 Enhanced Volume Descriptor.
2857  *
2858  * @since 0.6.2
2859  */
2861 
2862 /**
2863  * Whether El-Torito boot record is present present in the image imported.
2864  *
2865  * @since 0.6.2
2866  */
2868 
2869 /**
2870  * Increments the reference counting of the given image.
2871  *
2872  * @since 0.6.2
2873  */
2874 void iso_image_ref(IsoImage *image);
2875 
2876 /**
2877  * Decrements the reference couting of the given image.
2878  * If it reaches 0, the image is free, together with its tree nodes (whether
2879  * their refcount reach 0 too, of course).
2880  *
2881  * @since 0.6.2
2882  */
2883 void iso_image_unref(IsoImage *image);
2884 
2885 /**
2886  * Attach user defined data to the image. Use this if your application needs
2887  * to store addition info together with the IsoImage. If the image already
2888  * has data attached, the old data will be freed.
2889  *
2890  * @param image
2891  * The image to which data shall be attached.
2892  * @param data
2893  * Pointer to application defined data that will be attached to the
2894  * image. You can pass NULL to remove any already attached data.
2895  * @param give_up
2896  * Function that will be called when the image does not need the data
2897  * any more. It receives the data pointer as an argumente, and eventually
2898  * causes data to be freed. It can be NULL if you don't need it.
2899  * @return
2900  * 1 on succes, < 0 on error
2901  *
2902  * @since 0.6.2
2903  */
2904 int iso_image_attach_data(IsoImage *image, void *data, void (*give_up)(void*));
2905 
2906 /**
2907  * The the data previously attached with iso_image_attach_data()
2908  *
2909  * @since 0.6.2
2910  */
2912 
2913 /**
2914  * Get the root directory of the image.
2915  * No extra ref is added to it, so you musn't unref it. Use iso_node_ref()
2916  * if you want to get your own reference.
2917  *
2918  * @since 0.6.2
2919  */
2920 IsoDir *iso_image_get_root(const IsoImage *image);
2921 
2922 /**
2923  * Fill in the volset identifier for a image.
2924  *
2925  * @since 0.6.2
2926  */
2927 void iso_image_set_volset_id(IsoImage *image, const char *volset_id);
2928 
2929 /**
2930  * Get the volset identifier.
2931  * The returned string is owned by the image and must not be freed nor
2932  * changed.
2933  *
2934  * @since 0.6.2
2935  */
2936 const char *iso_image_get_volset_id(const IsoImage *image);
2937 
2938 /**
2939  * Fill in the volume identifier for a image.
2940  *
2941  * @since 0.6.2
2942  */
2943 void iso_image_set_volume_id(IsoImage *image, const char *volume_id);
2944 
2945 /**
2946  * Get the volume identifier.
2947  * The returned string is owned by the image and must not be freed nor
2948  * changed.
2949  *
2950  * @since 0.6.2
2951  */
2952 const char *iso_image_get_volume_id(const IsoImage *image);
2953 
2954 /**
2955  * Fill in the publisher for a image.
2956  *
2957  * @since 0.6.2
2958  */
2959 void iso_image_set_publisher_id(IsoImage *image, const char *publisher_id);
2960 
2961 /**
2962  * Get the publisher of a image.
2963  * The returned string is owned by the image and must not be freed nor
2964  * changed.
2965  *
2966  * @since 0.6.2
2967  */
2968 const char *iso_image_get_publisher_id(const IsoImage *image);
2969 
2970 /**
2971  * Fill in the data preparer for a image.
2972  *
2973  * @since 0.6.2
2974  */
2976  const char *data_preparer_id);
2977 
2978 /**
2979  * Get the data preparer of a image.
2980  * The returned string is owned by the image and must not be freed nor
2981  * changed.
2982  *
2983  * @since 0.6.2
2984  */
2985 const char *iso_image_get_data_preparer_id(const IsoImage *image);
2986 
2987 /**
2988  * Fill in the system id for a image. Up to 32 characters.
2989  *
2990  * @since 0.6.2
2991  */
2992 void iso_image_set_system_id(IsoImage *image, const char *system_id);
2993 
2994 /**
2995  * Get the system id of a image.
2996  * The returned string is owned by the image and must not be freed nor
2997  * changed.
2998  *
2999  * @since 0.6.2
3000  */
3001 const char *iso_image_get_system_id(const IsoImage *image);
3002 
3003 /**
3004  * Fill in the application id for a image. Up to 128 chars.
3005  *
3006  * @since 0.6.2
3007  */
3008 void iso_image_set_application_id(IsoImage *image, const char *application_id);
3009 
3010 /**
3011  * Get the application id of a image.
3012  * The returned string is owned by the image and must not be freed nor
3013  * changed.
3014  *
3015  * @since 0.6.2
3016  */
3017 const char *iso_image_get_application_id(const IsoImage *image);
3018 
3019 /**
3020  * Fill copyright information for the image. Usually this refers
3021  * to a file on disc. Up to 37 characters.
3022  *
3023  * @since 0.6.2
3024  */
3026  const char *copyright_file_id);
3027 
3028 /**
3029  * Get the copyright information of a image.
3030  * The returned string is owned by the image and must not be freed nor
3031  * changed.
3032  *
3033  * @since 0.6.2
3034  */
3035 const char *iso_image_get_copyright_file_id(const IsoImage *image);
3036 
3037 /**
3038  * Fill abstract information for the image. Usually this refers
3039  * to a file on disc. Up to 37 characters.
3040  *
3041  * @since 0.6.2
3042  */
3044  const char *abstract_file_id);
3045 
3046 /**
3047  * Get the abstract information of a image.
3048  * The returned string is owned by the image and must not be freed nor
3049  * changed.
3050  *
3051  * @since 0.6.2
3052  */
3053 const char *iso_image_get_abstract_file_id(const IsoImage *image);
3054 
3055 /**
3056  * Fill biblio information for the image. Usually this refers
3057  * to a file on disc. Up to 37 characters.
3058  *
3059  * @since 0.6.2
3060  */
3061 void iso_image_set_biblio_file_id(IsoImage *image, const char *biblio_file_id);
3062 
3063 /**
3064  * Get the biblio information of a image.
3065  * The returned string is owned by the image and must not be freed or changed.
3066  *
3067  * @since 0.6.2
3068  */
3069 const char *iso_image_get_biblio_file_id(const IsoImage *image);
3070 
3071 /**
3072  * Fill Application Use field of the Primary Volume Descriptor.
3073  * ECMA-119 8.4.32 Application Use (BP 884 to 1395)
3074  * "This field shall be reserved for application use. Its content
3075  * is not specified by this Standard."
3076  *
3077  * @param image
3078  * The image to manipulate.
3079  * @param app_use_data
3080  * Up to 512 bytes of data.
3081  * @param count
3082  * The number of bytes in app_use_data. If the number is smaller than 512,
3083  * then the remaining bytes will be set to 0.
3084  * @since 1.3.2
3085  */
3086 void iso_image_set_app_use(IsoImage *image, const char *app_use_data,
3087  int count);
3088 
3089 /**
3090  * Get the current setting for the Application Use field of the Primary Volume
3091  * Descriptor.
3092  * The returned char array of 512 bytes is owned by the image and must not
3093  * be freed or changed.
3094  *
3095  * @param image
3096  * The image to inquire
3097  * @since 1.3.2
3098  */
3099 const char *iso_image_get_app_use(IsoImage *image);
3100 
3101 /**
3102  * Get the four timestamps from the Primary Volume Descriptor of the imported
3103  * ISO image. The timestamps are strings which are either empty or consist
3104  * of 16 digits of the form YYYYMMDDhhmmsscc, plus a signed byte in the range
3105  * of -48 to +52, which gives the timezone offset in steps of 15 minutes.
3106  * None of the returned string pointers shall be used for altering or freeing
3107  * data. They are just for reading.
3108  *
3109  * @param image
3110  * The image to be inquired.
3111  * @param vol_creation_time
3112  * Returns a pointer to the Volume Creation time:
3113  * When "the information in the volume was created."
3114  * @param vol_modification_time
3115  * Returns a pointer to Volume Modification time:
3116  * When "the information in the volume was last modified."
3117  * @param vol_expiration_time
3118  * Returns a pointer to Volume Expiration time:
3119  * When "the information in the volume may be regarded as obsolete."
3120  * @param vol_effective_time
3121  * Returns a pointer to Volume Expiration time:
3122  * When "the information in the volume may be used."
3123  * @return
3124  * ISO_SUCCESS or error
3125  *
3126  * @since 1.2.8
3127  */
3129  char **creation_time, char **modification_time,
3130  char **expiration_time, char **effective_time);
3131 
3132 /**
3133  * Create a new set of El-Torito bootable images by adding a boot catalog
3134  * and the default boot image.
3135  * Further boot images may then be added by iso_image_add_boot_image().
3136  *
3137  * @param image
3138  * The image to make bootable. If it was already bootable this function
3139  * returns an error and the image remains unmodified.
3140  * @param image_path
3141  * The absolute path of a IsoFile to be used as default boot image.
3142  * @param type
3143  * The boot media type. This can be one of 3 types:
3144  * - Floppy emulation: Boot image file must be exactly
3145  * 1200 kB, 1440 kB or 2880 kB.
3146  * - Hard disc emulation: The image must begin with a master
3147  * boot record with a single image.
3148  * - No emulation. You should specify load segment and load size
3149  * of image.
3150  * @param catalog_path
3151  * The absolute path in the image tree where the catalog will be stored.
3152  * The directory component of this path must be a directory existent on
3153  * the image tree, and the filename component must be unique among all
3154  * children of that directory on image. Otherwise a correspodent error
3155  * code will be returned. This function will add an IsoBoot node that acts
3156  * as a placeholder for the real catalog, that will be generated at image
3157  * creation time.
3158  * @param boot
3159  * Location where a pointer to the added boot image will be stored. That
3160  * object is owned by the IsoImage and must not be freed by the user,
3161  * nor dereferenced once the last reference to the IsoImage was disposed
3162  * via iso_image_unref(). A NULL value is allowed if you don't need a
3163  * reference to the boot image.
3164  * @return
3165  * 1 on success, < 0 on error
3166  *
3167  * @since 0.6.2
3168  */
3169 int iso_image_set_boot_image(IsoImage *image, const char *image_path,
3170  enum eltorito_boot_media_type type,
3171  const char *catalog_path,
3172  ElToritoBootImage **boot);
3173 
3174 /**
3175  * Add a further boot image to the set of El-Torito bootable images.
3176  * This set has already to be created by iso_image_set_boot_image().
3177  * Up to 31 further boot images may be added.
3178  *
3179  * @param image
3180  * The image to which the boot image shall be added.
3181  * returns an error and the image remains unmodified.
3182  * @param image_path
3183  * The absolute path of a IsoFile to be used as default boot image.
3184  * @param type
3185  * The boot media type. See iso_image_set_boot_image
3186  * @param flag
3187  * Bitfield for control purposes. Unused yet. Submit 0.
3188  * @param boot
3189  * Location where a pointer to the added boot image will be stored.
3190  * See iso_image_set_boot_image
3191  * @return
3192  * 1 on success, < 0 on error
3193  * ISO_BOOT_NO_CATALOG means iso_image_set_boot_image()
3194  * was not called first.
3195  *
3196  * @since 0.6.32
3197  */
3198 int iso_image_add_boot_image(IsoImage *image, const char *image_path,
3199  enum eltorito_boot_media_type type, int flag,
3200  ElToritoBootImage **boot);
3201 
3202 /**
3203  * Get the El-Torito boot catalog and the default boot image of an ISO image.
3204  *
3205  * This can be useful, for example, to check if a volume read from a previous
3206  * session or an existing image is bootable. It can also be useful to get
3207  * the image and catalog tree nodes. An application would want those, for
3208  * example, to prevent the user removing it.
3209  *
3210  * Both nodes are owned by libisofs and must not be freed. You can get your
3211  * own ref with iso_node_ref(). You can also check if the node is already
3212  * on the tree by getting its parent (note that when reading El-Torito info
3213  * from a previous image, the nodes might not be on the tree even if you haven't
3214  * removed them). Remember that you'll need to get a new ref
3215  * (with iso_node_ref()) before inserting them again to the tree, and probably
3216  * you will also need to set the name or permissions.
3217  *
3218  * @param image
3219  * The image from which to get the boot image.
3220  * @param boot
3221  * If not NULL, it will be filled with a pointer to the boot image, if
3222  * any. That object is owned by the IsoImage and must not be freed by
3223  * the user, nor dereferenced once the last reference to the IsoImage was
3224  * disposed via iso_image_unref().
3225  * @param imgnode
3226  * When not NULL, it will be filled with the image tree node. No extra ref
3227  * is added, you can use iso_node_ref() to get one if you need it.
3228  * @param catnode
3229  * When not NULL, it will be filled with the catnode tree node. No extra
3230  * ref is added, you can use iso_node_ref() to get one if you need it.
3231  * @return
3232  * 1 on success, 0 is the image is not bootable (i.e., it has no El-Torito
3233  * image), < 0 error.
3234  *
3235  * @since 0.6.2
3236  */
3238  IsoFile **imgnode, IsoBoot **catnode);
3239 
3240 /**
3241  * Get detailed information about the boot catalog that was loaded from
3242  * an ISO image.
3243  * The boot catalog links the El Torito boot record at LBA 17 with the
3244  * boot images which are IsoFile objects in the image. The boot catalog
3245  * itself is not a regular file and thus will not deliver an IsoStream.
3246  * Its content is usually quite short and can be obtained by this call.
3247  *
3248  * @param image
3249  * The image to inquire.
3250  * @param catnode
3251  * Will return the boot catalog tree node. No extra ref is taken.
3252  * @param lba
3253  * Will return the block address of the boot catalog in the image.
3254  * @param content
3255  * Will return either NULL or an allocated memory buffer with the
3256  * content bytes of the boot catalog.
3257  * Dispose it by free() when no longer needed.
3258  * @param size
3259  * Will return the number of bytes in content.
3260  * @return
3261  * 1 if reply is valid, 0 if not boot catalog was loaded, < 0 on error.
3262  *
3263  * @since 1.1.2
3264  */
3265 int iso_image_get_bootcat(IsoImage *image, IsoBoot **catnode, uint32_t *lba,
3266  char **content, off_t *size);
3267 
3268 
3269 /**
3270  * Get all El-Torito boot images of an ISO image.
3271  *
3272  * The first of these boot images is the same as returned by
3273  * iso_image_get_boot_image(). The others are alternative boot images.
3274  *
3275  * @param image
3276  * The image from which to get the boot images.
3277  * @param num_boots
3278  * The number of available array elements in boots and bootnodes.
3279  * @param boots
3280  * Returns NULL or an allocated array of pointers to boot images.
3281  * Apply system call free(boots) to dispose it.
3282  * @param bootnodes
3283  * Returns NULL or an allocated array of pointers to the IsoFile nodes
3284  * which bear the content of the boot images in boots.
3285  * @param flag
3286  * Bitfield for control purposes. Unused yet. Submit 0.
3287  * @return
3288  * 1 on success, 0 no El-Torito catalog and boot image attached,
3289  * < 0 error.
3290  *
3291  * @since 0.6.32
3292  */
3293 int iso_image_get_all_boot_imgs(IsoImage *image, int *num_boots,
3294  ElToritoBootImage ***boots, IsoFile ***bootnodes, int flag);
3295 
3296 
3297 /**
3298  * Removes all El-Torito boot images from the ISO image.
3299  *
3300  * The IsoBoot node that acts as placeholder for the catalog is also removed
3301  * for the image tree, if there.
3302  * If the image is not bootable (don't have el-torito boot image) this function
3303  * just returns.
3304  *
3305  * @since 0.6.2
3306  */
3308 
3309 /**
3310  * Sets the sort weight of the boot catalog that is attached to an IsoImage.
3311  *
3312  * For the meaning of sort weights see iso_node_set_sort_weight().
3313  * That function cannot be applied to the emerging boot catalog because
3314  * it is not represented by an IsoFile.
3315  *
3316  * @param image
3317  * The image to manipulate.
3318  * @param sort_weight
3319  * The larger this value, the lower will be the block address of the
3320  * boot catalog record.
3321  * @return
3322  * 0= no boot catalog attached , 1= ok , <0 = error
3323  *
3324  * @since 0.6.32
3325  */
3326 int iso_image_set_boot_catalog_weight(IsoImage *image, int sort_weight);
3327 
3328 /**
3329  * Hides the boot catalog file from directory trees.
3330  *
3331  * For the meaning of hiding files see iso_node_set_hidden().
3332  *
3333  *
3334  * @param image
3335  * The image to manipulate.
3336  * @param hide_attrs
3337  * Or-combination of values from enum IsoHideNodeFlag to set the trees
3338  * in which the record.
3339  * @return
3340  * 0= no boot catalog attached , 1= ok , <0 = error
3341  *
3342  * @since 0.6.34
3343  */
3344 int iso_image_set_boot_catalog_hidden(IsoImage *image, int hide_attrs);
3345 
3346 
3347 /**
3348  * Get the boot media type as of parameter "type" of iso_image_set_boot_image()
3349  * resp. iso_image_add_boot_image().
3350  *
3351  * @param bootimg
3352  * The image to inquire
3353  * @param media_type
3354  * Returns the media type
3355  * @return
3356  * 1 = ok , < 0 = error
3357  *
3358  * @since 0.6.32
3359  */
3361  enum eltorito_boot_media_type *media_type);
3362 
3363 /**
3364  * Sets the platform ID of the boot image.
3365  *
3366  * The Platform ID gets written into the boot catalog at byte 1 of the
3367  * Validation Entry, or at byte 1 of a Section Header Entry.
3368  * If Platform ID and ID String of two consequtive bootimages are the same
3369  *
3370  * @param bootimg
3371  * The image to manipulate.
3372  * @param id
3373  * A Platform ID as of
3374  * El Torito 1.0 : 0x00= 80x86, 0x01= PowerPC, 0x02= Mac
3375  * Others : 0xef= EFI
3376  * @return
3377  * 1 ok , <=0 error
3378  *
3379  * @since 0.6.32
3380  */
3381 int el_torito_set_boot_platform_id(ElToritoBootImage *bootimg, uint8_t id);
3382 
3383 /**
3384  * Get the platform ID value. See el_torito_set_boot_platform_id().
3385  *
3386  * @param bootimg
3387  * The image to inquire
3388  * @return
3389  * 0 - 255 : The platform ID
3390  * < 0 : error
3391  *
3392  * @since 0.6.32
3393  */
3395 
3396 /**
3397  * Sets the load segment for the initial boot image. This is only for
3398  * no emulation boot images, and is a NOP for other image types.
3399  *
3400  * @since 0.6.2
3401  */
3402 void el_torito_set_load_seg(ElToritoBootImage *bootimg, short segment);
3403 
3404 /**
3405  * Get the load segment value. See el_torito_set_load_seg().
3406  *
3407  * @param bootimg
3408  * The image to inquire
3409  * @return
3410  * 0 - 65535 : The load segment value
3411  * < 0 : error
3412  *
3413  * @since 0.6.32
3414  */
3416 
3417 /**
3418  * Sets the number of sectors (512b) to be load at load segment during
3419  * the initial boot procedure. This is only for
3420  * no emulation boot images, and is a NOP for other image types.
3421  *
3422  * @since 0.6.2
3423  */
3424 void el_torito_set_load_size(ElToritoBootImage *bootimg, short sectors);
3425 
3426 /**
3427  * Get the load size. See el_torito_set_load_size().
3428  *
3429  * @param bootimg
3430  * The image to inquire
3431  * @return
3432  * 0 - 65535 : The load size value
3433  * < 0 : error
3434  *
3435  * @since 0.6.32
3436  */
3438 
3439 /**
3440  * Marks the specified boot image as not bootable
3441  *
3442  * @since 0.6.2
3443  */
3445 
3446 /**
3447  * Get the bootability flag. See el_torito_set_no_bootable().
3448  *
3449  * @param bootimg
3450  * The image to inquire
3451  * @return
3452  * 0 = not bootable, 1 = bootable , <0 = error
3453  *
3454  * @since 0.6.32
3455  */
3457 
3458 /**
3459  * Set the id_string of the Validation Entry resp. Sector Header Entry which
3460  * will govern the boot image Section Entry in the El Torito Catalog.
3461  *
3462  * @param bootimg
3463  * The image to manipulate.
3464  * @param id_string
3465  * The first boot image puts 24 bytes of ID string into the Validation
3466  * Entry, where they shall "identify the manufacturer/developer of
3467  * the CD-ROM".
3468  * Further boot images put 28 bytes into their Section Header.
3469  * El Torito 1.0 states that "If the BIOS understands the ID string, it
3470  * may choose to boot the system using one of these entries in place
3471  * of the INITIAL/DEFAULT entry." (The INITIAL/DEFAULT entry points to the
3472  * first boot image.)
3473  * @return
3474  * 1 = ok , <0 = error
3475  *
3476  * @since 0.6.32
3477  */
3478 int el_torito_set_id_string(ElToritoBootImage *bootimg, uint8_t id_string[28]);
3479 
3480 /**
3481  * Get the id_string as of el_torito_set_id_string().
3482  *
3483  * @param bootimg
3484  * The image to inquire
3485  * @param id_string
3486  * Returns 28 bytes of id string
3487  * @return
3488  * 1 = ok , <0 = error
3489  *
3490  * @since 0.6.32
3491  */
3492 int el_torito_get_id_string(ElToritoBootImage *bootimg, uint8_t id_string[28]);
3493 
3494 /**
3495  * Set the Selection Criteria of a boot image.
3496  *
3497  * @param bootimg
3498  * The image to manipulate.
3499  * @param crit
3500  * The first boot image has no selection criteria. They will be ignored.
3501  * Further boot images put 1 byte of Selection Criteria Type and 19
3502  * bytes of data into their Section Entry.
3503  * El Torito 1.0 states that "The format of the selection criteria is
3504  * a function of the BIOS vendor. In the case of a foreign language
3505  * BIOS three bytes would be used to identify the language".
3506  * Type byte == 0 means "no criteria",
3507  * type byte == 1 means "Language and Version Information (IBM)".
3508  * @return
3509  * 1 = ok , <0 = error
3510  *
3511  * @since 0.6.32
3512  */
3513 int el_torito_set_selection_crit(ElToritoBootImage *bootimg, uint8_t crit[20]);
3514 
3515 /**
3516  * Get the Selection Criteria bytes as of el_torito_set_selection_crit().
3517  *
3518  * @param bootimg
3519  * The image to inquire
3520  * @param id_string
3521  * Returns 20 bytes of type and data
3522  * @return
3523  * 1 = ok , <0 = error
3524  *
3525  * @since 0.6.32
3526  */
3527 int el_torito_get_selection_crit(ElToritoBootImage *bootimg, uint8_t crit[20]);
3528 
3529 
3530 /**
3531  * Makes a guess whether the boot image was patched by a boot information
3532  * table. It is advisable to patch such boot images if their content gets
3533  * copied to a new location. See el_torito_set_isolinux_options().
3534  * Note: The reply can be positive only if the boot image was imported
3535  * from an existing ISO image.
3536  *
3537  * @param bootimg
3538  * The image to inquire
3539  * @param flag
3540  * Bitfield for control purposes:
3541  * bit0 - bit3= mode
3542  * 0 = inquire for classic boot info table as described in man mkisofs
3543  * @since 0.6.32
3544  * 1 = inquire for GRUB2 boot info as of bit9 of options of
3545  * el_torito_set_isolinux_options()
3546  * @since 1.3.0
3547  * @return
3548  * 1 = seems to contain the inquired boot info, 0 = quite surely not
3549  * @since 0.6.32
3550  */
3551 int el_torito_seems_boot_info_table(ElToritoBootImage *bootimg, int flag);
3552 
3553 /**
3554  * Specifies options for ISOLINUX or GRUB boot images. This should only be used
3555  * if the type of boot image is known.
3556  *
3557  * @param bootimg
3558  * The image to set options on
3559  * @param options
3560  * bitmask style flag. The following values are defined:
3561  *
3562  * bit0= Patch the boot info table of the boot image.
3563  * This does the same as mkisofs option -boot-info-table.
3564  * Needed for ISOLINUX or GRUB boot images with platform ID 0.
3565  * The table is located at byte 8 of the boot image file.
3566  * Its size is 56 bytes.
3567  * The original boot image file on disk will not be modified.
3568  *
3569  * One may use el_torito_seems_boot_info_table() for a
3570  * qualified guess whether a boot info table is present in
3571  * the boot image. If the result is 1 then it should get bit0
3572  * set if its content gets copied to a new LBA.
3573  *
3574  * bit1= Generate a ISOLINUX isohybrid image with MBR.
3575  * ----------------------------------------------------------
3576  * @deprecated since 31 Mar 2010:
3577  * The author of syslinux, H. Peter Anvin requested that this
3578  * feature shall not be used any more. He intends to cease
3579  * support for the MBR template that is included in libisofs.
3580  * ----------------------------------------------------------
3581  * A hybrid image is a boot image that boots from either
3582  * CD/DVD media or from disk-like media, e.g. USB stick.
3583  * For that you need isolinux.bin from SYSLINUX 3.72 or later.
3584  * IMPORTANT: The application has to take care that the image
3585  * on media gets padded up to the next full MB.
3586  * Under seiveral circumstances it might get aligned
3587  * automatically. But there is no warranty.
3588  * bit2-7= Mentioning in isohybrid GPT
3589  * 0= Do not mention in GPT
3590  * 1= Mention as Basic Data partition.
3591  * This cannot be combined with GPT partitions as of
3592  * iso_write_opts_set_efi_bootp()
3593  * @since 1.2.4
3594  * 2= Mention as HFS+ partition.
3595  * This cannot be combined with HFS+ production by
3596  * iso_write_opts_set_hfsplus().
3597  * @since 1.2.4
3598  * Primary GPT and backup GPT get written if at least one
3599  * ElToritoBootImage shall be mentioned.
3600  * The first three mentioned GPT partitions get mirrored in the
3601  * the partition table of the isohybrid MBR. They get type 0xfe.
3602  * The MBR partition entry for PC-BIOS gets type 0x00 rather
3603  * than 0x17.
3604  * Often it is one of the further MBR partitions which actually
3605  * gets used by EFI.
3606  * @since 1.2.4
3607  * bit8= Mention in isohybrid Apple partition map
3608  * APM get written if at least one ElToritoBootImage shall be
3609  * mentioned. The ISOLINUX MBR must look suitable or else an error
3610  * event will happen at image generation time.
3611  * @since 1.2.4
3612  * bit9= GRUB2 boot info
3613  * Patch the boot image file at byte 1012 with the 512-block
3614  * address + 2. Two little endian 32-bit words. Low word first.
3615  * This is combinable with bit0.
3616  * @since 1.3.0
3617  * @param flag
3618  * Reserved for future usage, set to 0.
3619  * @return
3620  * 1 success, < 0 on error
3621  * @since 0.6.12
3622  */
3624  int options, int flag);
3625 
3626 /**
3627  * Get the options as of el_torito_set_isolinux_options().
3628  *
3629  * @param bootimg
3630  * The image to inquire
3631  * @param flag
3632  * Reserved for future usage, set to 0.
3633  * @return
3634  * >= 0 returned option bits , <0 = error
3635  *
3636  * @since 0.6.32
3637  */
3638 int el_torito_get_isolinux_options(ElToritoBootImage *bootimg, int flag);
3639 
3640 /** Deprecated:
3641  * Specifies that this image needs to be patched. This involves the writing
3642  * of a 16 bytes boot information table at offset 8 of the boot image file.
3643  * The original boot image file won't be modified.
3644  * This is needed for isolinux boot images.
3645  *
3646  * @since 0.6.2
3647  * @deprecated Use el_torito_set_isolinux_options() instead
3648  */
3650 
3651 /**
3652  * Obtain a copy of the eventually loaded first 32768 bytes of the imported
3653  * session, the System Area.
3654  * It will be written to the start of the next session unless it gets
3655  * overwritten by iso_write_opts_set_system_area().
3656  *
3657  * @param img
3658  * The image to be inquired.
3659  * @param data
3660  * A byte array of at least 32768 bytes to take the loaded bytes.
3661  * @param options
3662  * The option bits which will be applied if not overridden by
3663  * iso_write_opts_set_system_area(). See there.
3664  * @param flag
3665  * Bitfield for control purposes, unused yet, submit 0
3666  * @return
3667  * 1 on success, 0 if no System Area was loaded, < 0 error.
3668  * @since 0.6.30
3669  */
3670 int iso_image_get_system_area(IsoImage *img, char data[32768],
3671  int *options, int flag);
3672 
3673 /**
3674  * Add a MIPS boot file path to the image.
3675  * Up to 15 such files can be written into a MIPS Big Endian Volume Header
3676  * if this is enabled by value 1 in iso_write_opts_set_system_area() option
3677  * bits 2 to 7.
3678  * A single file can be written into a DEC Boot Block if this is enabled by
3679  * value 2 in iso_write_opts_set_system_area() option bits 2 to 7. So only
3680  * the first added file gets into effect with this system area type.
3681  * The data files which shall serve as MIPS boot files have to be brought into
3682  * the image by the normal means.
3683  * @param img
3684  * The image to be manipulated.
3685  * @param path
3686  * Absolute path of the boot file in the ISO 9660 Rock Ridge tree.
3687  * @param flag
3688  * Bitfield for control purposes, unused yet, submit 0
3689  * @return
3690  * 1 on success, < 0 error
3691  * @since 0.6.38
3692  */
3693 int iso_image_add_mips_boot_file(IsoImage *image, char *path, int flag);
3694 
3695 /**
3696  * Obtain the number of added MIPS Big Endian boot files and pointers to
3697  * their paths in the ISO 9660 Rock Ridge tree.
3698  * @param img
3699  * The image to be inquired.
3700  * @param paths
3701  * An array of pointers to be set to the registered boot file paths.
3702  * This are just pointers to data inside IsoImage. Do not free() them.
3703  * Eventually make own copies of the data before manipulating the image.
3704  * @param flag
3705  * Bitfield for control purposes, unused yet, submit 0
3706  * @return
3707  * >= 0 is the number of valid path pointers , <0 means error
3708  * @since 0.6.38
3709  */
3710 int iso_image_get_mips_boot_files(IsoImage *image, char *paths[15], int flag);
3711 
3712 /**
3713  * Clear the list of MIPS Big Endian boot file paths.
3714  * @param img
3715  * The image to be manipulated.
3716  * @param flag
3717  * Bitfield for control purposes, unused yet, submit 0
3718  * @return
3719  * 1 is success , <0 means error
3720  * @since 0.6.38
3721  */
3722 int iso_image_give_up_mips_boot(IsoImage *image, int flag);
3723 
3724 /**
3725  * Designate a data file in the ISO image of which the position and size
3726  * shall be written after the SUN Disk Label. The position is written as
3727  * 64-bit big-endian number to byte position 0x228. The size is written
3728  * as 32-bit big-endian to 0x230.
3729  * This setting has an effect only if system area type is set to 3
3730  * with iso_write_opts_set_system_area().
3731  *
3732  * @param img
3733  * The image to be manipulated.
3734  * @param sparc_core
3735  * The IsoFile which shall be mentioned after the SUN Disk label.
3736  * NULL is a permissible value. It disables this feature.
3737  * @param flag
3738  * Bitfield for control purposes, unused yet, submit 0
3739  * @return
3740  * 1 is success , <0 means error
3741  * @since 1.3.0
3742  */
3743 int iso_image_set_sparc_core(IsoImage *img, IsoFile *sparc_core, int flag);
3744 
3745 /**
3746  * Obtain the current setting of iso_image_set_sparc_core().
3747  *
3748  * @param img
3749  * The image to be inquired.
3750  * @param sparc_core
3751  * Will return a pointer to the IsoFile (or NULL, which is not an error)
3752  * @param flag
3753  * Bitfield for control purposes, unused yet, submit 0
3754  * @return
3755  * 1 is success , <0 means error
3756  * @since 1.3.0
3757  */
3758 int iso_image_get_sparc_core(IsoImage *img, IsoFile **sparc_core, int flag);
3759 
3760 
3761 #ifdef Libisofs_enable_unreleased_hppa_palO
3762 
3763 /* <<< This API call and the implementation of its consequences are not yet
3764  stable. So it gets excluded from releases.
3765 */
3766 
3767 /**
3768  * Define a command line and submit the paths of four mandatory files for
3769  * production of a HP-PA PALO boot sector for PA-RISC machines.
3770  * The paths must lead to already existing data files in the ISO image
3771  * which stay with these paths until image production.
3772  *
3773  * @param img
3774  * The image to be manipulated.
3775  * @param cmdline
3776  * Up to 127 characters of command line.
3777  * @param bootloader
3778  * Absolute path of a data file in the ISO image.
3779  * @param kernel_32
3780  * Absolute path of a data file in the ISO image which serves as
3781  * 32 bit kernel.
3782  * @param kernel_64
3783  * Absolute path of a data file in the ISO image which serves as
3784  * 64 bit kernel.
3785  * @param ramdisk
3786  * Absolute path of a data file in the ISO image.
3787  * @param flag
3788  * Bitfield for control purposes
3789  * bit0= Let NULL parameters free the corresponding image properties.
3790  * Else only the non-NULL parameters of this call have an effect
3791  * @return
3792  * 1 is success , <0 means error
3793  * @since 1.3.8
3794  */
3795 int iso_image_set_hppa_palo(IsoImage *img, char *cmdline, char *bootloader,
3796  char *kernel_32, char *kernel_64, char *ramdisk,
3797  int flag);
3798 
3799 /**
3800  * Inquire the current settings of iso_image_set_hppa_palo().
3801  * Do not free() the returned pointers.
3802  *
3803  * @param img
3804  * The image to be inquired.
3805  * @param cmdline
3806  * Will return the command line.
3807  * @param bootloader
3808  * Will return the absolute path of the bootloader file.
3809  * @param kernel_32
3810  * Will return the absolute path of the 32 bit kernel file.
3811  * @param kernel_64
3812  * Will return the absolute path of the 64 bit kernel file.
3813  * @param ramdisk
3814  * Will return the absolute path of the RAM disk file.
3815  * @return
3816  * 1 is success , <0 means error
3817  * @since 1.3.8
3818  */
3819 int iso_image_get_hppa_palo(IsoImage *img, char **cmdline, char **bootloader,
3820  char **kernel_32, char **kernel_64, char **ramdisk);
3821 
3822 #endif /* Libisofs_enable_unreleased_hppa_palO */
3823 
3824 /**
3825  * Increments the reference counting of the given node.
3826  *
3827  * @since 0.6.2
3828  */
3829 void iso_node_ref(IsoNode *node);
3830 
3831 /**
3832  * Decrements the reference couting of the given node.
3833  * If it reach 0, the node is free, and, if the node is a directory,
3834  * its children will be unref() too.
3835  *
3836  * @since 0.6.2
3837  */
3838 void iso_node_unref(IsoNode *node);
3839 
3840 /**
3841  * Get the type of an IsoNode.
3842  *
3843  * @since 0.6.2
3844  */
3846 
3847 /**
3848  * Class of functions to handle particular extended information. A function
3849  * instance acts as an identifier for the type of the information. Structs
3850  * with same information type must use a pointer to the same function.
3851  *
3852  * @param data
3853  * Attached data
3854  * @param flag
3855  * What to do with the data. At this time the following values are
3856  * defined:
3857  * -> 1 the data must be freed
3858  * @return
3859  * 1 in any case.
3860  *
3861  * @since 0.6.4
3862  */
3863 typedef int (*iso_node_xinfo_func)(void *data, int flag);
3864 
3865 /**
3866  * Add extended information to the given node. Extended info allows
3867  * applications (and libisofs itself) to add more information to an IsoNode.
3868  * You can use this facilities to associate temporary information with a given
3869  * node. This information is not written into the ISO 9660 image on media
3870  * and thus does not persist longer than the node memory object.
3871  *
3872  * Each node keeps a list of added extended info, meaning you can add several
3873  * extended info data to each node. Each extended info you add is identified
3874  * by the proc parameter, a pointer to a function that knows how to manage
3875  * the external info data. Thus, in order to add several types of extended
3876  * info, you need to define a "proc" function for each type.
3877  *
3878  * @param node
3879  * The node where to add the extended info
3880  * @param proc
3881  * A function pointer used to identify the type of the data, and that
3882  * knows how to manage it
3883  * @param data
3884  * Extended info to add.
3885  * @return
3886  * 1 if success, 0 if the given node already has extended info of the
3887  * type defined by the "proc" function, < 0 on error
3888  *
3889  * @since 0.6.4
3890  */
3891 int iso_node_add_xinfo(IsoNode *node, iso_node_xinfo_func proc, void *data);
3892 
3893 /**
3894  * Remove the given extended info (defined by the proc function) from the
3895  * given node.
3896  *
3897  * @return
3898  * 1 on success, 0 if node does not have extended info of the requested
3899  * type, < 0 on error
3900  *
3901  * @since 0.6.4
3902  */
3904 
3905 /**
3906  * Remove all extended information from the given node.
3907  *
3908  * @param node
3909  * The node where to remove all extended info
3910  * @param flag
3911  * Bitfield for control purposes, unused yet, submit 0
3912  * @return
3913  * 1 on success, < 0 on error
3914  *
3915  * @since 1.0.2
3916  */
3917 int iso_node_remove_all_xinfo(IsoNode *node, int flag);
3918 
3919 /**
3920  * Get the given extended info (defined by the proc function) from the
3921  * given node.
3922  *
3923  * @param node
3924  * The node to inquire
3925  * @param proc
3926  * The function pointer which serves as key
3927  * @param data
3928  * Will after successful call point to the xinfo data corresponding
3929  * to the given proc. This is a pointer, not a feeable data copy.
3930  * @return
3931  * 1 on success, 0 if node does not have extended info of the requested
3932  * type, < 0 on error
3933  *
3934  * @since 0.6.4
3935  */
3936 int iso_node_get_xinfo(IsoNode *node, iso_node_xinfo_func proc, void **data);
3937 
3938 
3939 /**
3940  * Get the next pair of function pointer and data of an iteration of the
3941  * list of extended informations. Like:
3942  * iso_node_xinfo_func proc;
3943  * void *handle = NULL, *data;
3944  * while (iso_node_get_next_xinfo(node, &handle, &proc, &data) == 1) {
3945  * ... make use of proc and data ...
3946  * }
3947  * The iteration allocates no memory. So you may end it without any disposal
3948  * action.
3949  * IMPORTANT: Do not continue iterations after manipulating the extended
3950  * information of a node. Memory corruption hazard !
3951  * @param node
3952  * The node to inquire
3953  * @param handle
3954  * The opaque iteration handle. Initialize iteration by submitting
3955  * a pointer to a void pointer with value NULL.
3956  * Do not alter its content until iteration has ended.
3957  * @param proc
3958  * The function pointer which serves as key
3959  * @param data
3960  * Will be filled with the extended info corresponding to the given proc
3961  * function
3962  * @return
3963  * 1 on success
3964  * 0 if iteration has ended (proc and data are invalid then)
3965  * < 0 on error
3966  *
3967  * @since 1.0.2
3968  */
3969 int iso_node_get_next_xinfo(IsoNode *node, void **handle,
3970  iso_node_xinfo_func *proc, void **data);
3971 
3972 
3973 /**
3974  * Class of functions to clone extended information. A function instance gets
3975  * associated to a particular iso_node_xinfo_func instance by function
3976  * iso_node_xinfo_make_clonable(). This is a precondition to have IsoNode
3977  * objects clonable which carry data for a particular iso_node_xinfo_func.
3978  *
3979  * @param old_data
3980  * Data item to be cloned
3981  * @param new_data
3982  * Shall return the cloned data item
3983  * @param flag
3984  * Unused yet, submit 0
3985  * The function shall return ISO_XINFO_NO_CLONE on unknown flag bits.
3986  * @return
3987  * > 0 number of allocated bytes
3988  * 0 no size info is available
3989  * < 0 error
3990  *
3991  * @since 1.0.2
3992  */
3993 typedef int (*iso_node_xinfo_cloner)(void *old_data, void **new_data,int flag);
3994 
3995 /**
3996  * Associate a iso_node_xinfo_cloner to a particular class of extended
3997  * information in order to make it clonable.
3998  *
3999  * @param proc
4000  * The key and disposal function which identifies the particular
4001  * extended information class.
4002  * @param cloner
4003  * The cloner function which shall be associated with proc.
4004  * @param flag
4005  * Unused yet, submit 0
4006  * @return
4007  * 1 success, < 0 error
4008  *
4009  * @since 1.0.2
4010  */
4012  iso_node_xinfo_cloner cloner, int flag);
4013 
4014 /**
4015  * Inquire the registered cloner function for a particular class of
4016  * extended information.
4017  *
4018  * @param proc
4019  * The key and disposal function which identifies the particular
4020  * extended information class.
4021  * @param cloner
4022  * Will return the cloner function which is associated with proc, or NULL.
4023  * @param flag
4024  * Unused yet, submit 0
4025  * @return
4026  * 1 success, 0 no cloner registered for proc, < 0 error
4027  *
4028  * @since 1.0.2
4029  */
4031  iso_node_xinfo_cloner *cloner, int flag);
4032 
4033 
4034 /**
4035  * Set the name of a node. Note that if the node is already added to a dir
4036  * this can fail if dir already contains a node with the new name.
4037  *
4038  * @param node
4039  * The node whose name you want to change. Note that you can't change
4040  * the name of the root.
4041  * @param name
4042  * The name for the node. If you supply an empty string or a
4043  * name greater than 255 characters this returns with failure, and
4044  * node name is not modified.
4045  * @return
4046  * 1 on success, < 0 on error
4047  *
4048  * @since 0.6.2
4049  */
4050 int iso_node_set_name(IsoNode *node, const char *name);
4051 
4052 /**
4053  * Get the name of a node.
4054  * The returned string belongs to the node and must not be modified nor
4055  * freed. Use strdup if you really need your own copy.
4056  *
4057  * @since 0.6.2
4058  */
4059 const char *iso_node_get_name(const IsoNode *node);
4060 
4061 /**
4062  * Set the permissions for the node. This attribute is only useful when
4063  * Rock Ridge extensions are enabled.
4064  *
4065  * @param node
4066  * The node to change
4067  * @param mode
4068  * bitmask with the permissions of the node, as specified in 'man 2 stat'.
4069  * The file type bitfields will be ignored, only file permissions will be
4070  * modified.
4071  *
4072  * @since 0.6.2
4073  */
4074 void iso_node_set_permissions(IsoNode *node, mode_t mode);
4075 
4076 /**
4077  * Get the permissions for the node
4078  *
4079  * @since 0.6.2
4080  */
4081 mode_t iso_node_get_permissions(const IsoNode *node);
4082 
4083 /**
4084  * Get the mode of the node, both permissions and file type, as specified in
4085  * 'man 2 stat'.
4086  *
4087  * @since 0.6.2
4088  */
4089 mode_t iso_node_get_mode(const IsoNode *node);
4090 
4091 /**
4092  * Set the user id for the node. This attribute is only useful when
4093  * Rock Ridge extensions are enabled.
4094  *
4095  * @since 0.6.2
4096  */
4097 void iso_node_set_uid(IsoNode *node, uid_t uid);
4098 
4099 /**
4100  * Get the user id of the node.
4101  *
4102  * @since 0.6.2
4103  */
4104 uid_t iso_node_get_uid(const IsoNode *node);
4105 
4106 /**
4107  * Set the group id for the node. This attribute is only useful when
4108  * Rock Ridge extensions are enabled.
4109  *
4110  * @since 0.6.2
4111  */
4112 void iso_node_set_gid(IsoNode *node, gid_t gid);
4113 
4114 /**
4115  * Get the group id of the node.
4116  *
4117  * @since 0.6.2
4118  */
4119 gid_t iso_node_get_gid(const IsoNode *node);
4120 
4121 /**
4122  * Set the time of last modification of the file
4123  *
4124  * @since 0.6.2
4125  */
4126 void iso_node_set_mtime(IsoNode *node, time_t time);
4127 
4128 /**
4129  * Get the time of last modification of the file
4130  *
4131  * @since 0.6.2
4132  */
4133 time_t iso_node_get_mtime(const IsoNode *node);
4134 
4135 /**
4136  * Set the time of last access to the file
4137  *
4138  * @since 0.6.2
4139  */
4140 void iso_node_set_atime(IsoNode *node, time_t time);
4141 
4142 /**
4143  * Get the time of last access to the file
4144  *
4145  * @since 0.6.2
4146  */
4147 time_t iso_node_get_atime(const IsoNode *node);
4148 
4149 /**
4150  * Set the time of last status change of the file
4151  *
4152  * @since 0.6.2
4153  */
4154 void iso_node_set_ctime(IsoNode *node, time_t time);
4155 
4156 /**
4157  * Get the time of last status change of the file
4158  *
4159  * @since 0.6.2
4160  */
4161 time_t iso_node_get_ctime(const IsoNode *node);
4162 
4163 /**
4164  * Set whether the node will be hidden in the directory trees of RR/ISO 9660,
4165  * or of Joliet (if enabled at all), or of ISO-9660:1999 (if enabled at all).
4166  *
4167  * A hidden file does not show up by name in the affected directory tree.
4168  * For example, if a file is hidden only in Joliet, it will normally
4169  * not be visible on Windows systems, while being shown on GNU/Linux.
4170  *
4171  * If a file is not shown in any of the enabled trees, then its content will
4172  * not be written to the image, unless LIBISO_HIDE_BUT_WRITE is given (which
4173  * is available only since release 0.6.34).
4174  *
4175  * @param node
4176  * The node that is to be hidden.
4177  * @param hide_attrs
4178  * Or-combination of values from enum IsoHideNodeFlag to set the trees
4179  * in which the node's name shall be hidden.
4180  *
4181  * @since 0.6.2
4182  */
4183 void iso_node_set_hidden(IsoNode *node, int hide_attrs);
4184 
4185 /**
4186  * Get the hide_attrs as eventually set by iso_node_set_hidden().
4187  *
4188  * @param node
4189  * The node to inquire.
4190  * @return
4191  * Or-combination of values from enum IsoHideNodeFlag which are
4192  * currently set for the node.
4193  *
4194  * @since 0.6.34
4195  */
4196 int iso_node_get_hidden(IsoNode *node);
4197 
4198 /**
4199  * Compare two nodes whether they are based on the same input and
4200  * can be considered as hardlinks to the same file objects.
4201  *
4202  * @param n1
4203  * The first node to compare.
4204  * @param n2
4205  * The second node to compare.
4206  * @return
4207  * -1 if n1 is smaller n2 , 0 if n1 matches n2 , 1 if n1 is larger n2
4208  * @param flag
4209  * Bitfield for control purposes, unused yet, submit 0
4210  * @since 0.6.20
4211  */
4212 int iso_node_cmp_ino(IsoNode *n1, IsoNode *n2, int flag);
4213 
4214 /**
4215  * Add a new node to a dir. Note that this function don't add a new ref to
4216  * the node, so you don't need to free it, it will be automatically freed
4217  * when the dir is deleted. Of course, if you want to keep using the node
4218  * after the dir life, you need to iso_node_ref() it.
4219  *
4220  * @param dir
4221  * the dir where to add the node
4222  * @param child
4223  * the node to add. You must ensure that the node hasn't previously added
4224  * to other dir, and that the node name is unique inside the child.
4225  * Otherwise this function will return a failure, and the child won't be
4226  * inserted.
4227  * @param replace
4228  * if the dir already contains a node with the same name, whether to
4229  * replace or not the old node with this.
4230  * @return
4231  * number of nodes in dir if succes, < 0 otherwise
4232  * Possible errors:
4233  * ISO_NULL_POINTER, if dir or child are NULL
4234  * ISO_NODE_ALREADY_ADDED, if child is already added to other dir
4235  * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
4236  * ISO_WRONG_ARG_VALUE, if child == dir, or replace != (0,1)
4237  *
4238  * @since 0.6.2
4239  */
4240 int iso_dir_add_node(IsoDir *dir, IsoNode *child,
4241  enum iso_replace_mode replace);
4242 
4243 /**
4244  * Locate a node inside a given dir.
4245  *
4246  * @param dir
4247  * The dir where to look for the node.
4248  * @param name
4249  * The name of the node
4250  * @param node
4251  * Location for a pointer to the node, it will filled with NULL if the dir
4252  * doesn't have a child with the given name.
4253  * The node will be owned by the dir and shouldn't be unref(). Just call
4254  * iso_node_ref() to get your own reference to the node.
4255  * Note that you can pass NULL is the only thing you want to do is check
4256  * if a node with such name already exists on dir.
4257  * @return
4258  * 1 node found, 0 child has no such node, < 0 error
4259  * Possible errors:
4260  * ISO_NULL_POINTER, if dir or name are NULL
4261  *
4262  * @since 0.6.2
4263  */
4264 int iso_dir_get_node(IsoDir *dir, const char *name, IsoNode **node);
4265 
4266 /**
4267  * Get the number of children of a directory.
4268  *
4269  * @return
4270  * >= 0 number of items, < 0 error
4271  * Possible errors:
4272  * ISO_NULL_POINTER, if dir is NULL
4273  *
4274  * @since 0.6.2
4275  */
4277 
4278 /**
4279  * Removes a child from a directory.
4280  * The child is not freed, so you will become the owner of the node. Later
4281  * you can add the node to another dir (calling iso_dir_add_node), or free
4282  * it if you don't need it (with iso_node_unref).
4283  *
4284  * @return
4285  * 1 on success, < 0 error
4286  * Possible errors:
4287  * ISO_NULL_POINTER, if node is NULL
4288  * ISO_NODE_NOT_ADDED_TO_DIR, if node doesn't belong to a dir
4289  *
4290  * @since 0.6.2
4291  */
4292 int iso_node_take(IsoNode *node);
4293 
4294 /**
4295  * Removes a child from a directory and free (unref) it.
4296  * If you want to keep the child alive, you need to iso_node_ref() it
4297  * before this call, but in that case iso_node_take() is a better
4298  * alternative.
4299  *
4300  * @return
4301  * 1 on success, < 0 error
4302  *
4303  * @since 0.6.2
4304  */
4305 int iso_node_remove(IsoNode *node);
4306 
4307 /*
4308  * Get the parent of the given iso tree node. No extra ref is added to the
4309  * returned directory, you must take your ref. with iso_node_ref() if you
4310  * need it.
4311  *
4312  * If node is the root node, the same node will be returned as its parent.
4313  *
4314  * This returns NULL if the node doesn't pertain to any tree
4315  * (it was removed/taken).
4316  *
4317  * @since 0.6.2
4318  */
4320 
4321 /**
4322  * Get an iterator for the children of the given dir.
4323  *
4324  * You can iterate over the children with iso_dir_iter_next. When finished,
4325  * you should free the iterator with iso_dir_iter_free.
4326  * You musn't delete a child of the same dir, using iso_node_take() or
4327  * iso_node_remove(), while you're using the iterator. You can use
4328  * iso_dir_iter_take() or iso_dir_iter_remove() instead.
4329  *
4330  * You can use the iterator in the way like this
4331  *
4332  * IsoDirIter *iter;
4333  * IsoNode *node;
4334  * if ( iso_dir_get_children(dir, &iter) != 1 ) {
4335  * // handle error
4336  * }
4337  * while ( iso_dir_iter_next(iter, &node) == 1 ) {
4338  * // do something with the child
4339  * }
4340  * iso_dir_iter_free(iter);
4341  *
4342  * An iterator is intended to be used in a single iteration over the
4343  * children of a dir. Thus, it should be treated as a temporary object,
4344  * and free as soon as possible.
4345  *
4346  * @return
4347  * 1 success, < 0 error
4348  * Possible errors:
4349  * ISO_NULL_POINTER, if dir or iter are NULL
4350  * ISO_OUT_OF_MEM
4351  *
4352  * @since 0.6.2
4353  */
4354 int iso_dir_get_children(const IsoDir *dir, IsoDirIter **iter);
4355 
4356 /**
4357  * Get the next child.
4358  * Take care that the node is owned by its parent, and will be unref() when
4359  * the parent is freed. If you want your own ref to it, call iso_node_ref()
4360  * on it.
4361  *
4362  * @return
4363  * 1 success, 0 if dir has no more elements, < 0 error
4364  * Possible errors:
4365  * ISO_NULL_POINTER, if node or iter are NULL
4366  * ISO_ERROR, on wrong iter usage, usual caused by modiying the
4367  * dir during iteration
4368  *
4369  * @since 0.6.2
4370  */
4371 int iso_dir_iter_next(IsoDirIter *iter, IsoNode **node);
4372 
4373 /**
4374  * Check if there're more children.
4375  *
4376  * @return
4377  * 1 dir has more elements, 0 no, < 0 error
4378  * Possible errors:
4379  * ISO_NULL_POINTER, if iter is NULL
4380  *
4381  * @since 0.6.2
4382  */
4384 
4385 /**
4386  * Free a dir iterator.
4387  *
4388  * @since 0.6.2
4389  */
4390 void iso_dir_iter_free(IsoDirIter *iter);
4391 
4392 /**
4393  * Removes a child from a directory during an iteration, without freeing it.
4394  * It's like iso_node_take(), but to be used during a directory iteration.
4395  * The node removed will be the last returned by the iteration.
4396  *
4397  * If you call this function twice without calling iso_dir_iter_next between
4398  * them is not allowed and you will get an ISO_ERROR in second call.
4399  *
4400  * @return
4401  * 1 on succes, < 0 error
4402  * Possible errors:
4403  * ISO_NULL_POINTER, if iter is NULL
4404  * ISO_ERROR, on wrong iter usage, for example by call this before
4405  * iso_dir_iter_next.
4406  *
4407  * @since 0.6.2
4408  */
4409 int iso_dir_iter_take(IsoDirIter *iter);
4410 
4411 /**
4412  * Removes a child from a directory during an iteration and unref() it.
4413  * Like iso_node_remove(), but to be used during a directory iteration.
4414  * The node removed will be the one returned by the previous iteration.
4415  *
4416  * It is not allowed to call this function twice without calling
4417  * iso_dir_iter_next inbetween.
4418  *
4419  * @return
4420  * 1 on succes, < 0 error
4421  * Possible errors:
4422  * ISO_NULL_POINTER, if iter is NULL
4423  * ISO_ERROR, on wrong iter usage, for example by calling this before
4424  * iso_dir_iter_next.
4425  *
4426  * @since 0.6.2
4427  */
4428 int iso_dir_iter_remove(IsoDirIter *iter);
4429 
4430 /**
4431  * Removes a node by iso_node_remove() or iso_dir_iter_remove(). If the node
4432  * is a directory then the whole tree of nodes underneath is removed too.
4433  *
4434  * @param node
4435  * The node to be removed.
4436  * @param iter
4437  * If not NULL, then the node will be removed by iso_dir_iter_remove(iter)
4438  * else it will be removed by iso_node_remove(node).
4439  * @return
4440  * 1 is success, <0 indicates error
4441  *
4442  * @since 1.0.2
4443  */
4444 int iso_node_remove_tree(IsoNode *node, IsoDirIter *boss_iter);
4445 
4446 
4447 /**
4448  * @since 0.6.4
4449  */
4450 typedef struct iso_find_condition IsoFindCondition;
4451 
4452 /**
4453  * Create a new condition that checks if the node name matches the given
4454  * wildcard.
4455  *
4456  * @param wildcard
4457  * @result
4458  * The created IsoFindCondition, NULL on error.
4459  *
4460  * @since 0.6.4
4461  */
4462 IsoFindCondition *iso_new_find_conditions_name(const char *wildcard);
4463 
4464 /**
4465  * Create a new condition that checks the node mode against a mode mask. It
4466  * can be used to check both file type and permissions.
4467  *
4468  * For example:
4469  *
4470  * iso_new_find_conditions_mode(S_IFREG) : search for regular files
4471  * iso_new_find_conditions_mode(S_IFCHR | S_IWUSR) : search for character
4472  * devices where owner has write permissions.
4473  *
4474  * @param mask
4475  * Mode mask to AND against node mode.
4476  * @result
4477  * The created IsoFindCondition, NULL on error.
4478  *
4479  * @since 0.6.4
4480  */
4482 
4483 /**
4484  * Create a new condition that checks the node gid.
4485  *
4486  * @param gid
4487  * Desired Group Id.
4488  * @result
4489  * The created IsoFindCondition, NULL on error.
4490  *
4491  * @since 0.6.4
4492  */
4494 
4495 /**
4496  * Create a new condition that checks the node uid.
4497  *
4498  * @param uid
4499  * Desired User Id.
4500  * @result
4501  * The created IsoFindCondition, NULL on error.
4502  *
4503  * @since 0.6.4
4504  */
4506 
4507 /**
4508  * Possible comparison between IsoNode and given conditions.
4509  *
4510  * @since 0.6.4
4511  */
4518 };
4519 
4520 /**
4521  * Create a new condition that checks the time of last access.
4522  *
4523  * @param time
4524  * Time to compare against IsoNode atime.
4525  * @param comparison
4526  * Comparison to be done between IsoNode atime and submitted time.
4527  * Note that ISO_FIND_COND_GREATER, for example, is true if the node
4528  * time is greater than the submitted time.
4529  * @result
4530  * The created IsoFindCondition, NULL on error.
4531  *
4532  * @since 0.6.4
4533  */
4535  enum iso_find_comparisons comparison);
4536 
4537 /**
4538  * Create a new condition that checks the time of last modification.
4539  *
4540  * @param time
4541  * Time to compare against IsoNode mtime.
4542  * @param comparison
4543  * Comparison to be done between IsoNode mtime and submitted time.
4544  * Note that ISO_FIND_COND_GREATER, for example, is true if the node
4545  * time is greater than the submitted time.
4546  * @result
4547  * The created IsoFindCondition, NULL on error.
4548  *
4549  * @since 0.6.4
4550  */
4552  enum iso_find_comparisons comparison);
4553 
4554 /**
4555  * Create a new condition that checks the time of last status change.
4556  *
4557  * @param time
4558  * Time to compare against IsoNode ctime.
4559  * @param comparison
4560  * Comparison to be done between IsoNode ctime and submitted time.
4561  * Note that ISO_FIND_COND_GREATER, for example, is true if the node
4562  * time is greater than the submitted time.
4563  * @result
4564  * The created IsoFindCondition, NULL on error.
4565  *
4566  * @since 0.6.4
4567  */
4569  enum iso_find_comparisons comparison);
4570 
4571 /**
4572  * Create a new condition that check if the two given conditions are
4573  * valid.
4574  *
4575  * @param a
4576  * @param b
4577  * IsoFindCondition to compare
4578  * @result
4579  * The created IsoFindCondition, NULL on error.
4580  *
4581  * @since 0.6.4
4582  */
4584  IsoFindCondition *b);
4585 
4586 /**
4587  * Create a new condition that check if at least one the two given conditions
4588  * is valid.
4589  *
4590  * @param a
4591  * @param b
4592  * IsoFindCondition to compare
4593  * @result
4594  * The created IsoFindCondition, NULL on error.
4595  *
4596  * @since 0.6.4
4597  */
4599  IsoFindCondition *b);
4600 
4601 /**
4602  * Create a new condition that check if the given conditions is false.
4603  *
4604  * @param negate
4605  * @result
4606  * The created IsoFindCondition, NULL on error.
4607  *
4608  * @since 0.6.4
4609  */
4611 
4612 /**
4613  * Find all directory children that match the given condition.
4614  *
4615  * @param dir
4616  * Directory where we will search children.
4617  * @param cond
4618  * Condition that the children must match in order to be returned.
4619  * It will be free together with the iterator. Remember to delete it
4620  * if this function return error.
4621  * @param iter
4622  * Iterator that returns only the children that match condition.
4623  * @return
4624  * 1 on success, < 0 on error
4625  *
4626  * @since 0.6.4
4627  */
4629  IsoDirIter **iter);
4630 
4631 /**
4632  * Get the destination of a node.
4633  * The returned string belongs to the node and must not be modified nor
4634  * freed. Use strdup if you really need your own copy.
4635  *
4636  * @since 0.6.2
4637  */
4638 const char *iso_symlink_get_dest(const IsoSymlink *link);
4639 
4640 /**
4641  * Set the destination of a link.
4642  *
4643  * @param opts
4644  * The option set to be manipulated
4645  * @param dest
4646  * New destination for the link. It must be a non-empty string, otherwise
4647  * this function doesn't modify previous destination.
4648  * @return
4649  * 1 on success, < 0 on error
4650  *
4651  * @since 0.6.2
4652  */
4653 int iso_symlink_set_dest(IsoSymlink *link, const char *dest);
4654 
4655 /**
4656  * Sets the order in which a node will be written on image. The data content
4657  * of files with high weight will be written to low block addresses.
4658  *
4659  * @param node
4660  * The node which weight will be changed. If it's a dir, this function
4661  * will change the weight of all its children. For nodes other that dirs
4662  * or regular files, this function has no effect.
4663  * @param w
4664  * The weight as a integer number, the greater this value is, the
4665  * closer from the begining of image the file will be written.
4666  * Default value at IsoNode creation is 0.
4667  *
4668  * @since 0.6.2
4669  */
4670 void iso_node_set_sort_weight(IsoNode *node, int w);
4671 
4672 /**
4673  * Get the sort weight of a file.
4674  *
4675  * @since 0.6.2
4676  */
4678 
4679 /**
4680  * Get the size of the file, in bytes
4681  *
4682  * @since 0.6.2
4683  */
4684 off_t iso_file_get_size(IsoFile *file);
4685 
4686 /**
4687  * Get the device id (major/minor numbers) of the given block or
4688  * character device file. The result is undefined for other kind
4689  * of special files, of first be sure iso_node_get_mode() returns either
4690  * S_IFBLK or S_IFCHR.
4691  *
4692  * @since 0.6.6
4693  */
4694 dev_t iso_special_get_dev(IsoSpecial *special);
4695 
4696 /**
4697  * Get the IsoStream that represents the contents of the given IsoFile.
4698  * The stream may be a filter stream which itself get its input from a
4699  * further stream. This may be inquired by iso_stream_get_input_stream().
4700  *
4701  * If you iso_stream_open() the stream, iso_stream_close() it before
4702  * image generation begins.
4703  *
4704  * @return
4705  * The IsoStream. No extra ref is added, so the IsoStream belongs to the
4706  * IsoFile, and it may be freed together with it. Add your own ref with
4707  * iso_stream_ref() if you need it.
4708  *
4709  * @since 0.6.4
4710  */
4712 
4713 /**
4714  * Get the block lba of a file node, if it was imported from an old image.
4715  *
4716  * @param file
4717  * The file
4718  * @param lba
4719  * Will be filled with the kba
4720  * @param flag
4721  * Reserved for future usage, submit 0
4722  * @return
4723  * 1 if lba is valid (file comes from old image), 0 if file was newly
4724  * added, i.e. it does not come from an old image, < 0 error
4725  *
4726  * @since 0.6.4
4727  *
4728  * @deprecated Use iso_file_get_old_image_sections(), as this function does
4729  * not work with multi-extend files.
4730  */
4731 int iso_file_get_old_image_lba(IsoFile *file, uint32_t *lba, int flag);
4732 
4733 /**
4734  * Get the start addresses and the sizes of the data extents of a file node
4735  * if it was imported from an old image.
4736  *
4737  * @param file
4738  * The file
4739  * @param section_count
4740  * Returns the number of extent entries in sections array.
4741  * @param sections
4742  * Returns the array of file sections. Apply free() to dispose it.
4743  * @param flag
4744  * Reserved for future usage, submit 0
4745  * @return
4746  * 1 if there are valid extents (file comes from old image),
4747  * 0 if file was newly added, i.e. it does not come from an old image,
4748  * < 0 error
4749  *
4750  * @since 0.6.8
4751  */
4752 int iso_file_get_old_image_sections(IsoFile *file, int *section_count,
4753  struct iso_file_section **sections,
4754  int flag);
4755 
4756 /*
4757  * Like iso_file_get_old_image_lba(), but take an IsoNode.
4758  *
4759  * @return
4760  * 1 if lba is valid (file comes from old image), 0 if file was newly
4761  * added, i.e. it does not come from an old image, 2 node type has no
4762  * LBA (no regular file), < 0 error
4763  *
4764  * @since 0.6.4
4765  */
4766 int iso_node_get_old_image_lba(IsoNode *node, uint32_t *lba, int flag);
4767 
4768 /**
4769  * Add a new directory to the iso tree. Permissions, owner and hidden atts
4770  * are taken from parent, you can modify them later.
4771  *
4772  * @param parent
4773  * the dir where the new directory will be created
4774  * @param name
4775  * name for the new dir. If a node with same name already exists on
4776  * parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE.
4777  * @param dir
4778  * place where to store a pointer to the newly created dir. No extra
4779  * ref is addded, so you will need to call iso_node_ref() if you really
4780  * need it. You can pass NULL in this parameter if you don't need the
4781  * pointer.
4782  * @return
4783  * number of nodes in parent if success, < 0 otherwise
4784  * Possible errors:
4785  * ISO_NULL_POINTER, if parent or name are NULL
4786  * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
4787  * ISO_OUT_OF_MEM
4788  *
4789  * @since 0.6.2
4790  */
4791 int iso_tree_add_new_dir(IsoDir *parent, const char *name, IsoDir **dir);
4792 
4793 /**
4794  * Add a new regular file to the iso tree. Permissions are set to 0444,
4795  * owner and hidden atts are taken from parent. You can modify any of them
4796  * later.
4797  *
4798  * @param parent
4799  * the dir where the new file will be created
4800  * @param name
4801  * name for the new file. If a node with same name already exists on
4802  * parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE.
4803  * @param stream
4804  * IsoStream for the contents of the file. The reference will be taken
4805  * by the newly created file, you will need to take an extra ref to it
4806  * if you need it.
4807  * @param file
4808  * place where to store a pointer to the newly created file. No extra
4809  * ref is addded, so you will need to call iso_node_ref() if you really
4810  * need it. You can pass NULL in this parameter if you don't need the
4811  * pointer
4812  * @return
4813  * number of nodes in parent if success, < 0 otherwise
4814  * Possible errors:
4815  * ISO_NULL_POINTER, if parent, name or dest are NULL
4816  * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
4817  * ISO_OUT_OF_MEM
4818  *
4819  * @since 0.6.4
4820  */
4821 int iso_tree_add_new_file(IsoDir *parent, const char *name, IsoStream *stream,
4822  IsoFile **file);
4823 
4824 /**
4825  * Create an IsoStream object from content which is stored in a dynamically
4826  * allocated memory buffer. The new stream will become owner of the buffer
4827  * and apply free() to it when the stream finally gets destroyed itself.
4828  *
4829  * @param buf
4830  * The dynamically allocated memory buffer with the stream content.
4831  * @parm size
4832  * The number of bytes which may be read from buf.
4833  * @param stream
4834  * Will return a reference to the newly created stream.
4835  * @return
4836  * ISO_SUCCESS or <0 for error. E.g. ISO_NULL_POINTER, ISO_OUT_OF_MEM.
4837  *
4838  * @since 1.0.0
4839  */
4840 int iso_memory_stream_new(unsigned char *buf, size_t size, IsoStream **stream);
4841 
4842 /**
4843  * Add a new symlink to the directory tree. Permissions are set to 0777,
4844  * owner and hidden atts are taken from parent. You can modify any of them
4845  * later.
4846  *
4847  * @param parent
4848  * the dir where the new symlink will be created
4849  * @param name
4850  * name for the new symlink. If a node with same name already exists on
4851  * parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE.
4852  * @param dest
4853  * destination of the link
4854  * @param link
4855  * place where to store a pointer to the newly created link. No extra
4856  * ref is addded, so you will need to call iso_node_ref() if you really
4857  * need it. You can pass NULL in this parameter if you don't need the
4858  * pointer
4859  * @return
4860  * number of nodes in parent if success, < 0 otherwise
4861  * Possible errors:
4862  * ISO_NULL_POINTER, if parent, name or dest are NULL
4863  * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
4864  * ISO_OUT_OF_MEM
4865  *
4866  * @since 0.6.2
4867  */
4868 int iso_tree_add_new_symlink(IsoDir *parent, const char *name,
4869  const char *dest, IsoSymlink **link);
4870 
4871 /**
4872  * Add a new special file to the directory tree. As far as libisofs concerns,
4873  * an special file is a block device, a character device, a FIFO (named pipe)
4874  * or a socket. You can choose the specific kind of file you want to add
4875  * by setting mode propertly (see man 2 stat).
4876  *
4877  * Note that special files are only written to image when Rock Ridge
4878  * extensions are enabled. Moreover, a special file is just a directory entry
4879  * in the image tree, no data is written beyond that.
4880  *
4881  * Owner and hidden atts are taken from parent. You can modify any of them
4882  * later.
4883  *
4884  * @param parent
4885  * the dir where the new special file will be created
4886  * @param name
4887  * name for the new special file. If a node with same name already exists
4888  * on parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE.
4889  * @param mode
4890  * file type and permissions for the new node. Note that you can't
4891  * specify any kind of file here, only special types are allowed. i.e,
4892  * S_IFSOCK, S_IFBLK, S_IFCHR and S_IFIFO are valid types; S_IFLNK,
4893  * S_IFREG and S_IFDIR aren't.
4894  * @param dev
4895  * device ID, equivalent to the st_rdev field in man 2 stat.
4896  * @param special
4897  * place where to store a pointer to the newly created special file. No
4898  * extra ref is addded, so you will need to call iso_node_ref() if you
4899  * really need it. You can pass NULL in this parameter if you don't need
4900  * the pointer.
4901  * @return
4902  * number of nodes in parent if success, < 0 otherwise
4903  * Possible errors:
4904  * ISO_NULL_POINTER, if parent, name or dest are NULL
4905  * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
4906  * ISO_WRONG_ARG_VALUE if you select a incorrect mode
4907  * ISO_OUT_OF_MEM
4908  *
4909  * @since 0.6.2
4910  */
4911 int iso_tree_add_new_special(IsoDir *parent, const char *name, mode_t mode,
4912  dev_t dev, IsoSpecial **special);
4913 
4914 /**
4915  * Set whether to follow or not symbolic links when added a file from a source
4916  * to IsoImage. Default behavior is to not follow symlinks.
4917  *
4918  * @since 0.6.2
4919  */
4920 void iso_tree_set_follow_symlinks(IsoImage *image, int follow);
4921 
4922 /**
4923  * Get current setting for follow_symlinks.
4924  *
4925  * @see iso_tree_set_follow_symlinks
4926  * @since 0.6.2
4927  */
4929 
4930 /**
4931  * Set whether to skip or not disk files with names beginning by '.'
4932  * when adding a directory recursively.
4933  * Default behavior is to not ignore them.
4934  *
4935  * Clarification: This is not related to the IsoNode property to be hidden
4936  * in one or more of the resulting image trees as of
4937  * IsoHideNodeFlag and iso_node_set_hidden().
4938  *
4939  * @since 0.6.2
4940  */
4941 void iso_tree_set_ignore_hidden(IsoImage *image, int skip);
4942 
4943 /**
4944  * Get current setting for ignore_hidden.
4945  *
4946  * @see iso_tree_set_ignore_hidden
4947  * @since 0.6.2
4948  */
4950 
4951 /**
4952  * Set the replace mode, that defines the behavior of libisofs when adding
4953  * a node whit the same name that an existent one, during a recursive
4954  * directory addition.
4955  *
4956  * @since 0.6.2
4957  */
4958 void iso_tree_set_replace_mode(IsoImage *image, enum iso_replace_mode mode);
4959 
4960 /**
4961  * Get current setting for replace_mode.
4962  *
4963  * @see iso_tree_set_replace_mode
4964  * @since 0.6.2
4965  */
4967 
4968 /**
4969  * Set whether to skip or not special files. Default behavior is to not skip
4970  * them. Note that, despite of this setting, special files will never be added
4971  * to an image unless RR extensions were enabled.
4972  *
4973  * @param image
4974  * The image to manipulate.
4975  * @param skip
4976  * Bitmask to determine what kind of special files will be skipped:
4977  * bit0: ignore FIFOs
4978  * bit1: ignore Sockets
4979  * bit2: ignore char devices
4980  * bit3: ignore block devices
4981  *
4982  * @since 0.6.2
4983  */
4984 void iso_tree_set_ignore_special(IsoImage *image, int skip);
4985 
4986 /**
4987  * Get current setting for ignore_special.
4988  *
4989  * @see iso_tree_set_ignore_special
4990  * @since 0.6.2
4991  */
4993 
4994 /**
4995  * Add a excluded path. These are paths that won't never added to image, and
4996  * will be excluded even when adding recursively its parent directory.
4997  *
4998  * For example, in
4999  *
5000  * iso_tree_add_exclude(image, "/home/user/data/private");
5001  * iso_tree_add_dir_rec(image, root, "/home/user/data");
5002  *
5003  * the directory /home/user/data/private won't be added to image.
5004  *
5005  * However, if you explicity add a deeper dir, it won't be excluded. i.e.,
5006  * in the following example.
5007  *
5008  * iso_tree_add_exclude(image, "/home/user/data");
5009  * iso_tree_add_dir_rec(image, root, "/home/user/data/private");
5010  *
5011  * the directory /home/user/data/private is added. On the other, side, and
5012  * foollowing the the example above,
5013  *
5014  * iso_tree_add_dir_rec(image, root, "/home/user");
5015  *
5016  * will exclude the directory "/home/user/data".
5017  *
5018  * Absolute paths are not mandatory, you can, for example, add a relative
5019  * path such as:
5020  *
5021  * iso_tree_add_exclude(image, "private");
5022  * iso_tree_add_exclude(image, "user/data");
5023  *
5024  * to excluve, respectively, all files or dirs named private, and also all
5025  * files or dirs named data that belong to a folder named "user". Not that the
5026  * above rule about deeper dirs is still valid. i.e., if you call
5027  *
5028  * iso_tree_add_dir_rec(image, root, "/home/user/data/music");
5029  *
5030  * it is included even containing "user/data" string. However, a possible
5031  * "/home/user/data/music/user/data" is not added.
5032  *
5033  * Usual wildcards, such as * or ? are also supported, with the usual meaning
5034  * as stated in "man 7 glob". For example
5035  *
5036  * // to exclude backup text files
5037  * iso_tree_add_exclude(image, "*.~");
5038  *
5039  * @return
5040  * 1 on success, < 0 on error
5041  *
5042  * @since 0.6.2
5043  */
5044 int iso_tree_add_exclude(IsoImage *image, const char *path);
5045 
5046 /**
5047  * Remove a previously added exclude.
5048  *
5049  * @see iso_tree_add_exclude
5050  * @return
5051  * 1 on success, 0 exclude do not exists, < 0 on error
5052  *
5053  * @since 0.6.2
5054  */
5055 int iso_tree_remove_exclude(IsoImage *image, const char *path);
5056 
5057 /**
5058  * Set a callback function that libisofs will call for each file that is
5059  * added to the given image by a recursive addition function. This includes
5060  * image import.
5061  *
5062  * @param image
5063  * The image to manipulate.
5064  * @param report
5065  * pointer to a function that will be called just before a file will be
5066  * added to the image. You can control whether the file will be in fact
5067  * added or ignored.
5068  * This function should return 1 to add the file, 0 to ignore it and
5069  * continue, < 0 to abort the process
5070  * NULL is allowed if you don't want any callback.
5071  *
5072  * @since 0.6.2
5073  */
5075  int (*report)(IsoImage*, IsoFileSource*));
5076 
5077 /**
5078  * Add a new node to the image tree, from an existing file.
5079  *
5080  * TODO comment Builder and Filesystem related issues when exposing both
5081  *
5082  * All attributes will be taken from the source file. The appropriate file
5083  * type will be created.
5084  *
5085  * @param image
5086  * The image
5087  * @param parent
5088  * The directory in the image tree where the node will be added.
5089  * @param path
5090  * The absolute path of the file in the local filesystem.
5091  * The node will have the same leaf name as the file on disk.
5092  * Its directory path depends on the parent node.
5093  * @param node
5094  * place where to store a pointer to the newly added file. No
5095  * extra ref is addded, so you will need to call iso_node_ref() if you
5096  * really need it. You can pass NULL in this parameter if you don't need
5097  * the pointer.
5098  * @return
5099  * number of nodes in parent if success, < 0 otherwise
5100  * Possible errors:
5101  * ISO_NULL_POINTER, if image, parent or path are NULL
5102  * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
5103  * ISO_OUT_OF_MEM
5104  *
5105  * @since 0.6.2
5106  */
5107 int iso_tree_add_node(IsoImage *image, IsoDir *parent, const char *path,
5108  IsoNode **node);
5109 
5110 /**
5111  * This is a more versatile form of iso_tree_add_node which allows to set
5112  * the node name in ISO image already when it gets added.
5113  *
5114  * Add a new node to the image tree, from an existing file, and with the
5115  * given name, that must not exist on dir.
5116  *
5117  * @param image
5118  * The image
5119  * @param parent
5120  * The directory in the image tree where the node will be added.
5121  * @param name
5122  * The leaf name that the node will have on image.
5123  * Its directory path depends on the parent node.
5124  * @param path
5125  * The absolute path of the file in the local filesystem.
5126  * @param node
5127  * place where to store a pointer to the newly added file. No
5128  * extra ref is addded, so you will need to call iso_node_ref() if you
5129  * really need it. You can pass NULL in this parameter if you don't need
5130  * the pointer.
5131  * @return
5132  * number of nodes in parent if success, < 0 otherwise
5133  * Possible errors:
5134  * ISO_NULL_POINTER, if image, parent or path are NULL
5135  * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
5136  * ISO_OUT_OF_MEM
5137  *
5138  * @since 0.6.4
5139  */
5140 int iso_tree_add_new_node(IsoImage *image, IsoDir *parent, const char *name,
5141  const char *path, IsoNode **node);
5142 
5143 /**
5144  * Add a new node to the image tree with the given name that must not exist
5145  * on dir. The node data content will be a byte interval out of the data
5146  * content of a file in the local filesystem.
5147  *
5148  * @param image
5149  * The image
5150  * @param parent
5151  * The directory in the image tree where the node will be added.
5152  * @param name
5153  * The leaf name that the node will have on image.
5154  * Its directory path depends on the parent node.
5155  * @param path
5156  * The absolute path of the file in the local filesystem. For now
5157  * only regular files and symlinks to regular files are supported.
5158  * @param offset
5159  * Byte number in the given file from where to start reading data.
5160  * @param size
5161  * Max size of the file. This may be more than actually available from
5162  * byte offset to the end of the file in the local filesystem.
5163  * @param node
5164  * place where to store a pointer to the newly added file. No
5165  * extra ref is addded, so you will need to call iso_node_ref() if you
5166  * really need it. You can pass NULL in this parameter if you don't need
5167  * the pointer.
5168  * @return
5169  * number of nodes in parent if success, < 0 otherwise
5170  * Possible errors:
5171  * ISO_NULL_POINTER, if image, parent or path are NULL
5172  * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists
5173  * ISO_OUT_OF_MEM
5174  *
5175  * @since 0.6.4
5176  */
5177 int iso_tree_add_new_cut_out_node(IsoImage *image, IsoDir *parent,
5178  const char *name, const char *path,
5179  off_t offset, off_t size,
5180  IsoNode **node);
5181 
5182 /**
5183  * Create a copy of the given node under a different path. If the node is
5184  * actually a directory then clone its whole subtree.
5185  * This call may fail because an IsoFile is encountered which gets fed by an
5186  * IsoStream which cannot be cloned. See also IsoStream_Iface method
5187  * clone_stream().
5188  * Surely clonable node types are:
5189  * IsoDir,
5190  * IsoSymlink,
5191  * IsoSpecial,
5192  * IsoFile from a loaded ISO image,
5193  * IsoFile referring to local filesystem files,
5194  * IsoFile created by iso_tree_add_new_file
5195  * from a stream created by iso_memory_stream_new(),
5196  * IsoFile created by iso_tree_add_new_cut_out_node()
5197  * Silently ignored are nodes of type IsoBoot.
5198  * An IsoFile node with IsoStream filters can be cloned if all those filters
5199  * are clonable and the node would be clonable without filter.
5200  * Clonable IsoStream filters are created by:
5201  * iso_file_add_zisofs_filter()
5202  * iso_file_add_gzip_filter()
5203  * iso_file_add_external_filter()
5204  * An IsoNode with extended information as of iso_node_add_xinfo() can only be
5205  * cloned if each of the iso_node_xinfo_func instances is associated to a
5206  * clone function. See iso_node_xinfo_make_clonable().
5207  * All internally used classes of extended information are clonable.
5208  *
5209  * @param node
5210  * The node to be cloned.
5211  * @param new_parent
5212  * The existing directory node where to insert the cloned node.
5213  * @param new_name
5214  * The name for the cloned node. It must not yet exist in new_parent,
5215  * unless it is a directory and node is a directory and flag bit0 is set.
5216  * @param new_node
5217  * Will return a pointer (without reference) to the newly created clone.
5218  * @param flag
5219  * Bitfield for control purposes. Submit any undefined bits as 0.
5220  * bit0= Merge directories rather than returning ISO_NODE_NAME_NOT_UNIQUE.
5221  * This will not allow to overwrite any existing node.
5222  * Attributes of existing directories will not be overwritten.
5223  * @return
5224  * <0 means error, 1 = new node created,
5225  * 2 = if flag bit0 is set: new_node is a directory which already existed.
5226  *
5227  * @since 1.0.2
5228  */
5229 int iso_tree_clone(IsoNode *node,
5230  IsoDir *new_parent, char *new_name, IsoNode **new_node,
5231  int flag);
5232 
5233 /**
5234  * Add the contents of a dir to a given directory of the iso tree.
5235  *
5236  * There are several options to control what files are added or how they are
5237  * managed. Take a look at iso_tree_set_* functions to see diferent options
5238  * for recursive directory addition.
5239  *
5240  * TODO comment Builder and Filesystem related issues when exposing both
5241  *
5242  * @param image
5243  * The image to which the directory belongs.
5244  * @param parent
5245  * Directory on the image tree where to add the contents of the dir
5246  * @param dir
5247  * Path to a dir in the filesystem
5248  * @return
5249  * number of nodes in parent if success, < 0 otherwise
5250  *
5251  * @since 0.6.2
5252  */
5253 int iso_tree_add_dir_rec(IsoImage *image, IsoDir *parent, const char *dir);
5254 
5255 /**
5256  * Locate a node by its absolute path on image.
5257  *
5258  * @param image
5259  * The image to which the node belongs.
5260  * @param node
5261  * Location for a pointer to the node, it will filled with NULL if the
5262  * given path does not exists on image.
5263  * The node will be owned by the image and shouldn't be unref(). Just call
5264  * iso_node_ref() to get your own reference to the node.
5265  * Note that you can pass NULL is the only thing you want to do is check
5266  * if a node with such path really exists.
5267  * @return
5268  * 1 found, 0 not found, < 0 error
5269  *
5270  * @since 0.6.2
5271  */
5272 int iso_tree_path_to_node(IsoImage *image, const char *path, IsoNode **node);
5273 
5274 /**
5275  * Get the absolute path on image of the given node.
5276  *
5277  * @return
5278  * The path on the image, that must be freed when no more needed. If the
5279  * given node is not added to any image, this returns NULL.
5280  * @since 0.6.4
5281  */
5282 char *iso_tree_get_node_path(IsoNode *node);
5283 
5284 /**
5285  * Get the destination node of a symbolic link within the IsoImage.
5286  *
5287  * @param img
5288  * The image wherein to try resolving the link.
5289  * @param sym
5290  * The symbolic link node which to resolve.
5291  * @param res
5292  * Will return the found destination node, in case of success.
5293  * Call iso_node_ref() / iso_node_unref() if you intend to use the node
5294  * over API calls which might in any event delete it.
5295  * @param depth
5296  * Prevents endless loops. Submit as 0.
5297  * @param flag
5298  * Bitfield for control purposes. Submit 0 for now.
5299  * @return
5300  * 1 on success,
5301  * < 0 on failure, especially ISO_DEEP_SYMLINK and ISO_DEAD_SYMLINK
5302  *
5303  * @since 1.2.4
5304  */
5305 int iso_tree_resolve_symlink(IsoImage *img, IsoSymlink *sym, IsoNode **res,
5306  int *depth, int flag);
5307 
5308 /* Maximum number link resolution steps before ISO_DEEP_SYMLINK gets
5309  * returned by iso_tree_resolve_symlink().
5310  *
5311  * @since 1.2.4
5312 */
5313 #define LIBISO_MAX_LINK_DEPTH 100
5314 
5315 /**
5316  * Increments the reference counting of the given IsoDataSource.
5317  *
5318  * @since 0.6.2
5319  */
5321 
5322 /**
5323  * Decrements the reference counting of the given IsoDataSource, freeing it
5324  * if refcount reach 0.
5325  *
5326  * @since 0.6.2
5327  */
5329 
5330 /**
5331  * Create a new IsoDataSource from a local file. This is suitable for
5332  * accessing regular files or block devices with ISO images.
5333  *
5334  * @param path
5335  * The absolute path of the file
5336  * @param src
5337  * Will be filled with the pointer to the newly created data source.
5338  * @return
5339  * 1 on success, < 0 on error.
5340  *
5341  * @since 0.6.2
5342  */
5343 int iso_data_source_new_from_file(const char *path, IsoDataSource **src);
5344 
5345 /**
5346  * Get the status of the buffer used by a burn_source.
5347  *
5348  * @param b
5349  * A burn_source previously obtained with
5350  * iso_image_create_burn_source().
5351  * @param size
5352  * Will be filled with the total size of the buffer, in bytes
5353  * @param free_bytes
5354  * Will be filled with the bytes currently available in buffer
5355  * @return
5356  * < 0 error, > 0 state:
5357  * 1="active" : input and consumption are active
5358  * 2="ending" : input has ended without error
5359  * 3="failing" : input had error and ended,
5360  * 5="abandoned" : consumption has ended prematurely
5361  * 6="ended" : consumption has ended without input error
5362  * 7="aborted" : consumption has ended after input error
5363  *
5364  * @since 0.6.2
5365  */
5366 int iso_ring_buffer_get_status(struct burn_source *b, size_t *size,
5367  size_t *free_bytes);
5368 
5369 #define ISO_MSGS_MESSAGE_LEN 4096
5370 
5371 /**
5372  * Control queueing and stderr printing of messages from libisofs.
5373  * Severity may be one of "NEVER", "FATAL", "SORRY", "WARNING", "HINT",
5374  * "NOTE", "UPDATE", "DEBUG", "ALL".
5375  *
5376  * @param queue_severity Gives the minimum limit for messages to be queued.
5377  * Default: "NEVER". If you queue messages then you
5378  * must consume them by iso_msgs_obtain().
5379  * @param print_severity Does the same for messages to be printed directly
5380  * to stderr.
5381  * @param print_id A text prefix to be printed before the message.
5382  * @return >0 for success, <=0 for error
5383  *
5384  * @since 0.6.2
5385  */
5386 int iso_set_msgs_severities(char *queue_severity, char *print_severity,
5387  char *print_id);
5388 
5389 /**
5390  * Obtain the oldest pending libisofs message from the queue which has at
5391  * least the given minimum_severity. This message and any older message of
5392  * lower severity will get discarded from the queue and is then lost forever.
5393  *
5394  * Severity may be one of "NEVER", "FATAL", "SORRY", "WARNING", "HINT",
5395  * "NOTE", "UPDATE", "DEBUG", "ALL". To call with minimum_severity "NEVER"
5396  * will discard the whole queue.
5397  *
5398  * @param minimum_severity
5399  * Threshhold
5400  * @param error_code
5401  * Will become a unique error code as listed at the end of this header
5402  * @param imgid
5403  * Id of the image that was issued the message.
5404  * @param msg_text
5405  * Must provide at least ISO_MSGS_MESSAGE_LEN bytes.
5406  * @param severity
5407  * Will become the severity related to the message and should provide at
5408  * least 80 bytes.
5409  * @return
5410  * 1 if a matching item was found, 0 if not, <0 for severe errors
5411  *
5412  * @since 0.6.2
5413  */
5414 int iso_obtain_msgs(char *minimum_severity, int *error_code, int *imgid,
5415  char msg_text[], char severity[]);
5416 
5417 
5418 /**
5419  * Submit a message to the libisofs queueing system. It will be queued or
5420  * printed as if it was generated by libisofs itself.
5421  *
5422  * @param error_code
5423  * The unique error code of your message.
5424  * Submit 0 if you do not have reserved error codes within the libburnia
5425  * project.
5426  * @param msg_text
5427  * Not more than ISO_MSGS_MESSAGE_LEN characters of message text.
5428  * @param os_errno
5429  * Eventual errno related to the message. Submit 0 if the message is not
5430  * related to a operating system error.
5431  * @param severity
5432  * One of "ABORT", "FATAL", "FAILURE", "SORRY", "WARNING", "HINT", "NOTE",
5433  * "UPDATE", "DEBUG". Defaults to "FATAL".
5434  * @param origin
5435  * Submit 0 for now.
5436  * @return
5437  * 1 if message was delivered, <=0 if failure
5438  *
5439  * @since 0.6.4
5440  */
5441 int iso_msgs_submit(int error_code, char msg_text[], int os_errno,
5442  char severity[], int origin);
5443 
5444 
5445 /**
5446  * Convert a severity name into a severity number, which gives the severity
5447  * rank of the name.
5448  *
5449  * @param severity_name
5450  * A name as with iso_msgs_submit(), e.g. "SORRY".
5451  * @param severity_number
5452  * The rank number: the higher, the more severe.
5453  * @return
5454  * >0 success, <=0 failure
5455  *
5456  * @since 0.6.4
5457  */
5458 int iso_text_to_sev(char *severity_name, int *severity_number);
5459 
5460 
5461 /**
5462  * Convert a severity number into a severity name
5463  *
5464  * @param severity_number
5465  * The rank number: the higher, the more severe.
5466  * @param severity_name
5467  * A name as with iso_msgs_submit(), e.g. "SORRY".
5468  *
5469  * @since 0.6.4
5470  */
5471 int iso_sev_to_text(int severity_number, char **severity_name);
5472 
5473 
5474 /**
5475  * Get the id of an IsoImage, used for message reporting. This message id,
5476  * retrieved with iso_obtain_msgs(), can be used to distinguish what
5477  * IsoImage has isssued a given message.
5478  *
5479  * @since 0.6.2
5480  */
5481 int iso_image_get_msg_id(IsoImage *image);
5482 
5483 /**
5484  * Get a textual description of a libisofs error.
5485  *
5486  * @since 0.6.2
5487  */
5488 const char *iso_error_to_msg(int errcode);
5489 
5490 /**
5491  * Get the severity of a given error code
5492  * @return
5493  * 0x10000000 -> DEBUG
5494  * 0x20000000 -> UPDATE
5495  * 0x30000000 -> NOTE
5496  * 0x40000000 -> HINT
5497  * 0x50000000 -> WARNING
5498  * 0x60000000 -> SORRY
5499  * 0x64000000 -> MISHAP
5500  * 0x68000000 -> FAILURE
5501  * 0x70000000 -> FATAL
5502  * 0x71000000 -> ABORT
5503  *
5504  * @since 0.6.2
5505  */
5506 int iso_error_get_severity(int e);
5507 
5508 /**
5509  * Get the priority of a given error.
5510  * @return
5511  * 0x00000000 -> ZERO
5512  * 0x10000000 -> LOW
5513  * 0x20000000 -> MEDIUM
5514  * 0x30000000 -> HIGH
5515  *
5516  * @since 0.6.2
5517  */
5518 int iso_error_get_priority(int e);
5519 
5520 /**
5521  * Get the message queue code of a libisofs error.
5522  */
5523 int iso_error_get_code(int e);
5524 
5525 /**
5526  * Set the minimum error severity that causes a libisofs operation to
5527  * be aborted as soon as possible.
5528  *
5529  * @param severity
5530  * one of "FAILURE", "MISHAP", "SORRY", "WARNING", "HINT", "NOTE".
5531  * Severities greater or equal than FAILURE always cause program to abort.
5532  * Severities under NOTE won't never cause function abort.
5533  * @return
5534  * Previous abort priority on success, < 0 on error.
5535  *
5536  * @since 0.6.2
5537  */
5538 int iso_set_abort_severity(char *severity);
5539 
5540 /**
5541  * Return the messenger object handle used by libisofs. This handle
5542  * may be used by related libraries to their own compatible
5543  * messenger objects and thus to direct their messages to the libisofs
5544  * message queue. See also: libburn, API function burn_set_messenger().
5545  *
5546  * @return the handle. Do only use with compatible
5547  *
5548  * @since 0.6.2
5549  */
5550 void *iso_get_messenger();
5551 
5552 /**
5553  * Take a ref to the given IsoFileSource.
5554  *
5555  * @since 0.6.2
5556  */
5558 
5559 /**
5560  * Drop your ref to the given IsoFileSource, eventually freeing the associated
5561  * system resources.
5562  *
5563  * @since 0.6.2
5564  */
5566 
5567 /*
5568  * this are just helpers to invoque methods in class
5569  */
5570 
5571 /**
5572  * Get the absolute path in the filesystem this file source belongs to.
5573  *
5574  * @return
5575  * the path of the FileSource inside the filesystem, it should be
5576  * freed when no more needed.
5577  *
5578  * @since 0.6.2
5579  */
5581 
5582 /**
5583  * Get the name of the file, with the dir component of the path.
5584  *
5585  * @return
5586  * the name of the file, it should be freed when no more needed.
5587  *
5588  * @since 0.6.2
5589  */
5591 
5592 /**
5593  * Get information about the file.
5594  * @return
5595  * 1 success, < 0 error
5596  * Error codes:
5597  * ISO_FILE_ACCESS_DENIED
5598  * ISO_FILE_BAD_PATH
5599  * ISO_FILE_DOESNT_EXIST
5600  * ISO_OUT_OF_MEM
5601  * ISO_FILE_ERROR
5602  * ISO_NULL_POINTER
5603  *
5604  * @since 0.6.2
5605  */
5606 int iso_file_source_lstat(IsoFileSource *src, struct stat *info);
5607 
5608 /**
5609  * Check if the process has access to read file contents. Note that this
5610  * is not necessarily related with (l)stat functions. For example, in a
5611  * filesystem implementation to deal with an ISO image, if the user has
5612  * read access to the image it will be able to read all files inside it,
5613  * despite of the particular permission of each file in the RR tree, that
5614  * are what the above functions return.
5615  *
5616  * @return
5617  * 1 if process has read access, < 0 on error
5618  * Error codes:
5619  * ISO_FILE_ACCESS_DENIED
5620  * ISO_FILE_BAD_PATH
5621  * ISO_FILE_DOESNT_EXIST
5622  * ISO_OUT_OF_MEM
5623  * ISO_FILE_ERROR
5624  * ISO_NULL_POINTER
5625  *
5626  * @since 0.6.2
5627  */
5629 
5630 /**
5631  * Get information about the file. If the file is a symlink, the info
5632  * returned refers to the destination.
5633  *
5634  * @return
5635  * 1 success, < 0 error
5636  * Error codes:
5637  * ISO_FILE_ACCESS_DENIED
5638  * ISO_FILE_BAD_PATH
5639  * ISO_FILE_DOESNT_EXIST
5640  * ISO_OUT_OF_MEM
5641  * ISO_FILE_ERROR
5642  * ISO_NULL_POINTER
5643  *
5644  * @since 0.6.2
5645  */
5646 int iso_file_source_stat(IsoFileSource *src, struct stat *info);
5647 
5648 /**
5649  * Opens the source.
5650  * @return 1 on success, < 0 on error
5651  * Error codes:
5652  * ISO_FILE_ALREADY_OPENED
5653  * ISO_FILE_ACCESS_DENIED
5654  * ISO_FILE_BAD_PATH
5655  * ISO_FILE_DOESNT_EXIST
5656  * ISO_OUT_OF_MEM
5657  * ISO_FILE_ERROR
5658  * ISO_NULL_POINTER
5659  *
5660  * @since 0.6.2
5661  */
5663 
5664 /**
5665  * Close a previuously openned file
5666  * @return 1 on success, < 0 on error
5667  * Error codes:
5668  * ISO_FILE_ERROR
5669  * ISO_NULL_POINTER
5670  * ISO_FILE_NOT_OPENED
5671  *
5672  * @since 0.6.2
5673  */
5675 
5676 /**
5677  * Attempts to read up to count bytes from the given source into
5678  * the buffer starting at buf.
5679  *
5680  * The file src must be open() before calling this, and close() when no
5681  * more needed. Not valid for dirs. On symlinks it reads the destination
5682  * file.
5683  *
5684  * @param src
5685  * The given source
5686  * @param buf
5687  * Pointer to a buffer of at least count bytes where the read data will be
5688  * stored
5689  * @param count
5690  * Bytes to read
5691  * @return
5692  * number of bytes read, 0 if EOF, < 0 on error
5693  * Error codes:
5694  * ISO_FILE_ERROR
5695  * ISO_NULL_POINTER
5696  * ISO_FILE_NOT_OPENED
5697  * ISO_WRONG_ARG_VALUE -> if count == 0
5698  * ISO_FILE_IS_DIR
5699  * ISO_OUT_OF_MEM
5700  * ISO_INTERRUPTED
5701  *
5702  * @since 0.6.2
5703  */
5704 int iso_file_source_read(IsoFileSource *src, void *buf, size_t count);
5705 
5706 /**
5707  * Repositions the offset of the given IsoFileSource (must be opened) to the
5708  * given offset according to the value of flag.
5709  *
5710  * @param src
5711  * The given source
5712  * @param offset
5713  * in bytes
5714  * @param flag
5715  * 0 The offset is set to offset bytes (SEEK_SET)
5716  * 1 The offset is set to its current location plus offset bytes
5717  * (SEEK_CUR)
5718  * 2 The offset is set to the size of the file plus offset bytes
5719  * (SEEK_END).
5720  * @return
5721  * Absolute offset posistion on the file, or < 0 on error. Cast the
5722  * returning value to int to get a valid libisofs error.
5723  * @since 0.6.4
5724  */
5725 off_t iso_file_source_lseek(IsoFileSource *src, off_t offset, int flag);
5726 
5727 /**
5728  * Read a directory.
5729  *
5730  * Each call to this function will return a new child, until we reach
5731  * the end of file (i.e, no more children), in that case it returns 0.
5732  *
5733  * The dir must be open() before calling this, and close() when no more
5734  * needed. Only valid for dirs.
5735  *
5736  * Note that "." and ".." children MUST NOT BE returned.
5737  *
5738  * @param src
5739  * The given source
5740  * @param child
5741  * pointer to be filled with the given child. Undefined on error or OEF
5742  * @return
5743  * 1 on success, 0 if EOF (no more children), < 0 on error
5744  * Error codes:
5745  * ISO_FILE_ERROR
5746  * ISO_NULL_POINTER
5747  * ISO_FILE_NOT_OPENED
5748  * ISO_FILE_IS_NOT_DIR
5749  * ISO_OUT_OF_MEM
5750  *
5751  * @since 0.6.2
5752  */
5754 
5755 /**
5756  * Read the destination of a symlink. You don't need to open the file
5757  * to call this.
5758  *
5759  * @param src
5760  * An IsoFileSource corresponding to a symbolic link.
5761  * @param buf
5762  * Allocated buffer of at least bufsiz bytes.
5763  * The destination string will be copied there, and it will be 0-terminated
5764  * if the return value indicates success or ISO_RR_PATH_TOO_LONG.
5765  * @param bufsiz
5766  * Maximum number of buf characters + 1. The string will be truncated if
5767  * it is larger than bufsiz - 1 and ISO_RR_PATH_TOO_LONG. will be returned.
5768  * @return
5769  * 1 on success, < 0 on error
5770  * Error codes:
5771  * ISO_FILE_ERROR
5772  * ISO_NULL_POINTER
5773  * ISO_WRONG_ARG_VALUE -> if bufsiz <= 0
5774  * ISO_FILE_IS_NOT_SYMLINK
5775  * ISO_OUT_OF_MEM
5776  * ISO_FILE_BAD_PATH
5777  * ISO_FILE_DOESNT_EXIST
5778  * ISO_RR_PATH_TOO_LONG (@since 1.0.6)
5779  *
5780  * @since 0.6.2
5781  */
5782 int iso_file_source_readlink(IsoFileSource *src, char *buf, size_t bufsiz);
5783 
5784 
5785 /**
5786  * Get the AAIP string with encoded ACL and xattr.
5787  * (Not to be confused with ECMA-119 Extended Attributes).
5788  * @param src The file source object to be inquired.
5789  * @param aa_string Returns a pointer to the AAIP string data. If no AAIP
5790  * string is available, *aa_string becomes NULL.
5791  * (See doc/susp_aaip_2_0.txt for the meaning of AAIP.)
5792  * The caller is responsible for finally calling free()
5793  * on non-NULL results.
5794  * @param flag Bitfield for control purposes
5795  * bit0= Transfer ownership of AAIP string data.
5796  * src will free the eventual cached data and might
5797  * not be able to produce it again.
5798  * bit1= No need to get ACL (but no guarantee of exclusion)
5799  * bit2= No need to get xattr (but no guarantee of exclusion)
5800  * @return 1 means success (*aa_string == NULL is possible)
5801  * <0 means failure and must b a valid libisofs error code
5802  * (e.g. ISO_FILE_ERROR if no better one can be found).
5803  * @since 0.6.14
5804  */
5806  unsigned char **aa_string, int flag);
5807 
5808 /**
5809  * Get the filesystem for this source. No extra ref is added, so you
5810  * musn't unref the IsoFilesystem.
5811  *
5812  * @return
5813  * The filesystem, NULL on error
5814  *
5815  * @since 0.6.2
5816  */
5818 
5819 /**
5820  * Take a ref to the given IsoFilesystem
5821  *
5822  * @since 0.6.2
5823  */
5825 
5826 /**
5827  * Drop your ref to the given IsoFilesystem, evetually freeing associated
5828  * resources.
5829  *
5830  * @since 0.6.2
5831  */
5833 
5834 /**
5835  * Create a new IsoFilesystem to access a existent ISO image.
5836  *
5837  * @param src
5838  * Data source to access data.
5839  * @param opts
5840  * Image read options
5841  * @param msgid
5842  * An image identifer, obtained with iso_image_get_msg_id(), used to
5843  * associated messages issued by the filesystem implementation with an
5844  * existent image. If you are not using this filesystem in relation with
5845  * any image context, just use 0x1fffff as the value for this parameter.
5846  * @param fs
5847  * Will be filled with a pointer to the filesystem that can be used
5848  * to access image contents.
5849  * @param
5850  * 1 on success, < 0 on error
5851  *
5852  * @since 0.6.2
5853  */
5854 int iso_image_filesystem_new(IsoDataSource *src, IsoReadOpts *opts, int msgid,
5855  IsoImageFilesystem **fs);
5856 
5857 /**
5858  * Get the volset identifier for an existent image. The returned string belong
5859  * to the IsoImageFilesystem and shouldn't be free() nor modified.
5860  *
5861  * @since 0.6.2
5862  */
5864 
5865 /**
5866  * Get the volume identifier for an existent image. The returned string belong
5867  * to the IsoImageFilesystem and shouldn't be free() nor modified.
5868  *
5869  * @since 0.6.2
5870  */
5872 
5873 /**
5874  * Get the publisher identifier for an existent image. The returned string
5875  * belong to the IsoImageFilesystem and shouldn't be free() nor modified.
5876  *
5877  * @since 0.6.2
5878  */
5880 
5881 /**
5882  * Get the data preparer identifier for an existent image. The returned string
5883  * belong to the IsoImageFilesystem and shouldn't be free() nor modified.
5884  *
5885  * @since 0.6.2
5886  */
5888 
5889 /**
5890  * Get the system identifier for an existent image. The returned string belong
5891  * to the IsoImageFilesystem and shouldn't be free() nor modified.
5892  *
5893  * @since 0.6.2
5894  */
5896 
5897 /**
5898  * Get the application identifier for an existent image. The returned string
5899  * belong to the IsoImageFilesystem and shouldn't be free() nor modified.
5900  *
5901  * @since 0.6.2
5902  */
5904 
5905 /**
5906  * Get the copyright file identifier for an existent image. The returned string
5907  * belong to the IsoImageFilesystem and shouldn't be free() nor modified.
5908  *
5909  * @since 0.6.2
5910  */
5912 
5913 /**
5914  * Get the abstract file identifier for an existent image. The returned string
5915  * belong to the IsoImageFilesystem and shouldn't be free() nor modified.
5916  *
5917  * @since 0.6.2
5918  */
5920 
5921 /**
5922  * Get the biblio file identifier for an existent image. The returned string
5923  * belong to the IsoImageFilesystem and shouldn't be free() nor modified.
5924  *
5925  * @since 0.6.2
5926  */
5928 
5929 /**
5930  * Increment reference count of an IsoStream.
5931  *
5932  * @since 0.6.4
5933  */
5934 void iso_stream_ref(IsoStream *stream);
5935 
5936 /**
5937  * Decrement reference count of an IsoStream, and eventually free it if
5938  * refcount reach 0.
5939  *
5940  * @since 0.6.4
5941  */
5942 void iso_stream_unref(IsoStream *stream);
5943 
5944 /**
5945  * Opens the given stream. Remember to close the Stream before writing the
5946  * image.
5947  *
5948  * @return
5949  * 1 on success, 2 file greater than expected, 3 file smaller than
5950  * expected, < 0 on error
5951  *
5952  * @since 0.6.4
5953  */
5954 int iso_stream_open(IsoStream *stream);
5955 
5956 /**
5957  * Close a previously openned IsoStream.
5958  *
5959  * @return
5960  * 1 on success, < 0 on error
5961  *
5962  * @since 0.6.4
5963  */
5964 int iso_stream_close(IsoStream *stream);
5965 
5966 /**
5967  * Get the size of a given stream. This function should always return the same
5968  * size, even if the underlying source size changes, unless you call
5969  * iso_stream_update_size().
5970  *
5971  * @return
5972  * IsoStream size in bytes
5973  *
5974  * @since 0.6.4
5975  */
5976 off_t iso_stream_get_size(IsoStream *stream);
5977 
5978 /**
5979  * Attempts to read up to count bytes from the given stream into
5980  * the buffer starting at buf.
5981  *
5982  * The stream must be open() before calling this, and close() when no
5983  * more needed.
5984  *
5985  * @return
5986  * number of bytes read, 0 if EOF, < 0 on error
5987  *
5988  * @since 0.6.4
5989  */
5990 int iso_stream_read(IsoStream *stream, void *buf, size_t count);
5991 
5992 /**
5993  * Whether the given IsoStream can be read several times, with the same
5994  * results.
5995  * For example, a regular file is repeatable, you can read it as many
5996  * times as you want. However, a pipe isn't.
5997  *
5998  * This function doesn't take into account if the file has been modified
5999  * between the two reads.
6000  *
6001  * @return
6002  * 1 if stream is repeatable, 0 if not, < 0 on error
6003  *
6004  * @since 0.6.4
6005  */
6006 int iso_stream_is_repeatable(IsoStream *stream);
6007 
6008 /**
6009  * Updates the size of the IsoStream with the current size of the
6010  * underlying source.
6011  *
6012  * @return
6013  * 1 if ok, < 0 on error (has to be a valid libisofs error code),
6014  * 0 if the IsoStream does not support this function.
6015  * @since 0.6.8
6016  */
6017 int iso_stream_update_size(IsoStream *stream);
6018 
6019 /**
6020  * Get an unique identifier for a given IsoStream.
6021  *
6022  * @since 0.6.4
6023  */
6024 void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id,
6025  ino_t *ino_id);
6026 
6027 /**
6028  * Try to get eventual source path string of a stream. Meaning and availability
6029  * of this string depends on the stream.class . Expect valid results with
6030  * types "fsrc" and "cout". Result formats are
6031  * fsrc: result of file_source_get_path()
6032  * cout: result of file_source_get_path() " " offset " " size
6033  * @param stream
6034  * The stream to be inquired.
6035  * @param flag
6036  * Bitfield for control purposes, unused yet, submit 0
6037  * @return
6038  * A copy of the path string. Apply free() when no longer needed.
6039  * NULL if no path string is available.
6040  *
6041  * @since 0.6.18
6042  */
6043 char *iso_stream_get_source_path(IsoStream *stream, int flag);
6044 
6045 /**
6046  * Compare two streams whether they are based on the same input and will
6047  * produce the same output. If in any doubt, then this comparison will
6048  * indicate no match.
6049  *
6050  * @param s1
6051  * The first stream to compare.
6052  * @param s2
6053  * The second stream to compare.
6054  * @return
6055  * -1 if s1 is smaller s2 , 0 if s1 matches s2 , 1 if s1 is larger s2
6056  * @param flag
6057  * bit0= do not use s1->class->compare() even if available
6058  * (e.g. because iso_stream_cmp_ino(0 is called as fallback
6059  * from said stream->class->compare())
6060  *
6061  * @since 0.6.20
6062  */
6063 int iso_stream_cmp_ino(IsoStream *s1, IsoStream *s2, int flag);
6064 
6065 
6066 /**
6067  * Produce a copy of a stream. It must be possible to operate both stream
6068  * objects concurrently. The success of this function depends on the
6069  * existence of a IsoStream_Iface.clone_stream() method with the stream
6070  * and with its eventual subordinate streams.
6071  * See iso_tree_clone() for a list of surely clonable built-in streams.
6072  *
6073  * @param old_stream
6074  * The existing stream object to be copied
6075  * @param new_stream
6076  * Will return a pointer to the copy
6077  * @param flag
6078  * Bitfield for control purposes. Submit 0 for now.
6079  * @return
6080  * >0 means success
6081  * ISO_STREAM_NO_CLONE is issued if no .clone_stream() exists
6082  * other error return values < 0 may occur depending on kind of stream
6083  *
6084  * @since 1.0.2
6085  */
6086 int iso_stream_clone(IsoStream *old_stream, IsoStream **new_stream, int flag);
6087 
6088 
6089 /* --------------------------------- AAIP --------------------------------- */
6090 
6091 /**
6092  * Function to identify and manage AAIP strings as xinfo of IsoNode.
6093  *
6094  * An AAIP string contains the Attribute List with the xattr and ACL of a node
6095  * in the image tree. It is formatted according to libisofs specification
6096  * AAIP-2.0 and ready to be written into the System Use Area resp. Continuation
6097  * Area of a directory entry in an ISO image.
6098  *
6099  * Applications are not supposed to manipulate AAIP strings directly.
6100  * They should rather make use of the appropriate iso_node_get_* and
6101  * iso_node_set_* calls.
6102  *
6103  * AAIP represents ACLs as xattr with empty name and AAIP-specific binary
6104  * content. Local filesystems may represent ACLs as xattr with names like
6105  * "system.posix_acl_access". libisofs does not interpret those local
6106  * xattr representations of ACL directly but rather uses the ACL interface of
6107  * the local system. By default the local xattr representations of ACL will
6108  * not become part of the AAIP Attribute List via iso_local_get_attrs() and
6109  * not be attached to local files via iso_local_set_attrs().
6110  *
6111  * @since 0.6.14
6112  */
6113 int aaip_xinfo_func(void *data, int flag);
6114 
6115 /**
6116  * The iso_node_xinfo_cloner function which gets associated to aaip_xinfo_func
6117  * by iso_init() resp. iso_init_with_flag() via iso_node_xinfo_make_clonable().
6118  * @since 1.0.2
6119  */
6120 int aaip_xinfo_cloner(void *old_data, void **new_data, int flag);
6121 
6122 /**
6123  * Get the eventual ACLs which are associated with the node.
6124  * The result will be in "long" text form as of man acl resp. acl_to_text().
6125  * Call this function with flag bit15 to finally release the memory
6126  * occupied by an ACL inquiry.
6127  *
6128  * @param node
6129  * The node that is to be inquired.
6130  * @param access_text
6131  * Will return a pointer to the eventual "access" ACL text or NULL if it
6132  * is not available and flag bit 4 is set.
6133  * @param default_text
6134  * Will return a pointer to the eventual "default" ACL or NULL if it
6135  * is not available.
6136  * (GNU/Linux directories can have a "default" ACL which influences
6137  * the permissions of newly created files.)
6138  * @param flag
6139  * Bitfield for control purposes
6140  * bit4= if no "access" ACL is available: return *access_text == NULL
6141  * else: produce ACL from stat(2) permissions
6142  * bit15= free memory and return 1 (node may be NULL)
6143  * @return
6144  * 2 *access_text was produced from stat(2) permissions
6145  * 1 *access_text was produced from ACL of node
6146  * 0 if flag bit4 is set and no ACL is available
6147  * < 0 on error
6148  *
6149  * @since 0.6.14
6150  */
6151 int iso_node_get_acl_text(IsoNode *node,
6152  char **access_text, char **default_text, int flag);
6153 
6154 
6155 /**
6156  * Set the ACLs of the given node to the lists in parameters access_text and
6157  * default_text or delete them.
6158  *
6159  * The stat(2) permission bits get updated according to the new "access" ACL if
6160  * neither bit1 of parameter flag is set nor parameter access_text is NULL.
6161  * Note that S_IRWXG permission bits correspond to ACL mask permissions
6162  * if a "mask::" entry exists in the ACL. Only if there is no "mask::" then
6163  * the "group::" entry corresponds to to S_IRWXG.
6164  *
6165  * @param node
6166  * The node that is to be manipulated.
6167  * @param access_text
6168  * The text to be set into effect as "access" ACL. NULL will delete an
6169  * eventually existing "access" ACL of the node.
6170  * @param default_text
6171  * The text to be set into effect as "default" ACL. NULL will delete an
6172  * eventually existing "default" ACL of the node.
6173  * (GNU/Linux directories can have a "default" ACL which influences
6174  * the permissions of newly created files.)
6175  * @param flag
6176  * Bitfield for control purposes
6177  * bit1= ignore text parameters but rather update eventual "access" ACL
6178  * to the stat(2) permissions of node. If no "access" ACL exists,
6179  * then do nothing and return success.
6180  * @return
6181  * > 0 success
6182  * < 0 failure
6183  *
6184  * @since 0.6.14
6185  */
6186 int iso_node_set_acl_text(IsoNode *node,
6187  char *access_text, char *default_text, int flag);
6188 
6189 /**
6190  * Like iso_node_get_permissions but reflecting ACL entry "group::" in S_IRWXG
6191  * rather than ACL entry "mask::". This is necessary if the permissions of a
6192  * node with ACL shall be restored to a filesystem without restoring the ACL.
6193  * The same mapping happens internally when the ACL of a node is deleted.
6194  * If the node has no ACL then the result is iso_node_get_permissions(node).
6195  * @param node
6196  * The node that is to be inquired.
6197  * @return
6198  * Permission bits as of stat(2)
6199  *
6200  * @since 0.6.14
6201  */
6202 mode_t iso_node_get_perms_wo_acl(const IsoNode *node);
6203 
6204 
6205 /**
6206  * Get the list of xattr which is associated with the node.
6207  * The resulting data may finally be disposed by a call to this function
6208  * with flag bit15 set, or its components may be freed one-by-one.
6209  * The following values are either NULL or malloc() memory:
6210  * *names, *value_lengths, *values, (*names)[i], (*values)[i]
6211  * with 0 <= i < *num_attrs.
6212  * It is allowed to replace or reallocate those memory items in order to
6213  * to manipulate the attribute list before submitting it to other calls.
6214  *
6215  * If enabled by flag bit0, this list possibly includes the ACLs of the node.
6216  * They are eventually encoded in a pair with empty name. It is not advisable
6217  * to alter the value or name of that pair. One may decide to erase both ACLs
6218  * by deleting this pair or to copy both ACLs by copying the content of this
6219  * pair to an empty named pair of another node.
6220  * For all other ACL purposes use iso_node_get_acl_text().
6221  *
6222  * @param node
6223  * The node that is to be inquired.
6224  * @param num_attrs
6225  * Will return the number of name-value pairs
6226  * @param names
6227  * Will return an array of pointers to 0-terminated names
6228  * @param value_lengths
6229  * Will return an arry with the lenghts of values
6230  * @param values
6231  * Will return an array of pointers to strings of 8-bit bytes
6232  * @param flag
6233  * Bitfield for control purposes
6234  * bit0= obtain eventual ACLs as attribute with empty name
6235  * bit2= with bit0: do not obtain attributes other than ACLs
6236  * bit15= free memory (node may be NULL)
6237  * @return
6238  * 1 = ok (but *num_attrs may be 0)
6239  * < 0 = error
6240  *
6241  * @since 0.6.14
6242  */
6243 int iso_node_get_attrs(IsoNode *node, size_t *num_attrs,
6244  char ***names, size_t **value_lengths, char ***values, int flag);
6245 
6246 
6247 /**
6248  * Obtain the value of a particular xattr name. Eventually make a copy of
6249  * that value and add a trailing 0 byte for caller convenience.
6250  * @param node
6251  * The node that is to be inquired.
6252  * @param name
6253  * The xattr name that shall be looked up.
6254  * @param value_length
6255  * Will return the lenght of value
6256  * @param value
6257  * Will return a string of 8-bit bytes. free() it when no longer needed.
6258  * @param flag
6259  * Bitfield for control purposes, unused yet, submit 0
6260  * @return
6261  * 1= name found , 0= name not found , <0 indicates error
6262  *
6263  * @since 0.6.18
6264  */
6265 int iso_node_lookup_attr(IsoNode *node, char *name,
6266  size_t *value_length, char **value, int flag);
6267 
6268 /**
6269  * Set the list of xattr which is associated with the node.
6270  * The data get copied so that you may dispose your input data afterwards.
6271  *
6272  * If enabled by flag bit0 then the submitted list of attributes will not only
6273  * overwrite xattr but also both eventual ACLs of the node. Eventual ACL in
6274  * the submitted list have to reside in an attribute with empty name.
6275  *
6276  * @param node
6277  * The node that is to be manipulated.
6278  * @param num_attrs
6279  * Number of attributes
6280  * @param names
6281  * Array of pointers to 0 terminated name strings
6282  * @param value_lengths
6283  * Array of byte lengths for each value
6284  * @param values
6285  * Array of pointers to the value bytes
6286  * @param flag
6287  * Bitfield for control purposes
6288  * bit0= Do not maintain eventual existing ACL of the node.
6289  * Set eventual new ACL from value of empty name.
6290  * bit1= Do not clear the existing attribute list but merge it with
6291  * the list given by this call.
6292  * The given values override the values of their eventually existing
6293  * names. If no xattr with a given name exists, then it will be
6294  * added as new xattr. So this bit can be used to set a single
6295  * xattr without inquiring any other xattr of the node.
6296  * bit2= Delete the attributes with the given names
6297  * bit3= Allow to affect non-user attributes.
6298  * I.e. those with a non-empty name which does not begin by "user."
6299  * (The empty name is always allowed and governed by bit0.) This
6300  * deletes all previously existing attributes if not bit1 is set.
6301  * bit4= Do not affect attributes from namespace "isofs".
6302  * To be combined with bit3 for copying attributes from local
6303  * filesystem to ISO image.
6304  * @since 1.2.4
6305  * @return
6306  * 1 = ok
6307  * < 0 = error
6308  *
6309  * @since 0.6.14
6310  */
6311 int iso_node_set_attrs(IsoNode *node, size_t num_attrs, char **names,
6312  size_t *value_lengths, char **values, int flag);
6313 
6314 
6315 /* ----- This is an interface to ACL and xattr of the local filesystem ----- */
6316 
6317 /**
6318  * libisofs has an internal system dependent adapter to ACL and xattr
6319  * operations. For the sake of completeness and simplicity it exposes this
6320  * functionality to its applications which might want to get and set ACLs
6321  * from local files.
6322  */
6323 
6324 /**
6325  * Inquire whether local filesystem operations with ACL or xattr are enabled
6326  * inside libisofs. They may be disabled because of compile time decisions.
6327  * E.g. because the operating system does not support these features or
6328  * because libisofs has not yet an adapter to use them.
6329  *
6330  * @param flag
6331  * Bitfield for control purposes
6332  * bit0= inquire availability of ACL
6333  * bit1= inquire availability of xattr
6334  * bit2 - bit7= Reserved for future types.
6335  * It is permissibile to set them to 1 already now.
6336  * bit8 and higher: reserved, submit 0
6337  * @return
6338  * Bitfield corresponding to flag. If bits are set, th
6339  * bit0= ACL adapter is enabled
6340  * bit1= xattr adapter is enabled
6341  * bit2 - bit7= Reserved for future types.
6342  * bit8 and higher: reserved, do not interpret these
6343  *
6344  * @since 1.1.6
6345  */
6346 int iso_local_attr_support(int flag);
6347 
6348 /**
6349  * Get an ACL of the given file in the local filesystem in long text form.
6350  *
6351  * @param disk_path
6352  * Absolute path to the file
6353  * @param text
6354  * Will return a pointer to the ACL text. If not NULL the text will be
6355  * 0 terminated and finally has to be disposed by a call to this function
6356  * with bit15 set.
6357  * @param flag
6358  * Bitfield for control purposes
6359  * bit0= get "default" ACL rather than "access" ACL
6360  * bit4= set *text = NULL and return 2
6361  * if the ACL matches st_mode permissions.
6362  * bit5= in case of symbolic link: inquire link target
6363  * bit15= free text and return 1
6364  * @return
6365  * 1 ok
6366  * 2 ok, trivial ACL found while bit4 is set, *text is NULL
6367  * 0 no ACL manipulation adapter available / ACL not supported on fs
6368  * -1 failure of system ACL service (see errno)
6369  * -2 attempt to inquire ACL of a symbolic link without bit4 or bit5
6370  * resp. with no suitable link target
6371  *
6372  * @since 0.6.14
6373  */
6374 int iso_local_get_acl_text(char *disk_path, char **text, int flag);
6375 
6376 
6377 /**
6378  * Set the ACL of the given file in the local filesystem to a given list
6379  * in long text form.
6380  *
6381  * @param disk_path
6382  * Absolute path to the file
6383  * @param text
6384  * The input text (0 terminated, ACL long text form)
6385  * @param flag
6386  * Bitfield for control purposes
6387  * bit0= set "default" ACL rather than "access" ACL
6388  * bit5= in case of symbolic link: manipulate link target
6389  * @return
6390  * > 0 ok
6391  * 0 no ACL manipulation adapter available for desired ACL type
6392  * -1 failure of system ACL service (see errno)
6393  * -2 attempt to manipulate ACL of a symbolic link without bit5
6394  * resp. with no suitable link target
6395  *
6396  * @since 0.6.14
6397  */
6398 int iso_local_set_acl_text(char *disk_path, char *text, int flag);
6399 
6400 
6401 /**
6402  * Obtain permissions of a file in the local filesystem which shall reflect
6403  * ACL entry "group::" in S_IRWXG rather than ACL entry "mask::". This is
6404  * necessary if the permissions of a disk file with ACL shall be copied to
6405  * an object which has no ACL.
6406  * @param disk_path
6407  * Absolute path to the local file which may have an "access" ACL or not.
6408  * @param flag
6409  * Bitfield for control purposes
6410  * bit5= in case of symbolic link: inquire link target
6411  * @param st_mode
6412  * Returns permission bits as of stat(2)
6413  * @return
6414  * 1 success
6415  * -1 failure of lstat() resp. stat() (see errno)
6416  *
6417  * @since 0.6.14
6418  */
6419 int iso_local_get_perms_wo_acl(char *disk_path, mode_t *st_mode, int flag);
6420 
6421 
6422 /**
6423  * Get xattr and non-trivial ACLs of the given file in the local filesystem.
6424  * The resulting data has finally to be disposed by a call to this function
6425  * with flag bit15 set.
6426  *
6427  * Eventual ACLs will get encoded as attribute pair with empty name if this is
6428  * enabled by flag bit0. An ACL which simply replects stat(2) permissions
6429  * will not be put into the result.
6430  *
6431  * @param disk_path
6432  * Absolute path to the file
6433  * @param num_attrs
6434  * Will return the number of name-value pairs
6435  * @param names
6436  * Will return an array of pointers to 0-terminated names
6437  * @param value_lengths
6438  * Will return an arry with the lenghts of values
6439  * @param values
6440  * Will return an array of pointers to 8-bit values
6441  * @param flag
6442  * Bitfield for control purposes
6443  * bit0= obtain eventual ACLs as attribute with empty name
6444  * bit2= do not obtain attributes other than ACLs
6445  * bit3= do not ignore eventual non-user attributes.
6446  * I.e. those with a name which does not begin by "user."
6447  * bit5= in case of symbolic link: inquire link target
6448  * bit15= free memory
6449  * @return
6450  * 1 ok
6451  * < 0 failure
6452  *
6453  * @since 0.6.14
6454  */
6455 int iso_local_get_attrs(char *disk_path, size_t *num_attrs, char ***names,
6456  size_t **value_lengths, char ***values, int flag);
6457 
6458 
6459 /**
6460  * Attach a list of xattr and ACLs to the given file in the local filesystem.
6461  *
6462  * Eventual ACLs have to be encoded as attribute pair with empty name.
6463  *
6464  * @param disk_path
6465  * Absolute path to the file
6466  * @param num_attrs
6467  * Number of attributes
6468  * @param names
6469  * Array of pointers to 0 terminated name strings
6470  * @param value_lengths
6471  * Array of byte lengths for each attribute payload
6472  * @param values
6473  * Array of pointers to the attribute payload bytes
6474  * @param flag
6475  * Bitfield for control purposes
6476  * bit0= do not attach ACLs from an eventual attribute with empty name
6477  * bit3= do not ignore eventual non-user attributes.
6478  * I.e. those with a name which does not begin by "user."
6479  * bit5= in case of symbolic link: manipulate link target
6480  * bit6= @since 1.1.6
6481  tolerate inappropriate presence or absence of
6482  * directory "default" ACL
6483  * @return
6484  * 1 = ok
6485  * < 0 = error
6486  *
6487  * @since 0.6.14
6488  */
6489 int iso_local_set_attrs(char *disk_path, size_t num_attrs, char **names,
6490  size_t *value_lengths, char **values, int flag);
6491 
6492 
6493 /* Default in case that the compile environment has no macro PATH_MAX.
6494 */
6495 #define Libisofs_default_path_maX 4096
6496 
6497 
6498 /* --------------------------- Filters in General -------------------------- */
6499 
6500 /*
6501  * A filter is an IsoStream which uses another IsoStream as input. It gets
6502  * attached to an IsoFile by specialized calls iso_file_add_*_filter() which
6503  * replace its current IsoStream by the filter stream which takes over the
6504  * current IsoStream as input.
6505  * The consequences are:
6506  * iso_file_get_stream() will return the filter stream.
6507  * iso_stream_get_size() will return the (cached) size of the filtered data,
6508  * iso_stream_open() will start eventual child processes,
6509  * iso_stream_close() will kill eventual child processes,
6510  * iso_stream_read() will return filtered data. E.g. as data file content
6511  * during ISO image generation.
6512  *
6513  * There are external filters which run child processes
6514  * iso_file_add_external_filter()
6515  * and internal filters
6516  * iso_file_add_zisofs_filter()
6517  * iso_file_add_gzip_filter()
6518  * which may or may not be available depending on compile time settings and
6519  * installed software packages like libz.
6520  *
6521  * During image generation filters get not in effect if the original IsoStream
6522  * is an "fsrc" stream based on a file in the loaded ISO image and if the
6523  * image generation type is set to 1 by iso_write_opts_set_appendable().
6524  */
6525 
6526 /**
6527  * Delete the top filter stream from a data file. This is the most recent one
6528  * which was added by iso_file_add_*_filter().
6529  * Caution: One should not do this while the IsoStream of the file is opened.
6530  * For now there is no general way to determine this state.
6531  * Filter stream implementations are urged to eventually call .close()
6532  * inside method .free() . This will close the input stream too.
6533  * @param file
6534  * The data file node which shall get rid of one layer of content
6535  * filtering.
6536  * @param flag
6537  * Bitfield for control purposes, unused yet, submit 0.
6538  * @return
6539  * 1 on success, 0 if no filter was present
6540  * <0 on error
6541  *
6542  * @since 0.6.18
6543  */
6544 int iso_file_remove_filter(IsoFile *file, int flag);
6545 
6546 /**
6547  * Obtain the eventual input stream of a filter stream.
6548  * @param stream
6549  * The eventual filter stream to be inquired.
6550  * @param flag
6551  * Bitfield for control purposes.
6552  * bit0= Follow the chain of input streams and return the one at the
6553  * end of the chain.
6554  * @since 1.3.2
6555  * @return
6556  * The input stream, if one exists. Elsewise NULL.
6557  * No extra reference to the stream is taken by this call.
6558  *
6559  * @since 0.6.18
6560  */
6561 IsoStream *iso_stream_get_input_stream(IsoStream *stream, int flag);
6562 
6563 
6564 /* ---------------------------- External Filters --------------------------- */
6565 
6566 /**
6567  * Representation of an external program that shall serve as filter for
6568  * an IsoStream. This object may be shared among many IsoStream objects.
6569  * It is to be created and disposed by the application.
6570  *
6571  * The filter will act as proxy between the original IsoStream of an IsoFile.
6572  * Up to completed image generation it will be run at least twice:
6573  * for IsoStream.class.get_size() and for .open() with subsequent .read().
6574  * So the original IsoStream has to return 1 by its .class.is_repeatable().
6575  * The filter program has to be repeateable too. I.e. it must produce the same
6576  * output on the same input.
6577  *
6578  * @since 0.6.18
6579  */
6581 {
6582  /* Will indicate future extensions. It has to be 0 for now. */
6583  int version;
6584 
6585  /* Tells how many IsoStream objects depend on this command object.
6586  * One may only dispose an IsoExternalFilterCommand when this count is 0.
6587  * Initially this value has to be 0.
6588  */
6590 
6591  /* An optional instance id.
6592  * Set to empty text if no individual name for this object is intended.
6593  */
6594  char *name;
6595 
6596  /* Absolute local filesystem path to the executable program. */
6597  char *path;
6598 
6599  /* Tells the number of arguments. */
6600  int argc;
6601 
6602  /* NULL terminated list suitable for system call execv(3).
6603  * I.e. argv[0] points to the alleged program name,
6604  * argv[1] to argv[argc] point to program arguments (if argc > 0)
6605  * argv[argc+1] is NULL
6606  */
6607  char **argv;
6608 
6609  /* A bit field which controls behavior variations:
6610  * bit0= Do not install filter if the input has size 0.
6611  * bit1= Do not install filter if the output is not smaller than the input.
6612  * bit2= Do not install filter if the number of output blocks is
6613  * not smaller than the number of input blocks. Block size is 2048.
6614  * Assume that non-empty input yields non-empty output and thus do
6615  * not attempt to attach a filter to files smaller than 2049 bytes.
6616  * bit3= suffix removed rather than added.
6617  * (Removal and adding suffixes is the task of the application.
6618  * This behavior bit serves only as reminder for the application.)
6619  */
6621 
6622  /* The eventual suffix which is supposed to be added to the IsoFile name
6623  * resp. to be removed from the name.
6624  * (This is to be done by the application, not by calls
6625  * iso_file_add_external_filter() or iso_file_remove_filter().
6626  * The value recorded here serves only as reminder for the application.)
6627  */
6628  char *suffix;
6629 };
6630 
6632 
6633 /**
6634  * Install an external filter command on top of the content stream of a data
6635  * file. The filter process must be repeatable. It will be run once by this
6636  * call in order to cache the output size.
6637  * @param file
6638  * The data file node which shall show filtered content.
6639  * @param cmd
6640  * The external program and its arguments which shall do the filtering.
6641  * @param flag
6642  * Bitfield for control purposes, unused yet, submit 0.
6643  * @return
6644  * 1 on success, 2 if filter installation revoked (e.g. cmd.behavior bit1)
6645  * <0 on error
6646  *
6647  * @since 0.6.18
6648  */
6650  int flag);
6651 
6652 /**
6653  * Obtain the IsoExternalFilterCommand which is eventually associated with the
6654  * given stream. (Typically obtained from an IsoFile by iso_file_get_stream()
6655  * or from an IsoStream by iso_stream_get_input_stream()).
6656  * @param stream
6657  * The stream to be inquired.
6658  * @param cmd
6659  * Will return the external IsoExternalFilterCommand. Valid only if
6660  * the call returns 1. This does not increment cmd->refcount.
6661  * @param flag
6662  * Bitfield for control purposes, unused yet, submit 0.
6663  * @return
6664  * 1 on success, 0 if the stream is not an external filter
6665  * <0 on error
6666  *
6667  * @since 0.6.18
6668  */
6670  IsoExternalFilterCommand **cmd, int flag);
6671 
6672 
6673 /* ---------------------------- Internal Filters --------------------------- */
6674 
6675 
6676 /**
6677  * Install a zisofs filter on top of the content stream of a data file.
6678  * zisofs is a compression format which is decompressed by some Linux kernels.
6679  * See also doc/zisofs_format.txt .
6680  * The filter will not be installed if its output size is not smaller than
6681  * the size of the input stream.
6682  * This is only enabled if the use of libz was enabled at compile time.
6683  * @param file
6684  * The data file node which shall show filtered content.
6685  * @param flag
6686  * Bitfield for control purposes
6687  * bit0= Do not install filter if the number of output blocks is
6688  * not smaller than the number of input blocks. Block size is 2048.
6689  * bit1= Install a decompression filter rather than one for compression.
6690  * bit2= Only inquire availability of zisofs filtering. file may be NULL.
6691  * If available return 2, else return error.
6692  * bit3= is reserved for internal use and will be forced to 0
6693  * @return
6694  * 1 on success, 2 if filter available but installation revoked
6695  * <0 on error, e.g. ISO_ZLIB_NOT_ENABLED
6696  *
6697  * @since 0.6.18
6698  */
6699 int iso_file_add_zisofs_filter(IsoFile *file, int flag);
6700 
6701 /**
6702  * Inquire the number of zisofs compression and uncompression filters which
6703  * are in use.
6704  * @param ziso_count
6705  * Will return the number of currently installed compression filters.
6706  * @param osiz_count
6707  * Will return the number of currently installed uncompression filters.
6708  * @param flag
6709  * Bitfield for control purposes, unused yet, submit 0
6710  * @return
6711  * 1 on success, <0 on error
6712  *
6713  * @since 0.6.18
6714  */
6715 int iso_zisofs_get_refcounts(off_t *ziso_count, off_t *osiz_count, int flag);
6716 
6717 
6718 /**
6719  * Parameter set for iso_zisofs_set_params().
6720  *
6721  * @since 0.6.18
6722  */
6724 
6725  /* Set to 0 for this version of the structure */
6726  int version;
6727 
6728  /* Compression level for zlib function compress2(). From <zlib.h>:
6729  * "between 0 and 9:
6730  * 1 gives best speed, 9 gives best compression, 0 gives no compression"
6731  * Default is 6.
6732  */
6734 
6735  /* Log2 of the block size for compression filters. Allowed values are:
6736  * 15 = 32 kiB , 16 = 64 kiB , 17 = 128 kiB
6737  */
6739 
6740 };
6741 
6742 /**
6743  * Set the global parameters for zisofs filtering.
6744  * This is only allowed while no zisofs compression filters are installed.
6745  * i.e. ziso_count returned by iso_zisofs_get_refcounts() has to be 0.
6746  * @param params
6747  * Pointer to a structure with the intended settings.
6748  * @param flag
6749  * Bitfield for control purposes, unused yet, submit 0
6750  * @return
6751  * 1 on success, <0 on error
6752  *
6753  * @since 0.6.18
6754  */
6755 int iso_zisofs_set_params(struct iso_zisofs_ctrl *params, int flag);
6756 
6757 /**
6758  * Get the current global parameters for zisofs filtering.
6759  * @param params
6760  * Pointer to a caller provided structure which shall take the settings.
6761  * @param flag
6762  * Bitfield for control purposes, unused yet, submit 0
6763  * @return
6764  * 1 on success, <0 on error
6765  *
6766  * @since 0.6.18
6767  */
6768 int iso_zisofs_get_params(struct iso_zisofs_ctrl *params, int flag);
6769 
6770 
6771 /**
6772  * Check for the given node or for its subtree whether the data file content
6773  * effectively bears zisofs file headers and eventually mark the outcome
6774  * by an xinfo data record if not already marked by a zisofs compressor filter.
6775  * This does not install any filter but only a hint for image generation
6776  * that the already compressed files shall get written with zisofs ZF entries.
6777  * Use this if you insert the compressed reults of program mkzftree from disk
6778  * into the image.
6779  * @param node
6780  * The node which shall be checked and eventually marked.
6781  * @param flag
6782  * Bitfield for control purposes, unused yet, submit 0
6783  * bit0= prepare for a run with iso_write_opts_set_appendable(,1).
6784  * Take into account that files from the imported image
6785  * do not get their content filtered.
6786  * bit1= permission to overwrite existing zisofs_zf_info
6787  * bit2= if no zisofs header is found:
6788  * create xinfo with parameters which indicate no zisofs
6789  * bit3= no tree recursion if node is a directory
6790  * bit4= skip files which stem from the imported image
6791  * @return
6792  * 0= no zisofs data found
6793  * 1= zf xinfo added
6794  * 2= found existing zf xinfo and flag bit1 was not set
6795  * 3= both encountered: 1 and 2
6796  * <0 means error
6797  *
6798  * @since 0.6.18
6799  */
6800 int iso_node_zf_by_magic(IsoNode *node, int flag);
6801 
6802 
6803 /**
6804  * Install a gzip or gunzip filter on top of the content stream of a data file.
6805  * gzip is a compression format which is used by programs gzip and gunzip.
6806  * The filter will not be installed if its output size is not smaller than
6807  * the size of the input stream.
6808  * This is only enabled if the use of libz was enabled at compile time.
6809  * @param file
6810  * The data file node which shall show filtered content.
6811  * @param flag
6812  * Bitfield for control purposes
6813  * bit0= Do not install filter if the number of output blocks is
6814  * not smaller than the number of input blocks. Block size is 2048.
6815  * bit1= Install a decompression filter rather than one for compression.
6816  * bit2= Only inquire availability of gzip filtering. file may be NULL.
6817  * If available return 2, else return error.
6818  * bit3= is reserved for internal use and will be forced to 0
6819  * @return
6820  * 1 on success, 2 if filter available but installation revoked
6821  * <0 on error, e.g. ISO_ZLIB_NOT_ENABLED
6822  *
6823  * @since 0.6.18
6824  */
6825 int iso_file_add_gzip_filter(IsoFile *file, int flag);
6826 
6827 
6828 /**
6829  * Inquire the number of gzip compression and uncompression filters which
6830  * are in use.
6831  * @param gzip_count
6832  * Will return the number of currently installed compression filters.
6833  * @param gunzip_count
6834  * Will return the number of currently installed uncompression filters.
6835  * @param flag
6836  * Bitfield for control purposes, unused yet, submit 0
6837  * @return
6838  * 1 on success, <0 on error
6839  *
6840  * @since 0.6.18
6841  */
6842 int iso_gzip_get_refcounts(off_t *gzip_count, off_t *gunzip_count, int flag);
6843 
6844 
6845 /* ---------------------------- MD5 Checksums --------------------------- */
6846 
6847 /* Production and loading of MD5 checksums is controlled by calls
6848  iso_write_opts_set_record_md5() and iso_read_opts_set_no_md5().
6849  For data representation details see doc/checksums.txt .
6850 */
6851 
6852 /**
6853  * Eventually obtain the recorded MD5 checksum of the session which was
6854  * loaded as ISO image. Such a checksum may be stored together with others
6855  * in a contiguous array at the end of the session. The session checksum
6856  * covers the data blocks from address start_lba to address end_lba - 1.
6857  * It does not cover the recorded array of md5 checksums.
6858  * Layout, size, and position of the checksum array is recorded in the xattr
6859  * "isofs.ca" of the session root node.
6860  * @param image
6861  * The image to inquire
6862  * @param start_lba
6863  * Eventually returns the first block address covered by md5
6864  * @param end_lba
6865  * Eventually returns the first block address not covered by md5 any more
6866  * @param md5
6867  * Eventually returns 16 byte of MD5 checksum
6868  * @param flag
6869  * Bitfield for control purposes, unused yet, submit 0
6870  * @return
6871  * 1= md5 found , 0= no md5 available , <0 indicates error
6872  *
6873  * @since 0.6.22
6874  */
6875 int iso_image_get_session_md5(IsoImage *image, uint32_t *start_lba,
6876  uint32_t *end_lba, char md5[16], int flag);
6877 
6878 /**
6879  * Eventually obtain the recorded MD5 checksum of a data file from the loaded
6880  * ISO image. Such a checksum may be stored with others in a contiguous
6881  * array at the end of the loaded session. The data file eventually has an
6882  * xattr "isofs.cx" which gives the index in that array.
6883  * @param image
6884  * The image from which file stems.
6885  * @param file
6886  * The file object to inquire
6887  * @param md5
6888  * Eventually returns 16 byte of MD5 checksum
6889  * @param flag
6890  * Bitfield for control purposes
6891  * bit0= only determine return value, do not touch parameter md5
6892  * @return
6893  * 1= md5 found , 0= no md5 available , <0 indicates error
6894  *
6895  * @since 0.6.22
6896  */
6897 int iso_file_get_md5(IsoImage *image, IsoFile *file, char md5[16], int flag);
6898 
6899 /**
6900  * Read the content of an IsoFile object, compute its MD5 and attach it to
6901  * the IsoFile. It can then be inquired by iso_file_get_md5() and will get
6902  * written into the next session if this is enabled at write time and if the
6903  * image write process does not compute an MD5 from content which it copies.
6904  * So this call can be used to equip nodes from the old image with checksums
6905  * or to make available checksums of newly added files before the session gets
6906  * written.
6907  * @param file
6908  * The file object to read data from and to which to attach the checksum.
6909  * If the file is from the imported image, then its most original stream
6910  * will be checksummed. Else the eventual filter streams will get into
6911  * effect.
6912  * @param flag
6913  * Bitfield for control purposes. Unused yet. Submit 0.
6914  * @return
6915  * 1= ok, MD5 is computed and attached , <0 indicates error
6916  *
6917  * @since 0.6.22
6918  */
6919 int iso_file_make_md5(IsoFile *file, int flag);
6920 
6921 /**
6922  * Check a data block whether it is a libisofs session checksum tag and
6923  * eventually obtain its recorded parameters. These tags get written after
6924  * volume descriptors, directory tree and checksum array and can be detected
6925  * without loading the image tree.
6926  * One may start reading and computing MD5 at the suspected image session
6927  * start and look out for a session tag on the fly. See doc/checksum.txt .
6928  * @param data
6929  * A complete and aligned data block read from an ISO image session.
6930  * @param tag_type
6931  * 0= no tag
6932  * 1= session tag
6933  * 2= superblock tag
6934  * 3= tree tag
6935  * 4= relocated 64 kB superblock tag (at LBA 0 of overwriteable media)
6936  * @param pos
6937  * Returns the LBA where the tag supposes itself to be stored.
6938  * If this does not match the data block LBA then the tag might be
6939  * image data payload and should be ignored for image checksumming.
6940  * @param range_start
6941  * Returns the block address where the session is supposed to start.
6942  * If this does not match the session start on media then the image
6943  * volume descriptors have been been relocated.
6944  * A proper checksum will only emerge if computing started at range_start.
6945  * @param range_size
6946  * Returns the number of blocks beginning at range_start which are
6947  * covered by parameter md5.
6948  * @param next_tag
6949  * Returns the predicted block address of the next tag.
6950  * next_tag is valid only if not 0 and only with return values 2, 3, 4.
6951  * With tag types 2 and 3, reading shall go on sequentially and the MD5
6952  * computation shall continue up to that address.
6953  * With tag type 4, reading shall resume either at LBA 32 for the first
6954  * session or at the given address for the session which is to be loaded
6955  * by default. In both cases the MD5 computation shall be re-started from
6956  * scratch.
6957  * @param md5
6958  * Returns 16 byte of MD5 checksum.
6959  * @param flag
6960  * Bitfield for control purposes:
6961  * bit0-bit7= tag type being looked for
6962  * 0= any checksum tag
6963  * 1= session tag
6964  * 2= superblock tag
6965  * 3= tree tag
6966  * 4= relocated superblock tag
6967  * @return
6968  * 0= not a checksum tag, return parameters are invalid
6969  * 1= checksum tag found, return parameters are valid
6970  * <0= error
6971  * (return parameters are valid with error ISO_MD5_AREA_CORRUPTED
6972  * but not trustworthy because the tag seems corrupted)
6973  *
6974  * @since 0.6.22
6975  */
6976 int iso_util_decode_md5_tag(char data[2048], int *tag_type, uint32_t *pos,
6977  uint32_t *range_start, uint32_t *range_size,
6978  uint32_t *next_tag, char md5[16], int flag);
6979 
6980 
6981 /* The following functions allow to do own MD5 computations. E.g for
6982  comparing the result with a recorded checksum.
6983 */
6984 /**
6985  * Create a MD5 computation context and hand out an opaque handle.
6986  *
6987  * @param md5_context
6988  * Returns the opaque handle. Submitted *md5_context must be NULL or
6989  * point to freeable memory.
6990  * @return
6991  * 1= success , <0 indicates error
6992  *
6993  * @since 0.6.22
6994  */
6995 int iso_md5_start(void **md5_context);
6996 
6997 /**
6998  * Advance the computation of a MD5 checksum by a chunk of data bytes.
6999  *
7000  * @param md5_context
7001  * An opaque handle once returned by iso_md5_start() or iso_md5_clone().
7002  * @param data
7003  * The bytes which shall be processed into to the checksum.
7004  * @param datalen
7005  * The number of bytes to be processed.
7006  * @return
7007  * 1= success , <0 indicates error
7008  *
7009  * @since 0.6.22
7010  */
7011 int iso_md5_compute(void *md5_context, char *data, int datalen);
7012 
7013 /**
7014  * Create a MD5 computation context as clone of an existing one. One may call
7015  * iso_md5_clone(old, &new, 0) and then iso_md5_end(&new, result, 0) in order
7016  * to obtain an intermediate MD5 sum before the computation goes on.
7017  *
7018  * @param old_md5_context
7019  * An opaque handle once returned by iso_md5_start() or iso_md5_clone().
7020  * @param new_md5_context
7021  * Returns the opaque handle to the new MD5 context. Submitted
7022  * *md5_context must be NULL or point to freeable memory.
7023  * @return
7024  * 1= success , <0 indicates error
7025  *
7026  * @since 0.6.22
7027  */
7028 int iso_md5_clone(void *old_md5_context, void **new_md5_context);
7029 
7030 /**
7031  * Obtain the MD5 checksum from a MD5 computation context and dispose this
7032  * context. (If you want to keep the context then call iso_md5_clone() and
7033  * apply iso_md5_end() to the clone.)
7034  *
7035  * @param md5_context
7036  * A pointer to an opaque handle once returned by iso_md5_start() or
7037  * iso_md5_clone(). *md5_context will be set to NULL in this call.
7038  * @param result
7039  * Gets filled with the 16 bytes of MD5 checksum.
7040  * @return
7041  * 1= success , <0 indicates error
7042  *
7043  * @since 0.6.22
7044  */
7045 int iso_md5_end(void **md5_context, char result[16]);
7046 
7047 /**
7048  * Inquire whether two MD5 checksums match. (This is trivial but such a call
7049  * is convenient and completes the interface.)
7050  * @param first_md5
7051  * A MD5 byte string as returned by iso_md5_end()
7052  * @param second_md5
7053  * A MD5 byte string as returned by iso_md5_end()
7054  * @return
7055  * 1= match , 0= mismatch
7056  *
7057  * @since 0.6.22
7058  */
7059 int iso_md5_match(char first_md5[16], char second_md5[16]);
7060 
7061 
7062 /* -------------------------------- For HFS+ ------------------------------- */
7063 
7064 
7065 /**
7066  * HFS+ attributes which may be attached to IsoNode objects as data parameter
7067  * of iso_node_add_xinfo(). As parameter proc use iso_hfsplus_xinfo_func().
7068  * Create instances of this struct by iso_hfsplus_xinfo_new().
7069  *
7070  * @since 1.2.4
7071  */
7073 
7074  /* Currently set to 0 by iso_hfsplus_xinfo_new() */
7075  int version;
7076 
7077  /* Attributes available with version 0.
7078  * See: http://en.wikipedia.org/wiki/Creator_code , .../Type_code
7079  * @since 1.2.4
7080  */
7081  uint8_t creator_code[4];
7082  uint8_t type_code[4];
7083 };
7084 
7085 /**
7086  * The function that is used to mark struct iso_hfsplus_xinfo_data at IsoNodes
7087  * and finally disposes such structs when their IsoNodes get disposed.
7088  * Usually an application does not call this function, but only uses it as
7089  * parameter of xinfo calls like iso_node_add_xinfo() or iso_node_get_xinfo().
7090  *
7091  * @since 1.2.4
7092  */
7093 int iso_hfsplus_xinfo_func(void *data, int flag);
7094 
7095 /**
7096  * Create an instance of struct iso_hfsplus_xinfo_new().
7097  *
7098  * @param flag
7099  * Bitfield for control purposes. Unused yet. Submit 0.
7100  * @return
7101  * A pointer to the new object
7102  * NULL indicates failure to allocate memory
7103  *
7104  * @since 1.2.4
7105  */
7107 
7108 
7109 /**
7110  * HFS+ blessings are relationships between HFS+ enhanced ISO images and
7111  * particular files in such images. Except for ISO_HFSPLUS_BLESS_INTEL_BOOTFILE
7112  * and ISO_HFSPLUS_BLESS_MAX, these files have to be directories.
7113  * No file may have more than one blessing. Each blessing can only be issued
7114  * to one file.
7115  *
7116  * @since 1.2.4
7117  */
7119  /* The blessing that is issued by mkisofs option -hfs-bless. */
7121 
7122  /* To be applied to a data file */
7124 
7125  /* Further blessings for directories */
7129 
7130  /* Not a blessing, but telling the number of blessings in this list */
7132 };
7133 
7134 /**
7135  * Issue a blessing to a particular IsoNode. If the blessing is already issued
7136  * to some file, then it gets revoked from that one.
7137  *
7138  * @param image
7139  * The image to manipulate.
7140  * @param blessing
7141  * The kind of blessing to be issued.
7142  * @param node
7143  * The file that shall be blessed. It must actually be an IsoDir or
7144  * IsoFile as is appropriate for the kind of blessing. (See above enum.)
7145  * The node may not yet bear a blessing other than the desired one.
7146  * If node is NULL, then the blessing will be revoked from any node
7147  * which bears it.
7148  * @param flag
7149  * Bitfield for control purposes.
7150  * bit0= Revoke blessing if node != NULL bears it.
7151  * bit1= Revoke any blessing of the node, regardless of parameter
7152  * blessing. If node is NULL, then revoke all blessings in
7153  * the image.
7154  * @return
7155  * 1 means successful blessing or revokation of an existing blessing.
7156  * 0 means the node already bears another blessing, or is of wrong type,
7157  * or that the node was not blessed and revokation was desired.
7158  * <0 is one of the listed error codes.
7159  *
7160  * @since 1.2.4
7161  */
7162 int iso_image_hfsplus_bless(IsoImage *img, enum IsoHfsplusBlessings blessing,
7163  IsoNode *node, int flag);
7164 
7165 /**
7166  * Get the array of nodes which are currently blessed.
7167  * Array indice correspond to enum IsoHfsplusBlessings.
7168  * Array element value NULL means that no node bears that blessing.
7169  *
7170  * Several usage restrictions apply. See parameter blessed_nodes.
7171  *
7172  * @param image
7173  * The image to inquire.
7174  * @param blessed_nodes
7175  * Will return a pointer to an internal node array of image.
7176  * This pointer is valid only as long as image exists and only until
7177  * iso_image_hfsplus_bless() gets used to manipulate the blessings.
7178  * Do not free() this array. Do not alter the content of the array
7179  * directly, but rather use iso_image_hfsplus_bless() and re-inquire
7180  * by iso_image_hfsplus_get_blessed().
7181  * This call does not impose an extra reference on the nodes in the
7182  * array. So do not iso_node_unref() them.
7183  * Nodes listed here are not necessarily grafted into the tree of
7184  * the IsoImage.
7185  * @param bless_max
7186  * Will return the number of elements in the array.
7187  * It is unlikely but not outruled that it will be larger than
7188  * ISO_HFSPLUS_BLESS_MAX in this libisofs.h file.
7189  * @param flag
7190  * Bitfield for control purposes. Submit 0.
7191  * @return
7192  * 1 means success, <0 means error
7193  *
7194  * @since 1.2.4
7195  */
7196 int iso_image_hfsplus_get_blessed(IsoImage *img, IsoNode ***blessed_nodes,
7197  int *bless_max, int flag);
7198 
7199 
7200 /* ----------------------------- Character sets ---------------------------- */
7201 
7202 /**
7203  * Convert the characters in name from local charset to another charset or
7204  * convert name to the representation of a particular ISO image name space.
7205  * In the latter case it is assumed that the conversion result does not
7206  * collide with any other converted name in the same directory.
7207  * I.e. this function does not take into respect possible name changes
7208  * due to collision handling.
7209  *
7210  * @param opts
7211  * Defines output charset, UCS-2 versus UTF-16 for Joliet,
7212  * and naming restrictions.
7213  * @param name
7214  * The input text which shall be converted.
7215  * @param name_len
7216  * The number of bytes in input text.
7217  * @param result
7218  * Will return the conversion result in case of success. Terminated by
7219  * a trailing zero byte.
7220  * Use free() to dispose it when no longer needed.
7221  * @param result_len
7222  * Will return the number of bytes in result (excluding trailing zero)
7223  * @param flag
7224  * Bitfield for control purposes.
7225  * bit0-bit7= Name space
7226  * 0= generic (to_charset is valid,
7227  * no reserved characters, no length limits)
7228  * 1= Rock Ridge (to_charset is valid)
7229  * 2= Joliet (to_charset gets overridden by UCS-2 or UTF-16)
7230  * 3= ECMA-119 (to_charset gets overridden by the
7231  * dull ISO 9660 subset of ASCII)
7232  * 4= HFS+ (to_charset gets overridden by UTF-16BE)
7233  * bit8= Treat input text as directory name
7234  * (matters for Joliet and ECMA-119)
7235  * bit9= Do not issue error messages
7236  * bit15= Reverse operation (best to be done only with results of
7237  * previous conversions)
7238  * @return
7239  * 1 means success, <0 means error
7240  *
7241  * @since 1.3.6
7242  */
7243 int iso_conv_name_chars(IsoWriteOpts *opts, char *name, size_t name_len,
7244  char **result, size_t *result_len, int flag);
7245 
7246 
7247 
7248 /************ Error codes and return values for libisofs ********************/
7249 
7250 /** successfully execution */
7251 #define ISO_SUCCESS 1
7252 
7253 /**
7254  * special return value, it could be or not an error depending on the
7255  * context.
7256  */
7257 #define ISO_NONE 0
7258 
7259 /** Operation canceled (FAILURE,HIGH, -1) */
7260 #define ISO_CANCELED 0xE830FFFF
7261 
7262 /** Unknown or unexpected fatal error (FATAL,HIGH, -2) */
7263 #define ISO_FATAL_ERROR 0xF030FFFE
7264 
7265 /** Unknown or unexpected error (FAILURE,HIGH, -3) */
7266 #define ISO_ERROR 0xE830FFFD
7267 
7268 /** Internal programming error. Please report this bug (FATAL,HIGH, -4) */
7269 #define ISO_ASSERT_FAILURE 0xF030FFFC
7270 
7271 /**
7272  * NULL pointer as value for an arg. that doesn't allow NULL (FAILURE,HIGH, -5)
7273  */
7274 #define ISO_NULL_POINTER 0xE830FFFB
7275 
7276 /** Memory allocation error (FATAL,HIGH, -6) */
7277 #define ISO_OUT_OF_MEM 0xF030FFFA
7278 
7279 /** Interrupted by a signal (FATAL,HIGH, -7) */
7280 #define ISO_INTERRUPTED 0xF030FFF9
7281 
7282 /** Invalid parameter value (FAILURE,HIGH, -8) */
7283 #define ISO_WRONG_ARG_VALUE 0xE830FFF8
7284 
7285 /** Can't create a needed thread (FATAL,HIGH, -9) */
7286 #define ISO_THREAD_ERROR 0xF030FFF7
7287 
7288 /** Write error (FAILURE,HIGH, -10) */
7289 #define ISO_WRITE_ERROR 0xE830FFF6
7290 
7291 /** Buffer read error (FAILURE,HIGH, -11) */
7292 #define ISO_BUF_READ_ERROR 0xE830FFF5
7293 
7294 /** Trying to add to a dir a node already added to a dir (FAILURE,HIGH, -64) */
7295 #define ISO_NODE_ALREADY_ADDED 0xE830FFC0
7296 
7297 /** Node with same name already exists (FAILURE,HIGH, -65) */
7298 #define ISO_NODE_NAME_NOT_UNIQUE 0xE830FFBF
7299 
7300 /** Trying to remove a node that was not added to dir (FAILURE,HIGH, -65) */
7301 #define ISO_NODE_NOT_ADDED_TO_DIR 0xE830FFBE
7302 
7303 /** A requested node does not exist (FAILURE,HIGH, -66) */
7304 #define ISO_NODE_DOESNT_EXIST 0xE830FFBD
7305 
7306 /**
7307  * Try to set the boot image of an already bootable image (FAILURE,HIGH, -67)
7308  */
7309 #define ISO_IMAGE_ALREADY_BOOTABLE 0xE830FFBC
7310 
7311 /** Trying to use an invalid file as boot image (FAILURE,HIGH, -68) */
7312 #define ISO_BOOT_IMAGE_NOT_VALID 0xE830FFBB
7313 
7314 /** Too many boot images (FAILURE,HIGH, -69) */
7315 #define ISO_BOOT_IMAGE_OVERFLOW 0xE830FFBA
7316 
7317 /** No boot catalog created yet ((FAILURE,HIGH, -70) */ /* @since 0.6.34 */
7318 #define ISO_BOOT_NO_CATALOG 0xE830FFB9
7319 
7320 
7321 /**
7322  * Error on file operation (FAILURE,HIGH, -128)
7323  * (take a look at more specified error codes below)
7324  */
7325 #define ISO_FILE_ERROR 0xE830FF80
7326 
7327 /** Trying to open an already opened file (FAILURE,HIGH, -129) */
7328 #define ISO_FILE_ALREADY_OPENED 0xE830FF7F
7329 
7330 /* @deprecated use ISO_FILE_ALREADY_OPENED instead */
7331 #define ISO_FILE_ALREADY_OPENNED 0xE830FF7F
7332 
7333 /** Access to file is not allowed (FAILURE,HIGH, -130) */
7334 #define ISO_FILE_ACCESS_DENIED 0xE830FF7E
7335 
7336 /** Incorrect path to file (FAILURE,HIGH, -131) */
7337 #define ISO_FILE_BAD_PATH 0xE830FF7D
7338 
7339 /** The file does not exist in the filesystem (FAILURE,HIGH, -132) */
7340 #define ISO_FILE_DOESNT_EXIST 0xE830FF7C
7341 
7342 /** Trying to read or close a file not openned (FAILURE,HIGH, -133) */
7343 #define ISO_FILE_NOT_OPENED 0xE830FF7B
7344 
7345 /* @deprecated use ISO_FILE_NOT_OPENED instead */
7346 #define ISO_FILE_NOT_OPENNED ISO_FILE_NOT_OPENED
7347 
7348 /** Directory used where no dir is expected (FAILURE,HIGH, -134) */
7349 #define ISO_FILE_IS_DIR 0xE830FF7A
7350 
7351 /** Read error (FAILURE,HIGH, -135) */
7352 #define ISO_FILE_READ_ERROR 0xE830FF79
7353 
7354 /** Not dir used where a dir is expected (FAILURE,HIGH, -136) */
7355 #define ISO_FILE_IS_NOT_DIR 0xE830FF78
7356 
7357 /** Not symlink used where a symlink is expected (FAILURE,HIGH, -137) */
7358 #define ISO_FILE_IS_NOT_SYMLINK 0xE830FF77
7359 
7360 /** Can't seek to specified location (FAILURE,HIGH, -138) */
7361 #define ISO_FILE_SEEK_ERROR 0xE830FF76
7362 
7363 /** File not supported in ECMA-119 tree and thus ignored (WARNING,MEDIUM, -139) */
7364 #define ISO_FILE_IGNORED 0xD020FF75
7365 
7366 /* A file is bigger than supported by used standard (WARNING,MEDIUM, -140) */
7367 #define ISO_FILE_TOO_BIG 0xD020FF74
7368 
7369 /* File read error during image creation (MISHAP,HIGH, -141) */
7370 #define ISO_FILE_CANT_WRITE 0xE430FF73
7371 
7372 /* Can't convert filename to requested charset (WARNING,MEDIUM, -142) */
7373 #define ISO_FILENAME_WRONG_CHARSET 0xD020FF72
7374 /* This was once a HINT. Deprecated now. */
7375 #define ISO_FILENAME_WRONG_CHARSET_OLD 0xC020FF72
7376 
7377 /* File can't be added to the tree (SORRY,HIGH, -143) */
7378 #define ISO_FILE_CANT_ADD 0xE030FF71
7379 
7380 /**
7381  * File path break specification constraints and will be ignored
7382  * (WARNING,MEDIUM, -144)
7383  */
7384 #define ISO_FILE_IMGPATH_WRONG 0xD020FF70
7385 
7386 /**
7387  * Offset greater than file size (FAILURE,HIGH, -150)
7388  * @since 0.6.4
7389  */
7390 #define ISO_FILE_OFFSET_TOO_BIG 0xE830FF6A
7391 
7392 
7393 /** Charset conversion error (FAILURE,HIGH, -256) */
7394 #define ISO_CHARSET_CONV_ERROR 0xE830FF00
7395 
7396 /**
7397  * Too many files to mangle, i.e. we cannot guarantee unique file names
7398  * (FAILURE,HIGH, -257)
7399  */
7400 #define ISO_MANGLE_TOO_MUCH_FILES 0xE830FEFF
7401 
7402 /* image related errors */
7403 
7404 /**
7405  * Wrong or damaged Primary Volume Descriptor (FAILURE,HIGH, -320)
7406  * This could mean that the file is not a valid ISO image.
7407  */
7408 #define ISO_WRONG_PVD 0xE830FEC0
7409 
7410 /** Wrong or damaged RR entry (SORRY,HIGH, -321) */
7411 #define ISO_WRONG_RR 0xE030FEBF
7412 
7413 /** Unsupported RR feature (SORRY,HIGH, -322) */
7414 #define ISO_UNSUPPORTED_RR 0xE030FEBE
7415 
7416 /** Wrong or damaged ECMA-119 (FAILURE,HIGH, -323) */
7417 #define ISO_WRONG_ECMA119 0xE830FEBD
7418 
7419 /** Unsupported ECMA-119 feature (FAILURE,HIGH, -324) */
7420 #define ISO_UNSUPPORTED_ECMA119 0xE830FEBC
7421 
7422 /** Wrong or damaged El-Torito catalog (WARN,HIGH, -325) */
7423 #define ISO_WRONG_EL_TORITO 0xD030FEBB
7424 
7425 /** Unsupported El-Torito feature (WARN,HIGH, -326) */
7426 #define ISO_UNSUPPORTED_EL_TORITO 0xD030FEBA
7427 
7428 /** Can't patch an isolinux boot image (SORRY,HIGH, -327) */
7429 #define ISO_ISOLINUX_CANT_PATCH 0xE030FEB9
7430 
7431 /** Unsupported SUSP feature (SORRY,HIGH, -328) */
7432 #define ISO_UNSUPPORTED_SUSP 0xE030FEB8
7433 
7434 /** Error on a RR entry that can be ignored (WARNING,HIGH, -329) */
7435 #define ISO_WRONG_RR_WARN 0xD030FEB7
7436 
7437 /** Error on a RR entry that can be ignored (HINT,MEDIUM, -330) */
7438 #define ISO_SUSP_UNHANDLED 0xC020FEB6
7439 
7440 /** Multiple ER SUSP entries found (WARNING,HIGH, -331) */
7441 #define ISO_SUSP_MULTIPLE_ER 0xD030FEB5
7442 
7443 /** Unsupported volume descriptor found (HINT,MEDIUM, -332) */
7444 #define ISO_UNSUPPORTED_VD 0xC020FEB4
7445 
7446 /** El-Torito related warning (WARNING,HIGH, -333) */
7447 #define ISO_EL_TORITO_WARN 0xD030FEB3
7448 
7449 /** Image write cancelled (MISHAP,HIGH, -334) */
7450 #define ISO_IMAGE_WRITE_CANCELED 0xE430FEB2
7451 
7452 /** El-Torito image is hidden (WARNING,HIGH, -335) */
7453 #define ISO_EL_TORITO_HIDDEN 0xD030FEB1
7454 
7455 
7456 /** AAIP info with ACL or xattr in ISO image will be ignored
7457  (NOTE, HIGH, -336) */
7458 #define ISO_AAIP_IGNORED 0xB030FEB0
7459 
7460 /** Error with decoding ACL from AAIP info (FAILURE, HIGH, -337) */
7461 #define ISO_AAIP_BAD_ACL 0xE830FEAF
7462 
7463 /** Error with encoding ACL for AAIP (FAILURE, HIGH, -338) */
7464 #define ISO_AAIP_BAD_ACL_TEXT 0xE830FEAE
7465 
7466 /** AAIP processing for ACL or xattr not enabled at compile time
7467  (FAILURE, HIGH, -339) */
7468 #define ISO_AAIP_NOT_ENABLED 0xE830FEAD
7469 
7470 /** Error with decoding AAIP info for ACL or xattr (FAILURE, HIGH, -340) */
7471 #define ISO_AAIP_BAD_AASTRING 0xE830FEAC
7472 
7473 /** Error with reading ACL or xattr from local file (FAILURE, HIGH, -341) */
7474 #define ISO_AAIP_NO_GET_LOCAL 0xE830FEAB
7475 
7476 /** Error with attaching ACL or xattr to local file (FAILURE, HIGH, -342) */
7477 #define ISO_AAIP_NO_SET_LOCAL 0xE830FEAA
7478 
7479 /** Unallowed attempt to set an xattr with non-userspace name
7480  (FAILURE, HIGH, -343) */
7481 #define ISO_AAIP_NON_USER_NAME 0xE830FEA9
7482 
7483 /** Too many references on a single IsoExternalFilterCommand
7484  (FAILURE, HIGH, -344) */
7485 #define ISO_EXTF_TOO_OFTEN 0xE830FEA8
7486 
7487 /** Use of zlib was not enabled at compile time (FAILURE, HIGH, -345) */
7488 #define ISO_ZLIB_NOT_ENABLED 0xE830FEA7
7489 
7490 /** Cannot apply zisofs filter to file >= 4 GiB (FAILURE, HIGH, -346) */
7491 #define ISO_ZISOFS_TOO_LARGE 0xE830FEA6
7492 
7493 /** Filter input differs from previous run (FAILURE, HIGH, -347) */
7494 #define ISO_FILTER_WRONG_INPUT 0xE830FEA5
7495 
7496 /** zlib compression/decompression error (FAILURE, HIGH, -348) */
7497 #define ISO_ZLIB_COMPR_ERR 0xE830FEA4
7498 
7499 /** Input stream is not in zisofs format (FAILURE, HIGH, -349) */
7500 #define ISO_ZISOFS_WRONG_INPUT 0xE830FEA3
7501 
7502 /** Cannot set global zisofs parameters while filters exist
7503  (FAILURE, HIGH, -350) */
7504 #define ISO_ZISOFS_PARAM_LOCK 0xE830FEA2
7505 
7506 /** Premature EOF of zlib input stream (FAILURE, HIGH, -351) */
7507 #define ISO_ZLIB_EARLY_EOF 0xE830FEA1
7508 
7509 /**
7510  * Checksum area or checksum tag appear corrupted (WARNING,HIGH, -352)
7511  * @since 0.6.22
7512 */
7513 #define ISO_MD5_AREA_CORRUPTED 0xD030FEA0
7514 
7515 /**
7516  * Checksum mismatch between checksum tag and data blocks
7517  * (FAILURE, HIGH, -353)
7518  * @since 0.6.22
7519 */
7520 #define ISO_MD5_TAG_MISMATCH 0xE830FE9F
7521 
7522 /**
7523  * Checksum mismatch in System Area, Volume Descriptors, or directory tree.
7524  * (FAILURE, HIGH, -354)
7525  * @since 0.6.22
7526 */
7527 #define ISO_SB_TREE_CORRUPTED 0xE830FE9E
7528 
7529 /**
7530  * Unexpected checksum tag type encountered. (WARNING, HIGH, -355)
7531  * @since 0.6.22
7532 */
7533 #define ISO_MD5_TAG_UNEXPECTED 0xD030FE9D
7534 
7535 /**
7536  * Misplaced checksum tag encountered. (WARNING, HIGH, -356)
7537  * @since 0.6.22
7538 */
7539 #define ISO_MD5_TAG_MISPLACED 0xD030FE9C
7540 
7541 /**
7542  * Checksum tag with unexpected address range encountered.
7543  * (WARNING, HIGH, -357)
7544  * @since 0.6.22
7545 */
7546 #define ISO_MD5_TAG_OTHER_RANGE 0xD030FE9B
7547 
7548 /**
7549  * Detected file content changes while it was written into the image.
7550  * (MISHAP, HIGH, -358)
7551  * @since 0.6.22
7552 */
7553 #define ISO_MD5_STREAM_CHANGE 0xE430FE9A
7554 
7555 /**
7556  * Session does not start at LBA 0. scdbackup checksum tag not written.
7557  * (WARNING, HIGH, -359)
7558  * @since 0.6.24
7559 */
7560 #define ISO_SCDBACKUP_TAG_NOT_0 0xD030FE99
7561 
7562 /**
7563  * The setting of iso_write_opts_set_ms_block() leaves not enough room
7564  * for the prescibed size of iso_write_opts_set_overwrite_buf().
7565  * (FAILURE, HIGH, -360)
7566  * @since 0.6.36
7567  */
7568 #define ISO_OVWRT_MS_TOO_SMALL 0xE830FE98
7569 
7570 /**
7571  * The partition offset is not 0 and leaves not not enough room for
7572  * system area, volume descriptors, and checksum tags of the first tree.
7573  * (FAILURE, HIGH, -361)
7574  */
7575 #define ISO_PART_OFFST_TOO_SMALL 0xE830FE97
7576 
7577 /**
7578  * The ring buffer is smaller than 64 kB + partition offset.
7579  * (FAILURE, HIGH, -362)
7580  */
7581 #define ISO_OVWRT_FIFO_TOO_SMALL 0xE830FE96
7582 
7583 /** Use of libjte was not enabled at compile time (FAILURE, HIGH, -363) */
7584 #define ISO_LIBJTE_NOT_ENABLED 0xE830FE95
7585 
7586 /** Failed to start up Jigdo Template Extraction (FAILURE, HIGH, -364) */
7587 #define ISO_LIBJTE_START_FAILED 0xE830FE94
7588 
7589 /** Failed to finish Jigdo Template Extraction (FAILURE, HIGH, -365) */
7590 #define ISO_LIBJTE_END_FAILED 0xE830FE93
7591 
7592 /** Failed to process file for Jigdo Template Extraction
7593  (MISHAP, HIGH, -366) */
7594 #define ISO_LIBJTE_FILE_FAILED 0xE430FE92
7595 
7596 /** Too many MIPS Big Endian boot files given (max. 15) (FAILURE, HIGH, -367)*/
7597 #define ISO_BOOT_TOO_MANY_MIPS 0xE830FE91
7598 
7599 /** Boot file missing in image (MISHAP, HIGH, -368) */
7600 #define ISO_BOOT_FILE_MISSING 0xE430FE90
7601 
7602 /** Partition number out of range (FAILURE, HIGH, -369) */
7603 #define ISO_BAD_PARTITION_NO 0xE830FE8F
7604 
7605 /** Cannot open data file for appended partition (FAILURE, HIGH, -370) */
7606 #define ISO_BAD_PARTITION_FILE 0xE830FE8E
7607 
7608 /** May not combine MBR partition with non-MBR system area
7609  (FAILURE, HIGH, -371) */
7610 #define ISO_NON_MBR_SYS_AREA 0xE830FE8D
7611 
7612 /** Displacement offset leads outside 32 bit range (FAILURE, HIGH, -372) */
7613 #define ISO_DISPLACE_ROLLOVER 0xE830FE8C
7614 
7615 /** File name cannot be written into ECMA-119 untranslated
7616  (FAILURE, HIGH, -373) */
7617 #define ISO_NAME_NEEDS_TRANSL 0xE830FE8B
7618 
7619 /** Data file input stream object offers no cloning method
7620  (FAILURE, HIGH, -374) */
7621 #define ISO_STREAM_NO_CLONE 0xE830FE8A
7622 
7623 /** Extended information class offers no cloning method
7624  (FAILURE, HIGH, -375) */
7625 #define ISO_XINFO_NO_CLONE 0xE830FE89
7626 
7627 /** Found copied superblock checksum tag (WARNING, HIGH, -376) */
7628 #define ISO_MD5_TAG_COPIED 0xD030FE88
7629 
7630 /** Rock Ridge leaf name too long (FAILURE, HIGH, -377) */
7631 #define ISO_RR_NAME_TOO_LONG 0xE830FE87
7632 
7633 /** Reserved Rock Ridge leaf name (FAILURE, HIGH, -378) */
7634 #define ISO_RR_NAME_RESERVED 0xE830FE86
7635 
7636 /** Rock Ridge path too long (FAILURE, HIGH, -379) */
7637 #define ISO_RR_PATH_TOO_LONG 0xE830FE85
7638 
7639 /** Attribute name cannot be represented (FAILURE, HIGH, -380) */
7640 #define ISO_AAIP_BAD_ATTR_NAME 0xE830FE84
7641 
7642 /** ACL text contains multiple entries of user::, group::, other::
7643  (FAILURE, HIGH, -381) */
7644 #define ISO_AAIP_ACL_MULT_OBJ 0xE830FE83
7645 
7646 /** File sections do not form consecutive array of blocks
7647  (FAILURE, HIGH, -382) */
7648 #define ISO_SECT_SCATTERED 0xE830FE82
7649 
7650 /** Too many Apple Partition Map entries requested (FAILURE, HIGH, -383) */
7651 #define ISO_BOOT_TOO_MANY_APM 0xE830FE81
7652 
7653 /** Overlapping Apple Partition Map entries requested (FAILURE, HIGH, -384) */
7654 #define ISO_BOOT_APM_OVERLAP 0xE830FE80
7655 
7656 /** Too many GPT entries requested (FAILURE, HIGH, -385) */
7657 #define ISO_BOOT_TOO_MANY_GPT 0xE830FE7F
7658 
7659 /** Overlapping GPT entries requested (FAILURE, HIGH, -386) */
7660 #define ISO_BOOT_GPT_OVERLAP 0xE830FE7E
7661 
7662 /** Too many MBR partition entries requested (FAILURE, HIGH, -387) */
7663 #define ISO_BOOT_TOO_MANY_MBR 0xE830FE7D
7664 
7665 /** Overlapping MBR partition entries requested (FAILURE, HIGH, -388) */
7666 #define ISO_BOOT_MBR_OVERLAP 0xE830FE7C
7667 
7668 /** Attempt to use an MBR partition entry twice (FAILURE, HIGH, -389) */
7669 #define ISO_BOOT_MBR_COLLISION 0xE830FE7B
7670 
7671 /** No suitable El Torito EFI boot image for exposure as GPT partition
7672  (FAILURE, HIGH, -390) */
7673 #define ISO_BOOT_NO_EFI_ELTO 0xE830FE7A
7674 
7675 /** Not a supported HFS+ or APM block size (FAILURE, HIGH, -391) */
7676 #define ISO_BOOT_HFSP_BAD_BSIZE 0xE830FE79
7677 
7678 /** APM block size prevents coexistence with GPT (FAILURE, HIGH, -392) */
7679 #define ISO_BOOT_APM_GPT_BSIZE 0xE830FE78
7680 
7681 /** Name collision in HFS+, mangling not possible (FAILURE, HIGH, -393) */
7682 #define ISO_HFSP_NO_MANGLE 0xE830FE77
7683 
7684 /** Symbolic link cannot be resolved (FAILURE, HIGH, -394) */
7685 #define ISO_DEAD_SYMLINK 0xE830FE76
7686 
7687 /** Too many chained symbolic links (FAILURE, HIGH, -395) */
7688 #define ISO_DEEP_SYMLINK 0xE830FE75
7689 
7690 /** Unrecognized file type in ISO image (FAILURE, HIGH, -396) */
7691 #define ISO_BAD_ISO_FILETYPE 0xE830FE74
7692 
7693 /** Filename not suitable for character set UCS-2 (WARNING, HIGH, -397) */
7694 #define ISO_NAME_NOT_UCS2 0xD030FE73
7695 
7696 /** File name collision during ISO image import (WARNING, HIGH, -398) */
7697 #define ISO_IMPORT_COLLISION 0xD030FE72
7698 
7699 /** Incomplete HP-PA PALO boot parameters (FAILURE, HIGH, -399) */
7700 #define ISO_HPPA_PALO_INCOMPL 0xE830FE71
7701 
7702 /** HP-PA PALO boot address exceeds 2 GB (FAILURE, HIGH, -400) */
7703 #define ISO_HPPA_PALO_OFLOW 0xE830FE70
7704 
7705 /** HP-PA PALO file is not a data file (FAILURE, HIGH, -401) */
7706 #define ISO_HPPA_PALO_NOTREG 0xE830FE6F
7707 
7708 /** HP-PA PALO command line too long (FAILURE, HIGH, -402) */
7709 #define ISO_HPPA_PALO_CMDLEN 0xE830FE6E
7710 
7711 
7712 /* Internal developer note:
7713  Place new error codes directly above this comment.
7714  Newly introduced errors must get a message entry in
7715  libisofs/messages.c, function iso_error_to_msg()
7716 */
7717 
7718 /* ! PLACE NEW ERROR CODES ABOVE. NOT AFTER THIS LINE ! */
7719 
7720 
7721 /** Read error occured with IsoDataSource (SORRY,HIGH, -513) */
7722 #define ISO_DATA_SOURCE_SORRY 0xE030FCFF
7723 
7724 /** Read error occured with IsoDataSource (MISHAP,HIGH, -513) */
7725 #define ISO_DATA_SOURCE_MISHAP 0xE430FCFF
7726 
7727 /** Read error occured with IsoDataSource (FAILURE,HIGH, -513) */
7728 #define ISO_DATA_SOURCE_FAILURE 0xE830FCFF
7729 
7730 /** Read error occured with IsoDataSource (FATAL,HIGH, -513) */
7731 #define ISO_DATA_SOURCE_FATAL 0xF030FCFF
7732 
7733 
7734 /* ! PLACE NEW ERROR CODES SEVERAL LINES ABOVE. NOT HERE ! */
7735 
7736 
7737 /* ------------------------------------------------------------------------- */
7738 
7739 #ifdef LIBISOFS_WITHOUT_LIBBURN
7740 
7741 /**
7742  This is a copy from the API of libburn-0.6.0 (under GPL).
7743  It is supposed to be as stable as any overall include of libburn.h.
7744  I.e. if this definition is out of sync then you cannot rely on any
7745  contract that was made with libburn.h.
7746 
7747  Libisofs does not need to be linked with libburn at all. But if it is
7748  linked with libburn then it must be libburn-0.4.2 or later.
7749 
7750  An application that provides own struct burn_source objects and does not
7751  include libburn/libburn.h has to define LIBISOFS_WITHOUT_LIBBURN before
7752  including libisofs/libisofs.h in order to make this copy available.
7753 */
7754 
7755 
7756 /** Data source interface for tracks.
7757  This allows to use arbitrary program code as provider of track input data.
7758 
7759  Objects compliant to this interface are either provided by the application
7760  or by API calls of libburn: burn_fd_source_new(), burn_file_source_new(),
7761  and burn_fifo_source_new().
7762 
7763  libisofs acts as "application" and implements an own class of burn_source.
7764  Instances of that class are handed out by iso_image_create_burn_source().
7765 
7766 */
7767 struct burn_source {
7768 
7769  /** Reference count for the data source. MUST be 1 when a new source
7770  is created and thus the first reference is handed out. Increment
7771  it to take more references for yourself. Use burn_source_free()
7772  to destroy your references to it. */
7773  int refcount;
7774 
7775 
7776  /** Read data from the source. Semantics like with read(2), but MUST
7777  either deliver the full buffer as defined by size or MUST deliver
7778  EOF (return 0) or failure (return -1) at this call or at the
7779  next following call. I.e. the only incomplete buffer may be the
7780  last one from that source.
7781  libburn will read a single sector by each call to (*read).
7782  The size of a sector depends on BURN_MODE_*. The known range is
7783  2048 to 2352.
7784 
7785  If this call is reading from a pipe then it will learn
7786  about the end of data only when that pipe gets closed on the
7787  feeder side. So if the track size is not fixed or if the pipe
7788  delivers less than the predicted amount or if the size is not
7789  block aligned, then burning will halt until the input process
7790  closes the pipe.
7791 
7792  IMPORTANT:
7793  If this function pointer is NULL, then the struct burn_source is of
7794  version >= 1 and the job of .(*read)() is done by .(*read_xt)().
7795  See below, member .version.
7796  */
7797  int (*read)(struct burn_source *, unsigned char *buffer, int size);
7798 
7799 
7800  /** Read subchannel data from the source (NULL if lib generated)
7801  WARNING: This is an obscure feature with CD raw write modes.
7802  Unless you checked the libburn code for correctness in that aspect
7803  you should not rely on raw writing with own subchannels.
7804  ADVICE: Set this pointer to NULL.
7805  */
7806  int (*read_sub)(struct burn_source *, unsigned char *buffer, int size);
7807 
7808 
7809  /** Get the size of the source's data. Return 0 means unpredictable
7810  size. If application provided (*get_size) allows return 0, then
7811  the application MUST provide a fully functional (*set_size).
7812  */
7813  off_t (*get_size)(struct burn_source *);
7814 
7815 
7816  /* @since 0.3.2 */
7817  /** Program the reply of (*get_size) to a fixed value. It is advised
7818  to implement this by a attribute off_t fixed_size; in *data .
7819  The read() function does not have to take into respect this fake
7820  setting. It is rather a note of libburn to itself. Eventually
7821  necessary truncation or padding is done in libburn. Truncation
7822  is usually considered a misburn. Padding is considered ok.
7823 
7824  libburn is supposed to work even if (*get_size) ignores the
7825  setting by (*set_size). But your application will not be able to
7826  enforce fixed track sizes by burn_track_set_size() and possibly
7827  even padding might be left out.
7828  */
7829  int (*set_size)(struct burn_source *source, off_t size);
7830 
7831 
7832  /** Clean up the source specific data. This function will be called
7833  once by burn_source_free() when the last referer disposes the
7834  source.
7835  */
7836  void (*free_data)(struct burn_source *);
7837 
7838 
7839  /** Next source, for when a source runs dry and padding is disabled
7840  WARNING: This is an obscure feature. Set to NULL at creation and
7841  from then on leave untouched and uninterpreted.
7842  */
7843  struct burn_source *next;
7844 
7845 
7846  /** Source specific data. Here the various source classes express their
7847  specific properties and the instance objects store their individual
7848  management data.
7849  E.g. data could point to a struct like this:
7850  struct app_burn_source
7851  {
7852  struct my_app *app_handle;
7853  ... other individual source parameters ...
7854  off_t fixed_size;
7855  };
7856 
7857  Function (*free_data) has to be prepared to clean up and free
7858  the struct.
7859  */
7860  void *data;
7861 
7862 
7863  /* @since 0.4.2 */
7864  /** Valid only if above member .(*read)() is NULL. This indicates a
7865  version of struct burn_source younger than 0.
7866  From then on, member .version tells which further members exist
7867  in the memory layout of struct burn_source. libburn will only touch
7868  those announced extensions.
7869 
7870  Versions:
7871  0 has .(*read)() != NULL, not even .version is present.
7872  1 has .version, .(*read_xt)(), .(*cancel)()
7873  */
7874  int version;
7875 
7876  /** This substitutes for (*read)() in versions above 0. */
7877  int (*read_xt)(struct burn_source *, unsigned char *buffer, int size);
7878 
7879  /** Informs the burn_source that the consumer of data prematurely
7880  ended reading. This call may or may not be issued by libburn
7881  before (*free_data)() is called.
7882  */
7883  int (*cancel)(struct burn_source *source);
7884 };
7885 
7886 #endif /* LIBISOFS_WITHOUT_LIBBURN */
7887 
7888 /* ----------------------------- Bug Fixes ----------------------------- */
7889 
7890 /* currently none being tested */
7891 
7892 
7893 /* ---------------------------- Improvements --------------------------- */
7894 
7895 /* currently none being tested */
7896 
7897 
7898 /* ---------------------------- Experiments ---------------------------- */
7899 
7900 
7901 /* Experiment: Write obsolete RR entries with Rock Ridge.
7902  I suspect Solaris wants to see them.
7903  DID NOT HELP: Solaris knows only RRIP_1991A.
7904 
7905  #define Libisofs_with_rrip_rR yes
7906 */
7907 
7908 
7909 #endif /*LIBISO_LIBISOFS_H_*/

Generated for libisofs by  doxygen 1.8.3.1