From 3f84ec1fa37d706dff6fcade67a2da8773f4f8a4 Mon Sep 17 00:00:00 2001 From: Vreixo Formoso Date: Tue, 5 Feb 2008 12:55:29 +0100 Subject: [PATCH] Changes to error handling. - API to get error code. - Errors are submited to message queue by its error code - Define error codes in libiso_msgs.h --- libisofs/libiso_msgs.h | 52 ++++++++++++++++++++++++++++++++++++++++++ libisofs/libisofs.h | 25 ++++++++++++-------- libisofs/messages.c | 17 +++++++++----- 3 files changed, 78 insertions(+), 16 deletions(-) diff --git a/libisofs/libiso_msgs.h b/libisofs/libiso_msgs.h index 482bdfc..b9c61bd 100644 --- a/libisofs/libiso_msgs.h +++ b/libisofs/libiso_msgs.h @@ -499,6 +499,58 @@ Range "scdbackup" : 0x00020000 to 0x0002ffff ------------------------------------------------------------------------------ Range "vreixo" : 0x00030000 to 0x0003ffff + 0x0003ffff (FAILURE,HIGH) = Operation canceled + 0x0003fffe (FATAL,HIGH) = Unknown or unexpected fatal error + 0x0003fffd (FAILURE,HIGH) = Unknown or unexpected error + 0x0003fffc (FATAL,HIGH) = Internal programming error + 0x0003fffb (FAILURE,HIGH) = NULL pointer where NULL not allowed + 0x0003fffa (FATAL,HIGH) = Memory allocation error + 0x0003fff9 (FATAL,HIGH) = Interrupted by a signal + 0x0003fff8 (FAILURE,HIGH) = Invalid parameter value + 0x0003fff7 (FATAL,HIGH) = Cannot create a needed thread + 0x0003fff6 (FAILURE,HIGH) = Write error + 0x0003fff5 (FAILURE,HIGH) = Buffer read error + 0x0003ffc0 (FAILURE,HIGH) = Trying to add a node already added to another dir + 0x0003ffbf (FAILURE,HIGH) = Node with same name already exist + 0x0003ffbe (FAILURE,HIGH) = Trying to remove a node that was not added to dir + 0x0003ffbd (FAILURE,HIGH) = A requested node does not exist + 0x0003ffbc (FAILURE,HIGH) = Image already bootable + 0x0003ffbb (FAILURE,HIGH) = Trying to use an invalid file as boot image + 0x0003ff80 (FAILURE,HIGH) = Error on file operation + 0x0003ff7f (FAILURE,HIGH) = Trying to open an already openned file + 0x0003ff7e (FAILURE,HIGH) = Access to file is not allowed + 0x0003ff7d (FAILURE,HIGH) = Incorrect path to file + 0x0003ff7c (FAILURE,HIGH) = The file does not exist in the filesystem + 0x0003ff7b (FAILURE,HIGH) = Trying to read or close a file not openned + 0x0003ff7a (FAILURE,HIGH) = Directory used where no dir is expected + 0x0003ff79 (FAILURE,HIGH) = File read error + 0x0003ff78 (FAILURE,HIGH) = Not dir used where a dir is expected + 0x0003ff77 (FAILURE,HIGH) = Not symlink used where a symlink is expected + 0x0003ff76 (FAILURE,HIGH) = Cannot seek to specified location + 0x0003ff75 (HINT,MEDIUM) = File not supported in ECMA-119 tree and ignored + 0x0003ff74 (HINT,MEDIUM) = File bigger than supported by used standard + 0x0003ff73 (SORRY,HIGH) = File read error during image creation + 0x0003ff72 (HINT,MEDIUM) = Cannot convert filename to requested charset + 0x0003ff71 (SORRY,HIGH) = File cannot be added to the tree + 0x0003ff70 (HINT,MEDIUM) = File path breaks specification constraints + 0x0003ff00 (FAILURE,HIGH) = Charset conversion error + 0x0003feff (FAILURE,HIGH) = Too much files to mangle + 0x0003fec0 (FAILURE,HIGH) = Wrong or damaged Primary Volume Descriptor + 0x0003febf (SORRY,HIGH) = Wrong or damaged RR entry + 0x0003febe (SORRY,HIGH) = Unsupported RR feature + 0x0003febd (FAILURE,HIGH) = Wrong or damaged ECMA-119 + 0x0003febc (FAILURE,HIGH) = Unsupported ECMA-119 feature + 0x0003febb (SORRY,HIGH) = Wrong or damaged El-Torito catalog + 0x0003feba (SORRY,HIGH) = Unsupported El-Torito feature + 0x0003feb9 (SORRY,HIGH) = Cannot patch isolinux boot image + 0x0003feb8 (SORRY,HIGH) = Unsupported SUSP feature + 0x0003feb7 (WARNING,HIGH) = Error on a RR entry that can be ignored + 0x0003feb6 (HINT,MEDIUM) = Error on a RR entry that can be ignored + 0x0003feb5 (WARNING,HIGH) = Multiple ER SUSP entries found + 0x0003feb4 (HINT,MEDIUM) = Unsupported volume descriptor found + 0x0003feb3 (WARNING,HIGH) = El-Torito related warning + 0x0003feb2 (SORRY,HIGH) = Image write cancelled + ------------------------------------------------------------------------------ Range "application" : 0x00040000 to 0x0004ffff diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 24c2244..238d7f7 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -2561,6 +2561,11 @@ int iso_error_get_severity(int e); */ int iso_error_get_priority(int e); +/** + * Get the message queue code of a libisofs error. + */ +int iso_error_get_code(int e); + /** * Set the minimum error severity that causes a libisofs operation to * be aborted as soon as possible. @@ -2972,7 +2977,7 @@ const char *iso_image_fs_get_biblio_file_id(IsoImageFilesystem *fs); /** 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) */ +/** A requested node does not exist (FAILURE,HIGH, -66) */ #define ISO_NODE_DOESNT_EXIST 0xE830FFBD /** @@ -2998,7 +3003,7 @@ const char *iso_image_fs_get_biblio_file_id(IsoImageFilesystem *fs); /** Incorrect path to file (FAILURE,HIGH, -131) */ #define ISO_FILE_BAD_PATH 0xE830FF7D -/** The file does not exists in the filesystem (FAILURE,HIGH, -132) */ +/** The file does not exist in the filesystem (FAILURE,HIGH, -132) */ #define ISO_FILE_DOESNT_EXIST 0xE830FF7C /** Trying to read or close a file not openned (FAILURE,HIGH, -133) */ @@ -3025,7 +3030,7 @@ const char *iso_image_fs_get_biblio_file_id(IsoImageFilesystem *fs); /* 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) */ +/* File read error during image creation (SORRY,HIGH, -141) */ #define ISO_FILE_CANT_WRITE 0xE030FF73 /* Can't convert filename to requested charset (HINT,MEDIUM, -142) */ @@ -3038,7 +3043,7 @@ const char *iso_image_fs_get_biblio_file_id(IsoImageFilesystem *fs); * File path break specification constraints and will be ignored * (HINT,MEDIUM, -141) */ -#define ISO_FILE_IMGPATH_WRONG 0xC020FF73 +#define ISO_FILE_IMGPATH_WRONG 0xC020FF70 /** Charset conversion error (FAILURE,HIGH, -256) */ #define ISO_CHARSET_CONV_ERROR 0xE830FF00 @@ -3081,20 +3086,20 @@ const char *iso_image_fs_get_biblio_file_id(IsoImageFilesystem *fs); /** 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 (WARNING,HIGH, -329) */ +#define ISO_WRONG_RR_WARN 0xD030FEB7 /** 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 +/** Multiple ER SUSP entries found (WARNING,HIGH, -331) */ +#define ISO_SUSP_MULTIPLE_ER 0xD030FEB5 /** 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 +/** El-Torito related warning (WARNING,HIGH, -333) */ +#define ISO_EL_TORITO_WARN 0xD030FEB3 /** Image write cancelled (SORRY,HIGH, -334) */ #define ISO_IMAGE_WRITE_CANCELED 0xE030FEB2 diff --git a/libisofs/messages.c b/libisofs/messages.c index fdf6224..c32ba50 100644 --- a/libisofs/messages.c +++ b/libisofs/messages.c @@ -40,7 +40,7 @@ */ #define ISO_ERR_SEV(e) (e & 0x7F000000) #define ISO_ERR_PRIO(e) ((e & 0x00F00000) << 8) -#define ISO_ERR_CODE(e) (e & 0x0000FFFF) +#define ISO_ERR_CODE(e) ((e & 0x0000FFFF) | 0x00030000) int iso_message_id = LIBISO_MSGS_ORIGIN_IMAGE_BASE; @@ -128,7 +128,7 @@ const char *iso_error_to_msg(int errcode) case ISO_NODE_NOT_ADDED_TO_DIR: return "Trying to remove a node that was not added to dir"; case ISO_NODE_DOESNT_EXIST: - return "A requested node does not exists"; + return "A requested node does not exist"; case ISO_IMAGE_ALREADY_BOOTABLE: return "Try to set the boot image of an already bootable image"; case ISO_BOOT_IMAGE_NOT_VALID: @@ -142,7 +142,7 @@ const char *iso_error_to_msg(int errcode) case ISO_FILE_BAD_PATH: return "Incorrect path to file"; case ISO_FILE_DOESNT_EXIST: - return "The file does not exists in the filesystem"; + return "The file does not exist in the filesystem"; case ISO_FILE_NOT_OPENNED: return "Trying to read or close a file not openned"; case ISO_FILE_IS_DIR: @@ -160,7 +160,7 @@ const char *iso_error_to_msg(int errcode) case ISO_FILE_TOO_BIG: return "A file is bigger than supported by used standard"; case ISO_FILE_CANT_WRITE: - return "File read error during image creations"; + return "File read error during image creation"; case ISO_FILENAME_WRONG_CHARSET: return "Can't convert filename to requested charset"; case ISO_FILE_CANT_ADD: @@ -224,8 +224,8 @@ int iso_msg_submit(int imgid, int errcode, int causedby, const char *fmt, ...) strncpy(msg, iso_error_to_msg(errcode), MAX_MSG_LEN); } - libiso_msgs_submit(libiso_msgr, imgid, errcode, ISO_ERR_SEV(errcode), - ISO_ERR_PRIO(errcode), msg, 0, 0); + libiso_msgs_submit(libiso_msgr, imgid, ISO_ERR_CODE(errcode), + ISO_ERR_SEV(errcode), ISO_ERR_PRIO(errcode), msg, 0, 0); if (causedby != 0) { iso_msg_debug(imgid, " > Caused by: %s", iso_error_to_msg(causedby)); if (ISO_ERR_SEV(causedby) == LIBISO_MSGS_SEV_FATAL) { @@ -351,3 +351,8 @@ int iso_error_get_priority(int e) { return ISO_ERR_PRIO(e); } + +int iso_error_get_code(int e) +{ + return ISO_ERR_CODE(e); +}