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