Browse Source

Better messages when aborting iso_image_import() due to checksum failure.

release-1.5.4.branch
Thomas Schmitt 13 years ago
parent
commit
363a39af3e
  1. 14
      libisofs/fs_image.c
  2. 10
      libisofs/messages.c
  3. 9
      libisofs/messages.h

14
libisofs/fs_image.c

@ -2323,8 +2323,8 @@ int iso_src_check_sb_tree(IsoDataSource *src, uint32_t start_lba, int flag)
/* Relocated Superblock: restart checking at real session start */
if (next_tag < 32) {
/* Non plausible session_start address */
iso_msg_submit(-1, ret, 0, NULL);
ret = ISO_SB_TREE_CORRUPTED;
iso_msg_submit(-1, ret, 0, NULL);
goto ex;
}
/* Check real session */
@ -2422,13 +2422,15 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
#ifdef Libisofs_with_checksumS
if (data->md5_load) {
/* From opts->block on : check for superblock and tree tags */;
ret = iso_src_check_sb_tree(src, opts->block, 0);
if (ret <= 0) {
/* >>> refuse to load, hint towards loading without MD5 check */;
if (ret < 0) {
iso_msgs_submit(0,
"Image loading aborted due to MD5 mismatch of image tree data",
0, "FAILURE", 0);
iso_msgs_submit(0,
"You may override this refusal by disabling MD5 checking",
0, "HINT", 0);
goto fs_cleanup;
}
}

10
libisofs/messages.c

@ -277,6 +277,14 @@ const char *iso_error_to_msg(int errcode)
}
}
int iso_msg_is_abort(int errcode)
{
if (ISO_ERR_SEV(errcode) >= abort_threshold)
return 1;
return 0;
}
int iso_msg_submit(int imgid, int errcode, int causedby, const char *fmt, ...)
{
char msg[MAX_MSG_LEN];
@ -307,7 +315,7 @@ int iso_msg_submit(int imgid, int errcode, int causedby, const char *fmt, ...)
}
}
if (ISO_ERR_SEV(errcode) >= abort_threshold) {
if (iso_msg_is_abort(errcode)) {
return ISO_CANCELED;
} else {
return 0;

9
libisofs/messages.h

@ -24,6 +24,13 @@ extern int iso_message_id;
*/
void iso_msg_debug(int imgid, const char *fmt, ...);
/**
* Inquire whether the given error code triggers the abort threshold
*/
int iso_msg_is_abort(int errcode);
/**
*
* @param errcode
@ -33,7 +40,7 @@ void iso_msg_debug(int imgid, const char *fmt, ...);
* < 0 will be returned in any case. Use 0 if there is no previous
* cause for the error.
* @return
* 1 on success, < 0 if function must abort asap.
* 0 on success, < 0 if function must abort asap.
*/
int iso_msg_submit(int imgid, int errcode, int causedby, const char *fmt, ...);

Loading…
Cancel
Save