00001 /* 00002 * Copyright (c) 2007-2008 Vreixo Formoso, Mario Danic 00003 * Copyright (c) 2009 Thomas Schmitt 00004 * 00005 * This file is part of the libisofs project; you can redistribute it and/or 00006 * modify it under the terms of the GNU General Public License version 2 00007 * or later as published by the Free Software Foundation. 00008 * See COPYING file for details. 00009 */ 00010 00011 /* 00012 * 00013 * Applications must use 64 bit off_t, e.g. on 32-bit Linux by defining 00014 * #define _LARGEFILE_SOURCE 00015 * #define _FILE_OFFSET_BITS 64 00016 * or take special precautions to interface with the library by 64 bit integers 00017 * where this .h files prescribe off_t. Not to use 64 bit file i/o will keep 00018 * the application from producing and processing ISO images of more than 2 GB 00019 * size. 00020 * 00021 */ 00022 00023 #ifndef LIBISO_LIBISOFS_H_ 00024 #define LIBISO_LIBISOFS_H_ 00025 00026 #include <sys/stat.h> 00027 #include <stdint.h> 00028 #include <stdlib.h> 00029 00030 struct burn_source; 00031 00032 /** 00033 * Context for image creation. It holds the files that will be added to image, 00034 * and several options to control libisofs behavior. 00035 * 00036 * @since 0.6.2 00037 */ 00038 typedef struct Iso_Image IsoImage; 00039 00040 /* 00041 * A node in the iso tree, i.e. a file that will be written to image. 00042 * 00043 * It can represent any kind of files. When needed, you can get the type with 00044 * iso_node_get_type() and cast it to the appropiate subtype. Useful macros 00045 * are provided, see below. 00046 * 00047 * @since 0.6.2 00048 */ 00049 typedef struct Iso_Node IsoNode; 00050 00051 /** 00052 * A directory in the iso tree. It is an special type of IsoNode and can be 00053 * casted to it in any case. 00054 * 00055 * @since 0.6.2 00056 */ 00057 typedef struct Iso_Dir IsoDir; 00058 00059 /** 00060 * A symbolic link in the iso tree. It is an special type of IsoNode and can be 00061 * casted to it in any case. 00062 * 00063 * @since 0.6.2 00064 */ 00065 typedef struct Iso_Symlink IsoSymlink; 00066 00067 /** 00068 * A regular file in the iso tree. It is an special type of IsoNode and can be 00069 * casted to it in any case. 00070 * 00071 * @since 0.6.2 00072 */ 00073 typedef struct Iso_File IsoFile; 00074 00075 /** 00076 * An special file in the iso tree. This is used to represent any POSIX file 00077 * other that regular files, directories or symlinks, i.e.: socket, block and 00078 * character devices, and fifos. 00079 * It is an special type of IsoNode and can be casted to it in any case. 00080 * 00081 * @since 0.6.2 00082 */ 00083 typedef struct Iso_Special IsoSpecial; 00084 00085 /** 00086 * The type of an IsoNode. 00087 * 00088 * When an user gets an IsoNode from an image, (s)he can use 00089 * iso_node_get_type() to get the current type of the node, and then 00090 * cast to the appropriate subtype. For example: 00091 * 00092 * ... 00093 * IsoNode *node; 00094 * res = iso_dir_iter_next(iter, &node); 00095 * if (res == 1 && iso_node_get_type(node) == LIBISO_DIR) { 00096 * IsoDir *dir = (IsoDir *)node; 00097 * ... 00098 * } 00099 * 00100 * @since 0.6.2 00101 */ 00102 enum IsoNodeType { 00103 LIBISO_DIR, 00104 LIBISO_FILE, 00105 LIBISO_SYMLINK, 00106 LIBISO_SPECIAL, 00107 LIBISO_BOOT 00108 }; 00109 00110 /* macros to check node type */ 00111 #define ISO_NODE_IS_DIR(n) (iso_node_get_type(n) == LIBISO_DIR) 00112 #define ISO_NODE_IS_FILE(n) (iso_node_get_type(n) == LIBISO_FILE) 00113 #define ISO_NODE_IS_SYMLINK(n) (iso_node_get_type(n) == LIBISO_SYMLINK) 00114 #define ISO_NODE_IS_SPECIAL(n) (iso_node_get_type(n) == LIBISO_SPECIAL) 00115 #define ISO_NODE_IS_BOOTCAT(n) (iso_node_get_type(n) == LIBISO_BOOT) 00116 00117 /* macros for safe downcasting */ 00118 #define ISO_DIR(n) ((IsoDir*)(ISO_NODE_IS_DIR(n) ? n : NULL)) 00119 #define ISO_FILE(n) ((IsoFile*)(ISO_NODE_IS_FILE(n) ? n : NULL)) 00120 #define ISO_SYMLINK(n) ((IsoSymlink*)(ISO_NODE_IS_SYMLINK(n) ? n : NULL)) 00121 #define ISO_SPECIAL(n) ((IsoSpecial*)(ISO_NODE_IS_SPECIAL(n) ? n : NULL)) 00122 00123 #define ISO_NODE(n) ((IsoNode*)n) 00124 00125 /** 00126 * File section in an old image. 00127 * 00128 * @since 0.6.8 00129 */ 00130 struct iso_file_section 00131 { 00132 uint32_t block; 00133 uint32_t size; 00134 }; 00135 00136 /** 00137 * Context for iterate on directory children. 00138 * @see iso_dir_get_children() 00139 * 00140 * @since 0.6.2 00141 */ 00142 typedef struct Iso_Dir_Iter IsoDirIter; 00143 00144 /** 00145 * It represents an El-Torito boot image. 00146 * 00147 * @since 0.6.2 00148 */ 00149 typedef struct el_torito_boot_image ElToritoBootImage; 00150 00151 /** 00152 * An special type of IsoNode that acts as a placeholder for an El-Torito 00153 * boot catalog. Once written, it will appear as a regular file. 00154 * 00155 * @since 0.6.2 00156 */ 00157 typedef struct Iso_Boot IsoBoot; 00158 00159 /** 00160 * Flag used to hide a file in the RR/ISO or Joliet tree. 00161 * 00162 * @see iso_node_set_hidden 00163 * @since 0.6.2 00164 */ 00165 enum IsoHideNodeFlag { 00166 /** Hide the node in the ECMA-119 / RR tree */ 00167 LIBISO_HIDE_ON_RR = 1 << 0, 00168 /** Hide the node in the Joliet tree, if Joliet extension are enabled */ 00169 LIBISO_HIDE_ON_JOLIET = 1 << 1, 00170 /** Hide the node in the ISO-9660:1999 tree, if that format is enabled */ 00171 LIBISO_HIDE_ON_1999 = 1 << 2 00172 }; 00173 00174 /** 00175 * El-Torito bootable image type. 00176 * 00177 * @since 0.6.2 00178 */ 00179 enum eltorito_boot_media_type { 00180 ELTORITO_FLOPPY_EMUL, 00181 ELTORITO_HARD_DISC_EMUL, 00182 ELTORITO_NO_EMUL 00183 }; 00184 00185 /** 00186 * Replace mode used when addding a node to a file. 00187 * This controls how libisofs will act when you tried to add to a dir a file 00188 * with the same name that an existing file. 00189 * 00190 * @since 0.6.2 00191 */ 00192 enum iso_replace_mode { 00193 /** 00194 * Never replace an existing node, and instead fail with 00195 * ISO_NODE_NAME_NOT_UNIQUE. 00196 */ 00197 ISO_REPLACE_NEVER, 00198 /** 00199 * Always replace the old node with the new. 00200 */ 00201 ISO_REPLACE_ALWAYS, 00202 /** 00203 * Replace with the new node if it is the same file type 00204 */ 00205 ISO_REPLACE_IF_SAME_TYPE, 00206 /** 00207 * Replace with the new node if it is the same file type and its ctime 00208 * is newer than the old one. 00209 */ 00210 ISO_REPLACE_IF_SAME_TYPE_AND_NEWER, 00211 /** 00212 * Replace with the new node if its ctime is newer than the old one. 00213 */ 00214 ISO_REPLACE_IF_NEWER 00215 /* 00216 * TODO #00006 define more values 00217 * -if both are dirs, add contents (and what to do with conflicts?) 00218 */ 00219 }; 00220 00221 /** 00222 * Options for image written. 00223 * @see iso_write_opts_new() 00224 * @since 0.6.2 00225 */ 00226 typedef struct iso_write_opts IsoWriteOpts; 00227 00228 /** 00229 * Options for image reading or import. 00230 * @see iso_read_opts_new() 00231 * @since 0.6.2 00232 */ 00233 typedef struct iso_read_opts IsoReadOpts; 00234 00235 /** 00236 * Source for image reading. 00237 * 00238 * @see struct iso_data_source 00239 * @since 0.6.2 00240 */ 00241 typedef struct iso_data_source IsoDataSource; 00242 00243 /** 00244 * Data source used by libisofs for reading an existing image. 00245 * 00246 * It offers homogeneous read access to arbitrary blocks to different sources 00247 * for images, such as .iso files, CD/DVD drives, etc... 00248 * 00249 * To create a multisession image, libisofs needs a IsoDataSource, that the 00250 * user must provide. The function iso_data_source_new_from_file() constructs 00251 * an IsoDataSource that uses POSIX I/O functions to access data. You can use 00252 * it with regular .iso images, and also with block devices that represent a 00253 * drive. 00254 * 00255 * @since 0.6.2 00256 */ 00257 struct iso_data_source 00258 { 00259 00260 /* reserved for future usage, set to 0 */ 00261 int version; 00262 00263 /** 00264 * Reference count for the data source. Should be 1 when a new source 00265 * is created. Don't access it directly, but with iso_data_source_ref() 00266 * and iso_data_source_unref() functions. 00267 */ 00268 unsigned int refcount; 00269 00270 /** 00271 * Opens the given source. You must open() the source before any attempt 00272 * to read data from it. The open is the right place for grabbing the 00273 * underlying resources. 00274 * 00275 * @return 00276 * 1 if success, < 0 on error (has to be a valid libisofs error code) 00277 */ 00278 int (*open)(IsoDataSource *src); 00279 00280 /** 00281 * Close a given source, freeing all system resources previously grabbed in 00282 * open(). 00283 * 00284 * @return 00285 * 1 if success, < 0 on error (has to be a valid libisofs error code) 00286 */ 00287 int (*close)(IsoDataSource *src); 00288 00289 /** 00290 * Read an arbitrary block (2048 bytes) of data from the source. 00291 * 00292 * @param lba 00293 * Block to be read. 00294 * @param buffer 00295 * Buffer where the data will be written. It should have at least 00296 * 2048 bytes. 00297 * @return 00298 * 1 if success, 00299 * < 0 if error. This function has to emit a valid libisofs error code. 00300 * Predifined (but not mandatory) for this purpose are: 00301 * ISO_DATA_SOURCE_SORRY , ISO_DATA_SOURCE_MISHAP, 00302 * ISO_DATA_SOURCE_FAILURE , ISO_DATA_SOURCE_FATAL 00303 */ 00304 int (*read_block)(IsoDataSource *src, uint32_t lba, uint8_t *buffer); 00305 00306 /** 00307 * Clean up the source specific data. Never call this directly, it is 00308 * automatically called by iso_data_source_unref() when refcount reach 00309 * 0. 00310 */ 00311 void (*free_data)(IsoDataSource *); 00312 00313 /** Source specific data */ 00314 void *data; 00315 }; 00316 00317 /** 00318 * Return information for image. This is optionally allocated by libisofs, 00319 * as a way to inform user about the features of an existing image, such as 00320 * extensions present, size, ... 00321 * 00322 * @see iso_image_import() 00323 * @since 0.6.2 00324 */ 00325 typedef struct iso_read_image_features IsoReadImageFeatures; 00326 00327 /** 00328 * POSIX abstraction for source files. 00329 * 00330 * @see struct iso_file_source 00331 * @since 0.6.2 00332 */ 00333 typedef struct iso_file_source IsoFileSource; 00334 00335 /** 00336 * Abstract for source filesystems. 00337 * 00338 * @see struct iso_filesystem 00339 * @since 0.6.2 00340 */ 00341 typedef struct iso_filesystem IsoFilesystem; 00342 00343 /** 00344 * Interface that defines the operations (methods) available for an 00345 * IsoFileSource. 00346 * 00347 * @see struct IsoFileSource_Iface 00348 * @since 0.6.2 00349 */ 00350 typedef struct IsoFileSource_Iface IsoFileSourceIface; 00351 00352 /** 00353 * IsoFilesystem implementation to deal with ISO images, and to offer a way to 00354 * access specific information of the image, such as several volume attributes, 00355 * extensions being used, El-Torito artifacts... 00356 * 00357 * @since 0.6.2 00358 */ 00359 typedef IsoFilesystem IsoImageFilesystem; 00360 00361 /** 00362 * See IsoFilesystem->get_id() for info about this. 00363 * @since 0.6.2 00364 */ 00365 extern unsigned int iso_fs_global_id; 00366 00367 /** 00368 * An IsoFilesystem is a handler for a source of files, or a "filesystem". 00369 * That is defined as a set of files that are organized in a hierarchical 00370 * structure. 00371 * 00372 * A filesystem allows libisofs to access files from several sources in 00373 * an homogeneous way, thus abstracting the underlying operations needed to 00374 * access and read file contents. Note that this doesn't need to be tied 00375 * to the disc filesystem used in the partition being accessed. For example, 00376 * we have an IsoFilesystem implementation to access any mounted filesystem, 00377 * using standard Linux functions. It is also legal, of course, to implement 00378 * an IsoFilesystem to deal with a specific filesystem over raw partitions. 00379 * That is what we do, for example, to access an ISO Image. 00380 * 00381 * Each file inside an IsoFilesystem is represented as an IsoFileSource object, 00382 * that defines POSIX-like interface for accessing files. 00383 * 00384 * @since 0.6.2 00385 */ 00386 struct iso_filesystem 00387 { 00388 /** 00389 * Type of filesystem. 00390 * "file" -> local filesystem 00391 * "iso " -> iso image filesystem 00392 */ 00393 char type[4]; 00394 00395 /* reserved for future usage, set to 0 */ 00396 int version; 00397 00398 /** 00399 * Get the root of a filesystem. 00400 * 00401 * @return 00402 * 1 on success, < 0 on error (has to be a valid libisofs error code) 00403 */ 00404 int (*get_root)(IsoFilesystem *fs, IsoFileSource **root); 00405 00406 /** 00407 * Retrieve a file from its absolute path inside the filesystem. 00408 * 00409 * @return 00410 * 1 success, < 0 error (has to be a valid libisofs error code) 00411 * Error codes: 00412 * ISO_FILE_ACCESS_DENIED 00413 * ISO_FILE_BAD_PATH 00414 * ISO_FILE_DOESNT_EXIST 00415 * ISO_OUT_OF_MEM 00416 * ISO_FILE_ERROR 00417 * ISO_NULL_POINTER 00418 */ 00419 int (*get_by_path)(IsoFilesystem *fs, const char *path, 00420 IsoFileSource **file); 00421 00422 /** 00423 * Get filesystem identifier. 00424 * 00425 * If the filesystem is able to generate correct values of the st_dev 00426 * and st_ino fields for the struct stat of each file, this should 00427 * return an unique number, greater than 0. 00428 * 00429 * To get a identifier for your filesystem implementation you should 00430 * use iso_fs_global_id, incrementing it by one each time. 00431 * 00432 * Otherwise, if you can't ensure values in the struct stat are valid, 00433 * this should return 0. 00434 */ 00435 unsigned int (*get_id)(IsoFilesystem *fs); 00436 00437 /** 00438 * Opens the filesystem for several read operations. Calling this funcion 00439 * is not needed at all, each time that the underlying system resource 00440 * needs to be accessed, it is openned propertly. 00441 * However, if you plan to execute several operations on the filesystem, 00442 * it is a good idea to open it previously, to prevent several open/close 00443 * operations to occur. 00444 * 00445 * @return 1 on success, < 0 on error (has to be a valid libisofs error code) 00446 */ 00447 int (*open)(IsoFilesystem *fs); 00448 00449 /** 00450 * Close the filesystem, thus freeing all system resources. You should 00451 * call this function if you have previously open() it. 00452 * Note that you can open()/close() a filesystem several times. 00453 * 00454 * @return 1 on success, < 0 on error (has to be a valid libisofs error code) 00455 */ 00456 int (*close)(IsoFilesystem *fs); 00457 00458 /** 00459 * Free implementation specific data. Should never be called by user. 00460 * Use iso_filesystem_unref() instead. 00461 */ 00462 void (*free)(IsoFilesystem *fs); 00463 00464 /* internal usage, do never access them directly */ 00465 unsigned int refcount; 00466 void *data; 00467 }; 00468 00469 /** 00470 * Interface definition for an IsoFileSource. Defines the POSIX-like function 00471 * to access files and abstract underlying source. 00472 * 00473 * @since 0.6.2 00474 */ 00475 struct IsoFileSource_Iface 00476 { 00477 /** 00478 * Tells the version of the interface: 00479 * Version 0 provides functions up to (*lseek)(). 00480 * @since 0.6.2 00481 * Version 1 additionally provides function *(get_aa_string)(). 00482 * @since 0.6.14 00483 */ 00484 int version; 00485 00486 /** 00487 * Get the absolute path in the filesystem this file source belongs to. 00488 * 00489 * @return 00490 * the path of the FileSource inside the filesystem, it should be 00491 * freed when no more needed. 00492 */ 00493 char* (*get_path)(IsoFileSource *src); 00494 00495 /** 00496 * Get the name of the file, with the dir component of the path. 00497 * 00498 * @return 00499 * the name of the file, it should be freed when no more needed. 00500 */ 00501 char* (*get_name)(IsoFileSource *src); 00502 00503 /** 00504 * Get information about the file. It is equivalent to lstat(2). 00505 * 00506 * @return 00507 * 1 success, < 0 error (has to be a valid libisofs error code) 00508 * Error codes: 00509 * ISO_FILE_ACCESS_DENIED 00510 * ISO_FILE_BAD_PATH 00511 * ISO_FILE_DOESNT_EXIST 00512 * ISO_OUT_OF_MEM 00513 * ISO_FILE_ERROR 00514 * ISO_NULL_POINTER 00515 */ 00516 int (*lstat)(IsoFileSource *src, struct stat *info); 00517 00518 /** 00519 * Get information about the file. If the file is a symlink, the info 00520 * returned refers to the destination. It is equivalent to stat(2). 00521 * 00522 * @return 00523 * 1 success, < 0 error 00524 * Error codes: 00525 * ISO_FILE_ACCESS_DENIED 00526 * ISO_FILE_BAD_PATH 00527 * ISO_FILE_DOESNT_EXIST 00528 * ISO_OUT_OF_MEM 00529 * ISO_FILE_ERROR 00530 * ISO_NULL_POINTER 00531 */ 00532 int (*stat)(IsoFileSource *src, struct stat *info); 00533 00534 /** 00535 * Check if the process has access to read file contents. Note that this 00536 * is not necessarily related with (l)stat functions. For example, in a 00537 * filesystem implementation to deal with an ISO image, if the user has 00538 * read access to the image it will be able to read all files inside it, 00539 * despite of the particular permission of each file in the RR tree, that 00540 * are what the above functions return. 00541 * 00542 * @return 00543 * 1 if process has read access, < 0 on error (has to be a valid 00544 * libisofs error code) 00545 * Error codes: 00546 * ISO_FILE_ACCESS_DENIED 00547 * ISO_FILE_BAD_PATH 00548 * ISO_FILE_DOESNT_EXIST 00549 * ISO_OUT_OF_MEM 00550 * ISO_FILE_ERROR 00551 * ISO_NULL_POINTER 00552 */ 00553 int (*access)(IsoFileSource *src); 00554 00555 /** 00556 * Opens the source. 00557 * @return 1 on success, < 0 on error (has to be a valid libisofs error code) 00558 * Error codes: 00559 * ISO_FILE_ALREADY_OPENED 00560 * ISO_FILE_ACCESS_DENIED 00561 * ISO_FILE_BAD_PATH 00562 * ISO_FILE_DOESNT_EXIST 00563 * ISO_OUT_OF_MEM 00564 * ISO_FILE_ERROR 00565 * ISO_NULL_POINTER 00566 */ 00567 int (*open)(IsoFileSource *src); 00568 00569 /** 00570 * Close a previuously openned file 00571 * @return 1 on success, < 0 on error 00572 * Error codes: 00573 * ISO_FILE_ERROR 00574 * ISO_NULL_POINTER 00575 * ISO_FILE_NOT_OPENED 00576 */ 00577 int (*close)(IsoFileSource *src); 00578 00579 /** 00580 * Attempts to read up to count bytes from the given source into 00581 * the buffer starting at buf. 00582 * 00583 * The file src must be open() before calling this, and close() when no 00584 * more needed. Not valid for dirs. On symlinks it reads the destination 00585 * file. 00586 * 00587 * @return 00588 * number of bytes read, 0 if EOF, < 0 on error (has to be a valid 00589 * libisofs error code) 00590 * Error codes: 00591 * ISO_FILE_ERROR 00592 * ISO_NULL_POINTER 00593 * ISO_FILE_NOT_OPENED 00594 * ISO_WRONG_ARG_VALUE -> if count == 0 00595 * ISO_FILE_IS_DIR 00596 * ISO_OUT_OF_MEM 00597 * ISO_INTERRUPTED 00598 */ 00599 int (*read)(IsoFileSource *src, void *buf, size_t count); 00600 00601 /** 00602 * Read a directory. 00603 * 00604 * Each call to this function will return a new children, until we reach 00605 * the end of file (i.e, no more children), in that case it returns 0. 00606 * 00607 * The dir must be open() before calling this, and close() when no more 00608 * needed. Only valid for dirs. 00609 * 00610 * Note that "." and ".." children MUST NOT BE returned. 00611 * 00612 * @param child 00613 * pointer to be filled with the given child. Undefined on error or OEF 00614 * @return 00615 * 1 on success, 0 if EOF (no more children), < 0 on error (has to be 00616 * a valid libisofs error code) 00617 * Error codes: 00618 * ISO_FILE_ERROR 00619 * ISO_NULL_POINTER 00620 * ISO_FILE_NOT_OPENED 00621 * ISO_FILE_IS_NOT_DIR 00622 * ISO_OUT_OF_MEM 00623 */ 00624 int (*readdir)(IsoFileSource *src, IsoFileSource **child); 00625 00626 /** 00627 * Read the destination of a symlink. You don't need to open the file 00628 * to call this. 00629 * 00630 * @param buf 00631 * allocated buffer of at least bufsiz bytes. 00632 * The dest. will be copied there, and it will be NULL-terminated 00633 * @param bufsiz 00634 * characters to be copied. Destination link will be truncated if 00635 * it is larger than given size. This include the \0 character. 00636 * @return 00637 * 1 on success, < 0 on error (has to be a valid libisofs error code) 00638 * Error codes: 00639 * ISO_FILE_ERROR 00640 * ISO_NULL_POINTER 00641 * ISO_WRONG_ARG_VALUE -> if bufsiz <= 0 00642 * ISO_FILE_IS_NOT_SYMLINK 00643 * ISO_OUT_OF_MEM 00644 * ISO_FILE_BAD_PATH 00645 * ISO_FILE_DOESNT_EXIST 00646 * 00647 */ 00648 int (*readlink)(IsoFileSource *src, char *buf, size_t bufsiz); 00649 00650 /** 00651 * Get the filesystem for this source. No extra ref is added, so you 00652 * musn't unref the IsoFilesystem. 00653 * 00654 * @return 00655 * The filesystem, NULL on error 00656 */ 00657 IsoFilesystem* (*get_filesystem)(IsoFileSource *src); 00658 00659 /** 00660 * Free implementation specific data. Should never be called by user. 00661 * Use iso_file_source_unref() instead. 00662 */ 00663 void (*free)(IsoFileSource *src); 00664 00665 /** 00666 * Repositions the offset of the IsoFileSource (must be opened) to the 00667 * given offset according to the value of flag. 00668 * 00669 * @param offset 00670 * in bytes 00671 * @param flag 00672 * 0 The offset is set to offset bytes (SEEK_SET) 00673 * 1 The offset is set to its current location plus offset bytes 00674 * (SEEK_CUR) 00675 * 2 The offset is set to the size of the file plus offset bytes 00676 * (SEEK_END). 00677 * @return 00678 * Absolute offset position of the file, or < 0 on error. Cast the 00679 * returning value to int to get a valid libisofs error. 00680 * 00681 * @since 0.6.4 00682 */ 00683 off_t (*lseek)(IsoFileSource *src, off_t offset, int flag); 00684 00685 /* Add-ons of .version 1 begin here */ 00686 00687 /** 00688 * Valid only if .version is > 0. See above. 00689 * Get the AAIP string with encoded ACL and xattr. 00690 * (Not to be confused with ECMA-119 Extended Attributes). 00691 * 00692 * bit1 and bit2 of flag should be implemented so that freshly fetched 00693 * info does not include the undesired ACL or xattr. Nevertheless if the 00694 * aa_string is cached, then it is permissible that ACL and xattr are still 00695 * delivered. 00696 * 00697 * @param flag Bitfield for control purposes 00698 * bit0= Transfer ownership of AAIP string data. 00699 * src will free the eventual cached data and might 00700 * not be able to produce it again. 00701 * bit1= No need to get ACL (no guarantee of exclusion) 00702 * bit2= No need to get xattr (no guarantee of exclusion) 00703 * @param aa_string Returns a pointer to the AAIP string data. If no AAIP 00704 * string is available, *aa_string becomes NULL. 00705 * (See doc/susp_aaip_*_*.txt for the meaning of AAIP and 00706 * libisofs/aaip_0_2.h for encoding and decoding.) 00707 * The caller is responsible for finally calling free() 00708 * on non-NULL results. 00709 * @return 1 means success (*aa_string == NULL is possible) 00710 * <0 means failure and must b a valid libisofs error code 00711 * (e.g. ISO_FILE_ERROR if no better one can be found). 00712 * @since 0.6.14 00713 */ 00714 int (*get_aa_string)(IsoFileSource *src, 00715 unsigned char **aa_string, int flag); 00716 00717 /* 00718 * TODO #00004 Add a get_mime_type() function. 00719 * This can be useful for GUI apps, to choose the icon of the file 00720 */ 00721 }; 00722 00723 /** 00724 * An IsoFile Source is a POSIX abstraction of a file. 00725 * 00726 * @since 0.6.2 00727 */ 00728 struct iso_file_source 00729 { 00730 const IsoFileSourceIface *class; 00731 int refcount; 00732 void *data; 00733 }; 00734 00735 /** 00736 * Representation of file contents. It is an stream of bytes, functionally 00737 * like a pipe. 00738 * 00739 * @since 0.6.4 00740 */ 00741 typedef struct iso_stream IsoStream; 00742 00743 /** 00744 * Interface that defines the operations (methods) available for an 00745 * IsoStream. 00746 * 00747 * @see struct IsoStream_Iface 00748 * @since 0.6.4 00749 */ 00750 typedef struct IsoStream_Iface IsoStreamIface; 00751 00752 /** 00753 * Serial number to be used when you can't get a valid id for a Stream by other 00754 * means. If you use this, both fs_id and dev_id should be set to 0. 00755 * This must be incremented each time you get a reference to it. 00756 * 00757 * @see IsoStreamIface->get_id() 00758 * @since 0.6.4 00759 */ 00760 extern ino_t serial_id; 00761 00762 /** 00763 * Interface definition for IsoStream methods. It is public to allow 00764 * implementation of own stream types. 00765 * The methods defined here typically make use of stream.data which points 00766 * to the individual state data of stream instances. 00767 * 00768 * @since 0.6.4 00769 */ 00770 struct IsoStream_Iface 00771 { 00772 /* 00773 * Current version of the interface, set to 1 or 2. 00774 * Version 0 (since 0.6.4) 00775 * deprecated but still valid. 00776 * Version 1 (since 0.6.8) 00777 * update_size() added. 00778 * Version 2 (since 0.6.18) 00779 * get_input_stream() added. A filter stream must have version 2. 00780 * Version 3 (since 0.6.20) 00781 * compare() added. A filter stream should have version 3. 00782 */ 00783 int version; 00784 00785 /** 00786 * Type of Stream. 00787 * "fsrc" -> Read from file source 00788 * "mem " -> Read from memory 00789 * "boot" -> Boot catalog 00790 * "extf" -> External filter program 00791 * "ziso" -> zisofs compression 00792 * "osiz" -> zisofs uncompression 00793 * "gzip" -> gzip compression 00794 * "pizg" -> gzip uncompression (gunzip) 00795 * "user" -> User supplied stream 00796 */ 00797 char type[4]; 00798 00799 /** 00800 * Opens the stream. 00801 * 00802 * @return 00803 * 1 on success, 2 file greater than expected, 3 file smaller than 00804 * expected, < 0 on error (has to be a valid libisofs error code) 00805 */ 00806 int (*open)(IsoStream *stream); 00807 00808 /** 00809 * Close the Stream. 00810 * @return 00811 * 1 on success, < 0 on error (has to be a valid libisofs error code) 00812 */ 00813 int (*close)(IsoStream *stream); 00814 00815 /** 00816 * Get the size (in bytes) of the stream. This function should always 00817 * return the same size, even if the underlying source size changes, 00818 * unless you call update_size() method. 00819 */ 00820 off_t (*get_size)(IsoStream *stream); 00821 00822 /** 00823 * Attempts to read up to count bytes from the given stream into 00824 * the buffer starting at buf. The implementation has to make sure that 00825 * either the full desired count of bytes is delivered or that the 00826 * next call to this function will return EOF or error. 00827 * I.e. only the last read block may be shorter than parameter count. 00828 * 00829 * The stream must be open() before calling this, and close() when no 00830 * more needed. 00831 * 00832 * @return 00833 * number of bytes read, 0 if EOF, < 0 on error (has to be a valid 00834 * libisofs error code) 00835 */ 00836 int (*read)(IsoStream *stream, void *buf, size_t count); 00837 00838 /** 00839 * Whether this IsoStream can be read several times, with the same results. 00840 * For example, a regular file is repeatable, you can read it as many 00841 * times as you want. However, a pipe isn't. 00842 * 00843 * This function doesn't take into account if the file has been modified 00844 * between the two reads. 00845 * 00846 * @return 00847 * 1 if stream is repeatable, 0 if not, 00848 * < 0 on error (has to be a valid libisofs error code) 00849 */ 00850 int (*is_repeatable)(IsoStream *stream); 00851 00852 /** 00853 * Get an unique identifier for the IsoStream. 00854 */ 00855 void (*get_id)(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, 00856 ino_t *ino_id); 00857 00858 /** 00859 * Free implementation specific data. Should never be called by user. 00860 * Use iso_stream_unref() instead. 00861 */ 00862 void (*free)(IsoStream *stream); 00863 00864 /** 00865 * Updates the size of the IsoStream with the current size of the 00866 * underlying source. After calling this, get_size() will return 00867 * the new size. This should never be called after 00868 * iso_image_create_burn_source() was called and the image was not 00869 * completely written. To update the size of all files before written the 00870 * image, you may want to call iso_image_update_sizes() just before 00871 * iso_image_create_burn_source(). 00872 * 00873 * @return 00874 * 1 if ok, < 0 on error (has to be a valid libisofs error code) 00875 * 00876 * @since 0.6.8 00877 * Present if .version is 1 or higher. 00878 */ 00879 int (*update_size)(IsoStream *stream); 00880 00881 /** 00882 * Obtains the eventual input stream of a filter stream. 00883 * 00884 * @param stream 00885 * The eventual filter stream to be inquired. 00886 * @param flag 00887 * Bitfield for control purposes. Submit 0 for now. 00888 * @return 00889 * The input stream, if one exists. Elsewise NULL. 00890 * No extra reference to the stream is taken by this call. 00891 * 00892 * @since 0.6.18 00893 * Present if .version is 2 or higher. 00894 */ 00895 IsoStream *(*get_input_stream)(IsoStream *stream, int flag); 00896 00897 /** 00898 * Compare two streams whether they are based on the same input and will 00899 * produce the same output. If in any doubt, then this comparison should 00900 * indicate no match. A match might allow hardlinking of IsoFile objects. 00901 * 00902 * This function has to establish an equivalence and order relation: 00903 * cmp_ino(A,A) == 0 00904 * cmp_ino(A,B) == -cmp_ino(B,A) 00905 * if cmp_ino(A,B) == 0 && cmp_ino(B,C) == 0 then cmp_ino(A,C) == 0 00906 * if cmp_ino(A,B) < 0 && cmp_ino(B,C) < 0 then cmp_ino(A,C) < 0 00907 * 00908 * A big hazard to the last constraint are tests which do not apply to some 00909 * types of streams. In this case for any A that is applicable and any B 00910 * that is not applicable, cmp_ino(A,B) must have the same non-zero 00911 * result. I.e. a pair of applicable and non-applicable streams must 00912 * return that non-zero result before the test for a pair of applicable 00913 * streams would happen. 00914 * 00915 * A function s1.(*cmp_ino)() must only accept stream s2 if function 00916 * s2.(*cmp_ino)() would accept s1. Best is to accept only the own stream 00917 * type or to have the same function for a family of similar stream types. 00918 * 00919 * If the function cannot accept one of the given stream types, then 00920 * the decision must be delegated to 00921 * iso_stream_cmp_ino(s1, s2, 1); 00922 * This is also appropriate if one has reason to implement stream.cmp_ino() 00923 * without special comparison algorithm. 00924 * With filter streams the decision whether the underlying chains of 00925 * streams match should be delegated to 00926 * iso_stream_cmp_ino(iso_stream_get_input_stream(s1, 0), 00927 * iso_stream_get_input_stream(s2, 0), 0); 00928 * 00929 * @param s1 00930 * The first stream to compare. Expect foreign stream types. 00931 * @param s2 00932 * The second stream to compare. Expect foreign stream types. 00933 * @return 00934 * -1 if s1 is smaller s2 , 0 if s1 matches s2 , 1 if s1 is larger s2 00935 * 00936 * @since 0.6.20 00937 * Present if .version is 3 or higher. 00938 */ 00939 int (*cmp_ino)(IsoStream *s1, IsoStream *s2); 00940 00941 }; 00942 00943 /** 00944 * Representation of file contents as a stream of bytes. 00945 * 00946 * @since 0.6.4 00947 */ 00948 struct iso_stream 00949 { 00950 IsoStreamIface *class; 00951 int refcount; 00952 void *data; 00953 }; 00954 00955 00956 /** 00957 * Initialize libisofs. Before any usage of the library you must either call 00958 * this function or iso_init_with_flag(). 00959 * @return 1 on success, < 0 on error 00960 * 00961 * @since 0.6.2 00962 */ 00963 int iso_init(); 00964 00965 /** 00966 * Initialize libisofs. Before any usage of the library you must either call 00967 * this function or iso_init() which is equivalent to iso_init_with_flag(0). 00968 * @param flag 00969 * Bitfield for control purposes 00970 * bit0= do not set up locale by LC_* environment variables 00971 * @return 1 on success, < 0 on error 00972 * 00973 * @since 0.6.18 00974 */ 00975 int iso_init_with_flag(int flag); 00976 00977 /** 00978 * Finalize libisofs. 00979 * 00980 * @since 0.6.2 00981 */ 00982 void iso_finish(); 00983 00984 /** 00985 * Override the reply of libc function nl_langinfo(CODESET) which may or may 00986 * not give the name of the character set which is in effect for your 00987 * environment. So this call can compensate for inconsistent terminal setups. 00988 * Another use case is to choose UTF-8 as intermediate character set for a 00989 * conversion from an exotic input character set to an exotic output set. 00990 * 00991 * @param name 00992 * Name of the character set to be assumed as "local" one. 00993 * @param flag 00994 * Unused yet. Submit 0. 00995 * @return 00996 * 1 indicates success, <=0 failure 00997 * 00998 * @since 0.6.12 00999 */ 01000 int iso_set_local_charset(char *name, int flag); 01001 01002 /** 01003 * Obtain the local charset as currently assumed by libisofs. 01004 * The result points to internal memory. It is volatile and must not be 01005 * altered. 01006 * 01007 * @param flag 01008 * Unused yet. Submit 0. 01009 * 01010 * @since 0.6.12 01011 */ 01012 char *iso_get_local_charset(int flag); 01013 01014 /** 01015 * Create a new image, empty. 01016 * 01017 * The image will be owned by you and should be unref() when no more needed. 01018 * 01019 * @param name 01020 * Name of the image. This will be used as volset_id and volume_id. 01021 * @param image 01022 * Location where the image pointer will be stored. 01023 * @return 01024 * 1 sucess, < 0 error 01025 * 01026 * @since 0.6.2 01027 */ 01028 int iso_image_new(const char *name, IsoImage **image); 01029 01030 01031 /** 01032 * Control whether ACL and xattr will be imported from external filesystems 01033 * (typically the local POSIX filesystem) when new nodes get inserted. If 01034 * enabled by iso_write_opts_set_aaip() they will later be written into the 01035 * image as AAIP extension fields. 01036 * 01037 * A change of this setting does neither affect existing IsoNode objects 01038 * nor the way how ACL and xattr are handled when loading an ISO image. 01039 * The latter is controlled by iso_read_opts_set_no_aaip(). 01040 * 01041 * @param image 01042 * The image of which the behavior is to be controlled 01043 * @param what 01044 * A bit field which sets the behavior: 01045 * bit0= ignore ACLs if the external file object bears some 01046 * bit1= ignore xattr if the external file object bears some 01047 * all other bits are reserved 01048 * 01049 * @since 0.6.14 01050 */ 01051 void iso_image_set_ignore_aclea(IsoImage *image, int what); 01052 01053 01054 /** 01055 * The following two functions three macros are utilities to help ensuring 01056 * version match of application, compile time header, and runtime library. 01057 */ 01058 /** 01059 * Get version of the libisofs library at runtime. 01060 * 01061 * @since 0.6.2 01062 */ 01063 void iso_lib_version(int *major, int *minor, int *micro); 01064 01065 /** 01066 * Check at runtime if the library is ABI compatible with the given version. 01067 * 01068 * @return 01069 * 1 lib is compatible, 0 is not. 01070 * 01071 * @since 0.6.2 01072 */ 01073 int iso_lib_is_compatible(int major, int minor, int micro); 01074 01075 01076 /** 01077 * These three release version numbers tell the revision of this header file 01078 * and of the API it describes. They are memorized by applications at 01079 * compile time. 01080 * They must show the same values as these symbols in ./configure.ac 01081 * LIBISOFS_MAJOR_VERSION=... 01082 * LIBISOFS_MINOR_VERSION=... 01083 * LIBISOFS_MICRO_VERSION=... 01084 * Note to anybody who does own work inside libisofs: 01085 * Any change of configure.ac or libisofs.h has to keep up this equality ! 01086 * 01087 * Before usage of these macros on your code, please read the usage discussion 01088 * below. 01089 * 01090 * @since 0.6.2 01091 */ 01092 #define iso_lib_header_version_major 0 01093 #define iso_lib_header_version_minor 6 01094 #define iso_lib_header_version_micro 28 01095 01096 /** 01097 * Usage discussion: 01098 * 01099 * Some developers of the libburnia project have differing opinions how to 01100 * ensure the compatibility of libaries and applications. 01101 * 01102 * It is about whether to use at compile time and at runtime the version 01103 * numbers provided here. Thomas Schmitt advises to use them. Vreixo Formoso 01104 * advises to use other means. 01105 * 01106 * At compile time: 01107 * 01108 * Vreixo Formoso advises to leave proper version matching to properly 01109 * programmed checks in the the application's build system, which will 01110 * eventually refuse compilation. 01111 * 01112 * Thomas Schmitt advises to use the macros defined here for comparison with 01113 * the application's requirements of library revisions and to eventually 01114 * break compilation. 01115 * 01116 * Both advises are combinable. I.e. be master of your build system and have 01117 * #if checks in the source code of your application, nevertheless. 01118 * 01119 * At runtime (via iso_lib_is_compatible()): 01120 * 01121 * Vreixo Formoso advises to compare the application's requirements of 01122 * library revisions with the runtime library. This is to allow runtime 01123 * libraries which are young enough for the application but too old for 01124 * the lib*.h files seen at compile time. 01125 * 01126 * Thomas Schmitt advises to compare the header revisions defined here with 01127 * the runtime library. This is to enforce a strictly monotonous chain of 01128 * revisions from app to header to library, at the cost of excluding some older 01129 * libraries. 01130 * 01131 * These two advises are mutually exclusive. 01132 */ 01133 01134 01135 /** 01136 * Creates an IsoWriteOpts for writing an image. You should set the options 01137 * desired with the correspondent setters. 01138 * 01139 * Options by default are determined by the selected profile. Fifo size is set 01140 * by default to 2 MB. 01141 * 01142 * @param opts 01143 * Pointer to the location where the newly created IsoWriteOpts will be 01144 * stored. You should free it with iso_write_opts_free() when no more 01145 * needed. 01146 * @param profile 01147 * Default profile for image creation. For now the following values are 01148 * defined: 01149 * ---> 0 [BASIC] 01150 * No extensions are enabled, and ISO level is set to 1. Only suitable 01151 * for usage for very old and limited systems (like MS-DOS), or by a 01152 * start point from which to set your custom options. 01153 * ---> 1 [BACKUP] 01154 * POSIX compatibility for backup. Simple settings, ISO level is set to 01155 * 3 and RR extensions are enabled. Useful for backup purposes. 01156 * Note that ACL and xattr are not enabled by default. 01157 * If you enable them, expect them not to show up in the mounted image. 01158 * They will have to be retrieved by libisofs applications like xorriso. 01159 * ---> 2 [DISTRIBUTION] 01160 * Setting for information distribution. Both RR and Joliet are enabled 01161 * to maximize compatibility with most systems. Permissions are set to 01162 * default values, and timestamps to the time of recording. 01163 * @return 01164 * 1 success, < 0 error 01165 * 01166 * @since 0.6.2 01167 */ 01168 int iso_write_opts_new(IsoWriteOpts **opts, int profile); 01169 01170 /** 01171 * Free an IsoWriteOpts previously allocated with iso_write_opts_new(). 01172 * 01173 * @since 0.6.2 01174 */ 01175 void iso_write_opts_free(IsoWriteOpts *opts); 01176 01177 /** 01178 * Set the ISO-9960 level to write at. 01179 * 01180 * @param level 01181 * -> 1 for higher compatibility with old systems. With this level 01182 * filenames are restricted to 8.3 characters. 01183 * -> 2 to allow up to 31 filename characters. 01184 * -> 3 to allow files greater than 4GB 01185 * @return 01186 * 1 success, < 0 error 01187 * 01188 * @since 0.6.2 01189 */ 01190 int iso_write_opts_set_iso_level(IsoWriteOpts *opts, int level); 01191 01192 /** 01193 * Whether to use or not Rock Ridge extensions. 01194 * 01195 * This are standard extensions to ECMA-119, intended to add POSIX filesystem 01196 * features to ECMA-119 images. Thus, usage of this flag is highly recommended 01197 * for images used on GNU/Linux systems. With the usage of RR extension, the 01198 * resulting image will have long filenames (up to 255 characters), deeper 01199 * directory structure, POSIX permissions and owner info on files and 01200 * directories, support for symbolic links or special files... All that 01201 * attributes can be modified/setted with the appropiate function. 01202 * 01203 * @param enable 01204 * 1 to enable RR extension, 0 to not add them 01205 * @return 01206 * 1 success, < 0 error 01207 * 01208 * @since 0.6.2 01209 */ 01210 int iso_write_opts_set_rockridge(IsoWriteOpts *opts, int enable); 01211 01212 /** 01213 * Whether to add the non-standard Joliet extension to the image. 01214 * 01215 * This extensions are heavily used in Microsoft Windows systems, so if you 01216 * plan to use your disc on such a system you should add this extension. 01217 * Usage of Joliet supplies longer filesystem length (up to 64 unicode 01218 * characters), and deeper directory structure. 01219 * 01220 * @param enable 01221 * 1 to enable Joliet extension, 0 to not add them 01222 * @return 01223 * 1 success, < 0 error 01224 * 01225 * @since 0.6.2 01226 */ 01227 int iso_write_opts_set_joliet(IsoWriteOpts *opts, int enable); 01228 01229 /** 01230 * Whether to use newer ISO-9660:1999 version. 01231 * 01232 * This is the second version of ISO-9660. It allows longer filenames and has 01233 * less restrictions than old ISO-9660. However, nobody is using it so there 01234 * are no much reasons to enable this. 01235 * 01236 * @since 0.6.2 01237 */ 01238 int iso_write_opts_set_iso1999(IsoWriteOpts *opts, int enable); 01239 01240 /** 01241 * Control generation of non-unique inode numbers for the emerging image. 01242 * Inode numbers get written as "file serial number" with PX entries as of 01243 * RRIP-1.12. They may mark families of hardlinks. 01244 * RRIP-1.10 prescribes a PX entry without file serial number. If not overriden 01245 * by iso_write_opts_set_rrip_1_10_px_ino() there will be no file serial 01246 * written into RRIP-1.10 images. 01247 * 01248 * Inode number generation does not affect IsoNode objects which imported their 01249 * inode numbers from the old ISO image (see iso_read_opts_set_new_inos()) 01250 * and which have not been altered since import. It rather applies to IsoNode 01251 * objects which were newly added to the image, or to IsoNode which brought no 01252 * inode number from the old image, or to IsoNode where certain properties 01253 * have been altered since image import. 01254 * 01255 * If two IsoNode are found with same imported inode number but differing 01256 * properties, then one of them will get assigned a new unique inode number. 01257 * I.e. the hardlink relation between both IsoNode objects ends. 01258 * 01259 * @param enable 01260 * 1 = Collect IsoNode objects which have identical data sources and 01261 * properties. 01262 * 0 = Generate unique inode numbers for all IsoNode objects which do not 01263 * have a valid inode number from an imported ISO image. 01264 * All other values are reserved. 01265 * 01266 * @since 0.6.20 01267 */ 01268 int iso_write_opts_set_hardlinks(IsoWriteOpts *opts, int enable); 01269 01270 /** 01271 * Control writing of AAIP informations for ACL and xattr. 01272 * For importing ACL and xattr when inserting nodes from external filesystems 01273 * (e.g. the local POSIX filesystem) see iso_image_set_ignore_aclea(). 01274 * For loading of this information from images see iso_read_opts_set_no_aaip(). 01275 * 01276 * @param enable 01277 * 1 = write AAIP information from nodes into the image 01278 * 0 = do not write AAIP information into the image 01279 * All other values are reserved. 01280 * 01281 * @since 0.6.14 01282 */ 01283 int iso_write_opts_set_aaip(IsoWriteOpts *opts, int enable); 01284 01285 /** 01286 * Omit the version number (";1") at the end of the ISO-9660 identifiers. 01287 * This breaks ECMA-119 specification, but version numbers are usually not 01288 * used, so it should work on most systems. Use with caution. 01289 * 01290 * @since 0.6.2 01291 */ 01292 int iso_write_opts_set_omit_version_numbers(IsoWriteOpts *opts, int omit); 01293 01294 /** 01295 * Allow ISO-9660 directory hierarchy to be deeper than 8 levels. 01296 * This breaks ECMA-119 specification. Use with caution. 01297 * 01298 * @since 0.6.2 01299 */ 01300 int iso_write_opts_set_allow_deep_paths(IsoWriteOpts *opts, int allow); 01301 01302 /** 01303 * Allow path in the ISO-9660 tree to have more than 255 characters. 01304 * This breaks ECMA-119 specification. Use with caution. 01305 * 01306 * @since 0.6.2 01307 */ 01308 int iso_write_opts_set_allow_longer_paths(IsoWriteOpts *opts, int allow); 01309 01310 /** 01311 * Allow a single file or directory hierarchy to have up to 37 characters. 01312 * This is larger than the 31 characters allowed by ISO level 2, and the 01313 * extra space is taken from the version number, so this also forces 01314 * omit_version_numbers. 01315 * This breaks ECMA-119 specification and could lead to buffer overflow 01316 * problems on old systems. Use with caution. 01317 * 01318 * @since 0.6.2 01319 */ 01320 int iso_write_opts_set_max_37_char_filenames(IsoWriteOpts *opts, int allow); 01321 01322 /** 01323 * ISO-9660 forces filenames to have a ".", that separates file name from 01324 * extension. libisofs adds it if original filename doesn't has one. Set 01325 * this to 1 to prevent this behavior. 01326 * This breaks ECMA-119 specification. Use with caution. 01327 * 01328 * @since 0.6.2 01329 */ 01330 int iso_write_opts_set_no_force_dots(IsoWriteOpts *opts, int no); 01331 01332 /** 01333 * Allow lowercase characters in ISO-9660 filenames. By default, only 01334 * uppercase characters, numbers and a few other characters are allowed. 01335 * This breaks ECMA-119 specification. Use with caution. 01336 * 01337 * @since 0.6.2 01338 */ 01339 int iso_write_opts_set_allow_lowercase(IsoWriteOpts *opts, int allow); 01340 01341 /** 01342 * Allow all ASCII characters to be appear on an ISO-9660 filename. Note 01343 * that "/" and "\0" characters are never allowed, even in RR names. 01344 * This breaks ECMA-119 specification. Use with caution. 01345 * 01346 * @since 0.6.2 01347 */ 01348 int iso_write_opts_set_allow_full_ascii(IsoWriteOpts *opts, int allow); 01349 01350 /** 01351 * Allow all characters to be part of Volume and Volset identifiers on 01352 * the Primary Volume Descriptor. This breaks ISO-9660 contraints, but 01353 * should work on modern systems. 01354 * 01355 * @since 0.6.2 01356 */ 01357 int iso_write_opts_set_relaxed_vol_atts(IsoWriteOpts *opts, int allow); 01358 01359 /** 01360 * Allow paths in the Joliet tree to have more than 240 characters. 01361 * This breaks Joliet specification. Use with caution. 01362 * 01363 * @since 0.6.2 01364 */ 01365 int iso_write_opts_set_joliet_longer_paths(IsoWriteOpts *opts, int allow); 01366 01367 /** 01368 * Write Rock Ridge info as of specification RRIP-1.10 rather than RRIP-1.12: 01369 * signature "RRIP_1991A" rather than "IEEE_1282", field PX without file 01370 * serial number. 01371 * 01372 * @since 0.6.12 01373 */ 01374 int iso_write_opts_set_rrip_version_1_10(IsoWriteOpts *opts, int oldvers); 01375 01376 /** 01377 * Write field PX with file serial number (i.e. inode number) even if 01378 * iso_write_opts_set_rrip_version_1_10(,1) is in effect. 01379 * This clearly violates the RRIP-1.10 specs. But it is done by mkisofs since 01380 * a while and no widespread protest is visible in the web. 01381 * If this option is not enabled, then iso_write_opts_set_hardlinks() will 01382 * only have an effect with iso_write_opts_set_rrip_version_1_10(,0). 01383 * 01384 * @since 0.6.20 01385 */ 01386 int iso_write_opts_set_rrip_1_10_px_ino(IsoWriteOpts *opts, int enable); 01387 01388 /** 01389 * Write AAIP as extension according to SUSP 1.10 rather than SUSP 1.12. 01390 * I.e. without announcing it by an ER field and thus without the need 01391 * to preceed the RRIP fields and the AAIP field by ES fields. 01392 * This saves 5 to 10 bytes per file and might avoid problems with readers 01393 * which dislike ER fields other than the ones for RRIP. 01394 * On the other hand, SUSP 1.12 frowns on such unannounced extensions 01395 * and prescribes ER and ES. It does this since the year 1994. 01396 * 01397 * In effect only if above iso_write_opts_set_aaip() enables writing of AAIP. 01398 * 01399 * @since 0.6.14 01400 */ 01401 int iso_write_opts_set_aaip_susp_1_10(IsoWriteOpts *opts, int oldvers); 01402 01403 /** 01404 * Store as ECMA-119 Directory Record timestamp the mtime of the source 01405 * rather than the image creation time. 01406 * 01407 * @since 0.6.12 01408 */ 01409 int iso_write_opts_set_dir_rec_mtime(IsoWriteOpts *opts, int allow); 01410 01411 /** 01412 * Whether to sort files based on their weight. 01413 * 01414 * @see iso_node_set_sort_weight 01415 * @since 0.6.2 01416 */ 01417 int iso_write_opts_set_sort_files(IsoWriteOpts *opts, int sort); 01418 01419 /** 01420 * Whether to compute and record MD5 checksums for the whole session and/or 01421 * for each single IsoFile object. The checksums represent the data as they 01422 * were written into the image output stream, not necessarily as they were 01423 * on hard disk at any point of time. 01424 * See also calls iso_image_get_session_md5() and iso_file_get_md5(). 01425 * @param opts 01426 * The option set to be manipulated. 01427 * @param session 01428 * If bit0 set: Compute session checksum 01429 * @param files 01430 * If bit0 set: Compute a checksum for each single IsoFile object which 01431 * gets its data content written into the session. Copy 01432 * checksums from files which keep their data in older 01433 * sessions. 01434 * If bit1 set: Check content stability (only with bit0). I.e. before 01435 * writing the file content into to image stream, read it 01436 * once and compute a MD5. Do a second reading for writing 01437 * into the image stream. Afterwards compare both MD5 and 01438 * issue a MISHAP event ISO_MD5_STREAM_CHANGE if they do not 01439 * match. 01440 * Such a mismatch indicates content changes between the 01441 * time point when the first MD5 reading started and the 01442 * time point when the last block was read for writing. 01443 * So there is high risk that the image stream was fed from 01444 * changing and possibly inconsistent file content. 01445 * 01446 * @since 0.6.22 01447 */ 01448 int iso_write_opts_set_record_md5(IsoWriteOpts *opts, int session, int files); 01449 01450 /** 01451 * Set the parameters "name" and "timestamp" for a scdbackup checksum tag. 01452 * It will be appended to the libisofs session tag if the image starts at 01453 * LBA 0 (see iso_write_opts_set_ms_block()). The scdbackup tag can be used 01454 * to verify the image by command scdbackup_verify <device> -auto_end. 01455 * See scdbackup/README appendix VERIFY for its inner details. 01456 * 01457 * @param name 01458 * A word of up to 80 characters. Typically <volno>_<totalno> telling 01459 * that this is volume <volno> of a total of <totalno> volumes. 01460 * @param timestamp 01461 * A string of 13 characters YYMMDD.hhmmss (e.g. A90831.190324). 01462 * A9 = 2009, B0 = 2010, B1 = 2011, ... C0 = 2020, ... 01463 * @param tag_written 01464 * Either NULL or the address of an array with at least 512 characters. 01465 * In the latter case the eventually produced scdbackup tag will be 01466 * copied to this array when the image gets written. This call sets 01467 * scdbackup_tag_written[0] = 0 to mark its preliminary invalidity. 01468 * @return 01469 * 1 indicates success, <0 is error 01470 * 01471 * @since 0.6.24 01472 */ 01473 int iso_write_opts_set_scdbackup_tag(IsoWriteOpts *opts, 01474 char *name, char *timestamp, 01475 char *tag_written); 01476 01477 /** 01478 * Whether to set default values for files and directory permissions, gid and 01479 * uid. All these take one of three values: 0, 1 or 2. 01480 * 01481 * If 0, the corresponding attribute will be kept as set in the IsoNode. 01482 * Unless you have changed it, it corresponds to the value on disc, so it 01483 * is suitable for backup purposes. If set to 1, the corresponding attrib. 01484 * will be changed by a default suitable value. Finally, if you set it to 01485 * 2, the attrib. will be changed with the value specified by the functioins 01486 * below. Note that for mode attributes, only the permissions are set, the 01487 * file type remains unchanged. 01488 * 01489 * @see iso_write_opts_set_default_dir_mode 01490 * @see iso_write_opts_set_default_file_mode 01491 * @see iso_write_opts_set_default_uid 01492 * @see iso_write_opts_set_default_gid 01493 * @since 0.6.2 01494 */ 01495 int iso_write_opts_set_replace_mode(IsoWriteOpts *opts, int dir_mode, 01496 int file_mode, int uid, int gid); 01497 01498 /** 01499 * Set the mode to use on dirs when you set the replace_mode of dirs to 2. 01500 * 01501 * @see iso_write_opts_set_replace_mode 01502 * @since 0.6.2 01503 */ 01504 int iso_write_opts_set_default_dir_mode(IsoWriteOpts *opts, mode_t dir_mode); 01505 01506 /** 01507 * Set the mode to use on files when you set the replace_mode of files to 2. 01508 * 01509 * @see iso_write_opts_set_replace_mode 01510 * @since 0.6.2 01511 */ 01512 int iso_write_opts_set_default_file_mode(IsoWriteOpts *opts, mode_t file_mode); 01513 01514 /** 01515 * Set the uid to use when you set the replace_uid to 2. 01516 * 01517 * @see iso_write_opts_set_replace_mode 01518 * @since 0.6.2 01519 */ 01520 int iso_write_opts_set_default_uid(IsoWriteOpts *opts, uid_t uid); 01521 01522 /** 01523 * Set the gid to use when you set the replace_gid to 2. 01524 * 01525 * @see iso_write_opts_set_replace_mode 01526 * @since 0.6.2 01527 */ 01528 int iso_write_opts_set_default_gid(IsoWriteOpts *opts, gid_t gid); 01529 01530 /** 01531 * 0 to use IsoNode timestamps, 1 to use recording time, 2 to use 01532 * values from timestamp field. This has only meaning if RR extensions 01533 * are enabled. 01534 * 01535 * @see iso_write_opts_set_default_timestamp 01536 * @since 0.6.2 01537 */ 01538 int iso_write_opts_set_replace_timestamps(IsoWriteOpts *opts, int replace); 01539 01540 /** 01541 * Set the timestamp to use when you set the replace_timestamps to 2. 01542 * 01543 * @see iso_write_opts_set_replace_timestamps 01544 * @since 0.6.2 01545 */ 01546 int iso_write_opts_set_default_timestamp(IsoWriteOpts *opts, time_t timestamp); 01547 01548 /** 01549 * Whether to always record timestamps in GMT. 01550 * 01551 * By default, libisofs stores local time information on image. You can set 01552 * this to always store timestamps converted to GMT. This prevents any 01553 * discrimination of the timezone of the image preparer by the image reader. 01554 * 01555 * It is useful if you want to hide your timezone, or you live in a timezone 01556 * that can't be represented in ECMA-119. These are timezones with an offset 01557 * from GMT greater than +13 hours, lower than -12 hours, or not a multiple 01558 * of 15 minutes. 01559 * Negative timezones (west of GMT) can trigger bugs in some operating systems 01560 * which typically appear in mounted ISO images as if the timezone shift from 01561 * GMT was applied twice (e.g. in New York 22:36 becomes 17:36). 01562 * 01563 * @since 0.6.2 01564 */ 01565 int iso_write_opts_set_always_gmt(IsoWriteOpts *opts, int gmt); 01566 01567 /** 01568 * Set the charset to use for the RR names of the files that will be created 01569 * on the image. 01570 * NULL to use default charset, that is the locale charset. 01571 * You can obtain the list of charsets supported on your system executing 01572 * "iconv -l" in a shell. 01573 * 01574 * @since 0.6.2 01575 */ 01576 int iso_write_opts_set_output_charset(IsoWriteOpts *opts, const char *charset); 01577 01578 /** 01579 * Set the type of image creation in case there was already an existing 01580 * image imported. Libisofs supports two types of creation: 01581 * stand-alone and appended. 01582 * 01583 * A stand-alone image is an image that does not need the old image any more 01584 * for being mounted by the operating system or imported by libisofs. It may 01585 * be written beginning with byte 0 of optical media or disk file objects. 01586 * There will be no distinction between files from the old image and those 01587 * which have been added by the new image generation. 01588 * 01589 * On the other side, an appended image is not self contained. It may refer 01590 * to files that stay stored in the imported existing image. 01591 * This usage model is inspired by CD multi-session. It demands that the 01592 * appended image is finally written to the same media resp. disk file 01593 * as the imported image at an address behind the end of that imported image. 01594 * The exact address may depend on media peculiarities and thus has to be 01595 * announced by the application via iso_write_opts_set_ms_block(). 01596 * The real address where the data will be written is under control of the 01597 * consumer of the struct burn_source which takes the output of libisofs 01598 * image generation. It may be the one announced to libisofs or an intermediate 01599 * one. Nevertheless, the image will be readable only at the announced address. 01600 * 01601 * If you have not imported a previous image by iso_image_import(), then the 01602 * image will always be a stand-alone image, as there is no previous data to 01603 * refer to. 01604 * 01605 * @param append 01606 * 1 to create an appended image, 0 for an stand-alone one. 01607 * 01608 * @since 0.6.2 01609 */ 01610 int iso_write_opts_set_appendable(IsoWriteOpts *opts, int append); 01611 01612 /** 01613 * Set the start block of the image. It is supposed to be the lba where the 01614 * first block of the image will be written on disc. All references inside the 01615 * ISO image will take this into account, thus providing a mountable image. 01616 * 01617 * For appendable images, that are written to a new session, you should 01618 * pass here the lba of the next writable address on disc. 01619 * 01620 * In stand alone images this is usually 0. However, you may want to 01621 * provide a different ms_block if you don't plan to burn the image in the 01622 * first session on disc, such as in some CD-Extra disc whether the data 01623 * image is written in a new session after some audio tracks. 01624 * 01625 * @since 0.6.2 01626 */ 01627 int iso_write_opts_set_ms_block(IsoWriteOpts *opts, uint32_t ms_block); 01628 01629 /** 01630 * Sets the buffer where to store the descriptors which shall to be written 01631 * at the beginning of an overwriteable media to point to the newly written 01632 * image. 01633 * This is needed if the write start address of the image is not 0. 01634 * In this case the first 64 KiB of the media have to be overwritten 01635 * by the buffer content after the session was written and the buffer 01636 * was updated by libisofs. Otherwise the new session would not be 01637 * found by operating system function mount() or by libisoburn. 01638 * (One could still mount that session if its start address is known.) 01639 * 01640 * If you do not need this information, for example because you are creating a 01641 * new image for LBA 0 or because you will create an image for a true 01642 * multisession media, just do not use this call or set buffer to NULL. 01643 * 01644 * Use cases: 01645 * 01646 * - Together with iso_write_opts_set_appendable(opts, 1) the buffer serves 01647 * for the growing of an image as done in growisofs by Andy Polyakov. 01648 * This allows appending of a new session to non-multisession media, such 01649 * as DVD+RW. The new session will refer to the data of previous sessions 01650 * on the same media. 01651 * libisoburn emulates multisession appendability on overwriteable media 01652 * and disk files by performing this use case. 01653 * 01654 * - Together with iso_write_opts_set_appendable(opts, 0) the buffer allows 01655 * to write the first session on overwriteable media to start addresses 01656 * other than 0. 01657 * libisoburn in most cases writes the first session on overwriteable media 01658 * and disk files to LBA 32 in order to preserve its descriptors from the 01659 * subsequent overwriting by the descriptor buffer of later sessions. 01660 * 01661 * @param buffer 01662 * When not NULL, it should point to at least 64KiB of memory, where 01663 * libisofs will install the contents that shall be written at the 01664 * beginning of overwriteable media. 01665 * You should initialize the buffer either with 0s, or with the contents 01666 * of the first 32 blocks of the image you are growing. In most cases, 01667 * 0 is good enought. 01668 * 01669 * @since 0.6.2 01670 */ 01671 int iso_write_opts_set_overwrite_buf(IsoWriteOpts *opts, uint8_t *overwrite); 01672 01673 /** 01674 * Set the size, in number of blocks, of the FIFO buffer used between the 01675 * writer thread and the burn_source. You have to provide at least a 32 01676 * blocks buffer. Default value is set to 2MB, if that is ok for you, you 01677 * don't need to call this function. 01678 * 01679 * @since 0.6.2 01680 */ 01681 int iso_write_opts_set_fifo_size(IsoWriteOpts *opts, size_t fifo_size); 01682 01683 /** 01684 * Inquire the start address of the file data blocks after having used 01685 * IsoWriteOpts with iso_image_create_burn_source(). 01686 * @param opts 01687 * The option set that was used when starting image creation 01688 * @param data_start 01689 * Returns the logical block address if it is already valid 01690 * @param flag 01691 * Reserved for future usage, set to 0. 01692 * @return 01693 * 1 indicates valid data_start, <0 indicates invalid data_start 01694 * 01695 * @since 0.6.16 01696 */ 01697 int iso_write_opts_get_data_start(IsoWriteOpts *opts, uint32_t *data_start, 01698 int flag); 01699 01700 /** 01701 * Create a burn_source and a thread which immediately begins to generate 01702 * the image. That burn_source can be used with libburn as a data source 01703 * for a track. A copy of its public declaration in libburn.h can be found 01704 * further below in this text. 01705 * 01706 * If image generation shall be aborted by the application program, then 01707 * the .cancel() method of the burn_source must be called to end the 01708 * generation thread: burn_src->cancel(burn_src); 01709 * 01710 * @param image 01711 * The image to write. 01712 * @param opts 01713 * The options for image generation. All needed data will be copied, so 01714 * you can free the given struct once this function returns. 01715 * @param burn_src 01716 * Location where the pointer to the burn_source will be stored 01717 * @return 01718 * 1 on success, < 0 on error 01719 * 01720 * @since 0.6.2 01721 */ 01722 int iso_image_create_burn_source(IsoImage *image, IsoWriteOpts *opts, 01723 struct burn_source **burn_src); 01724 01725 /** 01726 * Update the sizes of all files added to image. 01727 * 01728 * This may be called just before iso_image_create_burn_source() to force 01729 * libisofs to check the file sizes again (they're already checked when added 01730 * to IsoImage). It is useful if you have changed some files after adding then 01731 * to the image. 01732 * 01733 * @return 01734 * 1 on success, < 0 on error 01735 * @since 0.6.8 01736 */ 01737 int iso_image_update_sizes(IsoImage *image); 01738 01739 /** 01740 * Creates an IsoReadOpts for reading an existent image. You should set the 01741 * options desired with the correspondent setters. Note that you may want to 01742 * set the start block value. 01743 * 01744 * Options by default are determined by the selected profile. 01745 * 01746 * @param opts 01747 * Pointer to the location where the newly created IsoReadOpts will be 01748 * stored. You should free it with iso_read_opts_free() when no more 01749 * needed. 01750 * @param profile 01751 * Default profile for image reading. For now the following values are 01752 * defined: 01753 * ---> 0 [STANDARD] 01754 * Suitable for most situations. Most extension are read. When both 01755 * Joliet and RR extension are present, RR is used. 01756 * AAIP for ACL and xattr is not enabled by default. 01757 * @return 01758 * 1 success, < 0 error 01759 * 01760 * @since 0.6.2 01761 */ 01762 int iso_read_opts_new(IsoReadOpts **opts, int profile); 01763 01764 /** 01765 * Free an IsoReadOpts previously allocated with iso_read_opts_new(). 01766 * 01767 * @since 0.6.2 01768 */ 01769 void iso_read_opts_free(IsoReadOpts *opts); 01770 01771 /** 01772 * Set the block where the image begins. It is usually 0, but may be different 01773 * on a multisession disc. 01774 * 01775 * @since 0.6.2 01776 */ 01777 int iso_read_opts_set_start_block(IsoReadOpts *opts, uint32_t block); 01778 01779 /** 01780 * Do not read Rock Ridge extensions. 01781 * In most cases you don't want to use this. It could be useful if RR info 01782 * is damaged, or if you want to use the Joliet tree. 01783 * 01784 * @since 0.6.2 01785 */ 01786 int iso_read_opts_set_no_rockridge(IsoReadOpts *opts, int norr); 01787 01788 /** 01789 * Do not read Joliet extensions. 01790 * 01791 * @since 0.6.2 01792 */ 01793 int iso_read_opts_set_no_joliet(IsoReadOpts *opts, int nojoliet); 01794 01795 /** 01796 * Do not read ISO 9660:1999 enhanced tree 01797 * 01798 * @since 0.6.2 01799 */ 01800 int iso_read_opts_set_no_iso1999(IsoReadOpts *opts, int noiso1999); 01801 01802 /** 01803 * Control reading of AAIP informations about ACL and xattr when loading 01804 * existing images. 01805 * For importing ACL and xattr when inserting nodes from external filesystems 01806 * (e.g. the local POSIX filesystem) see iso_image_set_ignore_aclea(). 01807 * For eventual writing of this information see iso_write_opts_set_aaip(). 01808 * 01809 * @param noaaip 01810 * 1 = Do not read AAIP information 01811 * 0 = Read AAIP information if available 01812 * All other values are reserved. 01813 * @since 0.6.14 01814 */ 01815 int iso_read_opts_set_no_aaip(IsoReadOpts *opts, int noaaip); 01816 01817 /** 01818 * Control reading of an array of MD5 checksums which is eventually stored 01819 * at the end of a session. See also iso_write_opts_set_record_md5(). 01820 * Important: Loading of the MD5 array will only work if AAIP is enabled 01821 * because its position and layout is recorded in xattr "isofs.ca". 01822 * 01823 * @param no_md5 01824 * 1 = Do not read MD5 checksum array 01825 * 0 = Read Md% array if available 01826 * All other values are reserved. 01827 * 01828 * @since 0.6.22 01829 */ 01830 int iso_read_opts_set_no_md5(IsoReadOpts *opts, int no_md5); 01831 01832 01833 /** 01834 * Control discarding of eventual inode numbers from existing images. 01835 * Such numbers may come from RRIP 1.12 entries PX. If not discarded they 01836 * get written unchanged when the file object gets written into an ISO image. 01837 * If this inode number is missing with a file in the imported image, 01838 * or if it has been discarded during image reading, then a unique inode number 01839 * will be generated at some time before the file gets written into an ISO 01840 * image. 01841 * Two image nodes which have the same inode number represent two hardlinks 01842 * of the same file object. So discarding the numbers splits hardlinks. 01843 * 01844 * @param new_inos 01845 * 1 = Discard imported inode numbers and finally hand out a unique new 01846 * one to each single file before it gets written into an ISO image. 01847 * 0 = Keep eventual inode numbers from PX entries. 01848 * All other values are reserved. 01849 * @since 0.6.20 01850 */ 01851 int iso_read_opts_set_new_inos(IsoReadOpts *opts, int new_inos); 01852 01853 /** 01854 * Whether to prefer Joliet over RR. libisofs usually prefers RR over 01855 * Joliet, as it give us much more info about files. So, if both extensions 01856 * are present, RR is used. You can set this if you prefer Joliet, but 01857 * note that this is not very recommended. This doesn't mean than RR 01858 * extensions are not read: if no Joliet is present, libisofs will read 01859 * RR tree. 01860 * 01861 * @since 0.6.2 01862 */ 01863 int iso_read_opts_set_preferjoliet(IsoReadOpts *opts, int preferjoliet); 01864 01865 /** 01866 * Set default uid for files when RR extensions are not present. 01867 * 01868 * @since 0.6.2 01869 */ 01870 int iso_read_opts_set_default_uid(IsoReadOpts *opts, uid_t uid); 01871 01872 /** 01873 * Set default gid for files when RR extensions are not present. 01874 * 01875 * @since 0.6.2 01876 */ 01877 int iso_read_opts_set_default_gid(IsoReadOpts *opts, gid_t gid); 01878 01879 /** 01880 * Set default permissions for files when RR extensions are not present. 01881 * 01882 * @param file_perm 01883 * Permissions for files. 01884 * @param dir_perm 01885 * Permissions for directories. 01886 * 01887 * @since 0.6.2 01888 */ 01889 int iso_read_opts_set_default_permissions(IsoReadOpts *opts, mode_t file_perm, 01890 mode_t dir_perm); 01891 01892 /** 01893 * Set the input charset of the file names on the image. NULL to use locale 01894 * charset. You have to specify a charset if the image filenames are encoded 01895 * in a charset different that the local one. This could happen, for example, 01896 * if the image was created on a system with different charset. 01897 * 01898 * @param charset 01899 * The charset to use as input charset. You can obtain the list of 01900 * charsets supported on your system executing "iconv -l" in a shell. 01901 * 01902 * @since 0.6.2 01903 */ 01904 int iso_read_opts_set_input_charset(IsoReadOpts *opts, const char *charset); 01905 01906 /** 01907 * Enable or disable methods to automatically choose an input charset. 01908 * This eventually overrides the name set via iso_read_opts_set_input_charset() 01909 * 01910 * @param mode 01911 * Bitfield for control purposes: 01912 * bit0= Allow to use the input character set name which is eventually 01913 * stored in attribute "isofs.cs" of the root directory. 01914 * Applications may attach this xattr by iso_node_set_attrs() to 01915 * the root node, call iso_write_opts_set_output_charset() with the 01916 * same name and enable iso_write_opts_set_aaip() when writing 01917 * an image. 01918 * Submit any other bits with value 0. 01919 * 01920 * @since 0.6.18 01921 * 01922 */ 01923 int iso_read_opts_auto_input_charset(IsoReadOpts *opts, int mode); 01924 01925 01926 /** 01927 * Import a previous session or image, for growing or modify. 01928 * 01929 * @param image 01930 * The image context to which old image will be imported. Note that all 01931 * files added to image, and image attributes, will be replaced with the 01932 * contents of the old image. 01933 * TODO #00025 support for merging old image files 01934 * @param src 01935 * Data Source from which old image will be read. A extra reference is 01936 * added, so you still need to iso_data_source_unref() yours. 01937 * @param opts 01938 * Options for image import. All needed data will be copied, so you 01939 * can free the given struct once this function returns. 01940 * @param features 01941 * If not NULL, a new IsoReadImageFeatures will be allocated and filled 01942 * with the features of the old image. It should be freed with 01943 * iso_read_image_features_destroy() when no more needed. You can pass 01944 * NULL if you're not interested on them. 01945 * @return 01946 * 1 on success, < 0 on error 01947 * 01948 * @since 0.6.2 01949 */ 01950 int iso_image_import(IsoImage *image, IsoDataSource *src, IsoReadOpts *opts, 01951 IsoReadImageFeatures **features); 01952 01953 /** 01954 * Destroy an IsoReadImageFeatures object obtained with iso_image_import. 01955 * 01956 * @since 0.6.2 01957 */ 01958 void iso_read_image_features_destroy(IsoReadImageFeatures *f); 01959 01960 /** 01961 * Get the size (in 2048 byte block) of the image, as reported in the PVM. 01962 * 01963 * @since 0.6.2 01964 */ 01965 uint32_t iso_read_image_features_get_size(IsoReadImageFeatures *f); 01966 01967 /** 01968 * Whether RockRidge extensions are present in the image imported. 01969 * 01970 * @since 0.6.2 01971 */ 01972 int iso_read_image_features_has_rockridge(IsoReadImageFeatures *f); 01973 01974 /** 01975 * Whether Joliet extensions are present in the image imported. 01976 * 01977 * @since 0.6.2 01978 */ 01979 int iso_read_image_features_has_joliet(IsoReadImageFeatures *f); 01980 01981 /** 01982 * Whether the image is recorded according to ISO 9660:1999, i.e. it has 01983 * a version 2 Enhanced Volume Descriptor. 01984 * 01985 * @since 0.6.2 01986 */ 01987 int iso_read_image_features_has_iso1999(IsoReadImageFeatures *f); 01988 01989 /** 01990 * Whether El-Torito boot record is present present in the image imported. 01991 * 01992 * @since 0.6.2 01993 */ 01994 int iso_read_image_features_has_eltorito(IsoReadImageFeatures *f); 01995 01996 /** 01997 * Increments the reference counting of the given image. 01998 * 01999 * @since 0.6.2 02000 */ 02001 void iso_image_ref(IsoImage *image); 02002 02003 /** 02004 * Decrements the reference couting of the given image. 02005 * If it reaches 0, the image is free, together with its tree nodes (whether 02006 * their refcount reach 0 too, of course). 02007 * 02008 * @since 0.6.2 02009 */ 02010 void iso_image_unref(IsoImage *image); 02011 02012 /** 02013 * Attach user defined data to the image. Use this if your application needs 02014 * to store addition info together with the IsoImage. If the image already 02015 * has data attached, the old data will be freed. 02016 * 02017 * @param data 02018 * Pointer to application defined data that will be attached to the 02019 * image. You can pass NULL to remove any already attached data. 02020 * @param give_up 02021 * Function that will be called when the image does not need the data 02022 * any more. It receives the data pointer as an argumente, and eventually 02023 * causes data to be freed. It can be NULL if you don't need it. 02024 * @return 02025 * 1 on succes, < 0 on error 02026 * 02027 * @since 0.6.2 02028 */ 02029 int iso_image_attach_data(IsoImage *image, void *data, void (*give_up)(void*)); 02030 02031 /** 02032 * The the data previously attached with iso_image_attach_data() 02033 * 02034 * @since 0.6.2 02035 */ 02036 void *iso_image_get_attached_data(IsoImage *image); 02037 02038 /** 02039 * Get the root directory of the image. 02040 * No extra ref is added to it, so you musn't unref it. Use iso_node_ref() 02041 * if you want to get your own reference. 02042 * 02043 * @since 0.6.2 02044 */ 02045 IsoDir *iso_image_get_root(const IsoImage *image); 02046 02047 /** 02048 * Fill in the volset identifier for a image. 02049 * 02050 * @since 0.6.2 02051 */ 02052 void iso_image_set_volset_id(IsoImage *image, const char *volset_id); 02053 02054 /** 02055 * Get the volset identifier. 02056 * The returned string is owned by the image and should not be freed nor 02057 * changed. 02058 * 02059 * @since 0.6.2 02060 */ 02061 const char *iso_image_get_volset_id(const IsoImage *image); 02062 02063 /** 02064 * Fill in the volume identifier for a image. 02065 * 02066 * @since 0.6.2 02067 */ 02068 void iso_image_set_volume_id(IsoImage *image, const char *volume_id); 02069 02070 /** 02071 * Get the volume identifier. 02072 * The returned string is owned by the image and should not be freed nor 02073 * changed. 02074 * 02075 * @since 0.6.2 02076 */ 02077 const char *iso_image_get_volume_id(const IsoImage *image); 02078 02079 /** 02080 * Fill in the publisher for a image. 02081 * 02082 * @since 0.6.2 02083 */ 02084 void iso_image_set_publisher_id(IsoImage *image, const char *publisher_id); 02085 02086 /** 02087 * Get the publisher of a image. 02088 * The returned string is owned by the image and should not be freed nor 02089 * changed. 02090 * 02091 * @since 0.6.2 02092 */ 02093 const char *iso_image_get_publisher_id(const IsoImage *image); 02094 02095 /** 02096 * Fill in the data preparer for a image. 02097 * 02098 * @since 0.6.2 02099 */ 02100 void iso_image_set_data_preparer_id(IsoImage *image, 02101 const char *data_preparer_id); 02102 02103 /** 02104 * Get the data preparer of a image. 02105 * The returned string is owned by the image and should not be freed nor 02106 * changed. 02107 * 02108 * @since 0.6.2 02109 */ 02110 const char *iso_image_get_data_preparer_id(const IsoImage *image); 02111 02112 /** 02113 * Fill in the system id for a image. Up to 32 characters. 02114 * 02115 * @since 0.6.2 02116 */ 02117 void iso_image_set_system_id(IsoImage *image, const char *system_id); 02118 02119 /** 02120 * Get the system id of a image. 02121 * The returned string is owned by the image and should not be freed nor 02122 * changed. 02123 * 02124 * @since 0.6.2 02125 */ 02126 const char *iso_image_get_system_id(const IsoImage *image); 02127 02128 /** 02129 * Fill in the application id for a image. Up to 128 chars. 02130 * 02131 * @since 0.6.2 02132 */ 02133 void iso_image_set_application_id(IsoImage *image, const char *application_id); 02134 02135 /** 02136 * Get the application id of a image. 02137 * The returned string is owned by the image and should not be freed nor 02138 * changed. 02139 * 02140 * @since 0.6.2 02141 */ 02142 const char *iso_image_get_application_id(const IsoImage *image); 02143 02144 /** 02145 * Fill copyright information for the image. Usually this refers 02146 * to a file on disc. Up to 37 characters. 02147 * 02148 * @since 0.6.2 02149 */ 02150 void iso_image_set_copyright_file_id(IsoImage *image, 02151 const char *copyright_file_id); 02152 02153 /** 02154 * Get the copyright information of a image. 02155 * The returned string is owned by the image and should not be freed nor 02156 * changed. 02157 * 02158 * @since 0.6.2 02159 */ 02160 const char *iso_image_get_copyright_file_id(const IsoImage *image); 02161 02162 /** 02163 * Fill abstract information for the image. Usually this refers 02164 * to a file on disc. Up to 37 characters. 02165 * 02166 * @since 0.6.2 02167 */ 02168 void iso_image_set_abstract_file_id(IsoImage *image, 02169 const char *abstract_file_id); 02170 02171 /** 02172 * Get the abstract information of a image. 02173 * The returned string is owned by the image and should not be freed nor 02174 * changed. 02175 * 02176 * @since 0.6.2 02177 */ 02178 const char *iso_image_get_abstract_file_id(const IsoImage *image); 02179 02180 /** 02181 * Fill biblio information for the image. Usually this refers 02182 * to a file on disc. Up to 37 characters. 02183 * 02184 * @since 0.6.2 02185 */ 02186 void iso_image_set_biblio_file_id(IsoImage *image, const char *biblio_file_id); 02187 02188 /** 02189 * Get the biblio information of a image. 02190 * The returned string is owned by the image and should not be freed nor 02191 * changed. 02192 * 02193 * @since 0.6.2 02194 */ 02195 const char *iso_image_get_biblio_file_id(const IsoImage *image); 02196 02197 /** 02198 * Create a bootable image by adding a El-Torito boot image. 02199 * 02200 * This also add a catalog boot node to the image filesystem tree. 02201 * 02202 * @param image 02203 * The image to make bootable. If it was already bootable this function 02204 * returns an error and the image remains unmodified. 02205 * @param image_path 02206 * The absolute path on the image tree of a regular file to use as 02207 * default boot image. 02208 * @param type 02209 * The boot media type. This can be one of 3 types: 02210 * - Floppy emulation: Boot image file must be exactly 02211 * 1200 kB, 1440 kB or 2880 kB. 02212 * - Hard disc emulation: The image must begin with a master 02213 * boot record with a single image. 02214 * - No emulation. You should specify load segment and load size 02215 * of image. 02216 * @param catalog_path 02217 * The absolute path in the image tree where the catalog will be stored. 02218 * The directory component of this path must be a directory existent on 02219 * the image tree, and the filename component must be unique among all 02220 * children of that directory on image. Otherwise a correspodent error 02221 * code will be returned. This function will add an IsoBoot node that acts 02222 * as a placeholder for the real catalog, that will be generated at image 02223 * creation time. 02224 * @param boot 02225 * Location where a pointer to the added boot image will be stored. That 02226 * object is owned by the IsoImage and should not be freed by the user, 02227 * nor dereferenced once the last reference to the IsoImage was disposed 02228 * via iso_image_unref(). A NULL value is allowed if you don't need a 02229 * reference to the boot image. 02230 * @return 02231 * 1 on success, < 0 on error 02232 * 02233 * @since 0.6.2 02234 */ 02235 int iso_image_set_boot_image(IsoImage *image, const char *image_path, 02236 enum eltorito_boot_media_type type, 02237 const char *catalog_path, 02238 ElToritoBootImage **boot); 02239 02240 /* TODO #00026 : add support for "hidden" bootable images. */ 02241 02242 /** 02243 * Get El-Torito boot image of an ISO image, if any. 02244 * 02245 * This can be useful, for example, to check if a volume read from a previous 02246 * session or an existing image is bootable. It can also be useful to get 02247 * the image and catalog tree nodes. An application would want those, for 02248 * example, to prevent the user removing it. 02249 * 02250 * Both nodes are owned by libisofs and should not be freed. You can get your 02251 * own ref with iso_node_ref(). You can can also check if the node is already 02252 * on the tree by getting its parent (note that when reading El-Torito info 02253 * from a previous image, the nodes might not be on the tree even if you haven't 02254 * removed them). Remember that you'll need to get a new ref 02255 * (with iso_node_ref()) before inserting them again to the tree, and probably 02256 * you will also need to set the name or permissions. 02257 * 02258 * @param image 02259 * The image from which to get the boot image. 02260 * @param boot 02261 * If not NULL, it will be filled with a pointer to the boot image, if 02262 * any. That object is owned by the IsoImage and should not be freed by 02263 * the user, nor dereferenced once the last reference to the IsoImage was 02264 * disposed via iso_image_unref(). 02265 * @param imgnode 02266 * When not NULL, it will be filled with the image tree node. No extra ref 02267 * is added, you can use iso_node_ref() to get one if you need it. 02268 * @param catnode 02269 * When not NULL, it will be filled with the catnode tree node. No extra 02270 * ref is added, you can use iso_node_ref() to get one if you need it. 02271 * @return 02272 * 1 on success, 0 is the image is not bootable (i.e., it has no El-Torito 02273 * image), < 0 error. 02274 * 02275 * @since 0.6.2 02276 */ 02277 int iso_image_get_boot_image(IsoImage *image, ElToritoBootImage **boot, 02278 IsoFile **imgnode, IsoBoot **catnode); 02279 02280 /** 02281 * Removes the El-Torito bootable image. 02282 * 02283 * The IsoBoot node that acts as placeholder for the catalog is also removed 02284 * for the image tree, if there. 02285 * If the image is not bootable (don't have el-torito boot image) this function 02286 * just returns. 02287 * 02288 * @since 0.6.2 02289 */ 02290 void iso_image_remove_boot_image(IsoImage *image); 02291 02292 /** 02293 * Sets the load segment for the initial boot image. This is only for 02294 * no emulation boot images, and is a NOP for other image types. 02295 * 02296 * @since 0.6.2 02297 */ 02298 void el_torito_set_load_seg(ElToritoBootImage *bootimg, short segment); 02299 02300 /** 02301 * Sets the number of sectors (512b) to be load at load segment during 02302 * the initial boot procedure. This is only for 02303 * no emulation boot images, and is a NOP for other image types. 02304 * 02305 * @since 0.6.2 02306 */ 02307 void el_torito_set_load_size(ElToritoBootImage *bootimg, short sectors); 02308 02309 /** 02310 * Marks the specified boot image as not bootable 02311 * 02312 * @since 0.6.2 02313 */ 02314 void el_torito_set_no_bootable(ElToritoBootImage *bootimg); 02315 02316 /** 02317 * Specifies that this image needs to be patched. This involves the writing 02318 * of a 56 bytes boot information table at offset 8 of the boot image file. 02319 * The original boot image file won't be modified. 02320 * This is needed for isolinux boot images. 02321 * 02322 * @since 0.6.2 02323 * @deprecated Use el_torito_set_isolinux_options() instead 02324 */ 02325 void el_torito_patch_isolinux_image(ElToritoBootImage *bootimg); 02326 02327 /** 02328 * Specifies options for IsoLinux boot images. This should only be used with 02329 * isolinux boot images. 02330 * 02331 * @param options 02332 * bitmask style flag. The following values are defined: 02333 * 02334 * bit 0 -> 1 to patch the image, 0 to not 02335 * Patching the image involves the writing of a 56 bytes 02336 * boot information table at offset 8 of the boot image file. 02337 * The original boot image file will not be modified. This is 02338 * needed to allow isolinux images to be bootable. 02339 * bit 1 -> 1 to generate an hybrid image with MBR, 0 to not 02340 * An hybrid image is a boot image that boots from either 02341 * CD/DVD media or from disk-like media, e.g. USB stick. 02342 * For that you need isolinux.bin from SYSLINUX 3.72 or later. 02343 * IMPORTANT: The application has to take care that the image 02344 * on media gets padded up to the next full MB. 02345 * @param flag 02346 * Reserved for future usage, set to 0. 02347 * @return 02348 * 1 success, < 0 on error 02349 * @since 0.6.12 02350 */ 02351 int el_torito_set_isolinux_options(ElToritoBootImage *bootimg, int options, int flag); 02352 02353 /** 02354 * Increments the reference counting of the given node. 02355 * 02356 * @since 0.6.2 02357 */ 02358 void iso_node_ref(IsoNode *node); 02359 02360 /** 02361 * Decrements the reference couting of the given node. 02362 * If it reach 0, the node is free, and, if the node is a directory, 02363 * its children will be unref() too. 02364 * 02365 * @since 0.6.2 02366 */ 02367 void iso_node_unref(IsoNode *node); 02368 02369 /** 02370 * Get the type of an IsoNode. 02371 * 02372 * @since 0.6.2 02373 */ 02374 enum IsoNodeType iso_node_get_type(IsoNode *node); 02375 02376 /** 02377 * Function to handle particular extended information. The function 02378 * pointer acts as an identifier for the type of the information. Structs 02379 * with same information type must use the same function. 02380 * 02381 * @param data 02382 * Attached data 02383 * @param flag 02384 * What to do with the data. At this time the following values are 02385 * defined: 02386 * -> 1 the data must be freed 02387 * @return 02388 * 1 in any case. 02389 * 02390 * @since 0.6.4 02391 */ 02392 typedef int (*iso_node_xinfo_func)(void *data, int flag); 02393 02394 /** 02395 * Add extended information to the given node. Extended info allows 02396 * applications (and libisofs itself) to add more information to an IsoNode. 02397 * You can use this facilities to associate temporary information with a given 02398 * node. This information is not written into the ISO 9660 image on media 02399 * and thus does not persist longer than the node memory object. 02400 * 02401 * Each node keeps a list of added extended info, meaning you can add several 02402 * extended info data to each node. Each extended info you add is identified 02403 * by the proc parameter, a pointer to a function that knows how to manage 02404 * the external info data. Thus, in order to add several types of extended 02405 * info, you need to define a "proc" function for each type. 02406 * 02407 * @param node 02408 * The node where to add the extended info 02409 * @param proc 02410 * A function pointer used to identify the type of the data, and that 02411 * knows how to manage it 02412 * @param data 02413 * Extended info to add. 02414 * @return 02415 * 1 if success, 0 if the given node already has extended info of the 02416 * type defined by the "proc" function, < 0 on error 02417 * 02418 * @since 0.6.4 02419 */ 02420 int iso_node_add_xinfo(IsoNode *node, iso_node_xinfo_func proc, void *data); 02421 02422 /** 02423 * Remove the given extended info (defined by the proc function) from the 02424 * given node. 02425 * 02426 * @return 02427 * 1 on success, 0 if node does not have extended info of the requested 02428 * type, < 0 on error 02429 * 02430 * @since 0.6.4 02431 */ 02432 int iso_node_remove_xinfo(IsoNode *node, iso_node_xinfo_func proc); 02433 02434 /** 02435 * Get the given extended info (defined by the proc function) from the 02436 * given node. 02437 * 02438 * @param data 02439 * Will be filled with the extended info corresponding to the given proc 02440 * function 02441 * @return 02442 * 1 on success, 0 if node does not have extended info of the requested 02443 * type, < 0 on error 02444 * 02445 * @since 0.6.4 02446 */ 02447 int iso_node_get_xinfo(IsoNode *node, iso_node_xinfo_func proc, void **data); 02448 02449 /** 02450 * Set the name of a node. Note that if the node is already added to a dir 02451 * this can fail if dir already contains a node with the new name. 02452 * 02453 * @param node 02454 * The node whose name you want to change. Note that you can't change 02455 * the name of the root. 02456 * @param name 02457 * The name for the node. If you supply an empty string or a 02458 * name greater than 255 characters this returns with failure, and 02459 * node name is not modified. 02460 * @return 02461 * 1 on success, < 0 on error 02462 * 02463 * @since 0.6.2 02464 */ 02465 int iso_node_set_name(IsoNode *node, const char *name); 02466 02467 /** 02468 * Get the name of a node. 02469 * The returned string belongs to the node and should not be modified nor 02470 * freed. Use strdup if you really need your own copy. 02471 * 02472 * @since 0.6.2 02473 */ 02474 const char *iso_node_get_name(const IsoNode *node); 02475 02476 /** 02477 * Set the permissions for the node. This attribute is only useful when 02478 * Rock Ridge extensions are enabled. 02479 * 02480 * @param mode 02481 * bitmask with the permissions of the node, as specified in 'man 2 stat'. 02482 * The file type bitfields will be ignored, only file permissions will be 02483 * modified. 02484 * 02485 * @since 0.6.2 02486 */ 02487 void iso_node_set_permissions(IsoNode *node, mode_t mode); 02488 02489 /** 02490 * Get the permissions for the node 02491 * 02492 * @since 0.6.2 02493 */ 02494 mode_t iso_node_get_permissions(const IsoNode *node); 02495 02496 /** 02497 * Get the mode of the node, both permissions and file type, as specified in 02498 * 'man 2 stat'. 02499 * 02500 * @since 0.6.2 02501 */ 02502 mode_t iso_node_get_mode(const IsoNode *node); 02503 02504 /** 02505 * Set the user id for the node. This attribute is only useful when 02506 * Rock Ridge extensions are enabled. 02507 * 02508 * @since 0.6.2 02509 */ 02510 void iso_node_set_uid(IsoNode *node, uid_t uid); 02511 02512 /** 02513 * Get the user id of the node. 02514 * 02515 * @since 0.6.2 02516 */ 02517 uid_t iso_node_get_uid(const IsoNode *node); 02518 02519 /** 02520 * Set the group id for the node. This attribute is only useful when 02521 * Rock Ridge extensions are enabled. 02522 * 02523 * @since 0.6.2 02524 */ 02525 void iso_node_set_gid(IsoNode *node, gid_t gid); 02526 02527 /** 02528 * Get the group id of the node. 02529 * 02530 * @since 0.6.2 02531 */ 02532 gid_t iso_node_get_gid(const IsoNode *node); 02533 02534 /** 02535 * Set the time of last modification of the file 02536 * 02537 * @since 0.6.2 02538 */ 02539 void iso_node_set_mtime(IsoNode *node, time_t time); 02540 02541 /** 02542 * Get the time of last modification of the file 02543 * 02544 * @since 0.6.2 02545 */ 02546 time_t iso_node_get_mtime(const IsoNode *node); 02547 02548 /** 02549 * Set the time of last access to the file 02550 * 02551 * @since 0.6.2 02552 */ 02553 void iso_node_set_atime(IsoNode *node, time_t time); 02554 02555 /** 02556 * Get the time of last access to the file 02557 * 02558 * @since 0.6.2 02559 */ 02560 time_t iso_node_get_atime(const IsoNode *node); 02561 02562 /** 02563 * Set the time of last status change of the file 02564 * 02565 * @since 0.6.2 02566 */ 02567 void iso_node_set_ctime(IsoNode *node, time_t time); 02568 02569 /** 02570 * Get the time of last status change of the file 02571 * 02572 * @since 0.6.2 02573 */ 02574 time_t iso_node_get_ctime(const IsoNode *node); 02575 02576 /** 02577 * Set if the node will be hidden in RR/ISO tree, Joliet tree or both. 02578 * 02579 * If the file is set as hidden in one tree, it won't be included there, so 02580 * it won't be visible in a OS accessing CD using that tree. For example, 02581 * GNU/Linux systems access to Rock Ridge / ISO9960 tree in order to see 02582 * what is recorded on CD, while MS Windows make use of the Joliet tree. If a 02583 * file is hidden only in Joliet, it won't be visible in Windows systems, 02584 * while still visible in Linux. 02585 * 02586 * If a file is hidden in both trees, it won't be written to image. 02587 * 02588 * @param node 02589 * The node that is to be hidden. 02590 * @param hide_attrs 02591 * IsoHideNodeFlag's to set the trees in which file will be hidden. 02592 * 02593 * @since 0.6.2 02594 */ 02595 void iso_node_set_hidden(IsoNode *node, int hide_attrs); 02596 02597 /** 02598 * Compare two nodes whether they are based on the same input and 02599 * can be considered as hardlinks to the same file objects. 02600 * 02601 * @param n1 02602 * The first node to compare. 02603 * @param n2 02604 * The second node to compare. 02605 * @return 02606 * -1 if s1 is smaller s2 , 0 if s1 matches s2 , 1 if s1 is larger s2 02607 * @param flag 02608 * Bitfield for control purposes, unused yet, submit 0 02609 * @since 0.6.20 02610 */ 02611 int iso_node_cmp_ino(IsoNode *n1, IsoNode *n2, int flag); 02612 02613 /** 02614 * Add a new node to a dir. Note that this function don't add a new ref to 02615 * the node, so you don't need to free it, it will be automatically freed 02616 * when the dir is deleted. Of course, if you want to keep using the node 02617 * after the dir life, you need to iso_node_ref() it. 02618 * 02619 * @param dir 02620 * the dir where to add the node 02621 * @param child 02622 * the node to add. You must ensure that the node hasn't previously added 02623 * to other dir, and that the node name is unique inside the child. 02624 * Otherwise this function will return a failure, and the child won't be 02625 * inserted. 02626 * @param replace 02627 * if the dir already contains a node with the same name, whether to 02628 * replace or not the old node with this. 02629 * @return 02630 * number of nodes in dir if succes, < 0 otherwise 02631 * Possible errors: 02632 * ISO_NULL_POINTER, if dir or child are NULL 02633 * ISO_NODE_ALREADY_ADDED, if child is already added to other dir 02634 * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists 02635 * ISO_WRONG_ARG_VALUE, if child == dir, or replace != (0,1) 02636 * 02637 * @since 0.6.2 02638 */ 02639 int iso_dir_add_node(IsoDir *dir, IsoNode *child, 02640 enum iso_replace_mode replace); 02641 02642 /** 02643 * Locate a node inside a given dir. 02644 * 02645 * @param dir 02646 * The dir where to look for the node. 02647 * @param name 02648 * The name of the node 02649 * @param node 02650 * Location for a pointer to the node, it will filled with NULL if the dir 02651 * doesn't have a child with the given name. 02652 * The node will be owned by the dir and shouldn't be unref(). Just call 02653 * iso_node_ref() to get your own reference to the node. 02654 * Note that you can pass NULL is the only thing you want to do is check 02655 * if a node with such name already exists on dir. 02656 * @return 02657 * 1 node found, 0 child has no such node, < 0 error 02658 * Possible errors: 02659 * ISO_NULL_POINTER, if dir or name are NULL 02660 * 02661 * @since 0.6.2 02662 */ 02663 int iso_dir_get_node(IsoDir *dir, const char *name, IsoNode **node); 02664 02665 /** 02666 * Get the number of children of a directory. 02667 * 02668 * @return 02669 * >= 0 number of items, < 0 error 02670 * Possible errors: 02671 * ISO_NULL_POINTER, if dir is NULL 02672 * 02673 * @since 0.6.2 02674 */ 02675 int iso_dir_get_children_count(IsoDir *dir); 02676 02677 /** 02678 * Removes a child from a directory. 02679 * The child is not freed, so you will become the owner of the node. Later 02680 * you can add the node to another dir (calling iso_dir_add_node), or free 02681 * it if you don't need it (with iso_node_unref). 02682 * 02683 * @return 02684 * 1 on success, < 0 error 02685 * Possible errors: 02686 * ISO_NULL_POINTER, if node is NULL 02687 * ISO_NODE_NOT_ADDED_TO_DIR, if node doesn't belong to a dir 02688 * 02689 * @since 0.6.2 02690 */ 02691 int iso_node_take(IsoNode *node); 02692 02693 /** 02694 * Removes a child from a directory and free (unref) it. 02695 * If you want to keep the child alive, you need to iso_node_ref() it 02696 * before this call, but in that case iso_node_take() is a better 02697 * alternative. 02698 * 02699 * @return 02700 * 1 on success, < 0 error 02701 * 02702 * @since 0.6.2 02703 */ 02704 int iso_node_remove(IsoNode *node); 02705 02706 /* 02707 * Get the parent of the given iso tree node. No extra ref is added to the 02708 * returned directory, you must take your ref. with iso_node_ref() if you 02709 * need it. 02710 * 02711 * If node is the root node, the same node will be returned as its parent. 02712 * 02713 * This returns NULL if the node doesn't pertain to any tree 02714 * (it was removed/taken). 02715 * 02716 * @since 0.6.2 02717 */ 02718 IsoDir *iso_node_get_parent(IsoNode *node); 02719 02720 /** 02721 * Get an iterator for the children of the given dir. 02722 * 02723 * You can iterate over the children with iso_dir_iter_next. When finished, 02724 * you should free the iterator with iso_dir_iter_free. 02725 * You musn't delete a child of the same dir, using iso_node_take() or 02726 * iso_node_remove(), while you're using the iterator. You can use 02727 * iso_dir_iter_take() or iso_dir_iter_remove() instead. 02728 * 02729 * You can use the iterator in the way like this 02730 * 02731 * IsoDirIter *iter; 02732 * IsoNode *node; 02733 * if ( iso_dir_get_children(dir, &iter) != 1 ) { 02734 * // handle error 02735 * } 02736 * while ( iso_dir_iter_next(iter, &node) == 1 ) { 02737 * // do something with the child 02738 * } 02739 * iso_dir_iter_free(iter); 02740 * 02741 * An iterator is intended to be used in a single iteration over the 02742 * children of a dir. Thus, it should be treated as a temporary object, 02743 * and free as soon as possible. 02744 * 02745 * @return 02746 * 1 success, < 0 error 02747 * Possible errors: 02748 * ISO_NULL_POINTER, if dir or iter are NULL 02749 * ISO_OUT_OF_MEM 02750 * 02751 * @since 0.6.2 02752 */ 02753 int iso_dir_get_children(const IsoDir *dir, IsoDirIter **iter); 02754 02755 /** 02756 * Get the next child. 02757 * Take care that the node is owned by its parent, and will be unref() when 02758 * the parent is freed. If you want your own ref to it, call iso_node_ref() 02759 * on it. 02760 * 02761 * @return 02762 * 1 success, 0 if dir has no more elements, < 0 error 02763 * Possible errors: 02764 * ISO_NULL_POINTER, if node or iter are NULL 02765 * ISO_ERROR, on wrong iter usage, usual caused by modiying the 02766 * dir during iteration 02767 * 02768 * @since 0.6.2 02769 */ 02770 int iso_dir_iter_next(IsoDirIter *iter, IsoNode **node); 02771 02772 /** 02773 * Check if there're more children. 02774 * 02775 * @return 02776 * 1 dir has more elements, 0 no, < 0 error 02777 * Possible errors: 02778 * ISO_NULL_POINTER, if iter is NULL 02779 * 02780 * @since 0.6.2 02781 */ 02782 int iso_dir_iter_has_next(IsoDirIter *iter); 02783 02784 /** 02785 * Free a dir iterator. 02786 * 02787 * @since 0.6.2 02788 */ 02789 void iso_dir_iter_free(IsoDirIter *iter); 02790 02791 /** 02792 * Removes a child from a directory during an iteration, without freeing it. 02793 * It's like iso_node_take(), but to be used during a directory iteration. 02794 * The node removed will be the last returned by the iteration. 02795 * 02796 * If you call this function twice without calling iso_dir_iter_next between 02797 * them is not allowed and you will get an ISO_ERROR in second call. 02798 * 02799 * @return 02800 * 1 on succes, < 0 error 02801 * Possible errors: 02802 * ISO_NULL_POINTER, if iter is NULL 02803 * ISO_ERROR, on wrong iter usage, for example by call this before 02804 * iso_dir_iter_next. 02805 * 02806 * @since 0.6.2 02807 */ 02808 int iso_dir_iter_take(IsoDirIter *iter); 02809 02810 /** 02811 * Removes a child from a directory during an iteration and unref() it. 02812 * It's like iso_node_remove(), but to be used during a directory iteration. 02813 * The node removed will be the last returned by the iteration. 02814 * 02815 * If you call this function twice without calling iso_dir_iter_next between 02816 * them is not allowed and you will get an ISO_ERROR in second call. 02817 * 02818 * @return 02819 * 1 on succes, < 0 error 02820 * Possible errors: 02821 * ISO_NULL_POINTER, if iter is NULL 02822 * ISO_ERROR, on wrong iter usage, for example by call this before 02823 * iso_dir_iter_next. 02824 * 02825 * @since 0.6.2 02826 */ 02827 int iso_dir_iter_remove(IsoDirIter *iter); 02828 02829 02830 /** 02831 * @since 0.6.4 02832 */ 02833 typedef struct iso_find_condition IsoFindCondition; 02834 02835 /** 02836 * Create a new condition that checks if the node name matches the given 02837 * wildcard. 02838 * 02839 * @param wildcard 02840 * @result 02841 * The created IsoFindCondition, NULL on error. 02842 * 02843 * @since 0.6.4 02844 */ 02845 IsoFindCondition *iso_new_find_conditions_name(const char *wildcard); 02846 02847 /** 02848 * Create a new condition that checks the node mode against a mode mask. It 02849 * can be used to check both file type and permissions. 02850 * 02851 * For example: 02852 * 02853 * iso_new_find_conditions_mode(S_IFREG) : search for regular files 02854 * iso_new_find_conditions_mode(S_IFCHR | S_IWUSR) : search for character 02855 * devices where owner has write permissions. 02856 * 02857 * @param mask 02858 * Mode mask to AND against node mode. 02859 * @result 02860 * The created IsoFindCondition, NULL on error. 02861 * 02862 * @since 0.6.4 02863 */ 02864 IsoFindCondition *iso_new_find_conditions_mode(mode_t mask); 02865 02866 /** 02867 * Create a new condition that checks the node gid. 02868 * 02869 * @param gid 02870 * Desired Group Id. 02871 * @result 02872 * The created IsoFindCondition, NULL on error. 02873 * 02874 * @since 0.6.4 02875 */ 02876 IsoFindCondition *iso_new_find_conditions_gid(gid_t gid); 02877 02878 /** 02879 * Create a new condition that checks the node uid. 02880 * 02881 * @param uid 02882 * Desired User Id. 02883 * @result 02884 * The created IsoFindCondition, NULL on error. 02885 * 02886 * @since 0.6.4 02887 */ 02888 IsoFindCondition *iso_new_find_conditions_uid(uid_t uid); 02889 02890 /** 02891 * Possible comparison between IsoNode and given conditions. 02892 * 02893 * @since 0.6.4 02894 */ 02895 enum iso_find_comparisons { 02896 ISO_FIND_COND_GREATER, 02897 ISO_FIND_COND_GREATER_OR_EQUAL, 02898 ISO_FIND_COND_EQUAL, 02899 ISO_FIND_COND_LESS, 02900 ISO_FIND_COND_LESS_OR_EQUAL 02901 }; 02902 02903 /** 02904 * Create a new condition that checks the time of last access. 02905 * 02906 * @param time 02907 * Time to compare against IsoNode atime. 02908 * @param comparison 02909 * Comparison to be done between IsoNode atime and submitted time. 02910 * Note that ISO_FIND_COND_GREATER, for example, is true if the node 02911 * time is greater than the submitted time. 02912 * @result 02913 * The created IsoFindCondition, NULL on error. 02914 * 02915 * @since 0.6.4 02916 */ 02917 IsoFindCondition *iso_new_find_conditions_atime(time_t time, 02918 enum iso_find_comparisons comparison); 02919 02920 /** 02921 * Create a new condition that checks the time of last modification. 02922 * 02923 * @param time 02924 * Time to compare against IsoNode mtime. 02925 * @param comparison 02926 * Comparison to be done between IsoNode mtime and submitted time. 02927 * Note that ISO_FIND_COND_GREATER, for example, is true if the node 02928 * time is greater than the submitted time. 02929 * @result 02930 * The created IsoFindCondition, NULL on error. 02931 * 02932 * @since 0.6.4 02933 */ 02934 IsoFindCondition *iso_new_find_conditions_mtime(time_t time, 02935 enum iso_find_comparisons comparison); 02936 02937 /** 02938 * Create a new condition that checks the time of last status change. 02939 * 02940 * @param time 02941 * Time to compare against IsoNode ctime. 02942 * @param comparison 02943 * Comparison to be done between IsoNode ctime and submitted time. 02944 * Note that ISO_FIND_COND_GREATER, for example, is true if the node 02945 * time is greater than the submitted time. 02946 * @result 02947 * The created IsoFindCondition, NULL on error. 02948 * 02949 * @since 0.6.4 02950 */ 02951 IsoFindCondition *iso_new_find_conditions_ctime(time_t time, 02952 enum iso_find_comparisons comparison); 02953 02954 /** 02955 * Create a new condition that check if the two given conditions are 02956 * valid. 02957 * 02958 * @param a 02959 * @param b 02960 * IsoFindCondition to compare 02961 * @result 02962 * The created IsoFindCondition, NULL on error. 02963 * 02964 * @since 0.6.4 02965 */ 02966 IsoFindCondition *iso_new_find_conditions_and(IsoFindCondition *a, 02967 IsoFindCondition *b); 02968 02969 /** 02970 * Create a new condition that check if at least one the two given conditions 02971 * is valid. 02972 * 02973 * @param a 02974 * @param b 02975 * IsoFindCondition to compare 02976 * @result 02977 * The created IsoFindCondition, NULL on error. 02978 * 02979 * @since 0.6.4 02980 */ 02981 IsoFindCondition *iso_new_find_conditions_or(IsoFindCondition *a, 02982 IsoFindCondition *b); 02983 02984 /** 02985 * Create a new condition that check if the given conditions is false. 02986 * 02987 * @param negate 02988 * @result 02989 * The created IsoFindCondition, NULL on error. 02990 * 02991 * @since 0.6.4 02992 */ 02993 IsoFindCondition *iso_new_find_conditions_not(IsoFindCondition *negate); 02994 02995 /** 02996 * Find all directory children that match the given condition. 02997 * 02998 * @param dir 02999 * Directory where we will search children. 03000 * @param cond 03001 * Condition that the children must match in order to be returned. 03002 * It will be free together with the iterator. Remember to delete it 03003 * if this function return error. 03004 * @param iter 03005 * Iterator that returns only the children that match condition. 03006 * @return 03007 * 1 on success, < 0 on error 03008 * 03009 * @since 0.6.4 03010 */ 03011 int iso_dir_find_children(IsoDir* dir, IsoFindCondition *cond, 03012 IsoDirIter **iter); 03013 03014 /** 03015 * Get the destination of a node. 03016 * The returned string belongs to the node and should not be modified nor 03017 * freed. Use strdup if you really need your own copy. 03018 * 03019 * @since 0.6.2 03020 */ 03021 const char *iso_symlink_get_dest(const IsoSymlink *link); 03022 03023 /** 03024 * Set the destination of a link. 03025 * 03026 * @param dest 03027 * New destination for the link. It must be a non-empty string, otherwise 03028 * this function doesn't modify previous destination. 03029 * @return 03030 * 1 on success, < 0 on error 03031 * 03032 * @since 0.6.2 03033 */ 03034 int iso_symlink_set_dest(IsoSymlink *link, const char *dest); 03035 03036 /** 03037 * Sets the order in which a node will be written on image. High weihted files 03038 * will be written first, so in a disc them will be written near the center. 03039 * 03040 * @param node 03041 * The node which weight will be changed. If it's a dir, this function 03042 * will change the weight of all its children. For nodes other that dirs 03043 * or regular files, this function has no effect. 03044 * @param w 03045 * The weight as a integer number, the greater this value is, the 03046 * closer from the begining of image the file will be written. 03047 * 03048 * @since 0.6.2 03049 */ 03050 void iso_node_set_sort_weight(IsoNode *node, int w); 03051 03052 /** 03053 * Get the sort weight of a file. 03054 * 03055 * @since 0.6.2 03056 */ 03057 int iso_file_get_sort_weight(IsoFile *file); 03058 03059 /** 03060 * Get the size of the file, in bytes 03061 * 03062 * @since 0.6.2 03063 */ 03064 off_t iso_file_get_size(IsoFile *file); 03065 03066 /** 03067 * Get the device id (major/minor numbers) of the given block or 03068 * character device file. The result is undefined for other kind 03069 * of special files, of first be sure iso_node_get_mode() returns either 03070 * S_IFBLK or S_IFCHR. 03071 * 03072 * @since 0.6.6 03073 */ 03074 dev_t iso_special_get_dev(IsoSpecial *special); 03075 03076 /** 03077 * Get the IsoStream that represents the contents of the given IsoFile. 03078 * The stream may be a filter stream which itself get its input from a 03079 * further stream. This may be inquired by iso_stream_get_input_stream(). 03080 * 03081 * If you iso_stream_open() the stream, iso_stream_close() it before 03082 * image generation begins. 03083 * 03084 * @return 03085 * The IsoStream. No extra ref is added, so the IsoStream belongs to the 03086 * IsoFile, and it may be freed together with it. Add your own ref with 03087 * iso_stream_ref() if you need it. 03088 * 03089 * @since 0.6.4 03090 */ 03091 IsoStream *iso_file_get_stream(IsoFile *file); 03092 03093 /** 03094 * Get the block lba of a file node, if it was imported from an old image. 03095 * 03096 * @param file 03097 * The file 03098 * @param lba 03099 * Will be filled with the kba 03100 * @param flag 03101 * Reserved for future usage, submit 0 03102 * @return 03103 * 1 if lba is valid (file comes from old image), 0 if file was newly 03104 * added, i.e. it does not come from an old image, < 0 error 03105 * 03106 * @since 0.6.4 03107 * 03108 * @deprecated Use iso_file_get_old_image_sections(), as this function does 03109 * not work with multi-extend files. 03110 */ 03111 int iso_file_get_old_image_lba(IsoFile *file, uint32_t *lba, int flag); 03112 03113 /** 03114 * Get the start addresses and the sizes of the data extents of a file node 03115 * if it was imported from an old image. 03116 * 03117 * @param file 03118 * The file 03119 * @param section_count 03120 * Returns the number of extent entries in sections array. 03121 * @param sections 03122 * Returns the array of file sections. Apply free() to dispose it. 03123 * @param flag 03124 * Reserved for future usage, submit 0 03125 * @return 03126 * 1 if there are valid extents (file comes from old image), 03127 * 0 if file was newly added, i.e. it does not come from an old image, 03128 * < 0 error 03129 * 03130 * @since 0.6.8 03131 */ 03132 int iso_file_get_old_image_sections(IsoFile *file, int *section_count, 03133 struct iso_file_section **sections, 03134 int flag); 03135 03136 /* 03137 * Like iso_file_get_old_image_lba(), but take an IsoNode. 03138 * 03139 * @return 03140 * 1 if lba is valid (file comes from old image), 0 if file was newly 03141 * added, i.e. it does not come from an old image, 2 node type has no 03142 * LBA (no regular file), < 0 error 03143 * 03144 * @since 0.6.4 03145 */ 03146 int iso_node_get_old_image_lba(IsoNode *node, uint32_t *lba, int flag); 03147 03148 /** 03149 * Add a new directory to the iso tree. Permissions, owner and hidden atts 03150 * are taken from parent, you can modify them later. 03151 * 03152 * @param parent 03153 * the dir where the new directory will be created 03154 * @param name 03155 * name for the new dir. If a node with same name already exists on 03156 * parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE. 03157 * @param dir 03158 * place where to store a pointer to the newly created dir. No extra 03159 * ref is addded, so you will need to call iso_node_ref() if you really 03160 * need it. You can pass NULL in this parameter if you don't need the 03161 * pointer. 03162 * @return 03163 * number of nodes in parent if success, < 0 otherwise 03164 * Possible errors: 03165 * ISO_NULL_POINTER, if parent or name are NULL 03166 * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists 03167 * ISO_OUT_OF_MEM 03168 * 03169 * @since 0.6.2 03170 */ 03171 int iso_tree_add_new_dir(IsoDir *parent, const char *name, IsoDir **dir); 03172 03173 /** 03174 * Add a new regular file to the iso tree. Permissions are set to 0444, 03175 * owner and hidden atts are taken from parent. You can modify any of them 03176 * later. 03177 * 03178 * @param parent 03179 * the dir where the new file will be created 03180 * @param name 03181 * name for the new file. If a node with same name already exists on 03182 * parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE. 03183 * @param stream 03184 * IsoStream for the contents of the file. The reference will be taken 03185 * by the newly created file, you will need to take an extra ref to it 03186 * if you need it. 03187 * @param file 03188 * place where to store a pointer to the newly created file. No extra 03189 * ref is addded, so you will need to call iso_node_ref() if you really 03190 * need it. You can pass NULL in this parameter if you don't need the 03191 * pointer 03192 * @return 03193 * number of nodes in parent if success, < 0 otherwise 03194 * Possible errors: 03195 * ISO_NULL_POINTER, if parent, name or dest are NULL 03196 * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists 03197 * ISO_OUT_OF_MEM 03198 * 03199 * @since 0.6.4 03200 */ 03201 int iso_tree_add_new_file(IsoDir *parent, const char *name, IsoStream *stream, 03202 IsoFile **file); 03203 03204 /** 03205 * Add a new symlink to the directory tree. Permissions are set to 0777, 03206 * owner and hidden atts are taken from parent. You can modify any of them 03207 * later. 03208 * 03209 * @param parent 03210 * the dir where the new symlink will be created 03211 * @param name 03212 * name for the new symlink. If a node with same name already exists on 03213 * parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE. 03214 * @param dest 03215 * destination of the link 03216 * @param link 03217 * place where to store a pointer to the newly created link. No extra 03218 * ref is addded, so you will need to call iso_node_ref() if you really 03219 * need it. You can pass NULL in this parameter if you don't need the 03220 * pointer 03221 * @return 03222 * number of nodes in parent if success, < 0 otherwise 03223 * Possible errors: 03224 * ISO_NULL_POINTER, if parent, name or dest are NULL 03225 * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists 03226 * ISO_OUT_OF_MEM 03227 * 03228 * @since 0.6.2 03229 */ 03230 int iso_tree_add_new_symlink(IsoDir *parent, const char *name, 03231 const char *dest, IsoSymlink **link); 03232 03233 /** 03234 * Add a new special file to the directory tree. As far as libisofs concerns, 03235 * an special file is a block device, a character device, a FIFO (named pipe) 03236 * or a socket. You can choose the specific kind of file you want to add 03237 * by setting mode propertly (see man 2 stat). 03238 * 03239 * Note that special files are only written to image when Rock Ridge 03240 * extensions are enabled. Moreover, a special file is just a directory entry 03241 * in the image tree, no data is written beyond that. 03242 * 03243 * Owner and hidden atts are taken from parent. You can modify any of them 03244 * later. 03245 * 03246 * @param parent 03247 * the dir where the new special file will be created 03248 * @param name 03249 * name for the new special file. If a node with same name already exists 03250 * on parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE. 03251 * @param mode 03252 * file type and permissions for the new node. Note that you can't 03253 * specify any kind of file here, only special types are allowed. i.e, 03254 * S_IFSOCK, S_IFBLK, S_IFCHR and S_IFIFO are valid types; S_IFLNK, 03255 * S_IFREG and S_IFDIR aren't. 03256 * @param dev 03257 * device ID, equivalent to the st_rdev field in man 2 stat. 03258 * @param special 03259 * place where to store a pointer to the newly created special file. No 03260 * extra ref is addded, so you will need to call iso_node_ref() if you 03261 * really need it. You can pass NULL in this parameter if you don't need 03262 * the pointer. 03263 * @return 03264 * number of nodes in parent if success, < 0 otherwise 03265 * Possible errors: 03266 * ISO_NULL_POINTER, if parent, name or dest are NULL 03267 * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists 03268 * ISO_WRONG_ARG_VALUE if you select a incorrect mode 03269 * ISO_OUT_OF_MEM 03270 * 03271 * @since 0.6.2 03272 */ 03273 int iso_tree_add_new_special(IsoDir *parent, const char *name, mode_t mode, 03274 dev_t dev, IsoSpecial **special); 03275 03276 /** 03277 * Set whether to follow or not symbolic links when added a file from a source 03278 * to IsoImage. Default behavior is to not follow symlinks. 03279 * 03280 * @since 0.6.2 03281 */ 03282 void iso_tree_set_follow_symlinks(IsoImage *image, int follow); 03283 03284 /** 03285 * Get current setting for follow_symlinks. 03286 * 03287 * @see iso_tree_set_follow_symlinks 03288 * @since 0.6.2 03289 */ 03290 int iso_tree_get_follow_symlinks(IsoImage *image); 03291 03292 /** 03293 * Set whether to skip or not hidden files when adding a directory recursibely. 03294 * Default behavior is to not ignore them, i.e., to add hidden files to image. 03295 * 03296 * @since 0.6.2 03297 */ 03298 void iso_tree_set_ignore_hidden(IsoImage *image, int skip); 03299 03300 /** 03301 * Get current setting for ignore_hidden. 03302 * 03303 * @see iso_tree_set_ignore_hidden 03304 * @since 0.6.2 03305 */ 03306 int iso_tree_get_ignore_hidden(IsoImage *image); 03307 03308 /** 03309 * Set the replace mode, that defines the behavior of libisofs when adding 03310 * a node whit the same name that an existent one, during a recursive 03311 * directory addition. 03312 * 03313 * @since 0.6.2 03314 */ 03315 void iso_tree_set_replace_mode(IsoImage *image, enum iso_replace_mode mode); 03316 03317 /** 03318 * Get current setting for replace_mode. 03319 * 03320 * @see iso_tree_set_replace_mode 03321 * @since 0.6.2 03322 */ 03323 enum iso_replace_mode iso_tree_get_replace_mode(IsoImage *image); 03324 03325 /** 03326 * Set whether to skip or not special files. Default behavior is to not skip 03327 * them. Note that, despite of this setting, special files won't never be added 03328 * to an image unless RR extensions were enabled. 03329 * 03330 * @param skip 03331 * Bitmask to determine what kind of special files will be skipped: 03332 * bit0: ignore FIFOs 03333 * bit1: ignore Sockets 03334 * bit2: ignore char devices 03335 * bit3: ignore block devices 03336 * 03337 * @since 0.6.2 03338 */ 03339 void iso_tree_set_ignore_special(IsoImage *image, int skip); 03340 03341 /** 03342 * Get current setting for ignore_special. 03343 * 03344 * @see iso_tree_set_ignore_special 03345 * @since 0.6.2 03346 */ 03347 int iso_tree_get_ignore_special(IsoImage *image); 03348 03349 /** 03350 * Add a excluded path. These are paths that won't never added to image, and 03351 * will be excluded even when adding recursively its parent directory. 03352 * 03353 * For example, in 03354 * 03355 * iso_tree_add_exclude(image, "/home/user/data/private"); 03356 * iso_tree_add_dir_rec(image, root, "/home/user/data"); 03357 * 03358 * the directory /home/user/data/private won't be added to image. 03359 * 03360 * However, if you explicity add a deeper dir, it won't be excluded. i.e., 03361 * in the following example. 03362 * 03363 * iso_tree_add_exclude(image, "/home/user/data"); 03364 * iso_tree_add_dir_rec(image, root, "/home/user/data/private"); 03365 * 03366 * the directory /home/user/data/private is added. On the other, side, and 03367 * foollowing the the example above, 03368 * 03369 * iso_tree_add_dir_rec(image, root, "/home/user"); 03370 * 03371 * will exclude the directory "/home/user/data". 03372 * 03373 * Absolute paths are not mandatory, you can, for example, add a relative 03374 * path such as: 03375 * 03376 * iso_tree_add_exclude(image, "private"); 03377 * iso_tree_add_exclude(image, "user/data"); 03378 * 03379 * to excluve, respectively, all files or dirs named private, and also all 03380 * files or dirs named data that belong to a folder named "user". Not that the 03381 * above rule about deeper dirs is still valid. i.e., if you call 03382 * 03383 * iso_tree_add_dir_rec(image, root, "/home/user/data/music"); 03384 * 03385 * it is included even containing "user/data" string. However, a possible 03386 * "/home/user/data/music/user/data" is not added. 03387 * 03388 * Usual wildcards, such as * or ? are also supported, with the usual meaning 03389 * as stated in "man 7 glob". For example 03390 * 03391 * // to exclude backup text files 03392 * iso_tree_add_exclude(image, "*.~"); 03393 * 03394 * @return 03395 * 1 on success, < 0 on error 03396 * 03397 * @since 0.6.2 03398 */ 03399 int iso_tree_add_exclude(IsoImage *image, const char *path); 03400 03401 /** 03402 * Remove a previously added exclude. 03403 * 03404 * @see iso_tree_add_exclude 03405 * @return 03406 * 1 on success, 0 exclude do not exists, < 0 on error 03407 * 03408 * @since 0.6.2 03409 */ 03410 int iso_tree_remove_exclude(IsoImage *image, const char *path); 03411 03412 /** 03413 * Set a callback function that libisofs will call for each file that is 03414 * added to the given image by a recursive addition function. This includes 03415 * image import. 03416 * 03417 * @param report 03418 * pointer to a function that will be called just before a file will be 03419 * added to the image. You can control whether the file will be in fact 03420 * added or ignored. 03421 * This function should return 1 to add the file, 0 to ignore it and 03422 * continue, < 0 to abort the process 03423 * NULL is allowed if you don't want any callback. 03424 * 03425 * @since 0.6.2 03426 */ 03427 void iso_tree_set_report_callback(IsoImage *image, 03428 int (*report)(IsoImage*, IsoFileSource*)); 03429 03430 /** 03431 * Add a new node to the image tree, from an existing file. 03432 * 03433 * TODO comment Builder and Filesystem related issues when exposing both 03434 * 03435 * All attributes will be taken from the source file. The appropriate file 03436 * type will be created. 03437 * 03438 * @param image 03439 * The image 03440 * @param parent 03441 * The directory in the image tree where the node will be added. 03442 * @param path 03443 * The absolute path of the file in the local filesystem. 03444 * The node will have the same leaf name as the file on disk. 03445 * Its directory path depends on the parent node. 03446 * @param node 03447 * place where to store a pointer to the newly added file. No 03448 * extra ref is addded, so you will need to call iso_node_ref() if you 03449 * really need it. You can pass NULL in this parameter if you don't need 03450 * the pointer. 03451 * @return 03452 * number of nodes in parent if success, < 0 otherwise 03453 * Possible errors: 03454 * ISO_NULL_POINTER, if image, parent or path are NULL 03455 * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists 03456 * ISO_OUT_OF_MEM 03457 * 03458 * @since 0.6.2 03459 */ 03460 int iso_tree_add_node(IsoImage *image, IsoDir *parent, const char *path, 03461 IsoNode **node); 03462 03463 /** 03464 * This is a more versatile form of iso_tree_add_node which allows to set 03465 * the node name in ISO image already when it gets added. 03466 * 03467 * Add a new node to the image tree, from an existing file, and with the 03468 * given name, that must not exist on dir. 03469 * 03470 * @param image 03471 * The image 03472 * @param parent 03473 * The directory in the image tree where the node will be added. 03474 * @param name 03475 * The leaf name that the node will have on image. 03476 * Its directory path depends on the parent node. 03477 * @param path 03478 * The absolute path of the file in the local filesystem. 03479 * @param node 03480 * place where to store a pointer to the newly added file. No 03481 * extra ref is addded, so you will need to call iso_node_ref() if you 03482 * really need it. You can pass NULL in this parameter if you don't need 03483 * the pointer. 03484 * @return 03485 * number of nodes in parent if success, < 0 otherwise 03486 * Possible errors: 03487 * ISO_NULL_POINTER, if image, parent or path are NULL 03488 * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists 03489 * ISO_OUT_OF_MEM 03490 * 03491 * @since 0.6.4 03492 */ 03493 int iso_tree_add_new_node(IsoImage *image, IsoDir *parent, const char *name, 03494 const char *path, IsoNode **node); 03495 03496 /** 03497 * Add a new node to the image tree with the given name that must not exist 03498 * on dir. The node data content will be a byte interval out of the data 03499 * content of a file in the local filesystem. 03500 * 03501 * @param image 03502 * The image 03503 * @param parent 03504 * The directory in the image tree where the node will be added. 03505 * @param name 03506 * The leaf name that the node will have on image. 03507 * Its directory path depends on the parent node. 03508 * @param path 03509 * The absolute path of the file in the local filesystem. For now 03510 * only regular files and symlinks to regular files are supported. 03511 * @param offset 03512 * Byte number in the given file from where to start reading data. 03513 * @param size 03514 * Max size of the file. This may be more than actually available from 03515 * byte offset to the end of the file in the local filesystem. 03516 * @param node 03517 * place where to store a pointer to the newly added file. No 03518 * extra ref is addded, so you will need to call iso_node_ref() if you 03519 * really need it. You can pass NULL in this parameter if you don't need 03520 * the pointer. 03521 * @return 03522 * number of nodes in parent if success, < 0 otherwise 03523 * Possible errors: 03524 * ISO_NULL_POINTER, if image, parent or path are NULL 03525 * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists 03526 * ISO_OUT_OF_MEM 03527 * 03528 * @since 0.6.4 03529 */ 03530 int iso_tree_add_new_cut_out_node(IsoImage *image, IsoDir *parent, 03531 const char *name, const char *path, 03532 off_t offset, off_t size, 03533 IsoNode **node); 03534 03535 /** 03536 * Add the contents of a dir to a given directory of the iso tree. 03537 * 03538 * There are several options to control what files are added or how they are 03539 * managed. Take a look at iso_tree_set_* functions to see diferent options 03540 * for recursive directory addition. 03541 * 03542 * TODO comment Builder and Filesystem related issues when exposing both 03543 * 03544 * @param image 03545 * The image to which the directory belong. 03546 * @param parent 03547 * Directory on the image tree where to add the contents of the dir 03548 * @param dir 03549 * Path to a dir in the filesystem 03550 * @return 03551 * number of nodes in parent if success, < 0 otherwise 03552 * 03553 * @since 0.6.2 03554 */ 03555 int iso_tree_add_dir_rec(IsoImage *image, IsoDir *parent, const char *dir); 03556 03557 /** 03558 * Locate a node by its absolute path on image. 03559 * 03560 * @param node 03561 * Location for a pointer to the node, it will filled with NULL if the 03562 * given path does not exists on image. 03563 * The node will be owned by the image and shouldn't be unref(). Just call 03564 * iso_node_ref() to get your own reference to the node. 03565 * Note that you can pass NULL is the only thing you want to do is check 03566 * if a node with such path really exists. 03567 * @return 03568 * 1 found, 0 not found, < 0 error 03569 * 03570 * @since 0.6.2 03571 */ 03572 int iso_tree_path_to_node(IsoImage *image, const char *path, IsoNode **node); 03573 03574 /** 03575 * Get the absolute path on image of the given node. 03576 * 03577 * @return 03578 * The path on the image, that must be freed when no more needed. If the 03579 * given node is not added to any image, this returns NULL. 03580 * @since 0.6.4 03581 */ 03582 char *iso_tree_get_node_path(IsoNode *node); 03583 03584 /** 03585 * Increments the reference counting of the given IsoDataSource. 03586 * 03587 * @since 0.6.2 03588 */ 03589 void iso_data_source_ref(IsoDataSource *src); 03590 03591 /** 03592 * Decrements the reference counting of the given IsoDataSource, freeing it 03593 * if refcount reach 0. 03594 * 03595 * @since 0.6.2 03596 */ 03597 void iso_data_source_unref(IsoDataSource *src); 03598 03599 /** 03600 * Create a new IsoDataSource from a local file. This is suitable for 03601 * accessing regular files or block devices with ISO images. 03602 * 03603 * @param path 03604 * The absolute path of the file 03605 * @param src 03606 * Will be filled with the pointer to the newly created data source. 03607 * @return 03608 * 1 on success, < 0 on error. 03609 * 03610 * @since 0.6.2 03611 */ 03612 int iso_data_source_new_from_file(const char *path, IsoDataSource **src); 03613 03614 /** 03615 * Get the status of the buffer used by a burn_source. 03616 * 03617 * @param b 03618 * A burn_source previously obtained with 03619 * iso_image_create_burn_source(). 03620 * @param size 03621 * Will be filled with the total size of the buffer, in bytes 03622 * @param free_bytes 03623 * Will be filled with the bytes currently available in buffer 03624 * @return 03625 * < 0 error, > 0 state: 03626 * 1="active" : input and consumption are active 03627 * 2="ending" : input has ended without error 03628 * 3="failing" : input had error and ended, 03629 * 5="abandoned" : consumption has ended prematurely 03630 * 6="ended" : consumption has ended without input error 03631 * 7="aborted" : consumption has ended after input error 03632 * 03633 * @since 0.6.2 03634 */ 03635 int iso_ring_buffer_get_status(struct burn_source *b, size_t *size, 03636 size_t *free_bytes); 03637 03638 #define ISO_MSGS_MESSAGE_LEN 4096 03639 03640 /** 03641 * Control queueing and stderr printing of messages from libisofs. 03642 * Severity may be one of "NEVER", "FATAL", "SORRY", "WARNING", "HINT", 03643 * "NOTE", "UPDATE", "DEBUG", "ALL". 03644 * 03645 * @param queue_severity Gives the minimum limit for messages to be queued. 03646 * Default: "NEVER". If you queue messages then you 03647 * must consume them by iso_msgs_obtain(). 03648 * @param print_severity Does the same for messages to be printed directly 03649 * to stderr. 03650 * @param print_id A text prefix to be printed before the message. 03651 * @return >0 for success, <=0 for error 03652 * 03653 * @since 0.6.2 03654 */ 03655 int iso_set_msgs_severities(char *queue_severity, char *print_severity, 03656 char *print_id); 03657 03658 /** 03659 * Obtain the oldest pending libisofs message from the queue which has at 03660 * least the given minimum_severity. This message and any older message of 03661 * lower severity will get discarded from the queue and is then lost forever. 03662 * 03663 * Severity may be one of "NEVER", "FATAL", "SORRY", "WARNING", "HINT", 03664 * "NOTE", "UPDATE", "DEBUG", "ALL". To call with minimum_severity "NEVER" 03665 * will discard the whole queue. 03666 * 03667 * @param error_code 03668 * Will become a unique error code as listed at the end of this header 03669 * @param imgid 03670 * Id of the image that was issued the message. 03671 * @param msg_text 03672 * Must provide at least ISO_MSGS_MESSAGE_LEN bytes. 03673 * @param severity 03674 * Will become the severity related to the message and should provide at 03675 * least 80 bytes. 03676 * @return 03677 * 1 if a matching item was found, 0 if not, <0 for severe errors 03678 * 03679 * @since 0.6.2 03680 */ 03681 int iso_obtain_msgs(char *minimum_severity, int *error_code, int *imgid, 03682 char msg_text[], char severity[]); 03683 03684 03685 /** 03686 * Submit a message to the libisofs queueing system. It will be queued or 03687 * printed as if it was generated by libisofs itself. 03688 * 03689 * @param error_code 03690 * The unique error code of your message. 03691 * Submit 0 if you do not have reserved error codes within the libburnia 03692 * project. 03693 * @param msg_text 03694 * Not more than ISO_MSGS_MESSAGE_LEN characters of message text. 03695 * @param os_errno 03696 * Eventual errno related to the message. Submit 0 if the message is not 03697 * related to a operating system error. 03698 * @param severity 03699 * One of "ABORT", "FATAL", "FAILURE", "SORRY", "WARNING", "HINT", "NOTE", 03700 * "UPDATE", "DEBUG". Defaults to "FATAL". 03701 * @param origin 03702 * Submit 0 for now. 03703 * @return 03704 * 1 if message was delivered, <=0 if failure 03705 * 03706 * @since 0.6.4 03707 */ 03708 int iso_msgs_submit(int error_code, char msg_text[], int os_errno, 03709 char severity[], int origin); 03710 03711 03712 /** 03713 * Convert a severity name into a severity number, which gives the severity 03714 * rank of the name. 03715 * 03716 * @param severity_name 03717 * A name as with iso_msgs_submit(), e.g. "SORRY". 03718 * @param severity_number 03719 * The rank number: the higher, the more severe. 03720 * @return 03721 * >0 success, <=0 failure 03722 * 03723 * @since 0.6.4 03724 */ 03725 int iso_text_to_sev(char *severity_name, int *severity_number); 03726 03727 03728 /** 03729 * Convert a severity number into a severity name 03730 * 03731 * @param severity_number 03732 * The rank number: the higher, the more severe. 03733 * @param severity_name 03734 * A name as with iso_msgs_submit(), e.g. "SORRY". 03735 * 03736 * @since 0.6.4 03737 */ 03738 int iso_sev_to_text(int severity_number, char **severity_name); 03739 03740 03741 /** 03742 * Get the id of an IsoImage, used for message reporting. This message id, 03743 * retrieved with iso_obtain_msgs(), can be used to distinguish what 03744 * IsoImage has isssued a given message. 03745 * 03746 * @since 0.6.2 03747 */ 03748 int iso_image_get_msg_id(IsoImage *image); 03749 03750 /** 03751 * Get a textual description of a libisofs error. 03752 * 03753 * @since 0.6.2 03754 */ 03755 const char *iso_error_to_msg(int errcode); 03756 03757 /** 03758 * Get the severity of a given error code 03759 * @return 03760 * 0x10000000 -> DEBUG 03761 * 0x20000000 -> UPDATE 03762 * 0x30000000 -> NOTE 03763 * 0x40000000 -> HINT 03764 * 0x50000000 -> WARNING 03765 * 0x60000000 -> SORRY 03766 * 0x64000000 -> MISHAP 03767 * 0x68000000 -> FAILURE 03768 * 0x70000000 -> FATAL 03769 * 0x71000000 -> ABORT 03770 * 03771 * @since 0.6.2 03772 */ 03773 int iso_error_get_severity(int e); 03774 03775 /** 03776 * Get the priority of a given error. 03777 * @return 03778 * 0x00000000 -> ZERO 03779 * 0x10000000 -> LOW 03780 * 0x20000000 -> MEDIUM 03781 * 0x30000000 -> HIGH 03782 * 03783 * @since 0.6.2 03784 */ 03785 int iso_error_get_priority(int e); 03786 03787 /** 03788 * Get the message queue code of a libisofs error. 03789 */ 03790 int iso_error_get_code(int e); 03791 03792 /** 03793 * Set the minimum error severity that causes a libisofs operation to 03794 * be aborted as soon as possible. 03795 * 03796 * @param severity 03797 * one of "FAILURE", "MISHAP", "SORRY", "WARNING", "HINT", "NOTE". 03798 * Severities greater or equal than FAILURE always cause program to abort. 03799 * Severities under NOTE won't never cause function abort. 03800 * @return 03801 * Previous abort priority on success, < 0 on error. 03802 * 03803 * @since 0.6.2 03804 */ 03805 int iso_set_abort_severity(char *severity); 03806 03807 /** 03808 * Return the messenger object handle used by libisofs. This handle 03809 * may be used by related libraries to their own compatible 03810 * messenger objects and thus to direct their messages to the libisofs 03811 * message queue. See also: libburn, API function burn_set_messenger(). 03812 * 03813 * @return the handle. Do only use with compatible 03814 * 03815 * @since 0.6.2 03816 */ 03817 void *iso_get_messenger(); 03818 03819 /** 03820 * Take a ref to the given IsoFileSource. 03821 * 03822 * @since 0.6.2 03823 */ 03824 void iso_file_source_ref(IsoFileSource *src); 03825 03826 /** 03827 * Drop your ref to the given IsoFileSource, eventually freeing the associated 03828 * system resources. 03829 * 03830 * @since 0.6.2 03831 */ 03832 void iso_file_source_unref(IsoFileSource *src); 03833 03834 /* 03835 * this are just helpers to invoque methods in class 03836 */ 03837 03838 /** 03839 * Get the absolute path in the filesystem this file source belongs to. 03840 * 03841 * @return 03842 * the path of the FileSource inside the filesystem, it should be 03843 * freed when no more needed. 03844 * 03845 * @since 0.6.2 03846 */ 03847 char* iso_file_source_get_path(IsoFileSource *src); 03848 03849 /** 03850 * Get the name of the file, with the dir component of the path. 03851 * 03852 * @return 03853 * the name of the file, it should be freed when no more needed. 03854 * 03855 * @since 0.6.2 03856 */ 03857 char* iso_file_source_get_name(IsoFileSource *src); 03858 03859 /** 03860 * Get information about the file. 03861 * @return 03862 * 1 success, < 0 error 03863 * Error codes: 03864 * ISO_FILE_ACCESS_DENIED 03865 * ISO_FILE_BAD_PATH 03866 * ISO_FILE_DOESNT_EXIST 03867 * ISO_OUT_OF_MEM 03868 * ISO_FILE_ERROR 03869 * ISO_NULL_POINTER 03870 * 03871 * @since 0.6.2 03872 */ 03873 int iso_file_source_lstat(IsoFileSource *src, struct stat *info); 03874 03875 /** 03876 * Check if the process has access to read file contents. Note that this 03877 * is not necessarily related with (l)stat functions. For example, in a 03878 * filesystem implementation to deal with an ISO image, if the user has 03879 * read access to the image it will be able to read all files inside it, 03880 * despite of the particular permission of each file in the RR tree, that 03881 * are what the above functions return. 03882 * 03883 * @return 03884 * 1 if process has read access, < 0 on error 03885 * Error codes: 03886 * ISO_FILE_ACCESS_DENIED 03887 * ISO_FILE_BAD_PATH 03888 * ISO_FILE_DOESNT_EXIST 03889 * ISO_OUT_OF_MEM 03890 * ISO_FILE_ERROR 03891 * ISO_NULL_POINTER 03892 * 03893 * @since 0.6.2 03894 */ 03895 int iso_file_source_access(IsoFileSource *src); 03896 03897 /** 03898 * Get information about the file. If the file is a symlink, the info 03899 * returned refers to the destination. 03900 * 03901 * @return 03902 * 1 success, < 0 error 03903 * Error codes: 03904 * ISO_FILE_ACCESS_DENIED 03905 * ISO_FILE_BAD_PATH 03906 * ISO_FILE_DOESNT_EXIST 03907 * ISO_OUT_OF_MEM 03908 * ISO_FILE_ERROR 03909 * ISO_NULL_POINTER 03910 * 03911 * @since 0.6.2 03912 */ 03913 int iso_file_source_stat(IsoFileSource *src, struct stat *info); 03914 03915 /** 03916 * Opens the source. 03917 * @return 1 on success, < 0 on error 03918 * Error codes: 03919 * ISO_FILE_ALREADY_OPENED 03920 * ISO_FILE_ACCESS_DENIED 03921 * ISO_FILE_BAD_PATH 03922 * ISO_FILE_DOESNT_EXIST 03923 * ISO_OUT_OF_MEM 03924 * ISO_FILE_ERROR 03925 * ISO_NULL_POINTER 03926 * 03927 * @since 0.6.2 03928 */ 03929 int iso_file_source_open(IsoFileSource *src); 03930 03931 /** 03932 * Close a previuously openned file 03933 * @return 1 on success, < 0 on error 03934 * Error codes: 03935 * ISO_FILE_ERROR 03936 * ISO_NULL_POINTER 03937 * ISO_FILE_NOT_OPENED 03938 * 03939 * @since 0.6.2 03940 */ 03941 int iso_file_source_close(IsoFileSource *src); 03942 03943 /** 03944 * Attempts to read up to count bytes from the given source into 03945 * the buffer starting at buf. 03946 * 03947 * The file src must be open() before calling this, and close() when no 03948 * more needed. Not valid for dirs. On symlinks it reads the destination 03949 * file. 03950 * 03951 * @param src 03952 * The given source 03953 * @param buf 03954 * Pointer to a buffer of at least count bytes where the read data will be 03955 * stored 03956 * @param count 03957 * Bytes to read 03958 * @return 03959 * number of bytes read, 0 if EOF, < 0 on error 03960 * Error codes: 03961 * ISO_FILE_ERROR 03962 * ISO_NULL_POINTER 03963 * ISO_FILE_NOT_OPENED 03964 * ISO_WRONG_ARG_VALUE -> if count == 0 03965 * ISO_FILE_IS_DIR 03966 * ISO_OUT_OF_MEM 03967 * ISO_INTERRUPTED 03968 * 03969 * @since 0.6.2 03970 */ 03971 int iso_file_source_read(IsoFileSource *src, void *buf, size_t count); 03972 03973 /** 03974 * Repositions the offset of the given IsoFileSource (must be opened) to the 03975 * given offset according to the value of flag. 03976 * 03977 * @param offset 03978 * in bytes 03979 * @param flag 03980 * 0 The offset is set to offset bytes (SEEK_SET) 03981 * 1 The offset is set to its current location plus offset bytes 03982 * (SEEK_CUR) 03983 * 2 The offset is set to the size of the file plus offset bytes 03984 * (SEEK_END). 03985 * @return 03986 * Absolute offset posistion on the file, or < 0 on error. Cast the 03987 * returning value to int to get a valid libisofs error. 03988 * @since 0.6.4 03989 */ 03990 off_t iso_file_source_lseek(IsoFileSource *src, off_t offset, int flag); 03991 03992 /** 03993 * Read a directory. 03994 * 03995 * Each call to this function will return a new children, until we reach 03996 * the end of file (i.e, no more children), in that case it returns 0. 03997 * 03998 * The dir must be open() before calling this, and close() when no more 03999 * needed. Only valid for dirs. 04000 * 04001 * Note that "." and ".." children MUST NOT BE returned. 04002 * 04003 * @param child 04004 * pointer to be filled with the given child. Undefined on error or OEF 04005 * @return 04006 * 1 on success, 0 if EOF (no more children), < 0 on error 04007 * Error codes: 04008 * ISO_FILE_ERROR 04009 * ISO_NULL_POINTER 04010 * ISO_FILE_NOT_OPENED 04011 * ISO_FILE_IS_NOT_DIR 04012 * ISO_OUT_OF_MEM 04013 * 04014 * @since 0.6.2 04015 */ 04016 int iso_file_source_readdir(IsoFileSource *src, IsoFileSource **child); 04017 04018 /** 04019 * Read the destination of a symlink. You don't need to open the file 04020 * to call this. 04021 * 04022 * @param src 04023 * An IsoFileSource corresponding to a symbolic link. 04024 * @param buf 04025 * allocated buffer of at least bufsiz bytes. 04026 * The dest. will be copied there, and it will be NULL-terminated 04027 * @param bufsiz 04028 * characters to be copied. Destination link will be truncated if 04029 * it is larger than given size. This include the '\0' character. 04030 * @return 04031 * 1 on success, < 0 on error 04032 * Error codes: 04033 * ISO_FILE_ERROR 04034 * ISO_NULL_POINTER 04035 * ISO_WRONG_ARG_VALUE -> if bufsiz <= 0 04036 * ISO_FILE_IS_NOT_SYMLINK 04037 * ISO_OUT_OF_MEM 04038 * ISO_FILE_BAD_PATH 04039 * ISO_FILE_DOESNT_EXIST 04040 * 04041 * @since 0.6.2 04042 */ 04043 int iso_file_source_readlink(IsoFileSource *src, char *buf, size_t bufsiz); 04044 04045 04046 /** 04047 * Get the AAIP string with encoded ACL and xattr. 04048 * (Not to be confused with ECMA-119 Extended Attributes). 04049 * @param src The file source object to be inquired. 04050 * @param aa_string Returns a pointer to the AAIP string data. If no AAIP 04051 * string is available, *aa_string becomes NULL. 04052 * (See doc/susp_aaip_2_0.txt for the meaning of AAIP.) 04053 * The caller is responsible for finally calling free() 04054 * on non-NULL results. 04055 * @param flag Bitfield for control purposes 04056 * bit0= Transfer ownership of AAIP string data. 04057 * src will free the eventual cached data and might 04058 * not be able to produce it again. 04059 * bit1= No need to get ACL (but no guarantee of exclusion) 04060 * bit2= No need to get xattr (but no guarantee of exclusion) 04061 * @return 1 means success (*aa_string == NULL is possible) 04062 * <0 means failure and must b a valid libisofs error code 04063 * (e.g. ISO_FILE_ERROR if no better one can be found). 04064 * @since 0.6.14 04065 */ 04066 int iso_file_source_get_aa_string(IsoFileSource *src, 04067 unsigned char **aa_string, int flag); 04068 04069 /** 04070 * Get the filesystem for this source. No extra ref is added, so you 04071 * musn't unref the IsoFilesystem. 04072 * 04073 * @return 04074 * The filesystem, NULL on error 04075 * 04076 * @since 0.6.2 04077 */ 04078 IsoFilesystem* iso_file_source_get_filesystem(IsoFileSource *src); 04079 04080 /** 04081 * Take a ref to the given IsoFilesystem 04082 * 04083 * @since 0.6.2 04084 */ 04085 void iso_filesystem_ref(IsoFilesystem *fs); 04086 04087 /** 04088 * Drop your ref to the given IsoFilesystem, evetually freeing associated 04089 * resources. 04090 * 04091 * @since 0.6.2 04092 */ 04093 void iso_filesystem_unref(IsoFilesystem *fs); 04094 04095 /** 04096 * Create a new IsoFilesystem to access a existent ISO image. 04097 * 04098 * @param src 04099 * Data source to access data. 04100 * @param opts 04101 * Image read options 04102 * @param msgid 04103 * An image identifer, obtained with iso_image_get_msg_id(), used to 04104 * associated messages issued by the filesystem implementation with an 04105 * existent image. If you are not using this filesystem in relation with 04106 * any image context, just use 0x1fffff as the value for this parameter. 04107 * @param fs 04108 * Will be filled with a pointer to the filesystem that can be used 04109 * to access image contents. 04110 * @param 04111 * 1 on success, < 0 on error 04112 * 04113 * @since 0.6.2 04114 */ 04115 int iso_image_filesystem_new(IsoDataSource *src, IsoReadOpts *opts, int msgid, 04116 IsoImageFilesystem **fs); 04117 04118 /** 04119 * Get the volset identifier for an existent image. The returned string belong 04120 * to the IsoImageFilesystem and shouldn't be free() nor modified. 04121 * 04122 * @since 0.6.2 04123 */ 04124 const char *iso_image_fs_get_volset_id(IsoImageFilesystem *fs); 04125 04126 /** 04127 * Get the volume identifier for an existent image. The returned string belong 04128 * to the IsoImageFilesystem and shouldn't be free() nor modified. 04129 * 04130 * @since 0.6.2 04131 */ 04132 const char *iso_image_fs_get_volume_id(IsoImageFilesystem *fs); 04133 04134 /** 04135 * Get the publisher identifier for an existent image. The returned string 04136 * belong to the IsoImageFilesystem and shouldn't be free() nor modified. 04137 * 04138 * @since 0.6.2 04139 */ 04140 const char *iso_image_fs_get_publisher_id(IsoImageFilesystem *fs); 04141 04142 /** 04143 * Get the data preparer identifier for an existent image. The returned string 04144 * belong to the IsoImageFilesystem and shouldn't be free() nor modified. 04145 * 04146 * @since 0.6.2 04147 */ 04148 const char *iso_image_fs_get_data_preparer_id(IsoImageFilesystem *fs); 04149 04150 /** 04151 * Get the system identifier for an existent image. The returned string belong 04152 * to the IsoImageFilesystem and shouldn't be free() nor modified. 04153 * 04154 * @since 0.6.2 04155 */ 04156 const char *iso_image_fs_get_system_id(IsoImageFilesystem *fs); 04157 04158 /** 04159 * Get the application identifier for an existent image. The returned string 04160 * belong to the IsoImageFilesystem and shouldn't be free() nor modified. 04161 * 04162 * @since 0.6.2 04163 */ 04164 const char *iso_image_fs_get_application_id(IsoImageFilesystem *fs); 04165 04166 /** 04167 * Get the copyright file identifier for an existent image. The returned string 04168 * belong to the IsoImageFilesystem and shouldn't be free() nor modified. 04169 * 04170 * @since 0.6.2 04171 */ 04172 const char *iso_image_fs_get_copyright_file_id(IsoImageFilesystem *fs); 04173 04174 /** 04175 * Get the abstract file identifier for an existent image. The returned string 04176 * belong to the IsoImageFilesystem and shouldn't be free() nor modified. 04177 * 04178 * @since 0.6.2 04179 */ 04180 const char *iso_image_fs_get_abstract_file_id(IsoImageFilesystem *fs); 04181 04182 /** 04183 * Get the biblio file identifier for an existent image. The returned string 04184 * belong to the IsoImageFilesystem and shouldn't be free() nor modified. 04185 * 04186 * @since 0.6.2 04187 */ 04188 const char *iso_image_fs_get_biblio_file_id(IsoImageFilesystem *fs); 04189 04190 /** 04191 * Increment reference count of an IsoStream. 04192 * 04193 * @since 0.6.4 04194 */ 04195 void iso_stream_ref(IsoStream *stream); 04196 04197 /** 04198 * Decrement reference count of an IsoStream, and eventually free it if 04199 * refcount reach 0. 04200 * 04201 * @since 0.6.4 04202 */ 04203 void iso_stream_unref(IsoStream *stream); 04204 04205 /** 04206 * Opens the given stream. Remember to close the Stream before writing the 04207 * image. 04208 * 04209 * @return 04210 * 1 on success, 2 file greater than expected, 3 file smaller than 04211 * expected, < 0 on error 04212 * 04213 * @since 0.6.4 04214 */ 04215 int iso_stream_open(IsoStream *stream); 04216 04217 /** 04218 * Close a previously openned IsoStream. 04219 * 04220 * @return 04221 * 1 on success, < 0 on error 04222 * 04223 * @since 0.6.4 04224 */ 04225 int iso_stream_close(IsoStream *stream); 04226 04227 /** 04228 * Get the size of a given stream. This function should always return the same 04229 * size, even if the underlying source size changes, unless you call 04230 * iso_stream_update_size(). 04231 * 04232 * @return 04233 * IsoStream size in bytes 04234 * 04235 * @since 0.6.4 04236 */ 04237 off_t iso_stream_get_size(IsoStream *stream); 04238 04239 /** 04240 * Attempts to read up to count bytes from the given stream into 04241 * the buffer starting at buf. 04242 * 04243 * The stream must be open() before calling this, and close() when no 04244 * more needed. 04245 * 04246 * @return 04247 * number of bytes read, 0 if EOF, < 0 on error 04248 * 04249 * @since 0.6.4 04250 */ 04251 int iso_stream_read(IsoStream *stream, void *buf, size_t count); 04252 04253 /** 04254 * Whether the given IsoStream can be read several times, with the same 04255 * results. 04256 * For example, a regular file is repeatable, you can read it as many 04257 * times as you want. However, a pipe isn't. 04258 * 04259 * This function doesn't take into account if the file has been modified 04260 * between the two reads. 04261 * 04262 * @return 04263 * 1 if stream is repeatable, 0 if not, < 0 on error 04264 * 04265 * @since 0.6.4 04266 */ 04267 int iso_stream_is_repeatable(IsoStream *stream); 04268 04269 /** 04270 * Updates the size of the IsoStream with the current size of the 04271 * underlying source. 04272 * 04273 * @return 04274 * 1 if ok, < 0 on error (has to be a valid libisofs error code), 04275 * 0 if the IsoStream does not support this function. 04276 * @since 0.6.8 04277 */ 04278 int iso_stream_update_size(IsoStream *stream); 04279 04280 /** 04281 * Get an unique identifier for a given IsoStream. 04282 * 04283 * @since 0.6.4 04284 */ 04285 void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, 04286 ino_t *ino_id); 04287 04288 /** 04289 * Try to get eventual source path string of a stream. Meaning and availability 04290 * of this string depends on the stream.class . Expect valid results with 04291 * types "fsrc" and "cout". Result formats are 04292 * fsrc: result of file_source_get_path() 04293 * cout: result of file_source_get_path() " " offset " " size 04294 * @param stream 04295 * The stream to be inquired. 04296 * @param flag 04297 * Bitfield for control purposes, unused yet, submit 0 04298 * @return 04299 * A copy of the path string. Apply free() when no longer needed. 04300 * NULL if no path string is available. 04301 * 04302 * @since 0.6.18 04303 */ 04304 char *iso_stream_get_source_path(IsoStream *stream, int flag); 04305 04306 /** 04307 * Compare two streams whether they are based on the same input and will 04308 * produce the same output. If in any doubt, then this comparison will 04309 * indicate no match. 04310 * 04311 * @param s1 04312 * The first stream to compare. 04313 * @param s2 04314 * The second stream to compare. 04315 * @return 04316 * -1 if s1 is smaller s2 , 0 if s1 matches s2 , 1 if s1 is larger s2 04317 * @param flag 04318 * bit0= do not use s1->class->compare() even if available 04319 * (e.g. because iso_stream_cmp_ino(0 is called as fallback 04320 * from said stream->class->compare()) 04321 * 04322 * @since 0.6.20 04323 */ 04324 int iso_stream_cmp_ino(IsoStream *s1, IsoStream *s2, int flag); 04325 04326 /* --------------------------------- AAIP --------------------------------- */ 04327 04328 /** 04329 * Function to identify and manage AAIP strings as xinfo of IsoNode. 04330 * 04331 * An AAIP string contains the Attribute List with the xattr and ACL of a node 04332 * in the image tree. It is formatted according to libisofs specification 04333 * AAIP-2.0 and ready to be written into the System Use Area resp. Continuation 04334 * Area of a directory entry in an ISO image. 04335 * 04336 * Applications are not supposed to manipulate AAIP strings directly. 04337 * They should rather make use of the appropriate iso_node_get_* and 04338 * iso_node_set_* calls. 04339 * 04340 * AAIP represents ACLs as xattr with empty name and AAIP-specific binary 04341 * content. Local filesystems may represent ACLs as xattr with names like 04342 * "system.posix_acl_access". libisofs does not interpret those local 04343 * xattr representations of ACL directly but rather uses the ACL interface of 04344 * the local system. By default the local xattr representations of ACL will 04345 * not become part of the AAIP Attribute List via iso_local_get_attrs() and 04346 * not be attached to local files via iso_local_set_attrs(). 04347 * 04348 * @since 0.6.14 04349 */ 04350 int aaip_xinfo_func(void *data, int flag); 04351 04352 04353 /** 04354 * Get the eventual ACLs which are associated with the node. 04355 * The result will be in "long" text form as of man acl resp. acl_to_text(). 04356 * Call this function with flag bit15 to finally release the memory 04357 * occupied by an ACL inquiry. 04358 * 04359 * @param node 04360 * The node that is to be inquired. 04361 * @param access_text 04362 * Will return a pointer to the eventual "access" ACL text or NULL if it 04363 * is not available and flag bit 4 is set. 04364 * @param default_text 04365 * Will return a pointer to the eventual "default" ACL or NULL if it 04366 * is not available. 04367 * (Linux directories can have a "default" ACL which influences 04368 * the permissions of newly created files.) 04369 * @param flag 04370 * Bitfield for control purposes 04371 * bit4= if no "access" ACL is available: return *access_text == NULL 04372 * else: produce ACL from stat(2) permissions 04373 * bit15= free memory and return 1 (node may be NULL) 04374 * @return 04375 * 2 *access_text was produced from stat(2) permissions 04376 * 1 *access_text was produced from ACL of node 04377 * 0 if flag bit4 is set and no ACL is available 04378 * < 0 on error 04379 * 04380 * @since 0.6.14 04381 */ 04382 int iso_node_get_acl_text(IsoNode *node, 04383 char **access_text, char **default_text, int flag); 04384 04385 04386 /** 04387 * Set the ACLs of the given node to the lists in parameters access_text and 04388 * default_text or delete them. 04389 * 04390 * The stat(2) permission bits get updated according to the new "access" ACL if 04391 * neither bit1 of parameter flag is set nor parameter access_text is NULL. 04392 * Note that S_IRWXG permission bits correspond to ACL mask permissions 04393 * if a "mask::" entry exists in the ACL. Only if there is no "mask::" then 04394 * the "group::" entry corresponds to to S_IRWXG. 04395 * 04396 * @param node 04397 * The node that is to be manipulated. 04398 * @param access_text 04399 * The text to be set into effect as "access" ACL. NULL will delete an 04400 * eventually existing "access" ACL of the node. 04401 * @param default_text 04402 * The text to be set into effect as "default" ACL. NULL will delete an 04403 * eventually existing "default" ACL of the node. 04404 * (Linux directories can have a "default" ACL which influences 04405 * the permissions of newly created files.) 04406 * @param flag 04407 * Bitfield for control purposes 04408 * bit1= ignore text parameters but rather update eventual "access" ACL 04409 * to the stat(2) permissions of node. If no "access" ACL exists, 04410 * then do nothing and return success. 04411 * @return 04412 * > 0 success 04413 * < 0 failure 04414 * 04415 * @since 0.6.14 04416 */ 04417 int iso_node_set_acl_text(IsoNode *node, 04418 char *access_text, char *default_text, int flag); 04419 04420 /** 04421 * Like iso_node_get_permissions but reflecting ACL entry "group::" in S_IRWXG 04422 * rather than ACL entry "mask::". This is necessary if the permissions of a 04423 * node with ACL shall be restored to a filesystem without restoring the ACL. 04424 * The same mapping happens internally when the ACL of a node is deleted. 04425 * If the node has no ACL then the result is iso_node_get_permissions(node). 04426 * @param node 04427 * The node that is to be inquired. 04428 * @return 04429 * Permission bits as of stat(2) 04430 * 04431 * @since 0.6.14 04432 */ 04433 mode_t iso_node_get_perms_wo_acl(const IsoNode *node); 04434 04435 04436 /** 04437 * Get the list of xattr which is associated with the node. 04438 * The resulting data may finally be disposed by a call to this function 04439 * with flag bit15 set, or its components may be freed one-by-one. 04440 * The following values are either NULL or malloc() memory: 04441 * *names, *value_lengths, *values, (*names)[i], (*values)[i] 04442 * with 0 <= i < *num_attrs. 04443 * It is allowed to replace or reallocate those memory items in order to 04444 * to manipulate the attribute list before submitting it to other calls. 04445 * 04446 * If enabled by flag bit0, this list possibly includes the ACLs of the node. 04447 * They are eventually encoded in a pair with empty name. It is not advisable 04448 * to alter the value or name of that pair. One may decide to erase both ACLs 04449 * by deleting this pair or to copy both ACLs by copying the content of this 04450 * pair to an empty named pair of another node. 04451 * For all other ACL purposes use iso_node_get_acl_text(). 04452 * 04453 * @param node 04454 * The node that is to be inquired. 04455 * @param num_attrs 04456 * Will return the number of name-value pairs 04457 * @param names 04458 * Will return an array of pointers to 0-terminated names 04459 * @param value_lengths 04460 * Will return an arry with the lenghts of values 04461 * @param values 04462 * Will return an array of pointers to strings of 8-bit bytes 04463 * @param flag 04464 * Bitfield for control purposes 04465 * bit0= obtain eventual ACLs as attribute with empty name 04466 * bit2= with bit0: do not obtain attributes other than ACLs 04467 * bit15= free memory (node may be NULL) 04468 * @return 04469 * 1 = ok (but *num_attrs may be 0) 04470 * < 0 = error 04471 * 04472 * @since 0.6.14 04473 */ 04474 int iso_node_get_attrs(IsoNode *node, size_t *num_attrs, 04475 char ***names, size_t **value_lengths, char ***values, int flag); 04476 04477 04478 /** 04479 * Obtain the value of a particular xattr name. Eventually make a copy of 04480 * that value and add a trailing 0 byte for caller convenience. 04481 * @param node 04482 * The node that is to be inquired. 04483 * @param name 04484 * The xattr name that shall be looked up. 04485 * @param value_length 04486 * Will return the lenght of value 04487 * @param value 04488 * Will return a string of 8-bit bytes. free() it when no longer needed. 04489 * @param flag 04490 * Bitfield for control purposes, unused yet, submit 0 04491 * @return 04492 * 1= name found , 0= name not found , <0 indicates error 04493 * 04494 * @since 0.6.18 04495 */ 04496 int iso_node_lookup_attr(IsoNode *node, char *name, 04497 size_t *value_length, char **value, int flag); 04498 04499 /** 04500 * Set the list of xattr which is associated with the node. 04501 * The data get copied so that you may dispose your input data afterwards. 04502 * 04503 * If enabled by flag bit0 then the submitted list of attributes will not only 04504 * overwrite xattr but also both eventual ACLs of the node. Eventual ACL in 04505 * the submitted list have to reside in an attribute with empty name. 04506 * 04507 * @param node 04508 * The node that is to be manipulated. 04509 * @param num_attrs 04510 * Number of attributes 04511 * @param names 04512 * Array of pointers to 0 terminated name strings 04513 * @param value_lengths 04514 * Array of byte lengths for each value 04515 * @param values 04516 * Array of pointers to the value bytes 04517 * @param flag 04518 * Bitfield for control purposes 04519 * bit0= Do not maintain eventual existing ACL of the node. 04520 * Set eventual new ACL from value of empty name. 04521 * bit1= Do not clear the existing attribute list but merge it with 04522 * the list given by this call. 04523 * The given values override the values of their eventually existing 04524 * names. If no xattr with a given name exists, then it will be 04525 * added as new xattr. So this bit can be used to set a single 04526 * xattr without inquiring any other xattr of the node. 04527 * bit2= Delete the attributes with the given names 04528 * bit3= Allow to affect non-user attributes. 04529 * I.e. those with a non-empty name which does not begin by "user." 04530 * (The empty name is always allowed and governed by bit0.) This 04531 * deletes all previously existing attributes if not bit1 is set. 04532 * @return 04533 * 1 = ok 04534 * < 0 = error 04535 * 04536 * @since 0.6.14 04537 */ 04538 int iso_node_set_attrs(IsoNode *node, size_t num_attrs, char **names, 04539 size_t *value_lengths, char **values, int flag); 04540 04541 04542 /* ----- This is an interface to ACL and xattr of the local filesystem ----- */ 04543 04544 /** 04545 * libisofs has an internal system dependent adapter to ACL and xattr 04546 * operations. For the sake of completeness and simplicity it exposes this 04547 * functionality to its applications which might want to get and set ACLs 04548 * from local files. 04549 */ 04550 04551 /** 04552 * Get an ACL of the given file in the local filesystem in long text form. 04553 * 04554 * @param disk_path 04555 * Absolute path to the file 04556 * @param text 04557 * Will return a pointer to the ACL text. If not NULL the text will be 04558 * 0 terminated and finally has to be disposed by a call to this function 04559 * with bit15 set. 04560 * @param flag 04561 * Bitfield for control purposes 04562 * bit0= get "default" ACL rather than "access" ACL 04563 * bit4= set *text = NULL and return 2 04564 * if the ACL matches st_mode permissions. 04565 * bit5= in case of symbolic link: inquire link target 04566 * bit15= free text and return 1 04567 * @return 04568 * 1 ok 04569 * 2 ok, trivial ACL found while bit4 is set, *text is NULL 04570 * 0 no ACL manipulation adapter available / ACL not supported on fs 04571 * -1 failure of system ACL service (see errno) 04572 * -2 attempt to inquire ACL of a symbolic link without bit4 or bit5 04573 * resp. with no suitable link target 04574 * 04575 * @since 0.6.14 04576 */ 04577 int iso_local_get_acl_text(char *disk_path, char **text, int flag); 04578 04579 04580 /** 04581 * Set the ACL of the given file in the local filesystem to a given list 04582 * in long text form. 04583 * 04584 * @param disk_path 04585 * Absolute path to the file 04586 * @param text 04587 * The input text (0 terminated, ACL long text form) 04588 * @param flag 04589 * Bitfield for control purposes 04590 * bit0= set "default" ACL rather than "access" ACL 04591 * bit5= in case of symbolic link: manipulate link target 04592 * @return 04593 * > 0 ok 04594 * 0 no ACL manipulation adapter available 04595 * -1 failure of system ACL service (see errno) 04596 * -2 attempt to manipulate ACL of a symbolic link without bit5 04597 * resp. with no suitable link target 04598 * 04599 * @since 0.6.14 04600 */ 04601 int iso_local_set_acl_text(char *disk_path, char *text, int flag); 04602 04603 04604 /** 04605 * Obtain permissions of a file in the local filesystem which shall reflect 04606 * ACL entry "group::" in S_IRWXG rather than ACL entry "mask::". This is 04607 * necessary if the permissions of a disk file with ACL shall be copied to 04608 * an object which has no ACL. 04609 * @param disk_path 04610 * Absolute path to the local file which may have an "access" ACL or not. 04611 * @param flag 04612 * Bitfield for control purposes 04613 * bit5= in case of symbolic link: inquire link target 04614 * @param st_mode 04615 * Returns permission bits as of stat(2) 04616 * @return 04617 * 1 success 04618 * -1 failure of lstat() resp. stat() (see errno) 04619 * 04620 * @since 0.6.14 04621 */ 04622 int iso_local_get_perms_wo_acl(char *disk_path, mode_t *st_mode, int flag); 04623 04624 04625 /** 04626 * Get xattr and non-trivial ACLs of the given file in the local filesystem. 04627 * The resulting data has finally to be disposed by a call to this function 04628 * with flag bit15 set. 04629 * 04630 * Eventual ACLs will get encoded as attribute pair with empty name if this is 04631 * enabled by flag bit0. An ACL which simply replects stat(2) permissions 04632 * will not be put into the result. 04633 * 04634 * @param disk_path 04635 * Absolute path to the file 04636 * @param num_attrs 04637 * Will return the number of name-value pairs 04638 * @param names 04639 * Will return an array of pointers to 0-terminated names 04640 * @param value_lengths 04641 * Will return an arry with the lenghts of values 04642 * @param values 04643 * Will return an array of pointers to 8-bit values 04644 * @param flag 04645 * Bitfield for control purposes 04646 * bit0= obtain eventual ACLs as attribute with empty name 04647 * bit2= do not obtain attributes other than ACLs 04648 * bit3= do not ignore eventual non-user attributes. 04649 * I.e. those with a name which does not begin by "user." 04650 * bit5= in case of symbolic link: inquire link target 04651 * bit15= free memory 04652 * @return 04653 * 1 ok 04654 * < 0 failure 04655 * 04656 * @since 0.6.14 04657 */ 04658 int iso_local_get_attrs(char *disk_path, size_t *num_attrs, char ***names, 04659 size_t **value_lengths, char ***values, int flag); 04660 04661 04662 /** 04663 * Attach a list of xattr and ACLs to the given file in the local filesystem. 04664 * 04665 * Eventual ACLs have to be encoded as attribute pair with empty name. 04666 * 04667 * @param disk_path 04668 * Absolute path to the file 04669 * @param num_attrs 04670 * Number of attributes 04671 * @param names 04672 * Array of pointers to 0 terminated name strings 04673 * @param value_lengths 04674 * Array of byte lengths for each attribute payload 04675 * @param values 04676 * Array of pointers to the attribute payload bytes 04677 * @param flag 04678 * Bitfield for control purposes 04679 * bit0= do not attach ACLs from an eventual attribute with empty name 04680 * bit3= do not ignore eventual non-user attributes. 04681 * I.e. those with a name which does not begin by "user." 04682 * bit5= in case of symbolic link: manipulate link target 04683 * @return 04684 * 1 = ok 04685 * < 0 = error 04686 * 04687 * @since 0.6.14 04688 */ 04689 int iso_local_set_attrs(char *disk_path, size_t num_attrs, char **names, 04690 size_t *value_lengths, char **values, int flag); 04691 04692 04693 /* Default in case that the compile environment has no macro PATH_MAX. 04694 */ 04695 #define Libisofs_default_path_maX 4096 04696 04697 04698 /* --------------------------- Filters in General -------------------------- */ 04699 04700 /* 04701 * A filter is an IsoStream which uses another IsoStream as input. It gets 04702 * attached to an IsoFile by specialized calls iso_file_add_*_filter() which 04703 * replace its current IsoStream by the filter stream which takes over the 04704 * current IsoStream as input. 04705 * The consequences are: 04706 * iso_file_get_stream() will return the filter stream. 04707 * iso_stream_get_size() will return the (cached) size of the filtered data, 04708 * iso_stream_open() will start eventual child processes, 04709 * iso_stream_close() will kill eventual child processes, 04710 * iso_stream_read() will return filtered data. E.g. as data file content 04711 * during ISO image generation. 04712 * 04713 * There are external filters which run child processes 04714 * iso_file_add_external_filter() 04715 * and internal filters 04716 * iso_file_add_zisofs_filter() 04717 * iso_file_add_gzip_filter() 04718 * which may or may not be available depending on compile time settings and 04719 * installed software packages like libz. 04720 * 04721 * During image generation filters get not in effect if the original IsoStream 04722 * is an "fsrc" stream based on a file in the loaded ISO image and if the 04723 * image generation type is set to 1 by iso_write_opts_set_appendable(). 04724 */ 04725 04726 /** 04727 * Delete the top filter stream from a data file. This is the most recent one 04728 * which was added by iso_file_add_*_filter(). 04729 * Caution: One should not do this while the IsoStream of the file is opened. 04730 * For now there is no general way to determine this state. 04731 * Filter stream implementations are urged to eventually call .close() 04732 * inside method .free() . This will close the input stream too. 04733 * @param file 04734 * The data file node which shall get rid of one layer of content 04735 * filtering. 04736 * @param flag 04737 * Bitfield for control purposes, unused yet, submit 0. 04738 * @return 04739 * 1 on success, 0 if no filter was present 04740 * <0 on error 04741 * 04742 * @since 0.6.18 04743 */ 04744 int iso_file_remove_filter(IsoFile *file, int flag); 04745 04746 /** 04747 * Obtain the eventual input stream of a filter stream. 04748 * @param stream 04749 * The eventual filter stream to be inquired. 04750 * @param flag 04751 * Bitfield for control purposes. Submit 0 for now. 04752 * @return 04753 * The input stream, if one exists. Elsewise NULL. 04754 * No extra reference to the stream is taken by this call. 04755 * 04756 * @since 0.6.18 04757 */ 04758 IsoStream *iso_stream_get_input_stream(IsoStream *stream, int flag); 04759 04760 04761 /* ---------------------------- External Filters --------------------------- */ 04762 04763 /** 04764 * Representation of an external program that shall serve as filter for 04765 * an IsoStream. This object may be shared among many IsoStream objects. 04766 * It is to be created and disposed by the application. 04767 * 04768 * The filter will act as proxy between the original IsoStream of an IsoFile. 04769 * Up to completed image generation it will be run at least twice: 04770 * for IsoStream.class.get_size() and for .open() with subsequent .read(). 04771 * So the original IsoStream has to return 1 by its .class.is_repeatable(). 04772 * The filter program has to be repeateable too. I.e. it must produce the same 04773 * output on the same input. 04774 * 04775 * @since 0.6.18 04776 */ 04777 struct iso_external_filter_command 04778 { 04779 /* Will indicate future extensions. It has to be 0 for now. */ 04780 int version; 04781 04782 /* Tells how many IsoStream objects depend on this command object. 04783 * One may only dispose an IsoExternalFilterCommand when this count is 0. 04784 * Initially this value has to be 0. 04785 */ 04786 int refcount; 04787 04788 /* An optional instance id. 04789 * Set to empty text if no individual name for this object is intended. 04790 */ 04791 char *name; 04792 04793 /* Absolute local filesystem path to the executable program. */ 04794 char *path; 04795 04796 /* Tells the number of arguments. */ 04797 int argc; 04798 04799 /* NULL terminated list suitable for system call execv(3). 04800 * I.e. argv[0] points to the alleged program name, 04801 * argv[1] to argv[argc] point to program arguments (if argc > 0) 04802 * argv[argc+1] is NULL 04803 */ 04804 char **argv; 04805 04806 /* A bit field which controls behavior variations: 04807 * bit0= Do not install filter if the input has size 0. 04808 * bit1= Do not install filter if the output is not smaller than the input. 04809 * bit2= Do not install filter if the number of output blocks is 04810 * not smaller than the number of input blocks. Block size is 2048. 04811 * Assume that non-empty input yields non-empty output and thus do 04812 * not attempt to attach a filter to files smaller than 2049 bytes. 04813 * bit3= suffix removed rather than added. 04814 * (Removal and adding suffixes is the task of the application. 04815 * This behavior bit serves only as reminder for the application.) 04816 */ 04817 int behavior; 04818 04819 /* The eventual suffix which is supposed to be added to the IsoFile name 04820 * resp. to be removed from the name. 04821 * (This is to be done by the application, not by calls 04822 * iso_file_add_external_filter() or iso_file_remove_filter(). 04823 * The value recorded here serves only as reminder for the application.) 04824 */ 04825 char *suffix; 04826 }; 04827 04828 typedef struct iso_external_filter_command IsoExternalFilterCommand; 04829 04830 /** 04831 * Install an external filter command on top of the content stream of a data 04832 * file. The filter process must be repeatable. It will be run once by this 04833 * call in order to cache the output size. 04834 * @param file 04835 * The data file node which shall show filtered content. 04836 * @param cmd 04837 * The external program and its arguments which shall do the filtering. 04838 * @param flag 04839 * Bitfield for control purposes, unused yet, submit 0. 04840 * @return 04841 * 1 on success, 2 if filter installation revoked (e.g. cmd.behavior bit1) 04842 * <0 on error 04843 * 04844 * @since 0.6.18 04845 */ 04846 int iso_file_add_external_filter(IsoFile *file, IsoExternalFilterCommand *cmd, 04847 int flag); 04848 04849 /** 04850 * Obtain the IsoExternalFilterCommand which is eventually associated with the 04851 * given stream. (Typically obtained from an IsoFile by iso_file_get_stream() 04852 * or from an IsoStream by iso_stream_get_input_stream()). 04853 * @param stream 04854 * The stream to be inquired. 04855 * @param cmd 04856 * Will return the external IsoExternalFilterCommand. Valid only if 04857 * the call returns 1. This does not increment cmd->refcount. 04858 * @param flag 04859 * Bitfield for control purposes, unused yet, submit 0. 04860 * @return 04861 * 1 on success, 0 if the stream is not an external filter 04862 * <0 on error 04863 * 04864 * @since 0.6.18 04865 */ 04866 int iso_stream_get_external_filter(IsoStream *stream, 04867 IsoExternalFilterCommand **cmd, int flag); 04868 04869 04870 /* ---------------------------- Internal Filters --------------------------- */ 04871 04872 04873 /** 04874 * Install a zisofs filter on top of the content stream of a data file. 04875 * zisofs is a compression format which is decompressed by some Linux kernels. 04876 * See also doc/zisofs_format.txt . 04877 * The filter will not be installed if its output size is not smaller than 04878 * the size of the input stream. 04879 * This is only enabled if the use of libz was enabled at compile time. 04880 * @param file 04881 * The data file node which shall show filtered content. 04882 * @param flag 04883 * Bitfield for control purposes 04884 * bit0= Do not install filter if the number of output blocks is 04885 * not smaller than the number of input blocks. Block size is 2048. 04886 * bit1= Install a decompression filter rather than one for compression. 04887 * bit2= Only inquire availability of zisofs filtering. file may be NULL. 04888 * If available return 2, else return error. 04889 * bit3= is reserved for internal use and will be forced to 0 04890 * @return 04891 * 1 on success, 2 if filter available but installation revoked 04892 * <0 on error, e.g. ISO_ZLIB_NOT_ENABLED 04893 * 04894 * @since 0.6.18 04895 */ 04896 int iso_file_add_zisofs_filter(IsoFile *file, int flag); 04897 04898 /** 04899 * Inquire the number of zisofs compression and uncompression filters which 04900 * are in use. 04901 * @param ziso_count 04902 * Will return the number of currently installed compression filters. 04903 * @param osiz_count 04904 * Will return the number of currently installed uncompression filters. 04905 * @param flag 04906 * Bitfield for control purposes, unused yet, submit 0 04907 * @return 04908 * 1 on success, <0 on error 04909 * 04910 * @since 0.6.18 04911 */ 04912 int iso_zisofs_get_refcounts(off_t *ziso_count, off_t *osiz_count, int flag); 04913 04914 04915 /** 04916 * Parameter set for iso_zisofs_set_params(). 04917 * 04918 * @since 0.6.18 04919 */ 04920 struct iso_zisofs_ctrl { 04921 04922 /* Set to 0 for this version of the structure */ 04923 int version; 04924 04925 /* Compression level for zlib function compress2(). From <zlib.h>: 04926 * "between 0 and 9: 04927 * 1 gives best speed, 9 gives best compression, 0 gives no compression" 04928 * Default is 6. 04929 */ 04930 int compression_level; 04931 04932 /* Log2 of the block size for compression filters. Allowed values are: 04933 * 15 = 32 kiB , 16 = 64 kiB , 17 = 128 kiB 04934 */ 04935 uint8_t block_size_log2; 04936 04937 }; 04938 04939 /** 04940 * Set the global parameters for zisofs filtering. 04941 * This is only allowed while no zisofs compression filters are installed. 04942 * i.e. ziso_count returned by iso_zisofs_get_refcounts() has to be 0. 04943 * @param params 04944 * Pointer to a structure with the intended settings. 04945 * @param flag 04946 * Bitfield for control purposes, unused yet, submit 0 04947 * @return 04948 * 1 on success, <0 on error 04949 * 04950 * @since 0.6.18 04951 */ 04952 int iso_zisofs_set_params(struct iso_zisofs_ctrl *params, int flag); 04953 04954 /** 04955 * Get the current global parameters for zisofs filtering. 04956 * @param params 04957 * Pointer to a caller provided structure which shall take the settings. 04958 * @param flag 04959 * Bitfield for control purposes, unused yet, submit 0 04960 * @return 04961 * 1 on success, <0 on error 04962 * 04963 * @since 0.6.18 04964 */ 04965 int iso_zisofs_get_params(struct iso_zisofs_ctrl *params, int flag); 04966 04967 04968 /** 04969 * Check for the given node or for its subtree whether the data file content 04970 * effectively bears zisofs file headers and eventually mark the outcome 04971 * by an xinfo data record if not already marked by a zisofs compressor filter. 04972 * This does not install any filter but only a hint for image generation 04973 * that the already compressed files shall get written with zisofs ZF entries. 04974 * Use this if you insert the compressed reults of program mkzftree from disk 04975 * into the image. 04976 * @param node 04977 * The node which shall be checked and eventually marked. 04978 * @param flag 04979 * Bitfield for control purposes, unused yet, submit 0 04980 * bit0= prepare for a run with iso_write_opts_set_appendable(,1). 04981 * Take into account that files from the imported image 04982 * do not get their content filtered. 04983 * bit1= permission to overwrite existing zisofs_zf_info 04984 * bit2= if no zisofs header is found: 04985 * create xinfo with parameters which indicate no zisofs 04986 * bit3= no tree recursion if node is a directory 04987 * bit4= skip files which stem from the imported image 04988 * @return 04989 * 0= no zisofs data found 04990 * 1= zf xinfo added 04991 * 2= found existing zf xinfo and flag bit1 was not set 04992 * 3= both encountered: 1 and 2 04993 * <0 means error 04994 * 04995 * @since 0.6.18 04996 */ 04997 int iso_node_zf_by_magic(IsoNode *node, int flag); 04998 04999 05000 /** 05001 * Install a gzip or gunzip filter on top of the content stream of a data file. 05002 * gzip is a compression format which is used by programs gzip and gunzip. 05003 * The filter will not be installed if its output size is not smaller than 05004 * the size of the input stream. 05005 * This is only enabled if the use of libz was enabled at compile time. 05006 * @param file 05007 * The data file node which shall show filtered content. 05008 * @param flag 05009 * Bitfield for control purposes 05010 * bit0= Do not install filter if the number of output blocks is 05011 * not smaller than the number of input blocks. Block size is 2048. 05012 * bit1= Install a decompression filter rather than one for compression. 05013 * bit2= Only inquire availability of gzip filtering. file may be NULL. 05014 * If available return 2, else return error. 05015 * bit3= is reserved for internal use and will be forced to 0 05016 * @return 05017 * 1 on success, 2 if filter available but installation revoked 05018 * <0 on error, e.g. ISO_ZLIB_NOT_ENABLED 05019 * 05020 * @since 0.6.18 05021 */ 05022 int iso_file_add_gzip_filter(IsoFile *file, int flag); 05023 05024 05025 /** 05026 * Inquire the number of gzip compression and uncompression filters which 05027 * are in use. 05028 * @param gzip_count 05029 * Will return the number of currently installed compression filters. 05030 * @param gunzip_count 05031 * Will return the number of currently installed uncompression filters. 05032 * @param flag 05033 * Bitfield for control purposes, unused yet, submit 0 05034 * @return 05035 * 1 on success, <0 on error 05036 * 05037 * @since 0.6.18 05038 */ 05039 int iso_gzip_get_refcounts(off_t *gzip_count, off_t *gunzip_count, int flag); 05040 05041 05042 /* ---------------------------- MD5 Checksums --------------------------- */ 05043 05044 /* Production and loading of MD5 checksums is controlled by calls 05045 iso_write_opts_set_record_md5() and iso_read_opts_set_no_md5(). 05046 For data representation details see doc/checksums.txt . 05047 */ 05048 05049 /** 05050 * Eventually obtain the recorded MD5 checksum of the session which was 05051 * loaded as ISO image. Such a checksum may be stored together with others 05052 * in a contiguous array at the end of the session. The session checksum 05053 * covers the data blocks from address start_lba to address end_lba - 1. 05054 * It does not cover the recorded array of md5 checksums. 05055 * Layout, size, and position of the checksum array is recorded in the xattr 05056 * "isofs.ca" of the session root node. 05057 * @param image 05058 * The image to inquire 05059 * @param start_lba 05060 * Eventually returns the first block address covered by md5 05061 * @param end_lba 05062 * Eventually returns the first block address not covered by md5 any more 05063 * @param md5 05064 * Eventually returns 16 byte of MD5 checksum 05065 * @param flag 05066 * Bitfield for control purposes, unused yet, submit 0 05067 * @return 05068 * 1= md5 found , 0= no md5 available , <0 indicates error 05069 * 05070 * @since 0.6.22 05071 */ 05072 int iso_image_get_session_md5(IsoImage *image, uint32_t *start_lba, 05073 uint32_t *end_lba, char md5[16], int flag); 05074 05075 /** 05076 * Eventually obtain the recorded MD5 checksum of a data file from the loaded 05077 * ISO image. Such a checksum may be stored with others in a contiguous 05078 * array at the end of the loaded session. The data file eventually has an 05079 * xattr "isofs.cx" which gives the index in that array. 05080 * @param image 05081 * The image from which file stems. 05082 * @param file 05083 * The file object to inquire 05084 * @param md5 05085 * Eventually returns 16 byte of MD5 checksum 05086 * @param flag 05087 * Bitfield for control purposes 05088 * bit0= only determine return value, do not touch parameter md5 05089 * @return 05090 * 1= md5 found , 0= no md5 available , <0 indicates error 05091 * 05092 * @since 0.6.22 05093 */ 05094 int iso_file_get_md5(IsoImage *image, IsoFile *file, char md5[16], int flag); 05095 05096 /** 05097 * Read the content of an IsoFile object, compute its MD5 and attach it to 05098 * the IsoFile. It can then be inquired by iso_file_get_md5() and will get 05099 * written into the next session if this is enabled at write time and if the 05100 * image write process does not compute an MD5 from content which it copies. 05101 * So this call can be used to equip nodes from the old image with checksums 05102 * or to make available checksums of newly added files before the session gets 05103 * written. 05104 * @param file 05105 * The file object to read data from and to which to attach the checksum. 05106 * If the file is from the imported image, then its most original stream 05107 * will be checksummed. Else the eventual filter streams will get into 05108 * effect. 05109 * @param flag 05110 * Bitfield for control purposes. Unused yet. Submit 0. 05111 * @return 05112 * 1= ok, MD5 is computed and attached , <0 indicates error 05113 * 05114 * @since 0.6.22 05115 */ 05116 int iso_file_make_md5(IsoFile *file, int flag); 05117 05118 /** 05119 * Check a data block whether it is a libisofs session checksum tag and 05120 * eventually obtain its recorded parameters. These tags get written after 05121 * volume descriptors, directory tree and checksum array and can be detected 05122 * without loading the image tree. 05123 * One may start reading and computing MD5 at the suspected image session 05124 * start and look out for a session tag on the fly. See doc/checksum.txt . 05125 * @param data 05126 * A complete and aligned data block read from an ISO image session. 05127 * @param tag_type 05128 * 0= no tag 05129 * 1= session tag 05130 * 2= superblock tag 05131 * 3= tree tag 05132 * 4= relocated 64 kB superblock tag (at LBA 0 of overwriteable media) 05133 * @param pos 05134 * Returns the LBA where the tag supposes itself to be stored. 05135 * If this does not match the data block LBA then the tag might be 05136 * image data payload and should be ignored for image checksumming. 05137 * @param range_start 05138 * Returns the block address where the session is supposed to start. 05139 * If this does not match the session start on media then the image 05140 * volume descriptors have been been relocated. 05141 * A proper checksum will only emerge if computing started at range_start. 05142 * @param range_size 05143 * Returns the number of blocks beginning at range_start which are 05144 * covered by parameter md5. 05145 * @param next_tag 05146 * Returns the predicted block address of the next tag. 05147 * next_tag is valid only if not 0 and only with return values 2, 3, 4. 05148 * With tag types 2 and 3, reading shall go on sequentially and the MD5 05149 * computation shall continue up to that address. 05150 * With tag type 4, reading shall resume either at LBA 32 for the first 05151 * session or at the given address for the session which is to be loaded 05152 * by default. In both cases the MD5 computation shall be re-started from 05153 * scratch. 05154 * @param md5 05155 * Returns 16 byte of MD5 checksum. 05156 * @param flag 05157 * Bitfield for control purposes: 05158 * bit0-bit7= tag type being looked for 05159 * 0= any checksum tag 05160 * 1= session tag 05161 * 2= superblock tag 05162 * 3= tree tag 05163 * 4= relocated superblock tag 05164 * @return 05165 * 0= not a checksum tag, return parameters are invalid 05166 * 1= checksum tag found, return parameters are valid 05167 * <0= error 05168 * (return parameters are valid with error ISO_MD5_AREA_CORRUPTED 05169 * but not trustworthy because the tag seems corrupted) 05170 * 05171 * @since 0.6.22 05172 */ 05173 int iso_util_decode_md5_tag(char data[2048], int *tag_type, uint32_t *pos, 05174 uint32_t *range_start, uint32_t *range_size, 05175 uint32_t *next_tag, char md5[16], int flag); 05176 05177 05178 /* The following functions allow to do own MD5 computations. E.g for 05179 comparing the result with a recorded checksum. 05180 */ 05181 /** 05182 * Create a MD5 computation context and hand out an opaque handle. 05183 * 05184 * @param md5_context 05185 * Returns the opaque handle. Submitted *md5_context must be NULL or 05186 * point to freeable memory. 05187 * @return 05188 * 1= success , <0 indicates error 05189 * 05190 * @since 0.6.22 05191 */ 05192 int iso_md5_start(void **md5_context); 05193 05194 /** 05195 * Advance the computation of a MD5 checksum by a chunk of data bytes. 05196 * 05197 * @param md5_context 05198 * An opaque handle once returned by iso_md5_start() or iso_md5_clone(). 05199 * @param data 05200 * The bytes which shall be processed into to the checksum. 05201 * @param datalen 05202 * The number of bytes to be processed. 05203 * @return 05204 * 1= success , <0 indicates error 05205 * 05206 * @since 0.6.22 05207 */ 05208 int iso_md5_compute(void *md5_context, char *data, int datalen); 05209 05210 /** 05211 * Create a MD5 computation context as clone of an existing one. One may call 05212 * iso_md5_clone(old, &new, 0) and then iso_md5_end(&new, result, 0) in order 05213 * to obtain an intermediate MD5 sum before the computation goes on. 05214 * 05215 * @param old_md5_context 05216 * An opaque handle once returned by iso_md5_start() or iso_md5_clone(). 05217 * @param new_md5_context 05218 * Returns the opaque handle to the new MD5 context. Submitted 05219 * *md5_context must be NULL or point to freeable memory. 05220 * @return 05221 * 1= success , <0 indicates error 05222 * 05223 * @since 0.6.22 05224 */ 05225 int iso_md5_clone(void *old_md5_context, void **new_md5_context); 05226 05227 /** 05228 * Obtain the MD5 checksum from a MD5 computation context and dispose this 05229 * context. (If you want to keep the context then call iso_md5_clone() and 05230 * apply iso_md5_end() to the clone.) 05231 * 05232 * @param md5_context 05233 * A pointer to an opaque handle once returned by iso_md5_start() or 05234 * iso_md5_clone(). *md5_context will be set to NULL in this call. 05235 * @param result 05236 * Gets filled with the 16 bytes of MD5 checksum. 05237 * @return 05238 * 1= success , <0 indicates error 05239 * 05240 * @since 0.6.22 05241 */ 05242 int iso_md5_end(void **md5_context, char result[16]); 05243 05244 /** 05245 * Inquire whether two MD5 checksums match. (This is trivial but such a call 05246 * is convenient and completes the interface.) 05247 * @param first_md5 05248 * A MD5 byte string as returned by iso_md5_end() 05249 * @param second_md5 05250 * A MD5 byte string as returned by iso_md5_end() 05251 * @return 05252 * 1= match , 0= mismatch 05253 * 05254 * @since 0.6.22 05255 */ 05256 int iso_md5_match(char first_md5[16], char second_md5[16]); 05257 05258 05259 /************ Error codes and return values for libisofs ********************/ 05260 05261 /** successfully execution */ 05262 #define ISO_SUCCESS 1 05263 05264 /** 05265 * special return value, it could be or not an error depending on the 05266 * context. 05267 */ 05268 #define ISO_NONE 0 05269 05270 /** Operation canceled (FAILURE,HIGH, -1) */ 05271 #define ISO_CANCELED 0xE830FFFF 05272 05273 /** Unknown or unexpected fatal error (FATAL,HIGH, -2) */ 05274 #define ISO_FATAL_ERROR 0xF030FFFE 05275 05276 /** Unknown or unexpected error (FAILURE,HIGH, -3) */ 05277 #define ISO_ERROR 0xE830FFFD 05278 05279 /** Internal programming error. Please report this bug (FATAL,HIGH, -4) */ 05280 #define ISO_ASSERT_FAILURE 0xF030FFFC 05281 05282 /** 05283 * NULL pointer as value for an arg. that doesn't allow NULL (FAILURE,HIGH, -5) 05284 */ 05285 #define ISO_NULL_POINTER 0xE830FFFB 05286 05287 /** Memory allocation error (FATAL,HIGH, -6) */ 05288 #define ISO_OUT_OF_MEM 0xF030FFFA 05289 05290 /** Interrupted by a signal (FATAL,HIGH, -7) */ 05291 #define ISO_INTERRUPTED 0xF030FFF9 05292 05293 /** Invalid parameter value (FAILURE,HIGH, -8) */ 05294 #define ISO_WRONG_ARG_VALUE 0xE830FFF8 05295 05296 /** Can't create a needed thread (FATAL,HIGH, -9) */ 05297 #define ISO_THREAD_ERROR 0xF030FFF7 05298 05299 /** Write error (FAILURE,HIGH, -10) */ 05300 #define ISO_WRITE_ERROR 0xE830FFF6 05301 05302 /** Buffer read error (FAILURE,HIGH, -11) */ 05303 #define ISO_BUF_READ_ERROR 0xE830FFF5 05304 05305 /** Trying to add to a dir a node already added to a dir (FAILURE,HIGH, -64) */ 05306 #define ISO_NODE_ALREADY_ADDED 0xE830FFC0 05307 05308 /** Node with same name already exists (FAILURE,HIGH, -65) */ 05309 #define ISO_NODE_NAME_NOT_UNIQUE 0xE830FFBF 05310 05311 /** Trying to remove a node that was not added to dir (FAILURE,HIGH, -65) */ 05312 #define ISO_NODE_NOT_ADDED_TO_DIR 0xE830FFBE 05313 05314 /** A requested node does not exist (FAILURE,HIGH, -66) */ 05315 #define ISO_NODE_DOESNT_EXIST 0xE830FFBD 05316 05317 /** 05318 * Try to set the boot image of an already bootable image (FAILURE,HIGH, -67) 05319 */ 05320 #define ISO_IMAGE_ALREADY_BOOTABLE 0xE830FFBC 05321 05322 /** Trying to use an invalid file as boot image (FAILURE,HIGH, -68) */ 05323 #define ISO_BOOT_IMAGE_NOT_VALID 0xE830FFBB 05324 05325 /** 05326 * Error on file operation (FAILURE,HIGH, -128) 05327 * (take a look at more specified error codes below) 05328 */ 05329 #define ISO_FILE_ERROR 0xE830FF80 05330 05331 /** Trying to open an already opened file (FAILURE,HIGH, -129) */ 05332 #define ISO_FILE_ALREADY_OPENED 0xE830FF7F 05333 05334 /* @deprecated use ISO_FILE_ALREADY_OPENED instead */ 05335 #define ISO_FILE_ALREADY_OPENNED 0xE830FF7F 05336 05337 /** Access to file is not allowed (FAILURE,HIGH, -130) */ 05338 #define ISO_FILE_ACCESS_DENIED 0xE830FF7E 05339 05340 /** Incorrect path to file (FAILURE,HIGH, -131) */ 05341 #define ISO_FILE_BAD_PATH 0xE830FF7D 05342 05343 /** The file does not exist in the filesystem (FAILURE,HIGH, -132) */ 05344 #define ISO_FILE_DOESNT_EXIST 0xE830FF7C 05345 05346 /** Trying to read or close a file not openned (FAILURE,HIGH, -133) */ 05347 #define ISO_FILE_NOT_OPENED 0xE830FF7B 05348 05349 /* @deprecated use ISO_FILE_NOT_OPENED instead */ 05350 #define ISO_FILE_NOT_OPENNED ISO_FILE_NOT_OPENED 05351 05352 /** Directory used where no dir is expected (FAILURE,HIGH, -134) */ 05353 #define ISO_FILE_IS_DIR 0xE830FF7A 05354 05355 /** Read error (FAILURE,HIGH, -135) */ 05356 #define ISO_FILE_READ_ERROR 0xE830FF79 05357 05358 /** Not dir used where a dir is expected (FAILURE,HIGH, -136) */ 05359 #define ISO_FILE_IS_NOT_DIR 0xE830FF78 05360 05361 /** Not symlink used where a symlink is expected (FAILURE,HIGH, -137) */ 05362 #define ISO_FILE_IS_NOT_SYMLINK 0xE830FF77 05363 05364 /** Can't seek to specified location (FAILURE,HIGH, -138) */ 05365 #define ISO_FILE_SEEK_ERROR 0xE830FF76 05366 05367 /** File not supported in ECMA-119 tree and thus ignored (WARNING,MEDIUM, -139) */ 05368 #define ISO_FILE_IGNORED 0xD020FF75 05369 05370 /* A file is bigger than supported by used standard (WARNING,MEDIUM, -140) */ 05371 #define ISO_FILE_TOO_BIG 0xD020FF74 05372 05373 /* File read error during image creation (MISHAP,HIGH, -141) */ 05374 #define ISO_FILE_CANT_WRITE 0xE430FF73 05375 05376 /* Can't convert filename to requested charset (WARNING,MEDIUM, -142) */ 05377 #define ISO_FILENAME_WRONG_CHARSET 0xD020FF72 05378 /* This was once a HINT. Deprecated now. */ 05379 #define ISO_FILENAME_WRONG_CHARSET_OLD 0xC020FF72 05380 05381 /* File can't be added to the tree (SORRY,HIGH, -143) */ 05382 #define ISO_FILE_CANT_ADD 0xE030FF71 05383 05384 /** 05385 * File path break specification constraints and will be ignored 05386 * (WARNING,MEDIUM, -144) 05387 */ 05388 #define ISO_FILE_IMGPATH_WRONG 0xD020FF70 05389 05390 /** 05391 * Offset greater than file size (FAILURE,HIGH, -150) 05392 * @since 0.6.4 05393 */ 05394 #define ISO_FILE_OFFSET_TOO_BIG 0xE830FF6A 05395 05396 05397 /** Charset conversion error (FAILURE,HIGH, -256) */ 05398 #define ISO_CHARSET_CONV_ERROR 0xE830FF00 05399 05400 /** 05401 * Too many files to mangle, i.e. we cannot guarantee unique file names 05402 * (FAILURE,HIGH, -257) 05403 */ 05404 #define ISO_MANGLE_TOO_MUCH_FILES 0xE830FEFF 05405 05406 /* image related errors */ 05407 05408 /** 05409 * Wrong or damaged Primary Volume Descriptor (FAILURE,HIGH, -320) 05410 * This could mean that the file is not a valid ISO image. 05411 */ 05412 #define ISO_WRONG_PVD 0xE830FEC0 05413 05414 /** Wrong or damaged RR entry (SORRY,HIGH, -321) */ 05415 #define ISO_WRONG_RR 0xE030FEBF 05416 05417 /** Unsupported RR feature (SORRY,HIGH, -322) */ 05418 #define ISO_UNSUPPORTED_RR 0xE030FEBE 05419 05420 /** Wrong or damaged ECMA-119 (FAILURE,HIGH, -323) */ 05421 #define ISO_WRONG_ECMA119 0xE830FEBD 05422 05423 /** Unsupported ECMA-119 feature (FAILURE,HIGH, -324) */ 05424 #define ISO_UNSUPPORTED_ECMA119 0xE830FEBC 05425 05426 /** Wrong or damaged El-Torito catalog (SORRY,HIGH, -325) */ 05427 #define ISO_WRONG_EL_TORITO 0xE030FEBB 05428 05429 /** Unsupported El-Torito feature (SORRY,HIGH, -326) */ 05430 #define ISO_UNSUPPORTED_EL_TORITO 0xE030FEBA 05431 05432 /** Can't patch an isolinux boot image (SORRY,HIGH, -327) */ 05433 #define ISO_ISOLINUX_CANT_PATCH 0xE030FEB9 05434 05435 /** Unsupported SUSP feature (SORRY,HIGH, -328) */ 05436 #define ISO_UNSUPPORTED_SUSP 0xE030FEB8 05437 05438 /** Error on a RR entry that can be ignored (WARNING,HIGH, -329) */ 05439 #define ISO_WRONG_RR_WARN 0xD030FEB7 05440 05441 /** Error on a RR entry that can be ignored (HINT,MEDIUM, -330) */ 05442 #define ISO_SUSP_UNHANDLED 0xC020FEB6 05443 05444 /** Multiple ER SUSP entries found (WARNING,HIGH, -331) */ 05445 #define ISO_SUSP_MULTIPLE_ER 0xD030FEB5 05446 05447 /** Unsupported volume descriptor found (HINT,MEDIUM, -332) */ 05448 #define ISO_UNSUPPORTED_VD 0xC020FEB4 05449 05450 /** El-Torito related warning (WARNING,HIGH, -333) */ 05451 #define ISO_EL_TORITO_WARN 0xD030FEB3 05452 05453 /** Image write cancelled (MISHAP,HIGH, -334) */ 05454 #define ISO_IMAGE_WRITE_CANCELED 0xE430FEB2 05455 05456 /** El-Torito image is hidden (WARNING,HIGH, -335) */ 05457 #define ISO_EL_TORITO_HIDDEN 0xD030FEB1 05458 05459 05460 /** AAIP info with ACL or xattr in ISO image will be ignored 05461 (NOTE, HIGH, -336) */ 05462 #define ISO_AAIP_IGNORED 0xB030FEB0 05463 05464 /** Error with decoding ACL from AAIP info (FAILURE, HIGH, -337) */ 05465 #define ISO_AAIP_BAD_ACL 0xE830FEAF 05466 05467 /** Error with encoding ACL for AAIP (FAILURE, HIGH, -338) */ 05468 #define ISO_AAIP_BAD_ACL_TEXT 0xE830FEAE 05469 05470 /** AAIP processing for ACL or xattr not enabled at compile time 05471 (FAILURE, HIGH, -339) */ 05472 #define ISO_AAIP_NOT_ENABLED 0xE830FEAD 05473 05474 /** Error with decoding AAIP info for ACL or xattr (FAILURE, HIGH, -340) */ 05475 #define ISO_AAIP_BAD_AASTRING 0xE830FEAC 05476 05477 /** Error with reading ACL or xattr from local file (FAILURE, HIGH, -341) */ 05478 #define ISO_AAIP_NO_GET_LOCAL 0xE830FEAB 05479 05480 /** Error with attaching ACL or xattr to local file (FAILURE, HIGH, -342) */ 05481 #define ISO_AAIP_NO_SET_LOCAL 0xE830FEAA 05482 05483 /** Unallowed attempt to set an xattr with non-userspace name 05484 (FAILURE, HIGH, -343) */ 05485 #define ISO_AAIP_NON_USER_NAME 0xE830FEA9 05486 05487 05488 /** Too many references on a single IsoExternalFilterCommand 05489 (FAILURE, HIGH, -344) */ 05490 #define ISO_EXTF_TOO_OFTEN 0xE830FEA8 05491 05492 /** Use of zlib was not enabled at compile time (FAILURE, HIGH, -345) */ 05493 #define ISO_ZLIB_NOT_ENABLED 0xE830FEA7 05494 05495 /** Cannot apply zisofs filter to file >= 4 GiB (FAILURE, HIGH, -346) */ 05496 #define ISO_ZISOFS_TOO_LARGE 0xE830FEA6 05497 05498 /** Filter input differs from previous run (FAILURE, HIGH, -347) */ 05499 #define ISO_FILTER_WRONG_INPUT 0xE830FEA5 05500 05501 /** zlib compression/decompression error (FAILURE, HIGH, -348) */ 05502 #define ISO_ZLIB_COMPR_ERR 0xE830FEA4 05503 05504 /** Input stream is not in zisofs format (FAILURE, HIGH, -349) */ 05505 #define ISO_ZISOFS_WRONG_INPUT 0xE830FEA3 05506 05507 /** Cannot set global zisofs parameters while filters exist 05508 (FAILURE, HIGH, -350) */ 05509 #define ISO_ZISOFS_PARAM_LOCK 0xE830FEA2 05510 05511 /** Premature EOF of zlib input stream (FAILURE, HIGH, -351) */ 05512 #define ISO_ZLIB_EARLY_EOF 0xE830FEA1 05513 05514 /** 05515 * Checksum area or checksum tag appear corrupted (WARNING,HIGH, -352) 05516 * @since 0.6.22 05517 */ 05518 #define ISO_MD5_AREA_CORRUPTED 0xD030FEA0 05519 05520 /** 05521 * Checksum mismatch between checksum tag and data blocks 05522 * (FAILURE, HIGH, -353) 05523 * @since 0.6.22 05524 */ 05525 #define ISO_MD5_TAG_MISMATCH 0xE830FE9F 05526 05527 /** 05528 * Checksum mismatch in System Area, Volume Descriptors, or directory tree. 05529 * (FAILURE, HIGH, -354) 05530 * @since 0.6.22 05531 */ 05532 #define ISO_SB_TREE_CORRUPTED 0xE830FE9E 05533 05534 /** 05535 * Unexpected checksum tag type encountered. (WARNING, HIGH, -355) 05536 * @since 0.6.22 05537 */ 05538 #define ISO_MD5_TAG_UNEXPECTED 0xD030FE9D 05539 05540 /** 05541 * Misplaced checksum tag encountered. (WARNING, HIGH, -356) 05542 * @since 0.6.22 05543 */ 05544 #define ISO_MD5_TAG_MISPLACED 0xD030FE9C 05545 05546 /** 05547 * Checksum tag with unexpected address range encountered. 05548 * (WARNING, HIGH, -357) 05549 * @since 0.6.22 05550 */ 05551 #define ISO_MD5_TAG_OTHER_RANGE 0xD030FE9B 05552 05553 /** 05554 * Detected file content changes while it was written into the image. 05555 * (MISHAP, HIGH, -358) 05556 * @since 0.6.22 05557 */ 05558 #define ISO_MD5_STREAM_CHANGE 0xE430FE9A 05559 05560 /** 05561 * Session does not start at LBA 0. scdbackup checksum tag not written. 05562 * (WARNING, HIGH, -359) 05563 * @since 0.6.24 05564 */ 05565 #define ISO_SCDBACKUP_TAG_NOT_0 0xD030FE99 05566 05567 05568 /* ! PLACE NEW ERROR CODES HERE ! */ 05569 05570 05571 /** Read error occured with IsoDataSource (SORRY,HIGH, -513) */ 05572 #define ISO_DATA_SOURCE_SORRY 0xE030FCFF 05573 05574 /** Read error occured with IsoDataSource (MISHAP,HIGH, -513) */ 05575 #define ISO_DATA_SOURCE_MISHAP 0xE430FCFF 05576 05577 /** Read error occured with IsoDataSource (FAILURE,HIGH, -513) */ 05578 #define ISO_DATA_SOURCE_FAILURE 0xE830FCFF 05579 05580 /** Read error occured with IsoDataSource (FATAL,HIGH, -513) */ 05581 #define ISO_DATA_SOURCE_FATAL 0xF030FCFF 05582 05583 05584 /* ! PLACE NEW ERROR CODES ABOVE. NOT HERE ! */ 05585 05586 05587 /* ------------------------------------------------------------------------- */ 05588 05589 #ifdef LIBISOFS_WITHOUT_LIBBURN 05590 05591 /** 05592 This is a copy from the API of libburn-0.6.0 (under GPL). 05593 It is supposed to be as stable as any overall include of libburn.h. 05594 I.e. if this definition is out of sync then you cannot rely on any 05595 contract that was made with libburn.h. 05596 05597 Libisofs does not need to be linked with libburn at all. But if it is 05598 linked with libburn then it must be libburn-0.4.2 or later. 05599 05600 An application that provides own struct burn_source objects and does not 05601 include libburn/libburn.h has to define LIBISOFS_WITHOUT_LIBBURN before 05602 including libisofs/libisofs.h in order to make this copy available. 05603 */ 05604 05605 05606 /** Data source interface for tracks. 05607 This allows to use arbitrary program code as provider of track input data. 05608 05609 Objects compliant to this interface are either provided by the application 05610 or by API calls of libburn: burn_fd_source_new() , burn_file_source_new(), 05611 and burn_fifo_source_new(). 05612 05613 The API calls allow to use any file object as data source. Consider to feed 05614 an eventual custom data stream asynchronously into a pipe(2) and to let 05615 libburn handle the rest. 05616 In this case the following rule applies: 05617 Call burn_source_free() exactly once for every source obtained from 05618 libburn API. You MUST NOT otherwise use or manipulate its components. 05619 05620 In general, burn_source objects can be freed as soon as they are attached 05621 to track objects. The track objects will keep them alive and dispose them 05622 when they are no longer needed. With a fifo burn_source it makes sense to 05623 keep the own reference for inquiring its state while burning is in 05624 progress. 05625 05626 --- 05627 05628 The following description of burn_source applies only to application 05629 implemented burn_source objects. You need not to know it for API provided 05630 ones. 05631 05632 If you really implement an own passive data producer by this interface, 05633 then beware: it can do anything and it can spoil everything. 05634 05635 In this case the functions (*read), (*get_size), (*set_size), (*free_data) 05636 MUST be implemented by the application and attached to the object at 05637 creation time. 05638 Function (*read_sub) is allowed to be NULL or it MUST be implemented and 05639 attached. 05640 05641 burn_source.refcount MUST be handled properly: If not exactly as many 05642 references are freed as have been obtained, then either memory leaks or 05643 corrupted memory are the consequence. 05644 All objects which are referred to by *data must be kept existent until 05645 (*free_data) is called via burn_source_free() by the last referer. 05646 */ 05647 struct burn_source { 05648 05649 /** Reference count for the data source. MUST be 1 when a new source 05650 is created and thus the first reference is handed out. Increment 05651 it to take more references for yourself. Use burn_source_free() 05652 to destroy your references to it. */ 05653 int refcount; 05654 05655 05656 /** Read data from the source. Semantics like with read(2), but MUST 05657 either deliver the full buffer as defined by size or MUST deliver 05658 EOF (return 0) or failure (return -1) at this call or at the 05659 next following call. I.e. the only incomplete buffer may be the 05660 last one from that source. 05661 libburn will read a single sector by each call to (*read). 05662 The size of a sector depends on BURN_MODE_*. The known range is 05663 2048 to 2352. 05664 05665 If this call is reading from a pipe then it will learn 05666 about the end of data only when that pipe gets closed on the 05667 feeder side. So if the track size is not fixed or if the pipe 05668 delivers less than the predicted amount or if the size is not 05669 block aligned, then burning will halt until the input process 05670 closes the pipe. 05671 05672 IMPORTANT: 05673 If this function pointer is NULL, then the struct burn_source is of 05674 version >= 1 and the job of .(*read)() is done by .(*read_xt)(). 05675 See below, member .version. 05676 */ 05677 int (*read)(struct burn_source *, unsigned char *buffer, int size); 05678 05679 05680 /** Read subchannel data from the source (NULL if lib generated) 05681 WARNING: This is an obscure feature with CD raw write modes. 05682 Unless you checked the libburn code for correctness in that aspect 05683 you should not rely on raw writing with own subchannels. 05684 ADVICE: Set this pointer to NULL. 05685 */ 05686 int (*read_sub)(struct burn_source *, unsigned char *buffer, int size); 05687 05688 05689 /** Get the size of the source's data. Return 0 means unpredictable 05690 size. If application provided (*get_size) allows return 0, then 05691 the application MUST provide a fully functional (*set_size). 05692 */ 05693 off_t (*get_size)(struct burn_source *); 05694 05695 05696 /* @since 0.3.2 */ 05697 /** Program the reply of (*get_size) to a fixed value. It is advised 05698 to implement this by a attribute off_t fixed_size; in *data . 05699 The read() function does not have to take into respect this fake 05700 setting. It is rather a note of libburn to itself. Eventually 05701 necessary truncation or padding is done in libburn. Truncation 05702 is usually considered a misburn. Padding is considered ok. 05703 05704 libburn is supposed to work even if (*get_size) ignores the 05705 setting by (*set_size). But your application will not be able to 05706 enforce fixed track sizes by burn_track_set_size() and possibly 05707 even padding might be left out. 05708 */ 05709 int (*set_size)(struct burn_source *source, off_t size); 05710 05711 05712 /** Clean up the source specific data. This function will be called 05713 once by burn_source_free() when the last referer disposes the 05714 source. 05715 */ 05716 void (*free_data)(struct burn_source *); 05717 05718 05719 /** Next source, for when a source runs dry and padding is disabled 05720 WARNING: This is an obscure feature. Set to NULL at creation and 05721 from then on leave untouched and uninterpreted. 05722 */ 05723 struct burn_source *next; 05724 05725 05726 /** Source specific data. Here the various source classes express their 05727 specific properties and the instance objects store their individual 05728 management data. 05729 E.g. data could point to a struct like this: 05730 struct app_burn_source 05731 { 05732 struct my_app *app_handle; 05733 ... other individual source parameters ... 05734 off_t fixed_size; 05735 }; 05736 05737 Function (*free_data) has to be prepared to clean up and free 05738 the struct. 05739 */ 05740 void *data; 05741 05742 05743 /* @since 0.4.2 */ 05744 /** Valid only if above member .(*read)() is NULL. This indicates a 05745 version of struct burn_source younger than 0. 05746 From then on, member .version tells which further members exist 05747 in the memory layout of struct burn_source. libburn will only touch 05748 those announced extensions. 05749 05750 Versions: 05751 0 has .(*read)() != NULL, not even .version is present. 05752 1 has .version, .(*read_xt)(), .(*cancel)() 05753 */ 05754 int version; 05755 05756 /** This substitutes for (*read)() in versions above 0. */ 05757 int (*read_xt)(struct burn_source *, unsigned char *buffer, int size); 05758 05759 /** Informs the burn_source that the consumer of data prematurely 05760 ended reading. This call may or may not be issued by libburn 05761 before (*free_data)() is called. 05762 */ 05763 int (*cancel)(struct burn_source *source); 05764 }; 05765 05766 #endif /* LIBISOFS_WITHOUT_LIBBURN */ 05767 05768 /* ----------------------------- Bug Fixes ----------------------------- */ 05769 05770 /* currently none being tested */ 05771 05772 05773 /* ---------------------------- Improvements --------------------------- */ 05774 05775 05776 /* Checksums : During image writing equip IsoFile objects with MD5 checksums 05777 and compute an overall checksum of the session. Store them in 05778 a separate checksum block area after the data area of the 05779 session. 05780 */ 05781 #define Libisofs_with_checksumS yes 05782 05783 05784 /* ---------------------------- Experiments ---------------------------- */ 05785 05786 05787 /* Experiment: Write obsolete RR entries with Rock Ridge. 05788 I suspect Solaris wants to see them. 05789 DID NOT HELP: Solaris knows only RRIP_1991A. 05790 05791 #define Libisofs_with_rrip_rR yes 05792 */ 05793 05794 05795 #endif /*LIBISO_LIBISOFS_H_*/