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