diff --git a/Makefile.am b/Makefile.am index 4424e85..d4c2149 100644 --- a/Makefile.am +++ b/Makefile.am @@ -51,8 +51,7 @@ libisofs_libisofs_la_SOURCES = \ libisofs/iso1999.c \ libisofs/data_source.c libinclude_HEADERS = \ - libisofs/libisofs.h \ - libisofs/error.h + libisofs/libisofs.h ## ========================================================================= ## diff --git a/doc/Tutorial b/doc/Tutorial index fbde4f5..7a1f93c 100755 --- a/doc/Tutorial +++ b/doc/Tutorial @@ -65,7 +65,7 @@ contexts at a time. In libisofs error reporting is done in two ways: with the return value of the functions and with the message queue. -Error codes are negative numbers, defined in "libisofs/error.h" header. An +Error codes are negative numbers, defined in "libisofs.h" header. An error code is associated with a given severity, either "DEBUG", "UPDATE", "NOTE", "HINT", "WARNING", "SORRY", "FAILURE" and "FATAL". For the meaning of each severity take a look at private header "libiso_msgs.h". Errors @@ -76,8 +76,8 @@ translate error severity to string] First of all, most libisofs functions return an integer. If such integer is a negative number, it means the function has returned an error. The error code -and its severity is encoded in the return value (take a look at -libisofs/error.h header). +and its severity is encoded in the return value (take a look at error codes in +libisofs.h header). Additionally, libisofs reports most of its errors in a message queue. Error messages on that queue can be printed directly to stderr or programmatically diff --git a/libisofs/buffer.c b/libisofs/buffer.c index 8618ad6..c59bad1 100644 --- a/libisofs/buffer.c +++ b/libisofs/buffer.c @@ -17,7 +17,6 @@ */ #include "buffer.h" -#include "error.h" #include "libburn/libburn.h" #include "ecma119.h" diff --git a/libisofs/builder.c b/libisofs/builder.c index 615fb27..9dbea87 100644 --- a/libisofs/builder.c +++ b/libisofs/builder.c @@ -7,7 +7,6 @@ */ #include "builder.h" -#include "error.h" #include "node.h" #include "fsource.h" diff --git a/libisofs/data_source.c b/libisofs/data_source.c index 7510a89..98515c6 100644 --- a/libisofs/data_source.c +++ b/libisofs/data_source.c @@ -7,7 +7,6 @@ */ #include "libisofs.h" -#include "error.h" #include "util.h" #include diff --git a/libisofs/ecma119.c b/libisofs/ecma119.c index aa34a07..3fff055 100644 --- a/libisofs/ecma119.c +++ b/libisofs/ecma119.c @@ -13,7 +13,6 @@ #include "iso1999.h" #include "eltorito.h" #include "ecma119_tree.h" -#include "error.h" #include "filesrc.h" #include "image.h" #include "writer.h" diff --git a/libisofs/ecma119_tree.c b/libisofs/ecma119_tree.c index a93ef79..943fa0a 100644 --- a/libisofs/ecma119_tree.c +++ b/libisofs/ecma119_tree.c @@ -8,7 +8,6 @@ #include "ecma119_tree.h" #include "ecma119.h" -#include "error.h" #include "node.h" #include "util.h" #include "filesrc.h" diff --git a/libisofs/eltorito.c b/libisofs/eltorito.c index 2bf50a7..8b0c9dd 100644 --- a/libisofs/eltorito.c +++ b/libisofs/eltorito.c @@ -8,7 +8,6 @@ #include "eltorito.h" #include "stream.h" -#include "error.h" #include "fsource.h" #include "filesrc.h" #include "image.h" diff --git a/libisofs/filesrc.c b/libisofs/filesrc.c index 879ab70..989445f 100644 --- a/libisofs/filesrc.c +++ b/libisofs/filesrc.c @@ -7,7 +7,6 @@ */ #include "filesrc.h" -#include "error.h" #include "node.h" #include "util.h" #include "writer.h" diff --git a/libisofs/fs_image.c b/libisofs/fs_image.c index db5ba67..1e123fb 100644 --- a/libisofs/fs_image.c +++ b/libisofs/fs_image.c @@ -12,7 +12,6 @@ */ #include "libisofs.h" -#include "error.h" #include "ecma119.h" #include "messages.h" #include "rockridge.h" diff --git a/libisofs/fs_local.c b/libisofs/fs_local.c index 90f9c0d..e9a28b7 100644 --- a/libisofs/fs_local.c +++ b/libisofs/fs_local.c @@ -11,7 +11,6 @@ */ #include "fsource.h" -#include "error.h" #include "util.h" #include diff --git a/libisofs/image.c b/libisofs/image.c index 569393b..0792483 100644 --- a/libisofs/image.c +++ b/libisofs/image.c @@ -8,7 +8,6 @@ #include "libisofs.h" #include "image.h" -#include "error.h" #include "node.h" #include "messages.h" #include "eltorito.h" diff --git a/libisofs/iso1999.c b/libisofs/iso1999.c index 92da386..827d5ad 100644 --- a/libisofs/iso1999.c +++ b/libisofs/iso1999.c @@ -9,7 +9,6 @@ #include "iso1999.h" #include "messages.h" #include "writer.h" -#include "error.h" #include "image.h" #include "filesrc.h" #include "eltorito.h" diff --git a/libisofs/joliet.c b/libisofs/joliet.c index 7c21fd9..0b86f03 100644 --- a/libisofs/joliet.c +++ b/libisofs/joliet.c @@ -10,7 +10,6 @@ #include "joliet.h" #include "messages.h" #include "writer.h" -#include "error.h" #include "image.h" #include "filesrc.h" #include "eltorito.h" diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 04b57b2..8e6d52c 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -2027,12 +2027,17 @@ int iso_set_msgs_severities(char *queue_severity, char *print_severity, * "NOTE", "UPDATE", "DEBUG", "ALL". To call with minimum_severity "NEVER" * will discard the whole queue. * - * @param error_code Will become a unique error code as listed in error.h - * @param imgid Id of the image that was issued the message. - * @param msg_text Must provide at least ISO_MSGS_MESSAGE_LEN bytes. - * @param severity Will become the severity related to the message and - * should provide at least 80 bytes. - * @return 1 if a matching item was found, 0 if not, <0 for severe errors + * @param error_code + * Will become a unique error code as listed at the end of this header + * @param imgid + * Id of the image that was issued the message. + * @param msg_text + * Must provide at least ISO_MSGS_MESSAGE_LEN bytes. + * @param severity + * Will become the severity related to the message and should provide at + * least 80 bytes. + * @return + * 1 if a matching item was found, 0 if not, <0 for severe errors */ int iso_obtain_msgs(char *minimum_severity, int *error_code, int *imgid, char msg_text[], char severity[]); @@ -2349,4 +2354,212 @@ const char *iso_image_fs_get_abstract_file_id(IsoImageFilesystem *fs); */ const char *iso_image_fs_get_biblio_file_id(IsoImageFilesystem *fs); +/************ Error codes and return values for libisofs ********************/ + +/* + * error codes are 32 bit numbers, that follow the following conventions: + * + * bit 31 (MSB) -> 1 (to make the value always negative) + * bits 30-24 -> Encoded severity (Use ISO_ERR_SEV to translate an error code + * to a LIBISO_MSGS_SEV_* constant) + * = 0x10 -> DEBUG + * = 0x20 -> UPDATE + * = 0x30 -> NOTE + * = 0x40 -> HINT + * = 0x50 -> WARNING + * = 0x60 -> SORRY + * = 0x68 -> FAILURE + * = 0x70 -> FATAL + * = 0x71 -> ABORT + * bits 23-20 -> Encoded priority (Use ISO_ERR_PRIO to translate an error code + * to a LIBISO_MSGS_PRIO_* constant) + * = 0x0 -> ZERO + * = 0x1 -> LOW + * = 0x2 -> MEDIUM + * = 0x3 -> HIGH + * bits 19-16 -> Reserved for future usage (maybe message ranges) + * bits 15-0 -> Error code + */ + +#define ISO_ERR_SEV(e) (e & 0x7F000000) +#define ISO_ERR_PRIO(e) ((e & 0x00F00000) << 8) +#define ISO_ERR_CODE(e) (e & 0x0000FFFF) + +/** successfully execution */ +#define ISO_SUCCESS 1 + +/** + * special return value, it could be or not an error depending on the + * context. + */ +#define ISO_NONE 0 + +/** Operation canceled (FAILURE,HIGH, -1) */ +#define ISO_CANCELED 0xE830FFFF + +/** Unknown or unexpected fatal error (FATAL,HIGH, -2) */ +#define ISO_FATAL_ERROR 0xF030FFFE + +/** Unknown or unexpected error (FAILURE,HIGH, -3) */ +#define ISO_ERROR 0xE830FFFD + +/** Internal programming error. Please report this bug (FATAL,HIGH, -4) */ +#define ISO_ASSERT_FAILURE 0xF030FFFC + +/** + * NULL pointer as value for an arg. that doesn't allow NULL (FAILURE,HIGH, -5) + */ +#define ISO_NULL_POINTER 0xE830FFFB + +/** Memory allocation error (FATAL,HIGH, -6) */ +#define ISO_OUT_OF_MEM 0xF030FFFA + +/** Interrupted by a signal (FATAL,HIGH, -7) */ +#define ISO_INTERRUPTED 0xF030FFF9 + +/** Invalid parameter value (FAILURE,HIGH, -8) */ +#define ISO_WRONG_ARG_VALUE 0xE830FFF8 + +/** Can't create a needed thread (FATAL,HIGH, -9) */ +#define ISO_THREAD_ERROR 0xF030FFF7 + +/** Write error (FAILURE,HIGH, -10) */ +#define ISO_WRITE_ERROR 0xE830FFF6 + +/** Buffer read error (FAILURE,HIGH, -11) */ +#define ISO_BUF_READ_ERROR 0xE830FFF5 + +/** Trying to add to a dir a node already added to a dir (FAILURE,HIGH, -64) */ +#define ISO_NODE_ALREADY_ADDED 0xE830FFC0 + +/** Node with same name already exists (FAILURE,HIGH, -65) */ +#define ISO_NODE_NAME_NOT_UNIQUE 0xE830FFBF + +/** Trying to remove a node that was not added to dir (FAILURE,HIGH, -65) */ +#define ISO_NODE_NOT_ADDED_TO_DIR 0xE830FFBE + +/** A requested node does not exists (FAILURE,HIGH, -66) */ +#define ISO_NODE_DOESNT_EXIST 0xE830FFBD + +/** + * Try to set the boot image of an already bootable image (FAILURE,HIGH, -67) + */ +#define ISO_IMAGE_ALREADY_BOOTABLE 0xE830FFBC + +/** Trying to use an invalid file as boot image (FAILURE,HIGH, -68) */ +#define ISO_BOOT_IMAGE_NOT_VALID 0xE830FFBB + +/** + * Error on file operation (FAILURE,HIGH, -128) + * (take a look at more specified error codes below) + */ +#define ISO_FILE_ERROR 0xE830FF80 + +/** Trying to open an already openned file (FAILURE,HIGH, -129) */ +#define ISO_FILE_ALREADY_OPENNED 0xE830FF7F + +/** Access to file is not allowed (FAILURE,HIGH, -130) */ +#define ISO_FILE_ACCESS_DENIED 0xE830FF7E + +/** Incorrect path to file (FAILURE,HIGH, -131) */ +#define ISO_FILE_BAD_PATH 0xE830FF7D + +/** The file does not exists in the filesystem (FAILURE,HIGH, -132) */ +#define ISO_FILE_DOESNT_EXIST 0xE830FF7C + +/** Trying to read or close a file not openned (FAILURE,HIGH, -133) */ +#define ISO_FILE_NOT_OPENNED 0xE830FF7B + +/** Directory used where no dir is expected (FAILURE,HIGH, -134) */ +#define ISO_FILE_IS_DIR 0xE830FF7A + +/** Read error (FAILURE,HIGH, -135) */ +#define ISO_FILE_READ_ERROR 0xE830FF79 + +/** Not dir used where a dir is expected (FAILURE,HIGH, -136) */ +#define ISO_FILE_IS_NOT_DIR 0xE830FF78 + +/** Not symlink used where a symlink is expected (FAILURE,HIGH, -137) */ +#define ISO_FILE_IS_NOT_SYMLINK 0xE830FF77 + +/** Can't seek to specified location (FAILURE,HIGH, -138) */ +#define ISO_FILE_SEEK_ERROR 0xE830FF76 + +/** File not supported in ECMA-119 tree and thus ignored (HINT,MEDIUM, -139) */ +#define ISO_FILE_IGNORED 0xC020FF75 + +/* A file is bigger than supported by used standard (HINT,MEDIUM, -140) */ +#define ISO_FILE_TOO_BIG 0xC020FF74 + +/* File read error during image creations (SORRY,HIGH, -141) */ +#define ISO_FILE_CANT_WRITE 0xE030FF73 + +/* Can't convert filename to requested charset (HINT,MEDIUM, -142) */ +#define ISO_FILENAME_WRONG_CHARSET 0xC020FF72 + +/* File can't be added to the tree (SORRY,HIGH, -143) */ +#define ISO_FILE_CANT_ADD 0xE030FF71 + +/** + * File path break specification constraints and will be ignored + * (HINT,MEDIUM, -141) + */ +#define ISO_FILE_IMGPATH_WRONG 0xC020FF73 + +/** Charset conversion error (FAILURE,HIGH, -256) */ +#define ISO_CHARSET_CONV_ERROR 0xE830FF00 + +/** + * Too much files to mangle, i.e. we cannot guarantee unique file names + * (FAILURE,HIGH, -257) + */ +#define ISO_MANGLE_TOO_MUCH_FILES 0xE830FEFF + +/* image related errors */ + +/** + * Wrong or damaged Primary Volume Descriptor (FAILURE,HIGH, -320) + * This could mean that the file is not a valid ISO image. + */ +#define ISO_WRONG_PVD 0xE830FEC0 + +/** Wrong or damaged RR entry (SORRY,HIGH, -321) */ +#define ISO_WRONG_RR 0xE030FEBF + +/** Unsupported RR feature (SORRY,HIGH, -322) */ +#define ISO_UNSUPPORTED_RR 0xE030FEBE + +/** Wrong or damaged ECMA-119 (FAILURE,HIGH, -323) */ +#define ISO_WRONG_ECMA119 0xE830FEBD + +/** Unsupported ECMA-119 feature (FAILURE,HIGH, -324) */ +#define ISO_UNSUPPORTED_ECMA119 0xE830FEBC + +/** Wrong or damaged El-Torito catalog (SORRY,HIGH, -325) */ +#define ISO_WRONG_EL_TORITO 0xE030FEBB + +/** Unsupported El-Torito feature (SORRY,HIGH, -326) */ +#define ISO_UNSUPPORTED_EL_TORITO 0xE030FEBA + +/** Can't patch an isolinux boot image (SORRY,HIGH, -327) */ +#define ISO_ISOLINUX_CANT_PATCH 0xE030FEB9 + +/** Unsupported SUSP feature (SORRY,HIGH, -328) */ +#define ISO_UNSUPPORTED_SUSP 0xE030FEB8 + +/** Error on a RR entry that can be ignored (WARNING,MEDIUM, -329) */ +#define ISO_WRONG_RR_WARN 0xD020FEB7 + +/** Error on a RR entry that can be ignored (HINT,MEDIUM, -330) */ +#define ISO_SUSP_UNHANDLED 0xC020FEB6 + +/** Multiple ER SUSP entries found (WARNING,MEDIUM, -331) */ +#define ISO_SUSP_MULTIPLE_ER 0xD020FEB5 + +/** Unsupported volume descriptor found (HINT,MEDIUM, -332) */ +#define ISO_UNSUPPORTED_VD 0xC020FEB4 + +/** El-Torito related warning (WARNING,MEDIUM, -333) */ +#define ISO_EL_TORITO_WARN 0xD020FEB3 + #endif /*LIBISO_LIBISOFS_H_*/ diff --git a/libisofs/messages.c b/libisofs/messages.c index 19282aa..92f6e24 100644 --- a/libisofs/messages.c +++ b/libisofs/messages.c @@ -12,7 +12,6 @@ #include "libisofs.h" #include "messages.h" -#include "error.h" int iso_message_id = LIBISO_MSGS_ORIGIN_IMAGE_BASE; diff --git a/libisofs/node.c b/libisofs/node.c index 04846db..9df3bac 100644 --- a/libisofs/node.c +++ b/libisofs/node.c @@ -8,7 +8,6 @@ #include "libisofs.h" #include "node.h" -#include "error.h" #include "stream.h" #include diff --git a/libisofs/rockridge.c b/libisofs/rockridge.c index c48b9e4..e57ed3d 100644 --- a/libisofs/rockridge.c +++ b/libisofs/rockridge.c @@ -10,7 +10,6 @@ #include "rockridge.h" #include "node.h" #include "ecma119_tree.h" -#include "error.h" #include "writer.h" #include "messages.h" #include "image.h" diff --git a/libisofs/rockridge_read.c b/libisofs/rockridge_read.c index 87d2271..02dbc86 100644 --- a/libisofs/rockridge_read.c +++ b/libisofs/rockridge_read.c @@ -15,7 +15,6 @@ #include "ecma119.h" #include "util.h" #include "rockridge.h" -#include "error.h" #include "messages.h" #include diff --git a/libisofs/stream.c b/libisofs/stream.c index 60bcafb..9d315c6 100644 --- a/libisofs/stream.c +++ b/libisofs/stream.c @@ -9,7 +9,6 @@ #include "libisofs.h" #include "stream.h" #include "fsource.h" -#include "error.h" #include "util.h" #include diff --git a/libisofs/tree.c b/libisofs/tree.c index aba8683..7f0d7ff 100644 --- a/libisofs/tree.c +++ b/libisofs/tree.c @@ -12,7 +12,6 @@ #include "libisofs.h" #include "node.h" -#include "error.h" #include "image.h" #include "fsource.h" #include "builder.h" diff --git a/libisofs/util.c b/libisofs/util.c index 0c7512c..6317a8b 100644 --- a/libisofs/util.c +++ b/libisofs/util.c @@ -8,7 +8,7 @@ */ #include "util.h" -#include "error.h" +#include "libisofs.h" #include "../version.h" #include diff --git a/libisofs/util_htable.c b/libisofs/util_htable.c index 08b46c3..684ce6e 100644 --- a/libisofs/util_htable.c +++ b/libisofs/util_htable.c @@ -7,7 +7,7 @@ */ #include "util.h" -#include "error.h" +#include "libisofs.h" #include #include diff --git a/libisofs/util_rbtree.c b/libisofs/util_rbtree.c index d3eeb1b..7a30fc2 100644 --- a/libisofs/util_rbtree.c +++ b/libisofs/util_rbtree.c @@ -7,7 +7,7 @@ */ #include "util.h" -#include "error.h" +#include "libisofs.h" #include diff --git a/test/mocked_fsrc.c b/test/mocked_fsrc.c index 9f76ad5..13c6b45 100644 --- a/test/mocked_fsrc.c +++ b/test/mocked_fsrc.c @@ -5,7 +5,7 @@ #include "fsource.h" #include "mocked_fsrc.h" -#include "error.h" +#include "libisofs.h" #include #include diff --git a/test/test_node.c b/test/test_node.c index dad5c74..6e8f6f2 100644 --- a/test/test_node.c +++ b/test/test_node.c @@ -5,7 +5,6 @@ #include "libisofs.h" #include "node.h" #include "test.h" -#include "error.h" #include diff --git a/test/test_tree.c b/test/test_tree.c index 85946bd..8379439 100644 --- a/test/test_tree.c +++ b/test/test_tree.c @@ -4,7 +4,6 @@ #include "libisofs.h" #include "node.h" -#include "error.h" #include "image.h" #include "test.h" diff --git a/test/test_util.c b/test/test_util.c index 00b53b4..e1412e9 100644 --- a/test/test_util.c +++ b/test/test_util.c @@ -5,7 +5,6 @@ */ #include "test.h" #include "util.h" -#include "error.h" #include #include