00001 /* 00002 * Copyright (c) 2007-2008 Vreixo Formoso, Mario Danic 00003 * 00004 * This file is part of the libisofs project; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License version 2 as 00006 * published by the Free Software Foundation. See COPYING file for details. 00007 */ 00008 #ifndef LIBISO_LIBISOFS_H_ 00009 #define LIBISO_LIBISOFS_H_ 00010 00011 #include <sys/stat.h> 00012 #include <stdint.h> 00013 #include <stdlib.h> 00014 00015 struct burn_source; 00016 00017 /** 00018 * Context for image creation. It holds the files that will be added to image, 00019 * and several options to control libisofs behavior. 00020 * 00021 * @since 0.6.2 00022 */ 00023 typedef struct Iso_Image IsoImage; 00024 00025 /* 00026 * A node in the iso tree, i.e. a file that will be written to image. 00027 * 00028 * It can represent any kind of files. When needed, you can get the type with 00029 * iso_node_get_type() and cast it to the appropiate subtype. Useful macros 00030 * are provided, see below. 00031 * 00032 * @since 0.6.2 00033 */ 00034 typedef struct Iso_Node IsoNode; 00035 00036 /** 00037 * A directory in the iso tree. It is an special type of IsoNode and can be 00038 * casted to it in any case. 00039 * 00040 * @since 0.6.2 00041 */ 00042 typedef struct Iso_Dir IsoDir; 00043 00044 /** 00045 * A symbolic link in the iso tree. It is an special type of IsoNode and can be 00046 * casted to it in any case. 00047 * 00048 * @since 0.6.2 00049 */ 00050 typedef struct Iso_Symlink IsoSymlink; 00051 00052 /** 00053 * A regular file in the iso tree. It is an special type of IsoNode and can be 00054 * casted to it in any case. 00055 * 00056 * @since 0.6.2 00057 */ 00058 typedef struct Iso_File IsoFile; 00059 00060 /** 00061 * An special file in the iso tree. This is used to represent any POSIX file 00062 * other that regular files, directories or symlinks, i.e.: socket, block and 00063 * character devices, and fifos. 00064 * It is an special type of IsoNode and can be casted to it in any case. 00065 * 00066 * @since 0.6.2 00067 */ 00068 typedef struct Iso_Special IsoSpecial; 00069 00070 /** 00071 * The type of an IsoNode. 00072 * 00073 * When an user gets an IsoNode from an image, (s)he can use 00074 * iso_node_get_type() to get the current type of the node, and then 00075 * cast to the appropriate subtype. For example: 00076 * 00077 * ... 00078 * IsoNode *node; 00079 * res = iso_dir_iter_next(iter, &node); 00080 * if (res == 1 && iso_node_get_type(node) == LIBISO_DIR) { 00081 * IsoDir *dir = (IsoDir *)node; 00082 * ... 00083 * } 00084 * 00085 * @since 0.6.2 00086 */ 00087 enum IsoNodeType { 00088 LIBISO_DIR, 00089 LIBISO_FILE, 00090 LIBISO_SYMLINK, 00091 LIBISO_SPECIAL, 00092 LIBISO_BOOT 00093 }; 00094 00095 /* macros to check node type */ 00096 #define ISO_NODE_IS_DIR(n) (iso_node_get_type(n) == LIBISO_DIR) 00097 #define ISO_NODE_IS_FILE(n) (iso_node_get_type(n) == LIBISO_FILE) 00098 #define ISO_NODE_IS_SYMLINK(n) (iso_node_get_type(n) == LIBISO_SYMLINK) 00099 #define ISO_NODE_IS_SPECIAL(n) (iso_node_get_type(n) == LIBISO_SPECIAL) 00100 #define ISO_NODE_IS_BOOTCAT(n) (iso_node_get_type(n) == LIBISO_BOOT) 00101 00102 /* macros for safe downcasting */ 00103 #define ISO_DIR(n) ((IsoDir*)(ISO_NODE_IS_DIR(n) ? n : NULL)) 00104 #define ISO_FILE(n) ((IsoFile*)(ISO_NODE_IS_FILE(n) ? n : NULL)) 00105 #define ISO_SYMLINK(n) ((IsoSymlink*)(ISO_NODE_IS_SYMLINK(n) ? n : NULL)) 00106 #define ISO_SPECIAL(n) ((IsoSpecial*)(ISO_NODE_IS_SPECIAL(n) ? n : NULL)) 00107 00108 #define ISO_NODE(n) ((IsoNode*)n) 00109 00110 /** 00111 * File section in an old image. 00112 * 00113 * @since 0.6.8 00114 */ 00115 struct iso_file_section 00116 { 00117 uint32_t block; 00118 uint32_t size; 00119 }; 00120 00121 /** 00122 * Context for iterate on directory children. 00123 * @see iso_dir_get_children() 00124 * 00125 * @since 0.6.2 00126 */ 00127 typedef struct Iso_Dir_Iter IsoDirIter; 00128 00129 /** 00130 * It represents an El-Torito boot image. 00131 * 00132 * @since 0.6.2 00133 */ 00134 typedef struct el_torito_boot_image ElToritoBootImage; 00135 00136 /** 00137 * An special type of IsoNode that acts as a placeholder for an El-Torito 00138 * boot catalog. Once written, it will appear as a regular file. 00139 * 00140 * @since 0.6.2 00141 */ 00142 typedef struct Iso_Boot IsoBoot; 00143 00144 /** 00145 * Flag used to hide a file in the RR/ISO or Joliet tree. 00146 * 00147 * @see iso_node_set_hidden 00148 * @since 0.6.2 00149 */ 00150 enum IsoHideNodeFlag { 00151 /** Hide the node in the ECMA-119 / RR tree */ 00152 LIBISO_HIDE_ON_RR = 1 << 0, 00153 /** Hide the node in the Joliet tree, if Joliet extension are enabled */ 00154 LIBISO_HIDE_ON_JOLIET = 1 << 1, 00155 /** Hide the node in the ISO-9660:1999 tree, if that format is enabled */ 00156 LIBISO_HIDE_ON_1999 = 1 << 2 00157 }; 00158 00159 /** 00160 * El-Torito bootable image type. 00161 * 00162 * @since 0.6.2 00163 */ 00164 enum eltorito_boot_media_type { 00165 ELTORITO_FLOPPY_EMUL, 00166 ELTORITO_HARD_DISC_EMUL, 00167 ELTORITO_NO_EMUL 00168 }; 00169 00170 /** 00171 * Replace mode used when addding a node to a file. 00172 * This controls how libisofs will act when you tried to add to a dir a file 00173 * with the same name that an existing file. 00174 * 00175 * @since 0.6.2 00176 */ 00177 enum iso_replace_mode { 00178 /** 00179 * Never replace an existing node, and instead fail with 00180 * ISO_NODE_NAME_NOT_UNIQUE. 00181 */ 00182 ISO_REPLACE_NEVER, 00183 /** 00184 * Always replace the old node with the new. 00185 */ 00186 ISO_REPLACE_ALWAYS, 00187 /** 00188 * Replace with the new node if it is the same file type 00189 */ 00190 ISO_REPLACE_IF_SAME_TYPE, 00191 /** 00192 * Replace with the new node if it is the same file type and its ctime 00193 * is newer than the old one. 00194 */ 00195 ISO_REPLACE_IF_SAME_TYPE_AND_NEWER, 00196 /** 00197 * Replace with the new node if its ctime is newer than the old one. 00198 */ 00199 ISO_REPLACE_IF_NEWER 00200 /* 00201 * TODO #00006 define more values 00202 * -if both are dirs, add contents (and what to do with conflicts?) 00203 */ 00204 }; 00205 00206 /** 00207 * Options for image written. 00208 * @see iso_write_opts_new() 00209 * @since 0.6.2 00210 */ 00211 typedef struct iso_write_opts IsoWriteOpts; 00212 00213 /** 00214 * Options for image reading or import. 00215 * @see iso_read_opts_new() 00216 * @since 0.6.2 00217 */ 00218 typedef struct iso_read_opts IsoReadOpts; 00219 00220 /** 00221 * Source for image reading. 00222 * 00223 * @see struct iso_data_source 00224 * @since 0.6.2 00225 */ 00226 typedef struct iso_data_source IsoDataSource; 00227 00228 /** 00229 * Data source used by libisofs for reading an existing image. 00230 * 00231 * It offers homogeneous read access to arbitrary blocks to different sources 00232 * for images, such as .iso files, CD/DVD drives, etc... 00233 * 00234 * To create a multisession image, libisofs needs a IsoDataSource, that the 00235 * user must provide. The function iso_data_source_new_from_file() constructs 00236 * an IsoDataSource that uses POSIX I/O functions to access data. You can use 00237 * it with regular .iso images, and also with block devices that represent a 00238 * drive. 00239 * 00240 * @since 0.6.2 00241 */ 00242 struct iso_data_source 00243 { 00244 00245 /* reserved for future usage, set to 0 */ 00246 int version; 00247 00248 /** 00249 * Reference count for the data source. Should be 1 when a new source 00250 * is created. Don't access it directly, but with iso_data_source_ref() 00251 * and iso_data_source_unref() functions. 00252 */ 00253 unsigned int refcount; 00254 00255 /** 00256 * Opens the given source. You must open() the source before any attempt 00257 * to read data from it. The open is the right place for grabbing the 00258 * underlying resources. 00259 * 00260 * @return 00261 * 1 if success, < 0 on error (has to be a valid libisofs error code) 00262 */ 00263 int (*open)(IsoDataSource *src); 00264 00265 /** 00266 * Close a given source, freeing all system resources previously grabbed in 00267 * open(). 00268 * 00269 * @return 00270 * 1 if success, < 0 on error (has to be a valid libisofs error code) 00271 */ 00272 int (*close)(IsoDataSource *src); 00273 00274 /** 00275 * Read an arbitrary block (2048 bytes) of data from the source. 00276 * 00277 * @param lba 00278 * Block to be read. 00279 * @param buffer 00280 * Buffer where the data will be written. It should have at least 00281 * 2048 bytes. 00282 * @return 00283 * 1 if success, 00284 * < 0 if error. This function has to emit a valid libisofs error code. 00285 * Predifined (but not mandatory) for this purpose are: 00286 * ISO_DATA_SOURCE_SORRY , ISO_DATA_SOURCE_MISHAP, 00287 * ISO_DATA_SOURCE_FAILURE , ISO_DATA_SOURCE_FATAL 00288 */ 00289 int (*read_block)(IsoDataSource *src, uint32_t lba, uint8_t *buffer); 00290 00291 /** 00292 * Clean up the source specific data. Never call this directly, it is 00293 * automatically called by iso_data_source_unref() when refcount reach 00294 * 0. 00295 */ 00296 void (*free_data)(IsoDataSource *); 00297 00298 /** Source specific data */ 00299 void *data; 00300 }; 00301 00302 /** 00303 * Return information for image. This is optionally allocated by libisofs, 00304 * as a way to inform user about the features of an existing image, such as 00305 * extensions present, size, ... 00306 * 00307 * @see iso_image_import() 00308 * @since 0.6.2 00309 */ 00310 typedef struct iso_read_image_features IsoReadImageFeatures; 00311 00312 /** 00313 * POSIX abstraction for source files. 00314 * 00315 * @see struct iso_file_source 00316 * @since 0.6.2 00317 */ 00318 typedef struct iso_file_source IsoFileSource; 00319 00320 /** 00321 * Abstract for source filesystems. 00322 * 00323 * @see struct iso_filesystem 00324 * @since 0.6.2 00325 */ 00326 typedef struct iso_filesystem IsoFilesystem; 00327 00328 /** 00329 * Interface that defines the operations (methods) available for an 00330 * IsoFileSource. 00331 * 00332 * @see struct IsoFileSource_Iface 00333 * @since 0.6.2 00334 */ 00335 typedef struct IsoFileSource_Iface IsoFileSourceIface; 00336 00337 /** 00338 * IsoFilesystem implementation to deal with ISO images, and to offer a way to 00339 * access specific information of the image, such as several volume attributes, 00340 * extensions being used, El-Torito artifacts... 00341 * 00342 * @since 0.6.2 00343 */ 00344 typedef IsoFilesystem IsoImageFilesystem; 00345 00346 /** 00347 * See IsoFilesystem->get_id() for info about this. 00348 * @since 0.6.2 00349 */ 00350 extern unsigned int iso_fs_global_id; 00351 00352 /** 00353 * An IsoFilesystem is a handler for a source of files, or a "filesystem". 00354 * That is defined as a set of files that are organized in a hierarchical 00355 * structure. 00356 * 00357 * A filesystem allows libisofs to access files from several sources in 00358 * an homogeneous way, thus abstracting the underlying operations needed to 00359 * access and read file contents. Note that this doesn't need to be tied 00360 * to the disc filesystem used in the partition being accessed. For example, 00361 * we have an IsoFilesystem implementation to access any mounted filesystem, 00362 * using standard Linux functions. It is also legal, of course, to implement 00363 * an IsoFilesystem to deal with a specific filesystem over raw partitions. 00364 * That is what we do, for example, to access an ISO Image. 00365 * 00366 * Each file inside an IsoFilesystem is represented as an IsoFileSource object, 00367 * that defines POSIX-like interface for accessing files. 00368 * 00369 * @since 0.6.2 00370 */ 00371 struct iso_filesystem 00372 { 00373 /** 00374 * Type of filesystem. 00375 * "file" -> local filesystem 00376 * "iso " -> iso image filesystem 00377 */ 00378 char type[4]; 00379 00380 /* reserved for future usage, set to 0 */ 00381 int version; 00382 00383 /** 00384 * Get the root of a filesystem. 00385 * 00386 * @return 00387 * 1 on success, < 0 on error (has to be a valid libisofs error code) 00388 */ 00389 int (*get_root)(IsoFilesystem *fs, IsoFileSource **root); 00390 00391 /** 00392 * Retrieve a file from its absolute path inside the filesystem. 00393 * 00394 * @return 00395 * 1 success, < 0 error (has to be a valid libisofs error code) 00396 * Error codes: 00397 * ISO_FILE_ACCESS_DENIED 00398 * ISO_FILE_BAD_PATH 00399 * ISO_FILE_DOESNT_EXIST 00400 * ISO_OUT_OF_MEM 00401 * ISO_FILE_ERROR 00402 * ISO_NULL_POINTER 00403 */ 00404 int (*get_by_path)(IsoFilesystem *fs, const char *path, 00405 IsoFileSource **file); 00406 00407 /** 00408 * Get filesystem identifier. 00409 * 00410 * If the filesystem is able to generate correct values of the st_dev 00411 * and st_ino fields for the struct stat of each file, this should 00412 * return an unique number, greater than 0. 00413 * 00414 * To get a identifier for your filesystem implementation you should 00415 * use iso_fs_global_id, incrementing it by one each time. 00416 * 00417 * Otherwise, if you can't ensure values in the struct stat are valid, 00418 * this should return 0. 00419 */ 00420 unsigned int (*get_id)(IsoFilesystem *fs); 00421 00422 /** 00423 * Opens the filesystem for several read operations. Calling this funcion 00424 * is not needed at all, each time that the underlying system resource 00425 * needs to be accessed, it is openned propertly. 00426 * However, if you plan to execute several operations on the filesystem, 00427 * it is a good idea to open it previously, to prevent several open/close 00428 * operations to occur. 00429 * 00430 * @return 1 on success, < 0 on error (has to be a valid libisofs error code) 00431 */ 00432 int (*open)(IsoFilesystem *fs); 00433 00434 /** 00435 * Close the filesystem, thus freeing all system resources. You should 00436 * call this function if you have previously open() it. 00437 * Note that you can open()/close() a filesystem several times. 00438 * 00439 * @return 1 on success, < 0 on error (has to be a valid libisofs error code) 00440 */ 00441 int (*close)(IsoFilesystem *fs); 00442 00443 /** 00444 * Free implementation specific data. Should never be called by user. 00445 * Use iso_filesystem_unref() instead. 00446 */ 00447 void (*free)(IsoFilesystem *fs); 00448 00449 /* internal usage, do never access them directly */ 00450 unsigned int refcount; 00451 void *data; 00452 }; 00453 00454 /** 00455 * Interface definition for an IsoFileSource. Defines the POSIX-like function 00456 * to access files and abstract underlying source. 00457 * 00458 * @since 0.6.2 00459 */ 00460 struct IsoFileSource_Iface 00461 { 00462 /* reserved for future usage, set to 0 */ 00463 int version; 00464 00465 /** 00466 * Get the path, relative to the filesystem this file source belongs to. 00467 * 00468 * @return 00469 * the path of the FileSource inside the filesystem, it should be 00470 * freed when no more needed. 00471 */ 00472 char* (*get_path)(IsoFileSource *src); 00473 00474 /** 00475 * Get the name of the file, with the dir component of the path. 00476 * 00477 * @return 00478 * the name of the file, it should be freed when no more needed. 00479 */ 00480 char* (*get_name)(IsoFileSource *src); 00481 00482 /** 00483 * Get information about the file. It is equivalent to lstat(2). 00484 * 00485 * @return 00486 * 1 success, < 0 error (has to be a valid libisofs error code) 00487 * Error codes: 00488 * ISO_FILE_ACCESS_DENIED 00489 * ISO_FILE_BAD_PATH 00490 * ISO_FILE_DOESNT_EXIST 00491 * ISO_OUT_OF_MEM 00492 * ISO_FILE_ERROR 00493 * ISO_NULL_POINTER 00494 */ 00495 int (*lstat)(IsoFileSource *src, struct stat *info); 00496 00497 /** 00498 * Get information about the file. If the file is a symlink, the info 00499 * returned refers to the destination. It is equivalent to stat(2). 00500 * 00501 * @return 00502 * 1 success, < 0 error 00503 * Error codes: 00504 * ISO_FILE_ACCESS_DENIED 00505 * ISO_FILE_BAD_PATH 00506 * ISO_FILE_DOESNT_EXIST 00507 * ISO_OUT_OF_MEM 00508 * ISO_FILE_ERROR 00509 * ISO_NULL_POINTER 00510 */ 00511 int (*stat)(IsoFileSource *src, struct stat *info); 00512 00513 /** 00514 * Check if the process has access to read file contents. Note that this 00515 * is not necessarily related with (l)stat functions. For example, in a 00516 * filesystem implementation to deal with an ISO image, if the user has 00517 * read access to the image it will be able to read all files inside it, 00518 * despite of the particular permission of each file in the RR tree, that 00519 * are what the above functions return. 00520 * 00521 * @return 00522 * 1 if process has read access, < 0 on error (has to be a valid 00523 * libisofs error code) 00524 * Error codes: 00525 * ISO_FILE_ACCESS_DENIED 00526 * ISO_FILE_BAD_PATH 00527 * ISO_FILE_DOESNT_EXIST 00528 * ISO_OUT_OF_MEM 00529 * ISO_FILE_ERROR 00530 * ISO_NULL_POINTER 00531 */ 00532 int (*access)(IsoFileSource *src); 00533 00534 /** 00535 * Opens the source. 00536 * @return 1 on success, < 0 on error (has to be a valid libisofs error code) 00537 * Error codes: 00538 * ISO_FILE_ALREADY_OPENED 00539 * ISO_FILE_ACCESS_DENIED 00540 * ISO_FILE_BAD_PATH 00541 * ISO_FILE_DOESNT_EXIST 00542 * ISO_OUT_OF_MEM 00543 * ISO_FILE_ERROR 00544 * ISO_NULL_POINTER 00545 */ 00546 int (*open)(IsoFileSource *src); 00547 00548 /** 00549 * Close a previuously openned file 00550 * @return 1 on success, < 0 on error 00551 * Error codes: 00552 * ISO_FILE_ERROR 00553 * ISO_NULL_POINTER 00554 * ISO_FILE_NOT_OPENED 00555 */ 00556 int (*close)(IsoFileSource *src); 00557 00558 /** 00559 * Attempts to read up to count bytes from the given source into 00560 * the buffer starting at buf. 00561 * 00562 * The file src must be open() before calling this, and close() when no 00563 * more needed. Not valid for dirs. On symlinks it reads the destination 00564 * file. 00565 * 00566 * @return 00567 * number of bytes read, 0 if EOF, < 0 on error (has to be a valid 00568 * libisofs error code) 00569 * Error codes: 00570 * ISO_FILE_ERROR 00571 * ISO_NULL_POINTER 00572 * ISO_FILE_NOT_OPENED 00573 * ISO_WRONG_ARG_VALUE -> if count == 0 00574 * ISO_FILE_IS_DIR 00575 * ISO_OUT_OF_MEM 00576 * ISO_INTERRUPTED 00577 */ 00578 int (*read)(IsoFileSource *src, void *buf, size_t count); 00579 00580 /** 00581 * Read a directory. 00582 * 00583 * Each call to this function will return a new children, until we reach 00584 * the end of file (i.e, no more children), in that case it returns 0. 00585 * 00586 * The dir must be open() before calling this, and close() when no more 00587 * needed. Only valid for dirs. 00588 * 00589 * Note that "." and ".." children MUST NOT BE returned. 00590 * 00591 * @param child 00592 * pointer to be filled with the given child. Undefined on error or OEF 00593 * @return 00594 * 1 on success, 0 if EOF (no more children), < 0 on error (has to be 00595 * a valid libisofs error code) 00596 * Error codes: 00597 * ISO_FILE_ERROR 00598 * ISO_NULL_POINTER 00599 * ISO_FILE_NOT_OPENED 00600 * ISO_FILE_IS_NOT_DIR 00601 * ISO_OUT_OF_MEM 00602 */ 00603 int (*readdir)(IsoFileSource *src, IsoFileSource **child); 00604 00605 /** 00606 * Read the destination of a symlink. You don't need to open the file 00607 * to call this. 00608 * 00609 * @param buf 00610 * allocated buffer of at least bufsiz bytes. 00611 * The dest. will be copied there, and it will be NULL-terminated 00612 * @param bufsiz 00613 * characters to be copied. Destination link will be truncated if 00614 * it is larger than given size. This include the \0 character. 00615 * @return 00616 * 1 on success, < 0 on error (has to be a valid libisofs error code) 00617 * Error codes: 00618 * ISO_FILE_ERROR 00619 * ISO_NULL_POINTER 00620 * ISO_WRONG_ARG_VALUE -> if bufsiz <= 0 00621 * ISO_FILE_IS_NOT_SYMLINK 00622 * ISO_OUT_OF_MEM 00623 * ISO_FILE_BAD_PATH 00624 * ISO_FILE_DOESNT_EXIST 00625 * 00626 */ 00627 int (*readlink)(IsoFileSource *src, char *buf, size_t bufsiz); 00628 00629 /** 00630 * Get the filesystem for this source. No extra ref is added, so you 00631 * musn't unref the IsoFilesystem. 00632 * 00633 * @return 00634 * The filesystem, NULL on error 00635 */ 00636 IsoFilesystem* (*get_filesystem)(IsoFileSource *src); 00637 00638 /** 00639 * Free implementation specific data. Should never be called by user. 00640 * Use iso_file_source_unref() instead. 00641 */ 00642 void (*free)(IsoFileSource *src); 00643 00644 /** 00645 * Repositions the offset of the IsoFileSource (must be opened) to the 00646 * given offset according to the value of flag. 00647 * 00648 * @param offset 00649 * in bytes 00650 * @param flag 00651 * 0 The offset is set to offset bytes (SEEK_SET) 00652 * 1 The offset is set to its current location plus offset bytes 00653 * (SEEK_CUR) 00654 * 2 The offset is set to the size of the file plus offset bytes 00655 * (SEEK_END). 00656 * @return 00657 * Absolute offset posistion on the file, or < 0 on error. Cast the 00658 * returning value to int to get a valid libisofs error. 00659 * 00660 * @since 0.6.4 00661 */ 00662 off_t (*lseek)(IsoFileSource *src, off_t offset, int flag); 00663 00664 /* 00665 * TODO #00004 Add a get_mime_type() function. 00666 * This can be useful for GUI apps, to choose the icon of the file 00667 */ 00668 }; 00669 00670 /** 00671 * An IsoFile Source is a POSIX abstraction of a file. 00672 * 00673 * @since 0.6.2 00674 */ 00675 struct iso_file_source 00676 { 00677 const IsoFileSourceIface *class; 00678 int refcount; 00679 void *data; 00680 }; 00681 00682 /** 00683 * Representation of file contents. It is an stream of bytes, functionally 00684 * like a pipe. 00685 * 00686 * @since 0.6.4 00687 */ 00688 typedef struct iso_stream IsoStream; 00689 00690 /** 00691 * Interface that defines the operations (methods) available for an 00692 * IsoStream. 00693 * 00694 * @see struct IsoStream_Iface 00695 * @since 0.6.4 00696 */ 00697 typedef struct IsoStream_Iface IsoStreamIface; 00698 00699 /** 00700 * Serial number to be used when you can't get a valid id for a Stream by other 00701 * means. If you use this, both fs_id and dev_id should be set to 0. 00702 * This must be incremented each time you get a reference to it. 00703 * 00704 * @see IsoStreamIface->get_id() 00705 * @since 0.6.4 00706 */ 00707 extern ino_t serial_id; 00708 00709 /** 00710 * Interface definition for IsoStream methods. 00711 * 00712 * @since 0.6.4 00713 */ 00714 struct IsoStream_Iface 00715 { 00716 /* 00717 * Current version of the interface, set to 1. 00718 * 00719 * -version 1 (since 0.6.8) 00720 * update_size() added. 00721 */ 00722 int version; 00723 00724 /** 00725 * Type of Stream. 00726 * "fsrc" -> Read from file source 00727 * "mem " -> Read from memory 00728 * "boot" -> Boot catalog 00729 * "user" -> User supplied stream 00730 */ 00731 char type[4]; 00732 00733 /** 00734 * Opens the stream. 00735 * 00736 * @return 00737 * 1 on success, 2 file greater than expected, 3 file smaller than 00738 * expected, < 0 on error (has to be a valid libisofs error code) 00739 */ 00740 int (*open)(IsoStream *stream); 00741 00742 /** 00743 * Close the Stream. 00744 * @return 00745 * 1 on success, < 0 on error (has to be a valid libisofs error code) 00746 */ 00747 int (*close)(IsoStream *stream); 00748 00749 /** 00750 * Get the size (in bytes) of the stream. This function should always 00751 * return the same size, even if the underlying source size changes, 00752 * unless you call update_size() method. 00753 */ 00754 off_t (*get_size)(IsoStream *stream); 00755 00756 /** 00757 * Attempts to read up to count bytes from the given stream into 00758 * the buffer starting at buf. 00759 * 00760 * The stream must be open() before calling this, and close() when no 00761 * more needed. 00762 * 00763 * @return 00764 * number of bytes read, 0 if EOF, < 0 on error (has to be a valid 00765 * libisofs error code) 00766 */ 00767 int (*read)(IsoStream *stream, void *buf, size_t count); 00768 00769 /** 00770 * Whether this IsoStream can be read several times, with the same results. 00771 * For example, a regular file is repeatable, you can read it as many 00772 * times as you want. However, a pipe isn't. 00773 * 00774 * This function doesn't take into account if the file has been modified 00775 * between the two reads. 00776 * 00777 * @return 00778 * 1 if stream is repeatable, 0 if not, 00779 * < 0 on error (has to be a valid libisofs error code) 00780 */ 00781 int (*is_repeatable)(IsoStream *stream); 00782 00783 /** 00784 * Get an unique identifier for the IsoStream. 00785 */ 00786 void (*get_id)(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, 00787 ino_t *ino_id); 00788 00789 /** 00790 * Free implementation specific data. Should never be called by user. 00791 * Use iso_stream_unref() instead. 00792 */ 00793 void (*free)(IsoStream *stream); 00794 00795 /** 00796 * Updates the size of the IsoStream with the current size of the 00797 * underlying source. After calling this, get_size() will return 00798 * the new size. This should never be called after 00799 * iso_image_create_burn_source() was called and the image was not 00800 * completely written. To update the size of all files before written the 00801 * image, you may want to call iso_image_update_sizes() just before 00802 * iso_image_create_burn_source(). 00803 * 00804 * @return 00805 * 1 if ok, < 0 on error (has to be a valid libisofs error code) 00806 * @since 0.6.8 00807 */ 00808 int (*update_size)(IsoStream *stream); 00809 }; 00810 00811 /** 00812 * Representation of file contents as a stream of bytes. 00813 * 00814 * @since 0.6.4 00815 */ 00816 struct iso_stream 00817 { 00818 IsoStreamIface *class; 00819 int refcount; 00820 void *data; 00821 }; 00822 00823 /** 00824 * Initialize libisofs. You must call this before any usage of the library. 00825 * @return 1 on success, < 0 on error 00826 * 00827 * @since 0.6.2 00828 */ 00829 int iso_init(); 00830 00831 /** 00832 * Finalize libisofs. 00833 * 00834 * @since 0.6.2 00835 */ 00836 void iso_finish(); 00837 00838 /** 00839 * Override the reply of libc function nl_langinfo(CODESET) which may or may 00840 * not give the name of the character set which is in effect for your 00841 * environment. So this call can compensate for inconsistent terminal setups. 00842 * Another use case is to choose UTF-8 as intermediate character set for a 00843 * conversion from an exotic input character set to an exotic output set. 00844 * 00845 * @param name 00846 * Name of the character set to be assumed as "local" one. 00847 * @param flag 00848 * Unused yet. Submit 0. 00849 * @return 00850 * 1 indicates success, <=0 failure 00851 * 00852 * @since 0.6.12 00853 */ 00854 int iso_set_local_charset(char *name, int flag); 00855 00856 /** 00857 * Obtain the local charset as currently assumed by libisofs. 00858 * The result points to internal memory. It is volatile and must not be 00859 * altered. 00860 * 00861 * @param flag 00862 * Unused yet. Submit 0. 00863 * 00864 * @since 0.6.12 00865 */ 00866 char *iso_get_local_charset(int flag); 00867 00868 /** 00869 * Create a new image, empty. 00870 * 00871 * The image will be owned by you and should be unref() when no more needed. 00872 * 00873 * @param name 00874 * Name of the image. This will be used as volset_id and volume_id. 00875 * @param image 00876 * Location where the image pointer will be stored. 00877 * @return 00878 * 1 sucess, < 0 error 00879 * 00880 * @since 0.6.2 00881 */ 00882 int iso_image_new(const char *name, IsoImage **image); 00883 00884 00885 /** 00886 * The following two functions three macros are utilities to help ensuring 00887 * version match of application, compile time header, and runtime library. 00888 */ 00889 /** 00890 * Get version of the libisofs library at runtime. 00891 * 00892 * @since 0.6.2 00893 */ 00894 void iso_lib_version(int *major, int *minor, int *micro); 00895 00896 /** 00897 * Check at runtime if the library is ABI compatible with the given version. 00898 * 00899 * @return 00900 * 1 lib is compatible, 0 is not. 00901 * 00902 * @since 0.6.2 00903 */ 00904 int iso_lib_is_compatible(int major, int minor, int micro); 00905 00906 00907 /** 00908 * These three release version numbers tell the revision of this header file 00909 * and of the API it describes. They are memorized by applications at 00910 * compile time. 00911 * They must show the same values as these symbols in ./configure.ac 00912 * LIBISOFS_MAJOR_VERSION=... 00913 * LIBISOFS_MINOR_VERSION=... 00914 * LIBISOFS_MICRO_VERSION=... 00915 * Note to anybody who does own work inside libisofs: 00916 * Any change of configure.ac or libisofs.h has to keep up this equality ! 00917 * 00918 * Before usage of these macros on your code, please read the usage discussion 00919 * below. 00920 * 00921 * @since 0.6.2 00922 */ 00923 #define iso_lib_header_version_major 0 00924 #define iso_lib_header_version_minor 6 00925 #define iso_lib_header_version_micro 12 00926 00927 /** 00928 * Usage discussion: 00929 * 00930 * Some developers of the libburnia project have differing opinions how to 00931 * ensure the compatibility of libaries and applications. 00932 * 00933 * It is about whether to use at compile time and at runtime the version 00934 * numbers provided here. Thomas Schmitt advises to use them. Vreixo Formoso 00935 * advises to use other means. 00936 * 00937 * At compile time: 00938 * 00939 * Vreixo Formoso advises to leave proper version matching to properly 00940 * programmed checks in the the application's build system, which will 00941 * eventually refuse compilation. 00942 * 00943 * Thomas Schmitt advises to use the macros defined here for comparison with 00944 * the application's requirements of library revisions and to eventually 00945 * break compilation. 00946 * 00947 * Both advises are combinable. I.e. be master of your build system and have 00948 * #if checks in the source code of your application, nevertheless. 00949 * 00950 * At runtime (via iso_lib_is_compatible()): 00951 * 00952 * Vreixo Formoso advises to compare the application's requirements of 00953 * library revisions with the runtime library. This is to allow runtime 00954 * libraries which are young enough for the application but too old for 00955 * the lib*.h files seen at compile time. 00956 * 00957 * Thomas Schmitt advises to compare the header revisions defined here with 00958 * the runtime library. This is to enforce a strictly monotonous chain of 00959 * revisions from app to header to library, at the cost of excluding some older 00960 * libraries. 00961 * 00962 * These two advises are mutually exclusive. 00963 */ 00964 00965 00966 /** 00967 * Creates an IsoWriteOpts for writing an image. You should set the options 00968 * desired with the correspondent setters. 00969 * 00970 * Options by default are determined by the selected profile. Fifo size is set 00971 * by default to 2 MB. 00972 * 00973 * @param opts 00974 * Pointer to the location where the newly created IsoWriteOpts will be 00975 * stored. You should free it with iso_write_opts_free() when no more 00976 * needed. 00977 * @param profile 00978 * Default profile for image creation. For now the following values are 00979 * defined: 00980 * ---> 0 [BASIC] 00981 * No extensions are enabled, and ISO level is set to 1. Only suitable 00982 * for usage for very old and limited systems (like MS-DOS), or by a 00983 * start point from which to set your custom options. 00984 * ---> 1 [BACKUP] 00985 * POSIX compatibility for backup. Simple settings, ISO level is set to 00986 * 3 and RR extensions are enabled. Useful for backup purposes. 00987 * ---> 2 [DISTRIBUTION] 00988 * Setting for information distribution. Both RR and Joliet are enabled 00989 * to maximize compatibility with most systems. Permissions are set to 00990 * default values, and timestamps to the time of recording. 00991 * @return 00992 * 1 success, < 0 error 00993 * 00994 * @since 0.6.2 00995 */ 00996 int iso_write_opts_new(IsoWriteOpts **opts, int profile); 00997 00998 /** 00999 * Free an IsoWriteOpts previously allocated with iso_write_opts_new(). 01000 * 01001 * @since 0.6.2 01002 */ 01003 void iso_write_opts_free(IsoWriteOpts *opts); 01004 01005 /** 01006 * Set the ISO-9960 level to write at. 01007 * 01008 * @param level 01009 * -> 1 for higher compatibility with old systems. With this level 01010 * filenames are restricted to 8.3 characters. 01011 * -> 2 to allow up to 31 filename characters. 01012 * -> 3 to allow files greater than 4GB 01013 * @return 01014 * 1 success, < 0 error 01015 * 01016 * @since 0.6.2 01017 */ 01018 int iso_write_opts_set_iso_level(IsoWriteOpts *opts, int level); 01019 01020 /** 01021 * Whether to use or not Rock Ridge extensions. 01022 * 01023 * This are standard extensions to ECMA-119, intended to add POSIX filesystem 01024 * features to ECMA-119 images. Thus, usage of this flag is highly recommended 01025 * for images used on GNU/Linux systems. With the usage of RR extension, the 01026 * resulting image will have long filenames (up to 255 characters), deeper 01027 * directory structure, POSIX permissions and owner info on files and 01028 * directories, support for symbolic links or special files... All that 01029 * attributes can be modified/setted with the appropiate function. 01030 * 01031 * @param enable 01032 * 1 to enable RR extension, 0 to not add them 01033 * @return 01034 * 1 success, < 0 error 01035 * 01036 * @since 0.6.2 01037 */ 01038 int iso_write_opts_set_rockridge(IsoWriteOpts *opts, int enable); 01039 01040 /** 01041 * Whether to add the non-standard Joliet extension to the image. 01042 * 01043 * This extensions are heavily used in Microsoft Windows systems, so if you 01044 * plan to use your disc on such a system you should add this extension. 01045 * Usage of Joliet supplies longer filesystem length (up to 64 unicode 01046 * characters), and deeper directory structure. 01047 * 01048 * @param enable 01049 * 1 to enable Joliet extension, 0 to not add them 01050 * @return 01051 * 1 success, < 0 error 01052 * 01053 * @since 0.6.2 01054 */ 01055 int iso_write_opts_set_joliet(IsoWriteOpts *opts, int enable); 01056 01057 /** 01058 * Whether to use newer ISO-9660:1999 version. 01059 * 01060 * This is the second version of ISO-9660. It allows longer filenames and has 01061 * less restrictions than old ISO-9660. However, nobody is using it so there 01062 * are no much reasons to enable this. 01063 * 01064 * @since 0.6.2 01065 */ 01066 int iso_write_opts_set_iso1999(IsoWriteOpts *opts, int enable); 01067 01068 /** 01069 * Omit the version number (";1") at the end of the ISO-9660 identifiers. 01070 * This breaks ECMA-119 specification, but version numbers are usually not 01071 * used, so it should work on most systems. Use with caution. 01072 * 01073 * @since 0.6.2 01074 */ 01075 int iso_write_opts_set_omit_version_numbers(IsoWriteOpts *opts, int omit); 01076 01077 /** 01078 * Allow ISO-9660 directory hierarchy to be deeper than 8 levels. 01079 * This breaks ECMA-119 specification. Use with caution. 01080 * 01081 * @since 0.6.2 01082 */ 01083 int iso_write_opts_set_allow_deep_paths(IsoWriteOpts *opts, int allow); 01084 01085 /** 01086 * Allow path in the ISO-9660 tree to have more than 255 characters. 01087 * This breaks ECMA-119 specification. Use with caution. 01088 * 01089 * @since 0.6.2 01090 */ 01091 int iso_write_opts_set_allow_longer_paths(IsoWriteOpts *opts, int allow); 01092 01093 /** 01094 * Allow a single file or directory hierarchy to have up to 37 characters. 01095 * This is larger than the 31 characters allowed by ISO level 2, and the 01096 * extra space is taken from the version number, so this also forces 01097 * omit_version_numbers. 01098 * This breaks ECMA-119 specification and could lead to buffer overflow 01099 * problems on old systems. Use with caution. 01100 * 01101 * @since 0.6.2 01102 */ 01103 int iso_write_opts_set_max_37_char_filenames(IsoWriteOpts *opts, int allow); 01104 01105 /** 01106 * ISO-9660 forces filenames to have a ".", that separates file name from 01107 * extension. libisofs adds it if original filename doesn't has one. Set 01108 * this to 1 to prevent this behavior. 01109 * This breaks ECMA-119 specification. Use with caution. 01110 * 01111 * @since 0.6.2 01112 */ 01113 int iso_write_opts_set_no_force_dots(IsoWriteOpts *opts, int no); 01114 01115 /** 01116 * Allow lowercase characters in ISO-9660 filenames. By default, only 01117 * uppercase characters, numbers and a few other characters are allowed. 01118 * This breaks ECMA-119 specification. Use with caution. 01119 * 01120 * @since 0.6.2 01121 */ 01122 int iso_write_opts_set_allow_lowercase(IsoWriteOpts *opts, int allow); 01123 01124 /** 01125 * Allow all ASCII characters to be appear on an ISO-9660 filename. Note 01126 * that "/" and "\0" characters are never allowed, even in RR names. 01127 * This breaks ECMA-119 specification. Use with caution. 01128 * 01129 * @since 0.6.2 01130 */ 01131 int iso_write_opts_set_allow_full_ascii(IsoWriteOpts *opts, int allow); 01132 01133 /** 01134 * Allow all characters to be part of Volume and Volset identifiers on 01135 * the Primary Volume Descriptor. This breaks ISO-9660 contraints, but 01136 * should work on modern systems. 01137 * 01138 * @since 0.6.2 01139 */ 01140 int iso_write_opts_set_relaxed_vol_atts(IsoWriteOpts *opts, int allow); 01141 01142 /** 01143 * Allow paths in the Joliet tree to have more than 240 characters. 01144 * This breaks Joliet specification. Use with caution. 01145 * 01146 * @since 0.6.2 01147 */ 01148 int iso_write_opts_set_joliet_longer_paths(IsoWriteOpts *opts, int allow); 01149 01150 /** 01151 * Write Rock Ridge info as of specification RRIP-1.10 rather than RRIP-1.12: 01152 * signature "RRIP_1991A" rather than "IEEE_1282", field PX without file 01153 * serial number. 01154 * 01155 * @since 0.6.12 01156 */ 01157 int iso_write_opts_set_rrip_version_1_10(IsoWriteOpts *opts, int oldvers); 01158 01159 /** 01160 * Store as ECMA-119 Directory Record timestamp the mtime of the source 01161 * rather than the image creation time. 01162 * 01163 * @since 0.6.12 01164 */ 01165 int iso_write_opts_set_dir_rec_mtime(IsoWriteOpts *opts, int allow); 01166 01167 /** 01168 * Whether to sort files based on their weight. 01169 * 01170 * @see iso_node_set_sort_weight 01171 * @since 0.6.2 01172 */ 01173 int iso_write_opts_set_sort_files(IsoWriteOpts *opts, int sort); 01174 01175 /** 01176 * Whether to set default values for files and directory permissions, gid and 01177 * uid. All these take one of three values: 0, 1 or 2. 01178 * 01179 * If 0, the corresponding attribute will be kept as setted in the IsoNode. 01180 * Unless you have changed it, it corresponds to the value on disc, so it 01181 * is suitable for backup purposes. If set to 1, the corresponding attrib. 01182 * will be changed by a default suitable value. Finally, if you set it to 01183 * 2, the attrib. will be changed with the value specified by the functioins 01184 * below. Note that for mode attributes, only the permissions are set, the 01185 * file type remains unchanged. 01186 * 01187 * @see iso_write_opts_set_default_dir_mode 01188 * @see iso_write_opts_set_default_file_mode 01189 * @see iso_write_opts_set_default_uid 01190 * @see iso_write_opts_set_default_gid 01191 * @since 0.6.2 01192 */ 01193 int iso_write_opts_set_replace_mode(IsoWriteOpts *opts, int dir_mode, 01194 int file_mode, int uid, int gid); 01195 01196 /** 01197 * Set the mode to use on dirs when you set the replace_mode of dirs to 2. 01198 * 01199 * @see iso_write_opts_set_replace_mode 01200 * @since 0.6.2 01201 */ 01202 int iso_write_opts_set_default_dir_mode(IsoWriteOpts *opts, mode_t dir_mode); 01203 01204 /** 01205 * Set the mode to use on files when you set the replace_mode of files to 2. 01206 * 01207 * @see iso_write_opts_set_replace_mode 01208 * @since 0.6.2 01209 */ 01210 int iso_write_opts_set_default_file_mode(IsoWriteOpts *opts, mode_t file_mode); 01211 01212 /** 01213 * Set the uid to use when you set the replace_uid to 2. 01214 * 01215 * @see iso_write_opts_set_replace_mode 01216 * @since 0.6.2 01217 */ 01218 int iso_write_opts_set_default_uid(IsoWriteOpts *opts, uid_t uid); 01219 01220 /** 01221 * Set the gid to use when you set the replace_gid to 2. 01222 * 01223 * @see iso_write_opts_set_replace_mode 01224 * @since 0.6.2 01225 */ 01226 int iso_write_opts_set_default_gid(IsoWriteOpts *opts, gid_t gid); 01227 01228 /** 01229 * 0 to use IsoNode timestamps, 1 to use recording time, 2 to use 01230 * values from timestamp field. This has only meaning if RR extensions 01231 * are enabled. 01232 * 01233 * @see iso_write_opts_set_default_timestamp 01234 * @since 0.6.2 01235 */ 01236 int iso_write_opts_set_replace_timestamps(IsoWriteOpts *opts, int replace); 01237 01238 /** 01239 * Set the timestamp to use when you set the replace_timestamps to 2. 01240 * 01241 * @see iso_write_opts_set_replace_timestamps 01242 * @since 0.6.2 01243 */ 01244 int iso_write_opts_set_default_timestamp(IsoWriteOpts *opts, time_t timestamp); 01245 01246 /** 01247 * Whether to always record timestamps in GMT. 01248 * 01249 * By default, libisofs stores local time information on image. You can set 01250 * this to always store timestamps converted to GMT. This prevents any 01251 * discrimination of the timezone of the image preparer by the image reader. 01252 * 01253 * It is useful if you want to hide your timezone, or you live in a timezone 01254 * that can't be represented in ECMA-119. These are timezones with an offset 01255 * from GMT greater than +13 hours, lower than -12 hours, or not a multiple 01256 * of 15 minutes. 01257 * Negative timezones (west of GMT) can trigger bugs in some operating systems 01258 * which typically appear in mounted ISO images as if the timezone shift from 01259 * GMT was applied twice (e.g. in New York 22:36 becomes 17:36). 01260 * 01261 * @since 0.6.2 01262 */ 01263 int iso_write_opts_set_always_gmt(IsoWriteOpts *opts, int gmt); 01264 01265 /** 01266 * Set the charset to use for the RR names of the files that will be created 01267 * on the image. 01268 * NULL to use default charset, that is the locale charset. 01269 * You can obtain the list of charsets supported on your system executing 01270 * "iconv -l" in a shell. 01271 * 01272 * @since 0.6.2 01273 */ 01274 int iso_write_opts_set_output_charset(IsoWriteOpts *opts, const char *charset); 01275 01276 /** 01277 * Set the type of the image to create. Libisofs support two kind of images: 01278 * stand-alone and appendable. 01279 * 01280 * A stand-alone image is an image that is valid alone, and that can be 01281 * mounted by its own. This is the kind of image you will want to create 01282 * in most cases. A stand-alone image can be burned in an empty CD or DVD, 01283 * or write to an .iso file for future burning or distribution. 01284 * 01285 * On the other side, an appendable image is not self contained, it refers 01286 * to serveral files that are stored outside the image. Its usage is for 01287 * multisession discs, where you add data in a new session, while the 01288 * previous session data can still be accessed. In those cases, the old 01289 * data is not written again. Instead, the new image refers to it, and thus 01290 * it's only valid when appended to the original. Note that in those cases 01291 * the image will be written after the original, and thus you will want 01292 * to use a ms_block greater than 0. 01293 * 01294 * Note that if you haven't import a previous image (by means of 01295 * iso_image_import()), the image will always be a stand-alone image, as 01296 * there is no previous data to refer to. 01297 * 01298 * @param appendable 01299 * 1 to create an appendable image, 0 for an stand-alone one. 01300 * 01301 * @since 0.6.2 01302 */ 01303 int iso_write_opts_set_appendable(IsoWriteOpts *opts, int appendable); 01304 01305 /** 01306 * Set the start block of the image. It is supposed to be the lba where the 01307 * first block of the image will be written on disc. All references inside the 01308 * ISO image will take this into account, thus providing a mountable image. 01309 * 01310 * For appendable images, that are written to a new session, you should 01311 * pass here the lba of the next writable address on disc. 01312 * 01313 * In stand alone images this is usually 0. However, you may want to 01314 * provide a different ms_block if you don't plan to burn the image in the 01315 * first session on disc, such as in some CD-Extra disc whether the data 01316 * image is written in a new session after some audio tracks. 01317 * 01318 * @since 0.6.2 01319 */ 01320 int iso_write_opts_set_ms_block(IsoWriteOpts *opts, uint32_t ms_block); 01321 01322 /** 01323 * Sets the buffer where to store the descriptors which shall to be written 01324 * at the beginning of an overwriteable media to point to the newly written 01325 * image. 01326 * This is needed if the write start address of the image is not 0. 01327 * In this case the first 64 KiB of the media have to be overwritten 01328 * by the buffer content after the session was written and the buffer 01329 * was updated by libisofs. Otherwise the new session would not be 01330 * found by operating system function mount() or by libisoburn. 01331 * (One could still mount that session if its start address is known.) 01332 * 01333 * If you do not need this information, for example because you are creating a 01334 * new image for LBA 0 or because you will create an image for a true 01335 * multisession media, just do not use this call or set buffer to NULL. 01336 * 01337 * Use cases: 01338 * 01339 * - Together with iso_write_opts_set_appendable(opts, 1) the buffer serves 01340 * for the growing of an image as done in growisofs by Andy Polyakov. 01341 * This allows appending of a new session to non-multisession media, such 01342 * as DVD+RW. The new session will refer to the data of previous sessions 01343 * on the same media. 01344 * libisoburn emulates multisession appendability on overwriteable media 01345 * and disk files by performing this use case. 01346 * 01347 * - Together with iso_write_opts_set_appendable(opts, 0) the buffer allows 01348 * to write the first session on overwriteable media to start addresses 01349 * other than 0. 01350 * libisoburn in most cases writes the first session on overwriteable media 01351 * and disk files to LBA 32 in order to preserve its descriptors from the 01352 * subsequent overwriting by the descriptor buffer of later sessions. 01353 * 01354 * @param buffer 01355 * When not NULL, it should point to at least 64KiB of memory, where 01356 * libisofs will install the contents that shall be written at the 01357 * beginning of overwriteable media. 01358 * You should initialize the buffer either with 0s, or with the contents 01359 * of the first 32 blocks of the image you are growing. In most cases, 01360 * 0 is good enought. 01361 * 01362 * @since 0.6.2 01363 */ 01364 int iso_write_opts_set_overwrite_buf(IsoWriteOpts *opts, uint8_t *overwrite); 01365 01366 /** 01367 * Set the size, in number of blocks, of the FIFO buffer used between the 01368 * writer thread and the burn_source. You have to provide at least a 32 01369 * blocks buffer. Default value is set to 2MB, if that is ok for you, you 01370 * don't need to call this function. 01371 * 01372 * @since 0.6.2 01373 */ 01374 int iso_write_opts_set_fifo_size(IsoWriteOpts *opts, size_t fifo_size); 01375 01376 /** 01377 * Create a burn_source and a thread which immediately begins to generate 01378 * the image. That burn_source can be used with libburn as a data source 01379 * for a track. For its public declaration see libburn.h. 01380 * 01381 * If image generation shall be aborted by the application program, then 01382 * the .cancel() method of the burn_source must be called to end the 01383 * generation thread: burn_src->cancel(burn_src); 01384 * 01385 * @param image 01386 * The image to write. 01387 * @param opts 01388 * The options for image generation. All needed data will be copied, so 01389 * you can free the given struct once this function returns. 01390 * @param burn_src 01391 * Location where the pointer to the burn_source will be stored 01392 * @return 01393 * 1 on success, < 0 on error 01394 * 01395 * @since 0.6.2 01396 */ 01397 int iso_image_create_burn_source(IsoImage *image, IsoWriteOpts *opts, 01398 struct burn_source **burn_src); 01399 01400 /** 01401 * Update the sizes of all files added to image. 01402 * 01403 * This may be called just before iso_image_create_burn_source() to force 01404 * libisofs to check the file sizes again (they're already checked when added 01405 * to IsoImage). It is useful if you have changed some files after adding then 01406 * to the image. 01407 * 01408 * @return 01409 * 1 on success, < 0 on error 01410 * @since 0.6.8 01411 */ 01412 int iso_image_update_sizes(IsoImage *image); 01413 01414 /** 01415 * Creates an IsoReadOpts for reading an existent image. You should set the 01416 * options desired with the correspondent setters. Note that you may want to 01417 * set the start block value. 01418 * 01419 * Options by default are determined by the selected profile. 01420 * 01421 * @param opts 01422 * Pointer to the location where the newly created IsoReadOpts will be 01423 * stored. You should free it with iso_read_opts_free() when no more 01424 * needed. 01425 * @param profile 01426 * Default profile for image reading. For now the following values are 01427 * defined: 01428 * ---> 0 [STANDARD] 01429 * Suitable for most situations. All extension are read. When both 01430 * Joliet and RR extension are present, RR is used. 01431 * @return 01432 * 1 success, < 0 error 01433 * 01434 * @since 0.6.2 01435 */ 01436 int iso_read_opts_new(IsoReadOpts **opts, int profile); 01437 01438 /** 01439 * Free an IsoReadOpts previously allocated with iso_read_opts_new(). 01440 * 01441 * @since 0.6.2 01442 */ 01443 void iso_read_opts_free(IsoReadOpts *opts); 01444 01445 /** 01446 * Set the block where the image begins. It is usually 0, but may be different 01447 * on a multisession disc. 01448 * 01449 * @since 0.6.2 01450 */ 01451 int iso_read_opts_set_start_block(IsoReadOpts *opts, uint32_t block); 01452 01453 /** 01454 * Do not read Rock Ridge extensions. 01455 * In most cases you don't want to use this. It could be useful if RR info 01456 * is damaged, or if you want to use the Joliet tree. 01457 * 01458 * @since 0.6.2 01459 */ 01460 int iso_read_opts_set_no_rockridge(IsoReadOpts *opts, int norr); 01461 01462 /** 01463 * Do not read Joliet extensions. 01464 * 01465 * @since 0.6.2 01466 */ 01467 int iso_read_opts_set_no_joliet(IsoReadOpts *opts, int nojoliet); 01468 01469 /** 01470 * Do not read ISO 9660:1999 enhanced tree 01471 * 01472 * @since 0.6.2 01473 */ 01474 int iso_read_opts_set_no_iso1999(IsoReadOpts *opts, int noiso1999); 01475 01476 /** 01477 * Whether to prefer Joliet over RR. libisofs usually prefers RR over 01478 * Joliet, as it give us much more info about files. So, if both extensions 01479 * are present, RR is used. You can set this if you prefer Joliet, but 01480 * note that this is not very recommended. This doesn't mean than RR 01481 * extensions are not read: if no Joliet is present, libisofs will read 01482 * RR tree. 01483 * 01484 * @since 0.6.2 01485 */ 01486 int iso_read_opts_set_preferjoliet(IsoReadOpts *opts, int preferjoliet); 01487 01488 /** 01489 * Set default uid for files when RR extensions are not present. 01490 * 01491 * @since 0.6.2 01492 */ 01493 int iso_read_opts_set_default_uid(IsoReadOpts *opts, uid_t uid); 01494 01495 /** 01496 * Set default gid for files when RR extensions are not present. 01497 * 01498 * @since 0.6.2 01499 */ 01500 int iso_read_opts_set_default_gid(IsoReadOpts *opts, gid_t gid); 01501 01502 /** 01503 * Set default permissions for files when RR extensions are not present. 01504 * 01505 * @param file_perm 01506 * Permissions for files. 01507 * @param dir_perm 01508 * Permissions for directories. 01509 * 01510 * @since 0.6.2 01511 */ 01512 int iso_read_opts_set_default_permissions(IsoReadOpts *opts, mode_t file_perm, 01513 mode_t dir_perm); 01514 01515 /** 01516 * Set the input charset of the file names on the image. NULL to use locale 01517 * charset. You have to specify a charset if the image filenames are encoded 01518 * in a charset different that the local one. This could happen, for example, 01519 * if the image was created on a system with different charset. 01520 * 01521 * @param charset 01522 * The charset to use as input charset. You can obtain the list of 01523 * charsets supported on your system executing "iconv -l" in a shell. 01524 * 01525 * @since 0.6.2 01526 */ 01527 int iso_read_opts_set_input_charset(IsoReadOpts *opts, const char *charset); 01528 01529 /** 01530 * Import a previous session or image, for growing or modify. 01531 * 01532 * @param image 01533 * The image context to which old image will be imported. Note that all 01534 * files added to image, and image attributes, will be replaced with the 01535 * contents of the old image. 01536 * TODO #00025 support for merging old image files 01537 * @param src 01538 * Data Source from which old image will be read. A extra reference is 01539 * added, so you still need to iso_data_source_unref() yours. 01540 * @param opts 01541 * Options for image import. All needed data will be copied, so you 01542 * can free the given struct once this function returns. 01543 * @param features 01544 * If not NULL, a new IsoReadImageFeatures will be allocated and filled 01545 * with the features of the old image. It should be freed with 01546 * iso_read_image_features_destroy() when no more needed. You can pass 01547 * NULL if you're not interested on them. 01548 * @return 01549 * 1 on success, < 0 on error 01550 * 01551 * @since 0.6.2 01552 */ 01553 int iso_image_import(IsoImage *image, IsoDataSource *src, IsoReadOpts *opts, 01554 IsoReadImageFeatures **features); 01555 01556 /** 01557 * Destroy an IsoReadImageFeatures object obtained with iso_image_import. 01558 * 01559 * @since 0.6.2 01560 */ 01561 void iso_read_image_features_destroy(IsoReadImageFeatures *f); 01562 01563 /** 01564 * Get the size (in 2048 byte block) of the image, as reported in the PVM. 01565 * 01566 * @since 0.6.2 01567 */ 01568 uint32_t iso_read_image_features_get_size(IsoReadImageFeatures *f); 01569 01570 /** 01571 * Whether RockRidge extensions are present in the image imported. 01572 * 01573 * @since 0.6.2 01574 */ 01575 int iso_read_image_features_has_rockridge(IsoReadImageFeatures *f); 01576 01577 /** 01578 * Whether Joliet extensions are present in the image imported. 01579 * 01580 * @since 0.6.2 01581 */ 01582 int iso_read_image_features_has_joliet(IsoReadImageFeatures *f); 01583 01584 /** 01585 * Whether the image is recorded according to ISO 9660:1999, i.e. it has 01586 * a version 2 Enhanced Volume Descriptor. 01587 * 01588 * @since 0.6.2 01589 */ 01590 int iso_read_image_features_has_iso1999(IsoReadImageFeatures *f); 01591 01592 /** 01593 * Whether El-Torito boot record is present present in the image imported. 01594 * 01595 * @since 0.6.2 01596 */ 01597 int iso_read_image_features_has_eltorito(IsoReadImageFeatures *f); 01598 01599 /** 01600 * Increments the reference counting of the given image. 01601 * 01602 * @since 0.6.2 01603 */ 01604 void iso_image_ref(IsoImage *image); 01605 01606 /** 01607 * Decrements the reference couting of the given image. 01608 * If it reaches 0, the image is free, together with its tree nodes (whether 01609 * their refcount reach 0 too, of course). 01610 * 01611 * @since 0.6.2 01612 */ 01613 void iso_image_unref(IsoImage *image); 01614 01615 /** 01616 * Attach user defined data to the image. Use this if your application needs 01617 * to store addition info together with the IsoImage. If the image already 01618 * has data attached, the old data will be freed. 01619 * 01620 * @param data 01621 * Pointer to application defined data that will be attached to the 01622 * image. You can pass NULL to remove any already attached data. 01623 * @param give_up 01624 * Function that will be called when the image does not need the data 01625 * any more. It receives the data pointer as an argumente, and eventually 01626 * causes data to be freed. It can be NULL if you don't need it. 01627 * @return 01628 * 1 on succes, < 0 on error 01629 * 01630 * @since 0.6.2 01631 */ 01632 int iso_image_attach_data(IsoImage *image, void *data, void (*give_up)(void*)); 01633 01634 /** 01635 * The the data previously attached with iso_image_attach_data() 01636 * 01637 * @since 0.6.2 01638 */ 01639 void *iso_image_get_attached_data(IsoImage *image); 01640 01641 /** 01642 * Get the root directory of the image. 01643 * No extra ref is added to it, so you musn't unref it. Use iso_node_ref() 01644 * if you want to get your own reference. 01645 * 01646 * @since 0.6.2 01647 */ 01648 IsoDir *iso_image_get_root(const IsoImage *image); 01649 01650 /** 01651 * Fill in the volset identifier for a image. 01652 * 01653 * @since 0.6.2 01654 */ 01655 void iso_image_set_volset_id(IsoImage *image, const char *volset_id); 01656 01657 /** 01658 * Get the volset identifier. 01659 * The returned string is owned by the image and should not be freed nor 01660 * changed. 01661 * 01662 * @since 0.6.2 01663 */ 01664 const char *iso_image_get_volset_id(const IsoImage *image); 01665 01666 /** 01667 * Fill in the volume identifier for a image. 01668 * 01669 * @since 0.6.2 01670 */ 01671 void iso_image_set_volume_id(IsoImage *image, const char *volume_id); 01672 01673 /** 01674 * Get the volume identifier. 01675 * The returned string is owned by the image and should not be freed nor 01676 * changed. 01677 * 01678 * @since 0.6.2 01679 */ 01680 const char *iso_image_get_volume_id(const IsoImage *image); 01681 01682 /** 01683 * Fill in the publisher for a image. 01684 * 01685 * @since 0.6.2 01686 */ 01687 void iso_image_set_publisher_id(IsoImage *image, const char *publisher_id); 01688 01689 /** 01690 * Get the publisher of a image. 01691 * The returned string is owned by the image and should not be freed nor 01692 * changed. 01693 * 01694 * @since 0.6.2 01695 */ 01696 const char *iso_image_get_publisher_id(const IsoImage *image); 01697 01698 /** 01699 * Fill in the data preparer for a image. 01700 * 01701 * @since 0.6.2 01702 */ 01703 void iso_image_set_data_preparer_id(IsoImage *image, 01704 const char *data_preparer_id); 01705 01706 /** 01707 * Get the data preparer of a image. 01708 * The returned string is owned by the image and should not be freed nor 01709 * changed. 01710 * 01711 * @since 0.6.2 01712 */ 01713 const char *iso_image_get_data_preparer_id(const IsoImage *image); 01714 01715 /** 01716 * Fill in the system id for a image. Up to 32 characters. 01717 * 01718 * @since 0.6.2 01719 */ 01720 void iso_image_set_system_id(IsoImage *image, const char *system_id); 01721 01722 /** 01723 * Get the system id of a image. 01724 * The returned string is owned by the image and should not be freed nor 01725 * changed. 01726 * 01727 * @since 0.6.2 01728 */ 01729 const char *iso_image_get_system_id(const IsoImage *image); 01730 01731 /** 01732 * Fill in the application id for a image. Up to 128 chars. 01733 * 01734 * @since 0.6.2 01735 */ 01736 void iso_image_set_application_id(IsoImage *image, const char *application_id); 01737 01738 /** 01739 * Get the application id of a image. 01740 * The returned string is owned by the image and should not be freed nor 01741 * changed. 01742 * 01743 * @since 0.6.2 01744 */ 01745 const char *iso_image_get_application_id(const IsoImage *image); 01746 01747 /** 01748 * Fill copyright information for the image. Usually this refers 01749 * to a file on disc. Up to 37 characters. 01750 * 01751 * @since 0.6.2 01752 */ 01753 void iso_image_set_copyright_file_id(IsoImage *image, 01754 const char *copyright_file_id); 01755 01756 /** 01757 * Get the copyright information of a image. 01758 * The returned string is owned by the image and should not be freed nor 01759 * changed. 01760 * 01761 * @since 0.6.2 01762 */ 01763 const char *iso_image_get_copyright_file_id(const IsoImage *image); 01764 01765 /** 01766 * Fill abstract information for the image. Usually this refers 01767 * to a file on disc. Up to 37 characters. 01768 * 01769 * @since 0.6.2 01770 */ 01771 void iso_image_set_abstract_file_id(IsoImage *image, 01772 const char *abstract_file_id); 01773 01774 /** 01775 * Get the abstract information of a image. 01776 * The returned string is owned by the image and should not be freed nor 01777 * changed. 01778 * 01779 * @since 0.6.2 01780 */ 01781 const char *iso_image_get_abstract_file_id(const IsoImage *image); 01782 01783 /** 01784 * Fill biblio information for the image. Usually this refers 01785 * to a file on disc. Up to 37 characters. 01786 * 01787 * @since 0.6.2 01788 */ 01789 void iso_image_set_biblio_file_id(IsoImage *image, const char *biblio_file_id); 01790 01791 /** 01792 * Get the biblio information of a image. 01793 * The returned string is owned by the image and should not be freed nor 01794 * changed. 01795 * 01796 * @since 0.6.2 01797 */ 01798 const char *iso_image_get_biblio_file_id(const IsoImage *image); 01799 01800 /** 01801 * Create a bootable image by adding a El-Torito boot image. 01802 * 01803 * This also add a catalog boot node to the image filesystem tree. 01804 * 01805 * @param image 01806 * The image to make bootable. If it was already bootable this function 01807 * returns an error and the image remains unmodified. 01808 * @param image_path 01809 * The path on the image tree of a regular file to use as default boot 01810 * image. 01811 * @param type 01812 * The boot media type. This can be one of 3 types: 01813 * - Floppy emulation: Boot image file must be exactly 01814 * 1200 kB, 1440 kB or 2880 kB. 01815 * - Hard disc emulation: The image must begin with a master 01816 * boot record with a single image. 01817 * - No emulation. You should specify load segment and load size 01818 * of image. 01819 * @param catalog_path 01820 * The path on the image tree where the catalog will be stored. The 01821 * directory component of this path must be a directory existent on the 01822 * image tree, and the filename component must be unique among all 01823 * children of that directory on image. Otherwise a correspodent error 01824 * code will be returned. This function will add an IsoBoot node that acts 01825 * as a placeholder for the real catalog, that will be generated at image 01826 * creation time. 01827 * @param boot 01828 * Location where a pointer to the added boot image will be stored. That 01829 * object is owned by the IsoImage and should not be freed by the user, 01830 * nor dereferenced once the last reference to the IsoImage was disposed 01831 * via iso_image_unref(). A NULL value is allowed if you don't need a 01832 * reference to the boot image. 01833 * @return 01834 * 1 on success, < 0 on error 01835 * 01836 * @since 0.6.2 01837 */ 01838 int iso_image_set_boot_image(IsoImage *image, const char *image_path, 01839 enum eltorito_boot_media_type type, 01840 const char *catalog_path, 01841 ElToritoBootImage **boot); 01842 01843 /* TODO #00026 : add support for "hidden" bootable images. */ 01844 01845 /** 01846 * Get El-Torito boot image of an ISO image, if any. 01847 * 01848 * This can be useful, for example, to check if a volume read from a previous 01849 * session or an existing image is bootable. It can also be useful to get 01850 * the image and catalog tree nodes. An application would want those, for 01851 * example, to prevent the user removing it. 01852 * 01853 * Both nodes are owned by libisofs and should not be freed. You can get your 01854 * own ref with iso_node_ref(). You can can also check if the node is already 01855 * on the tree by getting its parent (note that when reading El-Torito info 01856 * from a previous image, the nodes might not be on the tree even if you haven't 01857 * removed them). Remember that you'll need to get a new ref 01858 * (with iso_node_ref()) before inserting them again to the tree, and probably 01859 * you will also need to set the name or permissions. 01860 * 01861 * @param image 01862 * The image from which to get the boot image. 01863 * @param boot 01864 * If not NULL, it will be filled with a pointer to the boot image, if 01865 * any. That object is owned by the IsoImage and should not be freed by 01866 * the user, nor dereferenced once the last reference to the IsoImage was 01867 * disposed via iso_image_unref(). 01868 * @param imgnode 01869 * When not NULL, it will be filled with the image tree node. No extra ref 01870 * is added, you can use iso_node_ref() to get one if you need it. 01871 * @param catnode 01872 * When not NULL, it will be filled with the catnode tree node. No extra 01873 * ref is added, you can use iso_node_ref() to get one if you need it. 01874 * @return 01875 * 1 on success, 0 is the image is not bootable (i.e., it has no El-Torito 01876 * image), < 0 error. 01877 * 01878 * @since 0.6.2 01879 */ 01880 int iso_image_get_boot_image(IsoImage *image, ElToritoBootImage **boot, 01881 IsoFile **imgnode, IsoBoot **catnode); 01882 01883 /** 01884 * Removes the El-Torito bootable image. 01885 * 01886 * The IsoBoot node that acts as placeholder for the catalog is also removed 01887 * for the image tree, if there. 01888 * If the image is not bootable (don't have el-torito boot image) this function 01889 * just returns. 01890 * 01891 * @since 0.6.2 01892 */ 01893 void iso_image_remove_boot_image(IsoImage *image); 01894 01895 /** 01896 * Sets the load segment for the initial boot image. This is only for 01897 * no emulation boot images, and is a NOP for other image types. 01898 * 01899 * @since 0.6.2 01900 */ 01901 void el_torito_set_load_seg(ElToritoBootImage *bootimg, short segment); 01902 01903 /** 01904 * Sets the number of sectors (512b) to be load at load segment during 01905 * the initial boot procedure. This is only for 01906 * no emulation boot images, and is a NOP for other image types. 01907 * 01908 * @since 0.6.2 01909 */ 01910 void el_torito_set_load_size(ElToritoBootImage *bootimg, short sectors); 01911 01912 /** 01913 * Marks the specified boot image as not bootable 01914 * 01915 * @since 0.6.2 01916 */ 01917 void el_torito_set_no_bootable(ElToritoBootImage *bootimg); 01918 01919 /** 01920 * Specifies that this image needs to be patched. This involves the writting 01921 * of a 56 bytes boot information table at offset 8 of the boot image file. 01922 * The original boot image file won't be modified. 01923 * This is needed for isolinux boot images. 01924 * 01925 * @since 0.6.2 01926 * @deprecated Use el_torito_set_isolinux_options() instead 01927 */ 01928 void el_torito_patch_isolinux_image(ElToritoBootImage *bootimg); 01929 01930 /** 01931 * Specifies options for IsoLinux boot images. This should only be used with 01932 * isolinux boot images. 01933 * 01934 * @param options 01935 * bitmask style flag. The following values are defined: 01936 * 01937 * bit 0 -> 1 to path the image, 0 to not 01938 * Patching the image involves the writing of a 56 bytes 01939 * boot information table at offset 8 of the boot image file. 01940 * The original boot image file will not be modified. This is 01941 * needed to allow isolinux images to be bootable. 01942 * bit 1 -> 1 to generate an hybrid image with MBR, 0 to not 01943 * An hybrid image is a boot image that boots from either 01944 * CD/DVD media or from disk-like media, e.g. USB stick. 01945 * For that you need isolinux.bin from SYSLINUX 3.72 or later. 01946 * IMPORTANT: The application has to take care that the image 01947 * on media gets padded up to the next full MB. 01948 * @param flag 01949 * Reserved for future usage, set to 0. 01950 * @return 01951 * 1 success, < 0 on error 01952 * @since 0.6.12 01953 */ 01954 int el_torito_set_isolinux_options(ElToritoBootImage *bootimg, int options, int flag); 01955 01956 /** 01957 * Increments the reference counting of the given node. 01958 * 01959 * @since 0.6.2 01960 */ 01961 void iso_node_ref(IsoNode *node); 01962 01963 /** 01964 * Decrements the reference couting of the given node. 01965 * If it reach 0, the node is free, and, if the node is a directory, 01966 * its children will be unref() too. 01967 * 01968 * @since 0.6.2 01969 */ 01970 void iso_node_unref(IsoNode *node); 01971 01972 /** 01973 * Get the type of an IsoNode. 01974 * 01975 * @since 0.6.2 01976 */ 01977 enum IsoNodeType iso_node_get_type(IsoNode *node); 01978 01979 /** 01980 * Function to handle particular extended information. The function 01981 * pointer acts as an identifier for the type of the information. Structs 01982 * with same information type must use the same function. 01983 * 01984 * @param data 01985 * Attached data 01986 * @param flag 01987 * What to do with the data. At this time the following values are 01988 * defined: 01989 * -> 1 the data must be freed 01990 * @return 01991 * 1 in any case. 01992 * 01993 * @since 0.6.4 01994 */ 01995 typedef int (*iso_node_xinfo_func)(void *data, int flag); 01996 01997 /** 01998 * Add extended information to the given node. Extended info allows 01999 * applications (and libisofs itself) to add more information to an IsoNode. 02000 * You can use this facilities to associate new information with a given 02001 * node. 02002 * 02003 * Each node keeps a list of added extended info, meaning you can add several 02004 * extended info data to each node. Each extended info you add is identified 02005 * by the proc parameter, a pointer to a function that knows how to manage 02006 * the external info data. Thus, in order to add several types of extended 02007 * info, you need to define a "proc" function for each type. 02008 * 02009 * @param node 02010 * The node where to add the extended info 02011 * @param proc 02012 * A function pointer used to identify the type of the data, and that 02013 * knows how to manage it 02014 * @param data 02015 * Extended info to add. 02016 * @return 02017 * 1 if success, 0 if the given node already has extended info of the 02018 * type defined by the "proc" function, < 0 on error 02019 * 02020 * @since 0.6.4 02021 */ 02022 int iso_node_add_xinfo(IsoNode *node, iso_node_xinfo_func proc, void *data); 02023 02024 /** 02025 * Remove the given extended info (defined by the proc function) from the 02026 * given node. 02027 * 02028 * @return 02029 * 1 on success, 0 if node does not have extended info of the requested 02030 * type, < 0 on error 02031 * 02032 * @since 0.6.4 02033 */ 02034 int iso_node_remove_xinfo(IsoNode *node, iso_node_xinfo_func proc); 02035 02036 /** 02037 * Get the given extended info (defined by the proc function) from the 02038 * given node. 02039 * 02040 * @param data 02041 * Will be filled with the extended info corresponding to the given proc 02042 * function 02043 * @return 02044 * 1 on success, 0 if node does not have extended info of the requested 02045 * type, < 0 on error 02046 * 02047 * @since 0.6.4 02048 */ 02049 int iso_node_get_xinfo(IsoNode *node, iso_node_xinfo_func proc, void **data); 02050 02051 /** 02052 * Set the name of a node. Note that if the node is already added to a dir 02053 * this can fail if dir already contains a node with the new name. 02054 * 02055 * @param node 02056 * The node whose name you want to change. Note that you can't change 02057 * the name of the root. 02058 * @param name 02059 * The name for the node. If you supply an empty string or a 02060 * name greater than 255 characters this returns with failure, and 02061 * node name is not modified. 02062 * @return 02063 * 1 on success, < 0 on error 02064 * 02065 * @since 0.6.2 02066 */ 02067 int iso_node_set_name(IsoNode *node, const char *name); 02068 02069 /** 02070 * Get the name of a node. 02071 * The returned string belongs to the node and should not be modified nor 02072 * freed. Use strdup if you really need your own copy. 02073 * 02074 * @since 0.6.2 02075 */ 02076 const char *iso_node_get_name(const IsoNode *node); 02077 02078 /** 02079 * Set the permissions for the node. This attribute is only useful when 02080 * Rock Ridge extensions are enabled. 02081 * 02082 * @param mode 02083 * bitmask with the permissions of the node, as specified in 'man 2 stat'. 02084 * The file type bitfields will be ignored, only file permissions will be 02085 * modified. 02086 * 02087 * @since 0.6.2 02088 */ 02089 void iso_node_set_permissions(IsoNode *node, mode_t mode); 02090 02091 /** 02092 * Get the permissions for the node 02093 * 02094 * @since 0.6.2 02095 */ 02096 mode_t iso_node_get_permissions(const IsoNode *node); 02097 02098 /** 02099 * Get the mode of the node, both permissions and file type, as specified in 02100 * 'man 2 stat'. 02101 * 02102 * @since 0.6.2 02103 */ 02104 mode_t iso_node_get_mode(const IsoNode *node); 02105 02106 /** 02107 * Set the user id for the node. This attribute is only useful when 02108 * Rock Ridge extensions are enabled. 02109 * 02110 * @since 0.6.2 02111 */ 02112 void iso_node_set_uid(IsoNode *node, uid_t uid); 02113 02114 /** 02115 * Get the user id of the node. 02116 * 02117 * @since 0.6.2 02118 */ 02119 uid_t iso_node_get_uid(const IsoNode *node); 02120 02121 /** 02122 * Set the group id for the node. This attribute is only useful when 02123 * Rock Ridge extensions are enabled. 02124 * 02125 * @since 0.6.2 02126 */ 02127 void iso_node_set_gid(IsoNode *node, gid_t gid); 02128 02129 /** 02130 * Get the group id of the node. 02131 * 02132 * @since 0.6.2 02133 */ 02134 gid_t iso_node_get_gid(const IsoNode *node); 02135 02136 /** 02137 * Set the time of last modification of the file 02138 * 02139 * @since 0.6.2 02140 */ 02141 void iso_node_set_mtime(IsoNode *node, time_t time); 02142 02143 /** 02144 * Get the time of last modification of the file 02145 * 02146 * @since 0.6.2 02147 */ 02148 time_t iso_node_get_mtime(const IsoNode *node); 02149 02150 /** 02151 * Set the time of last access to the file 02152 * 02153 * @since 0.6.2 02154 */ 02155 void iso_node_set_atime(IsoNode *node, time_t time); 02156 02157 /** 02158 * Get the time of last access to the file 02159 * 02160 * @since 0.6.2 02161 */ 02162 time_t iso_node_get_atime(const IsoNode *node); 02163 02164 /** 02165 * Set the time of last status change of the file 02166 * 02167 * @since 0.6.2 02168 */ 02169 void iso_node_set_ctime(IsoNode *node, time_t time); 02170 02171 /** 02172 * Get the time of last status change of the file 02173 * 02174 * @since 0.6.2 02175 */ 02176 time_t iso_node_get_ctime(const IsoNode *node); 02177 02178 /** 02179 * Set if the node will be hidden in RR/ISO tree, Joliet tree or both. 02180 * 02181 * If the file is setted as hidden in one tree, it won't be included there, so 02182 * it won't be visible in a OS accessing CD using that tree. For example, 02183 * GNU/Linux systems access to Rock Ridge / ISO9960 tree in order to see 02184 * what is recorded on CD, while MS Windows make use of the Joliet tree. If a 02185 * file is hidden only in Joliet, it won't be visible in Windows systems, 02186 * while still visible in Linux. 02187 * 02188 * If a file is hidden in both trees, it won't be written to image. 02189 * 02190 * @param node 02191 * The node that is to be hidden. 02192 * @param hide_attrs 02193 * IsoHideNodeFlag's to set the trees in which file will be hidden. 02194 * 02195 * @since 0.6.2 02196 */ 02197 void iso_node_set_hidden(IsoNode *node, int hide_attrs); 02198 02199 /** 02200 * Add a new node to a dir. Note that this function don't add a new ref to 02201 * the node, so you don't need to free it, it will be automatically freed 02202 * when the dir is deleted. Of course, if you want to keep using the node 02203 * after the dir life, you need to iso_node_ref() it. 02204 * 02205 * @param dir 02206 * the dir where to add the node 02207 * @param child 02208 * the node to add. You must ensure that the node hasn't previously added 02209 * to other dir, and that the node name is unique inside the child. 02210 * Otherwise this function will return a failure, and the child won't be 02211 * inserted. 02212 * @param replace 02213 * if the dir already contains a node with the same name, whether to 02214 * replace or not the old node with this. 02215 * @return 02216 * number of nodes in dir if succes, < 0 otherwise 02217 * Possible errors: 02218 * ISO_NULL_POINTER, if dir or child are NULL 02219 * ISO_NODE_ALREADY_ADDED, if child is already added to other dir 02220 * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists 02221 * ISO_WRONG_ARG_VALUE, if child == dir, or replace != (0,1) 02222 * 02223 * @since 0.6.2 02224 */ 02225 int iso_dir_add_node(IsoDir *dir, IsoNode *child, 02226 enum iso_replace_mode replace); 02227 02228 /** 02229 * Locate a node inside a given dir. 02230 * 02231 * @param dir 02232 * The dir where to look for the node. 02233 * @param name 02234 * The name of the node 02235 * @param node 02236 * Location for a pointer to the node, it will filled with NULL if the dir 02237 * doesn't have a child with the given name. 02238 * The node will be owned by the dir and shouldn't be unref(). Just call 02239 * iso_node_ref() to get your own reference to the node. 02240 * Note that you can pass NULL is the only thing you want to do is check 02241 * if a node with such name already exists on dir. 02242 * @return 02243 * 1 node found, 0 child has no such node, < 0 error 02244 * Possible errors: 02245 * ISO_NULL_POINTER, if dir or name are NULL 02246 * 02247 * @since 0.6.2 02248 */ 02249 int iso_dir_get_node(IsoDir *dir, const char *name, IsoNode **node); 02250 02251 /** 02252 * Get the number of children of a directory. 02253 * 02254 * @return 02255 * >= 0 number of items, < 0 error 02256 * Possible errors: 02257 * ISO_NULL_POINTER, if dir is NULL 02258 * 02259 * @since 0.6.2 02260 */ 02261 int iso_dir_get_children_count(IsoDir *dir); 02262 02263 /** 02264 * Removes a child from a directory. 02265 * The child is not freed, so you will become the owner of the node. Later 02266 * you can add the node to another dir (calling iso_dir_add_node), or free 02267 * it if you don't need it (with iso_node_unref). 02268 * 02269 * @return 02270 * 1 on success, < 0 error 02271 * Possible errors: 02272 * ISO_NULL_POINTER, if node is NULL 02273 * ISO_NODE_NOT_ADDED_TO_DIR, if node doesn't belong to a dir 02274 * 02275 * @since 0.6.2 02276 */ 02277 int iso_node_take(IsoNode *node); 02278 02279 /** 02280 * Removes a child from a directory and free (unref) it. 02281 * If you want to keep the child alive, you need to iso_node_ref() it 02282 * before this call, but in that case iso_node_take() is a better 02283 * alternative. 02284 * 02285 * @return 02286 * 1 on success, < 0 error 02287 * 02288 * @since 0.6.2 02289 */ 02290 int iso_node_remove(IsoNode *node); 02291 02292 /* 02293 * Get the parent of the given iso tree node. No extra ref is added to the 02294 * returned directory, you must take your ref. with iso_node_ref() if you 02295 * need it. 02296 * 02297 * If node is the root node, the same node will be returned as its parent. 02298 * 02299 * This returns NULL if the node doesn't pertain to any tree 02300 * (it was removed/take). 02301 * 02302 * @since 0.6.2 02303 */ 02304 IsoDir *iso_node_get_parent(IsoNode *node); 02305 02306 /** 02307 * Get an iterator for the children of the given dir. 02308 * 02309 * You can iterate over the children with iso_dir_iter_next. When finished, 02310 * you should free the iterator with iso_dir_iter_free. 02311 * You musn't delete a child of the same dir, using iso_node_take() or 02312 * iso_node_remove(), while you're using the iterator. You can use 02313 * iso_dir_iter_take() or iso_dir_iter_remove() instead. 02314 * 02315 * You can use the iterator in the way like this 02316 * 02317 * IsoDirIter *iter; 02318 * IsoNode *node; 02319 * if ( iso_dir_get_children(dir, &iter) != 1 ) { 02320 * // handle error 02321 * } 02322 * while ( iso_dir_iter_next(iter, &node) == 1 ) { 02323 * // do something with the child 02324 * } 02325 * iso_dir_iter_free(iter); 02326 * 02327 * An iterator is intended to be used in a single iteration over the 02328 * children of a dir. Thus, it should be treated as a temporary object, 02329 * and free as soon as possible. 02330 * 02331 * @return 02332 * 1 success, < 0 error 02333 * Possible errors: 02334 * ISO_NULL_POINTER, if dir or iter are NULL 02335 * ISO_OUT_OF_MEM 02336 * 02337 * @since 0.6.2 02338 */ 02339 int iso_dir_get_children(const IsoDir *dir, IsoDirIter **iter); 02340 02341 /** 02342 * Get the next child. 02343 * Take care that the node is owned by its parent, and will be unref() when 02344 * the parent is freed. If you want your own ref to it, call iso_node_ref() 02345 * on it. 02346 * 02347 * @return 02348 * 1 success, 0 if dir has no more elements, < 0 error 02349 * Possible errors: 02350 * ISO_NULL_POINTER, if node or iter are NULL 02351 * ISO_ERROR, on wrong iter usage, usual caused by modiying the 02352 * dir during iteration 02353 * 02354 * @since 0.6.2 02355 */ 02356 int iso_dir_iter_next(IsoDirIter *iter, IsoNode **node); 02357 02358 /** 02359 * Check if there're more children. 02360 * 02361 * @return 02362 * 1 dir has more elements, 0 no, < 0 error 02363 * Possible errors: 02364 * ISO_NULL_POINTER, if iter is NULL 02365 * 02366 * @since 0.6.2 02367 */ 02368 int iso_dir_iter_has_next(IsoDirIter *iter); 02369 02370 /** 02371 * Free a dir iterator. 02372 * 02373 * @since 0.6.2 02374 */ 02375 void iso_dir_iter_free(IsoDirIter *iter); 02376 02377 /** 02378 * Removes a child from a directory during an iteration, without freeing it. 02379 * It's like iso_node_take(), but to be used during a directory iteration. 02380 * The node removed will be the last returned by the iteration. 02381 * 02382 * If you call this function twice without calling iso_dir_iter_next between 02383 * them is not allowed and you will get an ISO_ERROR in second call. 02384 * 02385 * @return 02386 * 1 on succes, < 0 error 02387 * Possible errors: 02388 * ISO_NULL_POINTER, if iter is NULL 02389 * ISO_ERROR, on wrong iter usage, for example by call this before 02390 * iso_dir_iter_next. 02391 * 02392 * @since 0.6.2 02393 */ 02394 int iso_dir_iter_take(IsoDirIter *iter); 02395 02396 /** 02397 * Removes a child from a directory during an iteration and unref() it. 02398 * It's like iso_node_remove(), but to be used during a directory iteration. 02399 * The node removed will be the last returned by the iteration. 02400 * 02401 * If you call this function twice without calling iso_dir_iter_next between 02402 * them is not allowed and you will get an ISO_ERROR in second call. 02403 * 02404 * @return 02405 * 1 on succes, < 0 error 02406 * Possible errors: 02407 * ISO_NULL_POINTER, if iter is NULL 02408 * ISO_ERROR, on wrong iter usage, for example by call this before 02409 * iso_dir_iter_next. 02410 * 02411 * @since 0.6.2 02412 */ 02413 int iso_dir_iter_remove(IsoDirIter *iter); 02414 02415 02416 /** 02417 * @since 0.6.4 02418 */ 02419 typedef struct iso_find_condition IsoFindCondition; 02420 02421 /** 02422 * Create a new condition that checks if the node name matches the given 02423 * wildcard. 02424 * 02425 * @param wildcard 02426 * @result 02427 * The created IsoFindCondition, NULL on error. 02428 * 02429 * @since 0.6.4 02430 */ 02431 IsoFindCondition *iso_new_find_conditions_name(const char *wildcard); 02432 02433 /** 02434 * Create a new condition that checks the node mode against a mode mask. It 02435 * can be used to check both file type and permissions. 02436 * 02437 * For example: 02438 * 02439 * iso_new_find_conditions_mode(S_IFREG) : search for regular files 02440 * iso_new_find_conditions_mode(S_IFCHR | S_IWUSR) : search for character 02441 * devices where owner has write permissions. 02442 * 02443 * @param mask 02444 * Mode mask to AND against node mode. 02445 * @result 02446 * The created IsoFindCondition, NULL on error. 02447 * 02448 * @since 0.6.4 02449 */ 02450 IsoFindCondition *iso_new_find_conditions_mode(mode_t mask); 02451 02452 /** 02453 * Create a new condition that checks the node gid. 02454 * 02455 * @param gid 02456 * Desired Group Id. 02457 * @result 02458 * The created IsoFindCondition, NULL on error. 02459 * 02460 * @since 0.6.4 02461 */ 02462 IsoFindCondition *iso_new_find_conditions_gid(gid_t gid); 02463 02464 /** 02465 * Create a new condition that checks the node uid. 02466 * 02467 * @param uid 02468 * Desired User Id. 02469 * @result 02470 * The created IsoFindCondition, NULL on error. 02471 * 02472 * @since 0.6.4 02473 */ 02474 IsoFindCondition *iso_new_find_conditions_uid(uid_t uid); 02475 02476 /** 02477 * Possible comparison between IsoNode and given conditions. 02478 * 02479 * @since 0.6.4 02480 */ 02481 enum iso_find_comparisons { 02482 ISO_FIND_COND_GREATER, 02483 ISO_FIND_COND_GREATER_OR_EQUAL, 02484 ISO_FIND_COND_EQUAL, 02485 ISO_FIND_COND_LESS, 02486 ISO_FIND_COND_LESS_OR_EQUAL 02487 }; 02488 02489 /** 02490 * Create a new condition that checks the time of last access. 02491 * 02492 * @param time 02493 * Time to compare against IsoNode atime. 02494 * @param comparison 02495 * Comparison to be done between IsoNode atime and submitted time. 02496 * Note that ISO_FIND_COND_GREATER, for example, is true if the node 02497 * time is greater than the submitted time. 02498 * @result 02499 * The created IsoFindCondition, NULL on error. 02500 * 02501 * @since 0.6.4 02502 */ 02503 IsoFindCondition *iso_new_find_conditions_atime(time_t time, 02504 enum iso_find_comparisons comparison); 02505 02506 /** 02507 * Create a new condition that checks the time of last modification. 02508 * 02509 * @param time 02510 * Time to compare against IsoNode mtime. 02511 * @param comparison 02512 * Comparison to be done between IsoNode mtime and submitted time. 02513 * Note that ISO_FIND_COND_GREATER, for example, is true if the node 02514 * time is greater than the submitted time. 02515 * @result 02516 * The created IsoFindCondition, NULL on error. 02517 * 02518 * @since 0.6.4 02519 */ 02520 IsoFindCondition *iso_new_find_conditions_mtime(time_t time, 02521 enum iso_find_comparisons comparison); 02522 02523 /** 02524 * Create a new condition that checks the time of last status change. 02525 * 02526 * @param time 02527 * Time to compare against IsoNode ctime. 02528 * @param comparison 02529 * Comparison to be done between IsoNode ctime and submitted time. 02530 * Note that ISO_FIND_COND_GREATER, for example, is true if the node 02531 * time is greater than the submitted time. 02532 * @result 02533 * The created IsoFindCondition, NULL on error. 02534 * 02535 * @since 0.6.4 02536 */ 02537 IsoFindCondition *iso_new_find_conditions_ctime(time_t time, 02538 enum iso_find_comparisons comparison); 02539 02540 /** 02541 * Create a new condition that check if the two given conditions are 02542 * valid. 02543 * 02544 * @param a 02545 * @param b 02546 * IsoFindCondition to compare 02547 * @result 02548 * The created IsoFindCondition, NULL on error. 02549 * 02550 * @since 0.6.4 02551 */ 02552 IsoFindCondition *iso_new_find_conditions_and(IsoFindCondition *a, 02553 IsoFindCondition *b); 02554 02555 /** 02556 * Create a new condition that check if at least one the two given conditions 02557 * is valid. 02558 * 02559 * @param a 02560 * @param b 02561 * IsoFindCondition to compare 02562 * @result 02563 * The created IsoFindCondition, NULL on error. 02564 * 02565 * @since 0.6.4 02566 */ 02567 IsoFindCondition *iso_new_find_conditions_or(IsoFindCondition *a, 02568 IsoFindCondition *b); 02569 02570 /** 02571 * Create a new condition that check if the given conditions is false. 02572 * 02573 * @param negate 02574 * @result 02575 * The created IsoFindCondition, NULL on error. 02576 * 02577 * @since 0.6.4 02578 */ 02579 IsoFindCondition *iso_new_find_conditions_not(IsoFindCondition *negate); 02580 02581 /** 02582 * Find all directory children that match the given condition. 02583 * 02584 * @param dir 02585 * Directory where we will search children. 02586 * @param cond 02587 * Condition that the children must match in order to be returned. 02588 * It will be free together with the iterator. Remember to delete it 02589 * if this function return error. 02590 * @param iter 02591 * Iterator that returns only the children that match condition. 02592 * @return 02593 * 1 on success, < 0 on error 02594 * 02595 * @since 0.6.4 02596 */ 02597 int iso_dir_find_children(IsoDir* dir, IsoFindCondition *cond, 02598 IsoDirIter **iter); 02599 02600 /** 02601 * Get the destination of a node. 02602 * The returned string belongs to the node and should not be modified nor 02603 * freed. Use strdup if you really need your own copy. 02604 * 02605 * @since 0.6.2 02606 */ 02607 const char *iso_symlink_get_dest(const IsoSymlink *link); 02608 02609 /** 02610 * Set the destination of a link. 02611 * 02612 * @param dest 02613 * New destination for the link. It must be a non-empty string, otherwise 02614 * this function doesn't modify previous destination. 02615 * @return 02616 * 1 on success, < 0 on error 02617 * 02618 * @since 0.6.2 02619 */ 02620 int iso_symlink_set_dest(IsoSymlink *link, const char *dest); 02621 02622 /** 02623 * Sets the order in which a node will be written on image. High weihted files 02624 * will be written first, so in a disc them will be written near the center. 02625 * 02626 * @param node 02627 * The node which weight will be changed. If it's a dir, this function 02628 * will change the weight of all its children. For nodes other that dirs 02629 * or regular files, this function has no effect. 02630 * @param w 02631 * The weight as a integer number, the greater this value is, the 02632 * closer from the begining of image the file will be written. 02633 * 02634 * @since 0.6.2 02635 */ 02636 void iso_node_set_sort_weight(IsoNode *node, int w); 02637 02638 /** 02639 * Get the sort weight of a file. 02640 * 02641 * @since 0.6.2 02642 */ 02643 int iso_file_get_sort_weight(IsoFile *file); 02644 02645 /** 02646 * Get the size of the file, in bytes 02647 * 02648 * @since 0.6.2 02649 */ 02650 off_t iso_file_get_size(IsoFile *file); 02651 02652 /** 02653 * Get the device id (major/minor numbers) of the given block or 02654 * character device file. The result is undefined for other kind 02655 * of special files, of first be sure iso_node_get_mode() returns either 02656 * S_IFBLK or S_IFCHR. 02657 * 02658 * @since 0.6.6 02659 */ 02660 dev_t iso_special_get_dev(IsoSpecial *special); 02661 02662 /** 02663 * Get the IsoStream that represents the contents of the given IsoFile. 02664 * 02665 * If you open() the stream, it should be close() before image generation. 02666 * 02667 * @return 02668 * The IsoStream. No extra ref is added, so the IsoStream belong to the 02669 * IsoFile, and it may be freed together with it. Add your own ref with 02670 * iso_stream_ref() if you need it. 02671 * 02672 * @since 0.6.4 02673 */ 02674 IsoStream *iso_file_get_stream(IsoFile *file); 02675 02676 /** 02677 * Get the block lba of a file node, if it was imported from an old image. 02678 * 02679 * @param file 02680 * The file 02681 * @param lba 02682 * Will be filled with the kba 02683 * @param flag 02684 * Reserved for future usage, submit 0 02685 * @return 02686 * 1 if lba is valid (file comes from old image), 0 if file was newly 02687 * added, i.e. it does not come from an old image, < 0 error 02688 * 02689 * @since 0.6.4 02690 * 02691 * @deprecated Use iso_file_get_old_image_sections(), as this function does 02692 * not work with multi-extend files. 02693 */ 02694 int iso_file_get_old_image_lba(IsoFile *file, uint32_t *lba, int flag); 02695 02696 /** 02697 * Get the start addresses and the sizes of the data extents of a file node 02698 * if it was imported from an old image. 02699 * 02700 * @param file 02701 * The file 02702 * @param section_count 02703 * Returns the number of extent entries in sections array. 02704 * @param sections 02705 * Returns the array of file sections. Apply free() to dispose it. 02706 * @param flag 02707 * Reserved for future usage, submit 0 02708 * @return 02709 * 1 if there are valid extents (file comes from old image), 02710 * 0 if file was newly added, i.e. it does not come from an old image, 02711 * < 0 error 02712 * 02713 * @since 0.6.8 02714 */ 02715 int iso_file_get_old_image_sections(IsoFile *file, int *section_count, 02716 struct iso_file_section **sections, 02717 int flag); 02718 02719 /* 02720 * Like iso_file_get_old_image_lba(), but take an IsoNode. 02721 * 02722 * @return 02723 * 1 if lba is valid (file comes from old image), 0 if file was newly 02724 * added, i.e. it does not come from an old image, 2 node type has no 02725 * LBA (no regular file), < 0 error 02726 * 02727 * @since 0.6.4 02728 */ 02729 int iso_node_get_old_image_lba(IsoNode *node, uint32_t *lba, int flag); 02730 02731 /** 02732 * Add a new directory to the iso tree. Permissions, owner and hidden atts 02733 * are taken from parent, you can modify them later. 02734 * 02735 * @param parent 02736 * the dir where the new directory will be created 02737 * @param name 02738 * name for the new dir. If a node with same name already exists on 02739 * parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE. 02740 * @param dir 02741 * place where to store a pointer to the newly created dir. No extra 02742 * ref is addded, so you will need to call iso_node_ref() if you really 02743 * need it. You can pass NULL in this parameter if you don't need the 02744 * pointer. 02745 * @return 02746 * number of nodes in parent if success, < 0 otherwise 02747 * Possible errors: 02748 * ISO_NULL_POINTER, if parent or name are NULL 02749 * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists 02750 * ISO_OUT_OF_MEM 02751 * 02752 * @since 0.6.2 02753 */ 02754 int iso_tree_add_new_dir(IsoDir *parent, const char *name, IsoDir **dir); 02755 02756 /** 02757 * Add a new regular file to the iso tree. Permissions are set to 0444, 02758 * owner and hidden atts are taken from parent. You can modify any of them 02759 * later. 02760 * 02761 * @param parent 02762 * the dir where the new file will be created 02763 * @param name 02764 * name for the new file. If a node with same name already exists on 02765 * parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE. 02766 * @param stream 02767 * IsoStream for the contents of the file. The reference will be taken 02768 * by the newly created file, you will need to take an extra ref to it 02769 * if you need it. 02770 * @param file 02771 * place where to store a pointer to the newly created file. No extra 02772 * ref is addded, so you will need to call iso_node_ref() if you really 02773 * need it. You can pass NULL in this parameter if you don't need the 02774 * pointer 02775 * @return 02776 * number of nodes in parent if success, < 0 otherwise 02777 * Possible errors: 02778 * ISO_NULL_POINTER, if parent, name or dest are NULL 02779 * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists 02780 * ISO_OUT_OF_MEM 02781 * 02782 * @since 0.6.4 02783 */ 02784 int iso_tree_add_new_file(IsoDir *parent, const char *name, IsoStream *stream, 02785 IsoFile **file); 02786 02787 /** 02788 * Add a new symlink to the directory tree. Permissions are set to 0777, 02789 * owner and hidden atts are taken from parent. You can modify any of them 02790 * later. 02791 * 02792 * @param parent 02793 * the dir where the new symlink will be created 02794 * @param name 02795 * name for the new symlink. If a node with same name already exists on 02796 * parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE. 02797 * @param dest 02798 * destination of the link 02799 * @param link 02800 * place where to store a pointer to the newly created link. No extra 02801 * ref is addded, so you will need to call iso_node_ref() if you really 02802 * need it. You can pass NULL in this parameter if you don't need the 02803 * pointer 02804 * @return 02805 * number of nodes in parent if success, < 0 otherwise 02806 * Possible errors: 02807 * ISO_NULL_POINTER, if parent, name or dest are NULL 02808 * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists 02809 * ISO_OUT_OF_MEM 02810 * 02811 * @since 0.6.2 02812 */ 02813 int iso_tree_add_new_symlink(IsoDir *parent, const char *name, 02814 const char *dest, IsoSymlink **link); 02815 02816 /** 02817 * Add a new special file to the directory tree. As far as libisofs concerns, 02818 * an special file is a block device, a character device, a FIFO (named pipe) 02819 * or a socket. You can choose the specific kind of file you want to add 02820 * by setting mode propertly (see man 2 stat). 02821 * 02822 * Note that special files are only written to image when Rock Ridge 02823 * extensions are enabled. Moreover, a special file is just a directory entry 02824 * in the image tree, no data is written beyond that. 02825 * 02826 * Owner and hidden atts are taken from parent. You can modify any of them 02827 * later. 02828 * 02829 * @param parent 02830 * the dir where the new special file will be created 02831 * @param name 02832 * name for the new special file. If a node with same name already exists 02833 * on parent, this functions fails with ISO_NODE_NAME_NOT_UNIQUE. 02834 * @param mode 02835 * file type and permissions for the new node. Note that you can't 02836 * specify any kind of file here, only special types are allowed. i.e, 02837 * S_IFSOCK, S_IFBLK, S_IFCHR and S_IFIFO are valid types; S_IFLNK, 02838 * S_IFREG and S_IFDIR aren't. 02839 * @param dev 02840 * device ID, equivalent to the st_rdev field in man 2 stat. 02841 * @param special 02842 * place where to store a pointer to the newly created special file. No 02843 * extra ref is addded, so you will need to call iso_node_ref() if you 02844 * really need it. You can pass NULL in this parameter if you don't need 02845 * the pointer. 02846 * @return 02847 * number of nodes in parent if success, < 0 otherwise 02848 * Possible errors: 02849 * ISO_NULL_POINTER, if parent, name or dest are NULL 02850 * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists 02851 * ISO_WRONG_ARG_VALUE if you select a incorrect mode 02852 * ISO_OUT_OF_MEM 02853 * 02854 * @since 0.6.2 02855 */ 02856 int iso_tree_add_new_special(IsoDir *parent, const char *name, mode_t mode, 02857 dev_t dev, IsoSpecial **special); 02858 02859 /** 02860 * Set whether to follow or not symbolic links when added a file from a source 02861 * to IsoImage. Default behavior is to not follow symlinks. 02862 * 02863 * @since 0.6.2 02864 */ 02865 void iso_tree_set_follow_symlinks(IsoImage *image, int follow); 02866 02867 /** 02868 * Get current setting for follow_symlinks. 02869 * 02870 * @see iso_tree_set_follow_symlinks 02871 * @since 0.6.2 02872 */ 02873 int iso_tree_get_follow_symlinks(IsoImage *image); 02874 02875 /** 02876 * Set whether to skip or not hidden files when adding a directory recursibely. 02877 * Default behavior is to not ignore them, i.e., to add hidden files to image. 02878 * 02879 * @since 0.6.2 02880 */ 02881 void iso_tree_set_ignore_hidden(IsoImage *image, int skip); 02882 02883 /** 02884 * Get current setting for ignore_hidden. 02885 * 02886 * @see iso_tree_set_ignore_hidden 02887 * @since 0.6.2 02888 */ 02889 int iso_tree_get_ignore_hidden(IsoImage *image); 02890 02891 /** 02892 * Set the replace mode, that defines the behavior of libisofs when adding 02893 * a node whit the same name that an existent one, during a recursive 02894 * directory addition. 02895 * 02896 * @since 0.6.2 02897 */ 02898 void iso_tree_set_replace_mode(IsoImage *image, enum iso_replace_mode mode); 02899 02900 /** 02901 * Get current setting for replace_mode. 02902 * 02903 * @see iso_tree_set_replace_mode 02904 * @since 0.6.2 02905 */ 02906 enum iso_replace_mode iso_tree_get_replace_mode(IsoImage *image); 02907 02908 /** 02909 * Set whether to skip or not special files. Default behavior is to not skip 02910 * them. Note that, despite of this setting, special files won't never be added 02911 * to an image unless RR extensions were enabled. 02912 * 02913 * @param skip 02914 * Bitmask to determine what kind of special files will be skipped: 02915 * bit0: ignore FIFOs 02916 * bit1: ignore Sockets 02917 * bit2: ignore char devices 02918 * bit3: ignore block devices 02919 * 02920 * @since 0.6.2 02921 */ 02922 void iso_tree_set_ignore_special(IsoImage *image, int skip); 02923 02924 /** 02925 * Get current setting for ignore_special. 02926 * 02927 * @see iso_tree_set_ignore_special 02928 * @since 0.6.2 02929 */ 02930 int iso_tree_get_ignore_special(IsoImage *image); 02931 02932 /** 02933 * Add a excluded path. These are paths that won't never added to image, 02934 * and will be excluded even when adding recursively its parent directory. 02935 * 02936 * For example, in 02937 * 02938 * iso_tree_add_exclude(image, "/home/user/data/private"); 02939 * iso_tree_add_dir_rec(image, root, "/home/user/data"); 02940 * 02941 * the directory /home/user/data/private won't be added to image. 02942 * 02943 * However, if you explicity add a deeper dir, it won't be excluded. i.e., 02944 * in the following example. 02945 * 02946 * iso_tree_add_exclude(image, "/home/user/data"); 02947 * iso_tree_add_dir_rec(image, root, "/home/user/data/private"); 02948 * 02949 * the directory /home/user/data/private is added. On the other, side, and 02950 * foollowing the the example above, 02951 * 02952 * iso_tree_add_dir_rec(image, root, "/home/user"); 02953 * 02954 * will exclude the directory "/home/user/data". 02955 * 02956 * Absolute paths are not mandatory, you can, for example, add a relative 02957 * path such as: 02958 * 02959 * iso_tree_add_exclude(image, "private"); 02960 * iso_tree_add_exclude(image, "user/data"); 02961 * 02962 * to excluve, respectively, all files or dirs named private, and also all 02963 * files or dirs named data that belong to a folder named "user". Not that the 02964 * above rule about deeper dirs is still valid. i.e., if you call 02965 * 02966 * iso_tree_add_dir_rec(image, root, "/home/user/data/music"); 02967 * 02968 * it is included even containing "user/data" string. However, a possible 02969 * "/home/user/data/music/user/data" is not added. 02970 * 02971 * Usual wildcards, such as * or ? are also supported, with the usual meaning 02972 * as stated in "man 7 glob". For example 02973 * 02974 * // to exclude backup text files 02975 * iso_tree_add_exclude(image, "*.~"); 02976 * 02977 * @return 02978 * 1 on success, < 0 on error 02979 * 02980 * @since 0.6.2 02981 */ 02982 int iso_tree_add_exclude(IsoImage *image, const char *path); 02983 02984 /** 02985 * Remove a previously added exclude. 02986 * 02987 * @see iso_tree_add_exclude 02988 * @return 02989 * 1 on success, 0 exclude do not exists, < 0 on error 02990 * 02991 * @since 0.6.2 02992 */ 02993 int iso_tree_remove_exclude(IsoImage *image, const char *path); 02994 02995 /** 02996 * Set a callback function that libisofs will call for each file that is 02997 * added to the given image by a recursive addition function. This includes 02998 * image import. 02999 * 03000 * @param report 03001 * pointer to a function that will be called just before a file will be 03002 * added to the image. You can control whether the file will be in fact 03003 * added or ignored. 03004 * This function should return 1 to add the file, 0 to ignore it and 03005 * continue, < 0 to abort the process 03006 * NULL is allowed if you don't want any callback. 03007 * 03008 * @since 0.6.2 03009 */ 03010 void iso_tree_set_report_callback(IsoImage *image, 03011 int (*report)(IsoImage*, IsoFileSource*)); 03012 03013 /** 03014 * Add a new node to the image tree, from an existing file. 03015 * 03016 * TODO comment Builder and Filesystem related issues when exposing both 03017 * 03018 * All attributes will be taken from the source file. The appropriate file 03019 * type will be created. 03020 * 03021 * @param image 03022 * The image 03023 * @param parent 03024 * The directory in the image tree where the node will be added. 03025 * @param path 03026 * The path of the file to add in the filesystem. 03027 * @param node 03028 * place where to store a pointer to the newly added file. No 03029 * extra ref is addded, so you will need to call iso_node_ref() if you 03030 * really need it. You can pass NULL in this parameter if you don't need 03031 * the pointer. 03032 * @return 03033 * number of nodes in parent if success, < 0 otherwise 03034 * Possible errors: 03035 * ISO_NULL_POINTER, if image, parent or path are NULL 03036 * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists 03037 * ISO_OUT_OF_MEM 03038 * 03039 * @since 0.6.2 03040 */ 03041 int iso_tree_add_node(IsoImage *image, IsoDir *parent, const char *path, 03042 IsoNode **node); 03043 03044 /** 03045 * Add a new node to the image tree, from an existing file, and with the 03046 * given name, that must not exist on dir. 03047 * 03048 * @param image 03049 * The image 03050 * @param parent 03051 * The directory in the image tree where the node will be added. 03052 * @param name 03053 * The name that the node will have on image. 03054 * @param path 03055 * The path of the file to add in the filesystem. 03056 * @param node 03057 * place where to store a pointer to the newly added file. No 03058 * extra ref is addded, so you will need to call iso_node_ref() if you 03059 * really need it. You can pass NULL in this parameter if you don't need 03060 * the pointer. 03061 * @return 03062 * number of nodes in parent if success, < 0 otherwise 03063 * Possible errors: 03064 * ISO_NULL_POINTER, if image, parent or path are NULL 03065 * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists 03066 * ISO_OUT_OF_MEM 03067 * 03068 * @since 0.6.4 03069 */ 03070 int iso_tree_add_new_node(IsoImage *image, IsoDir *parent, const char *name, 03071 const char *path, IsoNode **node); 03072 03073 /** 03074 * Add a new node to the image tree, from an existing file, and with the 03075 * given name, that must not exist on dir. The node will be cut-out to the 03076 * submitted size, and its contents will be read from the given offset. This 03077 * function is thus suitable for adding only a piece of a file to the image. 03078 * 03079 * @param image 03080 * The image 03081 * @param parent 03082 * The directory in the image tree where the node will be added. 03083 * @param name 03084 * The name that the node will have on image. 03085 * @param path 03086 * The path of the file to add in the filesystem. For now only regular 03087 * files and symlinks to regular files are supported. 03088 * @param offset 03089 * Offset on the given file from where to start reading data. 03090 * @param size 03091 * Max size of the file. 03092 * @param node 03093 * place where to store a pointer to the newly added file. No 03094 * extra ref is addded, so you will need to call iso_node_ref() if you 03095 * really need it. You can pass NULL in this parameter if you don't need 03096 * the pointer. 03097 * @return 03098 * number of nodes in parent if success, < 0 otherwise 03099 * Possible errors: 03100 * ISO_NULL_POINTER, if image, parent or path are NULL 03101 * ISO_NODE_NAME_NOT_UNIQUE, a node with same name already exists 03102 * ISO_OUT_OF_MEM 03103 * 03104 * @since 0.6.4 03105 */ 03106 int iso_tree_add_new_cut_out_node(IsoImage *image, IsoDir *parent, 03107 const char *name, const char *path, 03108 off_t offset, off_t size, 03109 IsoNode **node); 03110 03111 /** 03112 * Add the contents of a dir to a given directory of the iso tree. 03113 * 03114 * There are several options to control what files are added or how they are 03115 * managed. Take a look at iso_tree_set_* functions to see diferent options 03116 * for recursive directory addition. 03117 * 03118 * TODO comment Builder and Filesystem related issues when exposing both 03119 * 03120 * @param image 03121 * The image to which the directory belong. 03122 * @param parent 03123 * Directory on the image tree where to add the contents of the dir 03124 * @param dir 03125 * Path to a dir in the filesystem 03126 * @return 03127 * number of nodes in parent if success, < 0 otherwise 03128 * 03129 * @since 0.6.2 03130 */ 03131 int iso_tree_add_dir_rec(IsoImage *image, IsoDir *parent, const char *dir); 03132 03133 /** 03134 * Locate a node by its path on image. 03135 * 03136 * @param node 03137 * Location for a pointer to the node, it will filled with NULL if the 03138 * given path does not exists on image. 03139 * The node will be owned by the image and shouldn't be unref(). Just call 03140 * iso_node_ref() to get your own reference to the node. 03141 * Note that you can pass NULL is the only thing you want to do is check 03142 * if a node with such path really exists. 03143 * @return 03144 * 1 found, 0 not found, < 0 error 03145 * 03146 * @since 0.6.2 03147 */ 03148 int iso_tree_path_to_node(IsoImage *image, const char *path, IsoNode **node); 03149 03150 /** 03151 * Get the path on image of the given node. 03152 * 03153 * @return 03154 * The path on the image, that must be freed when no more needed. If the 03155 * given node is not added to any image, this returns NULL. 03156 * @since 0.6.4 03157 */ 03158 char *iso_tree_get_node_path(IsoNode *node); 03159 03160 /** 03161 * Increments the reference counting of the given IsoDataSource. 03162 * 03163 * @since 0.6.2 03164 */ 03165 void iso_data_source_ref(IsoDataSource *src); 03166 03167 /** 03168 * Decrements the reference counting of the given IsoDataSource, freeing it 03169 * if refcount reach 0. 03170 * 03171 * @since 0.6.2 03172 */ 03173 void iso_data_source_unref(IsoDataSource *src); 03174 03175 /** 03176 * Create a new IsoDataSource from a local file. This is suitable for 03177 * accessing regular .iso images, or to acces drives via its block device 03178 * and standard POSIX I/O calls. 03179 * 03180 * @param path 03181 * The path of the file 03182 * @param src 03183 * Will be filled with the pointer to the newly created data source. 03184 * @return 03185 * 1 on success, < 0 on error. 03186 * 03187 * @since 0.6.2 03188 */ 03189 int iso_data_source_new_from_file(const char *path, IsoDataSource **src); 03190 03191 /** 03192 * Get the status of the buffer used by a burn_source. 03193 * 03194 * @param b 03195 * A burn_source previously obtained with 03196 * iso_image_create_burn_source(). 03197 * @param size 03198 * Will be filled with the total size of the buffer, in bytes 03199 * @param free_bytes 03200 * Will be filled with the bytes currently available in buffer 03201 * @return 03202 * < 0 error, > 0 state: 03203 * 1="active" : input and consumption are active 03204 * 2="ending" : input has ended without error 03205 * 3="failing" : input had error and ended, 03206 * 5="abandoned" : consumption has ended prematurely 03207 * 6="ended" : consumption has ended without input error 03208 * 7="aborted" : consumption has ended after input error 03209 * 03210 * @since 0.6.2 03211 */ 03212 int iso_ring_buffer_get_status(struct burn_source *b, size_t *size, 03213 size_t *free_bytes); 03214 03215 #define ISO_MSGS_MESSAGE_LEN 4096 03216 03217 /** 03218 * Control queueing and stderr printing of messages from libisofs. 03219 * Severity may be one of "NEVER", "FATAL", "SORRY", "WARNING", "HINT", 03220 * "NOTE", "UPDATE", "DEBUG", "ALL". 03221 * 03222 * @param queue_severity Gives the minimum limit for messages to be queued. 03223 * Default: "NEVER". If you queue messages then you 03224 * must consume them by iso_msgs_obtain(). 03225 * @param print_severity Does the same for messages to be printed directly 03226 * to stderr. 03227 * @param print_id A text prefix to be printed before the message. 03228 * @return >0 for success, <=0 for error 03229 * 03230 * @since 0.6.2 03231 */ 03232 int iso_set_msgs_severities(char *queue_severity, char *print_severity, 03233 char *print_id); 03234 03235 /** 03236 * Obtain the oldest pending libisofs message from the queue which has at 03237 * least the given minimum_severity. This message and any older message of 03238 * lower severity will get discarded from the queue and is then lost forever. 03239 * 03240 * Severity may be one of "NEVER", "FATAL", "SORRY", "WARNING", "HINT", 03241 * "NOTE", "UPDATE", "DEBUG", "ALL". To call with minimum_severity "NEVER" 03242 * will discard the whole queue. 03243 * 03244 * @param error_code 03245 * Will become a unique error code as listed at the end of this header 03246 * @param imgid 03247 * Id of the image that was issued the message. 03248 * @param msg_text 03249 * Must provide at least ISO_MSGS_MESSAGE_LEN bytes. 03250 * @param severity 03251 * Will become the severity related to the message and should provide at 03252 * least 80 bytes. 03253 * @return 03254 * 1 if a matching item was found, 0 if not, <0 for severe errors 03255 * 03256 * @since 0.6.2 03257 */ 03258 int iso_obtain_msgs(char *minimum_severity, int *error_code, int *imgid, 03259 char msg_text[], char severity[]); 03260 03261 03262 /** 03263 * Submit a message to the libisofs queueing system. It will be queued or 03264 * printed as if it was generated by libisofs itself. 03265 * 03266 * @param error_code 03267 * The unique error code of your message. 03268 * Submit 0 if you do not have reserved error codes within the libburnia 03269 * project. 03270 * @param msg_text 03271 * Not more than ISO_MSGS_MESSAGE_LEN characters of message text. 03272 * @param os_errno 03273 * Eventual errno related to the message. Submit 0 if the message is not 03274 * related to a operating system error. 03275 * @param severity 03276 * One of "ABORT", "FATAL", "FAILURE", "SORRY", "WARNING", "HINT", "NOTE", 03277 * "UPDATE", "DEBUG". Defaults to "FATAL". 03278 * @param origin 03279 * Submit 0 for now. 03280 * @return 03281 * 1 if message was delivered, <=0 if failure 03282 * 03283 * @since 0.6.4 03284 */ 03285 int iso_msgs_submit(int error_code, char msg_text[], int os_errno, 03286 char severity[], int origin); 03287 03288 03289 /** 03290 * Convert a severity name into a severity number, which gives the severity 03291 * rank of the name. 03292 * 03293 * @param severity_name 03294 * A name as with iso_msgs_submit(), e.g. "SORRY". 03295 * @param severity_number 03296 * The rank number: the higher, the more severe. 03297 * @return 03298 * >0 success, <=0 failure 03299 * 03300 * @since 0.6.4 03301 */ 03302 int iso_text_to_sev(char *severity_name, int *severity_number); 03303 03304 03305 /** 03306 * Convert a severity number into a severity name 03307 * 03308 * @param severity_number 03309 * The rank number: the higher, the more severe. 03310 * @param severity_name 03311 * A name as with iso_msgs_submit(), e.g. "SORRY". 03312 * 03313 * @since 0.6.4 03314 */ 03315 int iso_sev_to_text(int severity_number, char **severity_name); 03316 03317 03318 /** 03319 * Get the id of an IsoImage, used for message reporting. This message id, 03320 * retrieved with iso_obtain_msgs(), can be used to distinguish what 03321 * IsoImage has isssued a given message. 03322 * 03323 * @since 0.6.2 03324 */ 03325 int iso_image_get_msg_id(IsoImage *image); 03326 03327 /** 03328 * Get a textual description of a libisofs error. 03329 * 03330 * @since 0.6.2 03331 */ 03332 const char *iso_error_to_msg(int errcode); 03333 03334 /** 03335 * Get the severity of a given error code 03336 * @return 03337 * 0x10000000 -> DEBUG 03338 * 0x20000000 -> UPDATE 03339 * 0x30000000 -> NOTE 03340 * 0x40000000 -> HINT 03341 * 0x50000000 -> WARNING 03342 * 0x60000000 -> SORRY 03343 * 0x64000000 -> MISHAP 03344 * 0x68000000 -> FAILURE 03345 * 0x70000000 -> FATAL 03346 * 0x71000000 -> ABORT 03347 * 03348 * @since 0.6.2 03349 */ 03350 int iso_error_get_severity(int e); 03351 03352 /** 03353 * Get the priority of a given error. 03354 * @return 03355 * 0x00000000 -> ZERO 03356 * 0x10000000 -> LOW 03357 * 0x20000000 -> MEDIUM 03358 * 0x30000000 -> HIGH 03359 * 03360 * @since 0.6.2 03361 */ 03362 int iso_error_get_priority(int e); 03363 03364 /** 03365 * Get the message queue code of a libisofs error. 03366 */ 03367 int iso_error_get_code(int e); 03368 03369 /** 03370 * Set the minimum error severity that causes a libisofs operation to 03371 * be aborted as soon as possible. 03372 * 03373 * @param severity 03374 * one of "FAILURE", "MISHAP", "SORRY", "WARNING", "HINT", "NOTE". 03375 * Severities greater or equal than FAILURE always cause program to abort. 03376 * Severities under NOTE won't never cause function abort. 03377 * @return 03378 * Previous abort priority on success, < 0 on error. 03379 * 03380 * @since 0.6.2 03381 */ 03382 int iso_set_abort_severity(char *severity); 03383 03384 /** 03385 * Return the messenger object handle used by libisofs. This handle 03386 * may be used by related libraries to their own compatible 03387 * messenger objects and thus to direct their messages to the libisofs 03388 * message queue. See also: libburn, API function burn_set_messenger(). 03389 * 03390 * @return the handle. Do only use with compatible 03391 * 03392 * @since 0.6.2 03393 */ 03394 void *iso_get_messenger(); 03395 03396 /** 03397 * Take a ref to the given IsoFileSource. 03398 * 03399 * @since 0.6.2 03400 */ 03401 void iso_file_source_ref(IsoFileSource *src); 03402 03403 /** 03404 * Drop your ref to the given IsoFileSource, eventually freeing the associated 03405 * system resources. 03406 * 03407 * @since 0.6.2 03408 */ 03409 void iso_file_source_unref(IsoFileSource *src); 03410 03411 /* 03412 * this are just helpers to invoque methods in class 03413 */ 03414 03415 /** 03416 * Get the path, relative to the filesystem this file source 03417 * belongs to. 03418 * 03419 * @return 03420 * the path of the FileSource inside the filesystem, it should be 03421 * freed when no more needed. 03422 * 03423 * @since 0.6.2 03424 */ 03425 char* iso_file_source_get_path(IsoFileSource *src); 03426 03427 /** 03428 * Get the name of the file, with the dir component of the path. 03429 * 03430 * @return 03431 * the name of the file, it should be freed when no more needed. 03432 * 03433 * @since 0.6.2 03434 */ 03435 char* iso_file_source_get_name(IsoFileSource *src); 03436 03437 /** 03438 * Get information about the file. 03439 * @return 03440 * 1 success, < 0 error 03441 * Error codes: 03442 * ISO_FILE_ACCESS_DENIED 03443 * ISO_FILE_BAD_PATH 03444 * ISO_FILE_DOESNT_EXIST 03445 * ISO_OUT_OF_MEM 03446 * ISO_FILE_ERROR 03447 * ISO_NULL_POINTER 03448 * 03449 * @since 0.6.2 03450 */ 03451 int iso_file_source_lstat(IsoFileSource *src, struct stat *info); 03452 03453 /** 03454 * Check if the process has access to read file contents. Note that this 03455 * is not necessarily related with (l)stat functions. For example, in a 03456 * filesystem implementation to deal with an ISO image, if the user has 03457 * read access to the image it will be able to read all files inside it, 03458 * despite of the particular permission of each file in the RR tree, that 03459 * are what the above functions return. 03460 * 03461 * @return 03462 * 1 if process has read access, < 0 on error 03463 * Error codes: 03464 * ISO_FILE_ACCESS_DENIED 03465 * ISO_FILE_BAD_PATH 03466 * ISO_FILE_DOESNT_EXIST 03467 * ISO_OUT_OF_MEM 03468 * ISO_FILE_ERROR 03469 * ISO_NULL_POINTER 03470 * 03471 * @since 0.6.2 03472 */ 03473 int iso_file_source_access(IsoFileSource *src); 03474 03475 /** 03476 * Get information about the file. If the file is a symlink, the info 03477 * returned refers to the destination. 03478 * 03479 * @return 03480 * 1 success, < 0 error 03481 * Error codes: 03482 * ISO_FILE_ACCESS_DENIED 03483 * ISO_FILE_BAD_PATH 03484 * ISO_FILE_DOESNT_EXIST 03485 * ISO_OUT_OF_MEM 03486 * ISO_FILE_ERROR 03487 * ISO_NULL_POINTER 03488 * 03489 * @since 0.6.2 03490 */ 03491 int iso_file_source_stat(IsoFileSource *src, struct stat *info); 03492 03493 /** 03494 * Opens the source. 03495 * @return 1 on success, < 0 on error 03496 * Error codes: 03497 * ISO_FILE_ALREADY_OPENED 03498 * ISO_FILE_ACCESS_DENIED 03499 * ISO_FILE_BAD_PATH 03500 * ISO_FILE_DOESNT_EXIST 03501 * ISO_OUT_OF_MEM 03502 * ISO_FILE_ERROR 03503 * ISO_NULL_POINTER 03504 * 03505 * @since 0.6.2 03506 */ 03507 int iso_file_source_open(IsoFileSource *src); 03508 03509 /** 03510 * Close a previuously openned file 03511 * @return 1 on success, < 0 on error 03512 * Error codes: 03513 * ISO_FILE_ERROR 03514 * ISO_NULL_POINTER 03515 * ISO_FILE_NOT_OPENED 03516 * 03517 * @since 0.6.2 03518 */ 03519 int iso_file_source_close(IsoFileSource *src); 03520 03521 /** 03522 * Attempts to read up to count bytes from the given source into 03523 * the buffer starting at buf. 03524 * 03525 * The file src must be open() before calling this, and close() when no 03526 * more needed. Not valid for dirs. On symlinks it reads the destination 03527 * file. 03528 * 03529 * @param src 03530 * The given source 03531 * @param buf 03532 * Pointer to a buffer of at least count bytes where the read data will be 03533 * stored 03534 * @param count 03535 * Bytes to read 03536 * @return 03537 * number of bytes read, 0 if EOF, < 0 on error 03538 * Error codes: 03539 * ISO_FILE_ERROR 03540 * ISO_NULL_POINTER 03541 * ISO_FILE_NOT_OPENED 03542 * ISO_WRONG_ARG_VALUE -> if count == 0 03543 * ISO_FILE_IS_DIR 03544 * ISO_OUT_OF_MEM 03545 * ISO_INTERRUPTED 03546 * 03547 * @since 0.6.2 03548 */ 03549 int iso_file_source_read(IsoFileSource *src, void *buf, size_t count); 03550 03551 /** 03552 * Repositions the offset of the given IsoFileSource (must be opened) to the 03553 * given offset according to the value of flag. 03554 * 03555 * @param offset 03556 * in bytes 03557 * @param flag 03558 * 0 The offset is set to offset bytes (SEEK_SET) 03559 * 1 The offset is set to its current location plus offset bytes 03560 * (SEEK_CUR) 03561 * 2 The offset is set to the size of the file plus offset bytes 03562 * (SEEK_END). 03563 * @return 03564 * Absolute offset posistion on the file, or < 0 on error. Cast the 03565 * returning value to int to get a valid libisofs error. 03566 * @since 0.6.4 03567 */ 03568 off_t iso_file_source_lseek(IsoFileSource *src, off_t offset, int flag); 03569 03570 /** 03571 * Read a directory. 03572 * 03573 * Each call to this function will return a new children, until we reach 03574 * the end of file (i.e, no more children), in that case it returns 0. 03575 * 03576 * The dir must be open() before calling this, and close() when no more 03577 * needed. Only valid for dirs. 03578 * 03579 * Note that "." and ".." children MUST NOT BE returned. 03580 * 03581 * @param child 03582 * pointer to be filled with the given child. Undefined on error or OEF 03583 * @return 03584 * 1 on success, 0 if EOF (no more children), < 0 on error 03585 * Error codes: 03586 * ISO_FILE_ERROR 03587 * ISO_NULL_POINTER 03588 * ISO_FILE_NOT_OPENED 03589 * ISO_FILE_IS_NOT_DIR 03590 * ISO_OUT_OF_MEM 03591 * 03592 * @since 0.6.2 03593 */ 03594 int iso_file_source_readdir(IsoFileSource *src, IsoFileSource **child); 03595 03596 /** 03597 * Read the destination of a symlink. You don't need to open the file 03598 * to call this. 03599 * 03600 * @param src 03601 * An IsoFileSource corresponding to a symbolic link. 03602 * @param buf 03603 * allocated buffer of at least bufsiz bytes. 03604 * The dest. will be copied there, and it will be NULL-terminated 03605 * @param bufsiz 03606 * characters to be copied. Destination link will be truncated if 03607 * it is larger than given size. This include the '\0' character. 03608 * @return 03609 * 1 on success, < 0 on error 03610 * Error codes: 03611 * ISO_FILE_ERROR 03612 * ISO_NULL_POINTER 03613 * ISO_WRONG_ARG_VALUE -> if bufsiz <= 0 03614 * ISO_FILE_IS_NOT_SYMLINK 03615 * ISO_OUT_OF_MEM 03616 * ISO_FILE_BAD_PATH 03617 * ISO_FILE_DOESNT_EXIST 03618 * 03619 * @since 0.6.2 03620 */ 03621 int iso_file_source_readlink(IsoFileSource *src, char *buf, size_t bufsiz); 03622 03623 /** 03624 * Get the filesystem for this source. No extra ref is added, so you 03625 * musn't unref the IsoFilesystem. 03626 * 03627 * @return 03628 * The filesystem, NULL on error 03629 * 03630 * @since 0.6.2 03631 */ 03632 IsoFilesystem* iso_file_source_get_filesystem(IsoFileSource *src); 03633 03634 /** 03635 * Take a ref to the given IsoFilesystem 03636 * 03637 * @since 0.6.2 03638 */ 03639 void iso_filesystem_ref(IsoFilesystem *fs); 03640 03641 /** 03642 * Drop your ref to the given IsoFilesystem, evetually freeing associated 03643 * resources. 03644 * 03645 * @since 0.6.2 03646 */ 03647 void iso_filesystem_unref(IsoFilesystem *fs); 03648 03649 /** 03650 * Create a new IsoFilesystem to access a existent ISO image. 03651 * 03652 * @param src 03653 * Data source to access data. 03654 * @param opts 03655 * Image read options 03656 * @param msgid 03657 * An image identifer, obtained with iso_image_get_msg_id(), used to 03658 * associated messages issued by the filesystem implementation with an 03659 * existent image. If you are not using this filesystem in relation with 03660 * any image context, just use 0x1fffff as the value for this parameter. 03661 * @param fs 03662 * Will be filled with a pointer to the filesystem that can be used 03663 * to access image contents. 03664 * @param 03665 * 1 on success, < 0 on error 03666 * 03667 * @since 0.6.2 03668 */ 03669 int iso_image_filesystem_new(IsoDataSource *src, IsoReadOpts *opts, int msgid, 03670 IsoImageFilesystem **fs); 03671 03672 /** 03673 * Get the volset identifier for an existent image. The returned string belong 03674 * to the IsoImageFilesystem and shouldn't be free() nor modified. 03675 * 03676 * @since 0.6.2 03677 */ 03678 const char *iso_image_fs_get_volset_id(IsoImageFilesystem *fs); 03679 03680 /** 03681 * Get the volume identifier for an existent image. The returned string belong 03682 * to the IsoImageFilesystem and shouldn't be free() nor modified. 03683 * 03684 * @since 0.6.2 03685 */ 03686 const char *iso_image_fs_get_volume_id(IsoImageFilesystem *fs); 03687 03688 /** 03689 * Get the publisher identifier for an existent image. The returned string 03690 * belong to the IsoImageFilesystem and shouldn't be free() nor modified. 03691 * 03692 * @since 0.6.2 03693 */ 03694 const char *iso_image_fs_get_publisher_id(IsoImageFilesystem *fs); 03695 03696 /** 03697 * Get the data preparer identifier for an existent image. The returned string 03698 * belong to the IsoImageFilesystem and shouldn't be free() nor modified. 03699 * 03700 * @since 0.6.2 03701 */ 03702 const char *iso_image_fs_get_data_preparer_id(IsoImageFilesystem *fs); 03703 03704 /** 03705 * Get the system identifier for an existent image. The returned string belong 03706 * to the IsoImageFilesystem and shouldn't be free() nor modified. 03707 * 03708 * @since 0.6.2 03709 */ 03710 const char *iso_image_fs_get_system_id(IsoImageFilesystem *fs); 03711 03712 /** 03713 * Get the application identifier for an existent image. The returned string 03714 * belong to the IsoImageFilesystem and shouldn't be free() nor modified. 03715 * 03716 * @since 0.6.2 03717 */ 03718 const char *iso_image_fs_get_application_id(IsoImageFilesystem *fs); 03719 03720 /** 03721 * Get the copyright file identifier for an existent image. The returned string 03722 * belong to the IsoImageFilesystem and shouldn't be free() nor modified. 03723 * 03724 * @since 0.6.2 03725 */ 03726 const char *iso_image_fs_get_copyright_file_id(IsoImageFilesystem *fs); 03727 03728 /** 03729 * Get the abstract file identifier for an existent image. The returned string 03730 * belong to the IsoImageFilesystem and shouldn't be free() nor modified. 03731 * 03732 * @since 0.6.2 03733 */ 03734 const char *iso_image_fs_get_abstract_file_id(IsoImageFilesystem *fs); 03735 03736 /** 03737 * Get the biblio file identifier for an existent image. The returned string 03738 * belong to the IsoImageFilesystem and shouldn't be free() nor modified. 03739 * 03740 * @since 0.6.2 03741 */ 03742 const char *iso_image_fs_get_biblio_file_id(IsoImageFilesystem *fs); 03743 03744 /** 03745 * Increment reference count of an IsoStream. 03746 * 03747 * @since 0.6.4 03748 */ 03749 void iso_stream_ref(IsoStream *stream); 03750 03751 /** 03752 * Decrement reference count of an IsoStream, and eventually free it if 03753 * refcount reach 0. 03754 * 03755 * @since 0.6.4 03756 */ 03757 void iso_stream_unref(IsoStream *stream); 03758 03759 /** 03760 * Opens the given stream. Remember to close the Stream before writing the 03761 * image. 03762 * 03763 * @return 03764 * 1 on success, 2 file greater than expected, 3 file smaller than 03765 * expected, < 0 on error 03766 * 03767 * @since 0.6.4 03768 */ 03769 int iso_stream_open(IsoStream *stream); 03770 03771 /** 03772 * Close a previously openned IsoStream. 03773 * 03774 * @return 03775 * 1 on success, < 0 on error 03776 * 03777 * @since 0.6.4 03778 */ 03779 int iso_stream_close(IsoStream *stream); 03780 03781 /** 03782 * Get the size of a given stream. This function should always return the same 03783 * size, even if the underlying source size changes, unless you call 03784 * iso_stream_update_size(). 03785 * 03786 * @return 03787 * IsoStream size in bytes 03788 * 03789 * @since 0.6.4 03790 */ 03791 off_t iso_stream_get_size(IsoStream *stream); 03792 03793 /** 03794 * Attempts to read up to count bytes from the given stream into 03795 * the buffer starting at buf. 03796 * 03797 * The stream must be open() before calling this, and close() when no 03798 * more needed. 03799 * 03800 * @return 03801 * number of bytes read, 0 if EOF, < 0 on error 03802 * 03803 * @since 0.6.4 03804 */ 03805 int iso_stream_read(IsoStream *stream, void *buf, size_t count); 03806 03807 /** 03808 * Whether the given IsoStream can be read several times, with the same 03809 * results. 03810 * For example, a regular file is repeatable, you can read it as many 03811 * times as you want. However, a pipe isn't. 03812 * 03813 * This function doesn't take into account if the file has been modified 03814 * between the two reads. 03815 * 03816 * @return 03817 * 1 if stream is repeatable, 0 if not, < 0 on error 03818 * 03819 * @since 0.6.4 03820 */ 03821 int iso_stream_is_repeatable(IsoStream *stream); 03822 03823 /** 03824 * Updates the size of the IsoStream with the current size of the 03825 * underlying source. 03826 * 03827 * @return 03828 * 1 if ok, < 0 on error (has to be a valid libisofs error code), 03829 * 0 if the IsoStream does not support this function. 03830 * @since 0.6.8 03831 */ 03832 int iso_stream_update_size(IsoStream *stream); 03833 03834 /** 03835 * Get an unique identifier for a given IsoStream. 03836 * 03837 * @since 0.6.4 03838 */ 03839 void iso_stream_get_id(IsoStream *stream, unsigned int *fs_id, dev_t *dev_id, 03840 ino_t *ino_id); 03841 03842 /************ Error codes and return values for libisofs ********************/ 03843 03844 /** successfully execution */ 03845 #define ISO_SUCCESS 1 03846 03847 /** 03848 * special return value, it could be or not an error depending on the 03849 * context. 03850 */ 03851 #define ISO_NONE 0 03852 03853 /** Operation canceled (FAILURE,HIGH, -1) */ 03854 #define ISO_CANCELED 0xE830FFFF 03855 03856 /** Unknown or unexpected fatal error (FATAL,HIGH, -2) */ 03857 #define ISO_FATAL_ERROR 0xF030FFFE 03858 03859 /** Unknown or unexpected error (FAILURE,HIGH, -3) */ 03860 #define ISO_ERROR 0xE830FFFD 03861 03862 /** Internal programming error. Please report this bug (FATAL,HIGH, -4) */ 03863 #define ISO_ASSERT_FAILURE 0xF030FFFC 03864 03865 /** 03866 * NULL pointer as value for an arg. that doesn't allow NULL (FAILURE,HIGH, -5) 03867 */ 03868 #define ISO_NULL_POINTER 0xE830FFFB 03869 03870 /** Memory allocation error (FATAL,HIGH, -6) */ 03871 #define ISO_OUT_OF_MEM 0xF030FFFA 03872 03873 /** Interrupted by a signal (FATAL,HIGH, -7) */ 03874 #define ISO_INTERRUPTED 0xF030FFF9 03875 03876 /** Invalid parameter value (FAILURE,HIGH, -8) */ 03877 #define ISO_WRONG_ARG_VALUE 0xE830FFF8 03878 03879 /** Can't create a needed thread (FATAL,HIGH, -9) */ 03880 #define ISO_THREAD_ERROR 0xF030FFF7 03881 03882 /** Write error (FAILURE,HIGH, -10) */ 03883 #define ISO_WRITE_ERROR 0xE830FFF6 03884 03885 /** Buffer read error (FAILURE,HIGH, -11) */ 03886 #define ISO_BUF_READ_ERROR 0xE830FFF5 03887 03888 /** Trying to add to a dir a node already added to a dir (FAILURE,HIGH, -64) */ 03889 #define ISO_NODE_ALREADY_ADDED 0xE830FFC0 03890 03891 /** Node with same name already exists (FAILURE,HIGH, -65) */ 03892 #define ISO_NODE_NAME_NOT_UNIQUE 0xE830FFBF 03893 03894 /** Trying to remove a node that was not added to dir (FAILURE,HIGH, -65) */ 03895 #define ISO_NODE_NOT_ADDED_TO_DIR 0xE830FFBE 03896 03897 /** A requested node does not exist (FAILURE,HIGH, -66) */ 03898 #define ISO_NODE_DOESNT_EXIST 0xE830FFBD 03899 03900 /** 03901 * Try to set the boot image of an already bootable image (FAILURE,HIGH, -67) 03902 */ 03903 #define ISO_IMAGE_ALREADY_BOOTABLE 0xE830FFBC 03904 03905 /** Trying to use an invalid file as boot image (FAILURE,HIGH, -68) */ 03906 #define ISO_BOOT_IMAGE_NOT_VALID 0xE830FFBB 03907 03908 /** 03909 * Error on file operation (FAILURE,HIGH, -128) 03910 * (take a look at more specified error codes below) 03911 */ 03912 #define ISO_FILE_ERROR 0xE830FF80 03913 03914 /** Trying to open an already openned file (FAILURE,HIGH, -129) */ 03915 #define ISO_FILE_ALREADY_OPENED 0xE830FF7F 03916 03917 /* @deprecated use ISO_FILE_ALREADY_OPENED instead */ 03918 #define ISO_FILE_ALREADY_OPENNED 0xE830FF7F 03919 03920 /** Access to file is not allowed (FAILURE,HIGH, -130) */ 03921 #define ISO_FILE_ACCESS_DENIED 0xE830FF7E 03922 03923 /** Incorrect path to file (FAILURE,HIGH, -131) */ 03924 #define ISO_FILE_BAD_PATH 0xE830FF7D 03925 03926 /** The file does not exist in the filesystem (FAILURE,HIGH, -132) */ 03927 #define ISO_FILE_DOESNT_EXIST 0xE830FF7C 03928 03929 /** Trying to read or close a file not openned (FAILURE,HIGH, -133) */ 03930 #define ISO_FILE_NOT_OPENED 0xE830FF7B 03931 03932 /* @deprecated use ISO_FILE_NOT_OPENED instead */ 03933 #define ISO_FILE_NOT_OPENNED ISO_FILE_NOT_OPENED 03934 03935 /** Directory used where no dir is expected (FAILURE,HIGH, -134) */ 03936 #define ISO_FILE_IS_DIR 0xE830FF7A 03937 03938 /** Read error (FAILURE,HIGH, -135) */ 03939 #define ISO_FILE_READ_ERROR 0xE830FF79 03940 03941 /** Not dir used where a dir is expected (FAILURE,HIGH, -136) */ 03942 #define ISO_FILE_IS_NOT_DIR 0xE830FF78 03943 03944 /** Not symlink used where a symlink is expected (FAILURE,HIGH, -137) */ 03945 #define ISO_FILE_IS_NOT_SYMLINK 0xE830FF77 03946 03947 /** Can't seek to specified location (FAILURE,HIGH, -138) */ 03948 #define ISO_FILE_SEEK_ERROR 0xE830FF76 03949 03950 /** File not supported in ECMA-119 tree and thus ignored (WARNING,MEDIUM, -139) */ 03951 #define ISO_FILE_IGNORED 0xD020FF75 03952 03953 /* A file is bigger than supported by used standard (WARNING,MEDIUM, -140) */ 03954 #define ISO_FILE_TOO_BIG 0xD020FF74 03955 03956 /* File read error during image creation (MISHAP,HIGH, -141) */ 03957 #define ISO_FILE_CANT_WRITE 0xE430FF73 03958 03959 /* Can't convert filename to requested charset (HINT,MEDIUM, -142) */ 03960 #define ISO_FILENAME_WRONG_CHARSET 0xC020FF72 03961 03962 /* File can't be added to the tree (SORRY,HIGH, -143) */ 03963 #define ISO_FILE_CANT_ADD 0xE030FF71 03964 03965 /** 03966 * File path break specification constraints and will be ignored 03967 * (WARNING,MEDIUM, -144) 03968 */ 03969 #define ISO_FILE_IMGPATH_WRONG 0xD020FF70 03970 03971 /** 03972 * Offset greater than file size (FAILURE,HIGH, -145) 03973 * @since 0.6.4 03974 */ 03975 #define ISO_FILE_OFFSET_TOO_BIG 0xE830FF6A 03976 03977 /** Charset conversion error (FAILURE,HIGH, -256) */ 03978 #define ISO_CHARSET_CONV_ERROR 0xE830FF00 03979 03980 /** 03981 * Too much files to mangle, i.e. we cannot guarantee unique file names 03982 * (FAILURE,HIGH, -257) 03983 */ 03984 #define ISO_MANGLE_TOO_MUCH_FILES 0xE830FEFF 03985 03986 /* image related errors */ 03987 03988 /** 03989 * Wrong or damaged Primary Volume Descriptor (FAILURE,HIGH, -320) 03990 * This could mean that the file is not a valid ISO image. 03991 */ 03992 #define ISO_WRONG_PVD 0xE830FEC0 03993 03994 /** Wrong or damaged RR entry (SORRY,HIGH, -321) */ 03995 #define ISO_WRONG_RR 0xE030FEBF 03996 03997 /** Unsupported RR feature (SORRY,HIGH, -322) */ 03998 #define ISO_UNSUPPORTED_RR 0xE030FEBE 03999 04000 /** Wrong or damaged ECMA-119 (FAILURE,HIGH, -323) */ 04001 #define ISO_WRONG_ECMA119 0xE830FEBD 04002 04003 /** Unsupported ECMA-119 feature (FAILURE,HIGH, -324) */ 04004 #define ISO_UNSUPPORTED_ECMA119 0xE830FEBC 04005 04006 /** Wrong or damaged El-Torito catalog (SORRY,HIGH, -325) */ 04007 #define ISO_WRONG_EL_TORITO 0xE030FEBB 04008 04009 /** Unsupported El-Torito feature (SORRY,HIGH, -326) */ 04010 #define ISO_UNSUPPORTED_EL_TORITO 0xE030FEBA 04011 04012 /** Can't patch an isolinux boot image (SORRY,HIGH, -327) */ 04013 #define ISO_ISOLINUX_CANT_PATCH 0xE030FEB9 04014 04015 /** Unsupported SUSP feature (SORRY,HIGH, -328) */ 04016 #define ISO_UNSUPPORTED_SUSP 0xE030FEB8 04017 04018 /** Error on a RR entry that can be ignored (WARNING,HIGH, -329) */ 04019 #define ISO_WRONG_RR_WARN 0xD030FEB7 04020 04021 /** Error on a RR entry that can be ignored (HINT,MEDIUM, -330) */ 04022 #define ISO_SUSP_UNHANDLED 0xC020FEB6 04023 04024 /** Multiple ER SUSP entries found (WARNING,HIGH, -331) */ 04025 #define ISO_SUSP_MULTIPLE_ER 0xD030FEB5 04026 04027 /** Unsupported volume descriptor found (HINT,MEDIUM, -332) */ 04028 #define ISO_UNSUPPORTED_VD 0xC020FEB4 04029 04030 /** El-Torito related warning (WARNING,HIGH, -333) */ 04031 #define ISO_EL_TORITO_WARN 0xD030FEB3 04032 04033 /** Image write cancelled (MISHAP,HIGH, -334) */ 04034 #define ISO_IMAGE_WRITE_CANCELED 0xE430FEB2 04035 04036 /** El-Torito image is hidden (WARNING,HIGH, -335) */ 04037 #define ISO_EL_TORITO_HIDDEN 0xD030FEB1 04038 04039 /** Read error occured with IsoDataSource (SORRY,HIGH, -513) */ 04040 #define ISO_DATA_SOURCE_SORRY 0xE030FCFF 04041 04042 /** Read error occured with IsoDataSource (MISHAP,HIGH, -513) */ 04043 #define ISO_DATA_SOURCE_MISHAP 0xE430FCFF 04044 04045 /** Read error occured with IsoDataSource (FAILURE,HIGH, -513) */ 04046 #define ISO_DATA_SOURCE_FAILURE 0xE830FCFF 04047 04048 /** Read error occured with IsoDataSource (FATAL,HIGH, -513) */ 04049 #define ISO_DATA_SOURCE_FATAL 0xF030FCFF 04050 04051 #endif /*LIBISO_LIBISOFS_H_*/
1.5.6