Optionally pass to message function the reason of an error.

This commit is contained in:
Vreixo Formoso 2008-01-22 21:36:24 +01:00
parent be7b1f6fca
commit ab7ea855f6
8 changed files with 81 additions and 66 deletions

View File

@ -791,8 +791,8 @@ void *write_function(void *arg)
pthread_exit(NULL); pthread_exit(NULL);
write_error: ; write_error: ;
iso_msg_submit(target->image->id, ISO_WRITE_ERROR, iso_msg_submit(target->image->id, ISO_WRITE_ERROR, res,
"Image write error: %s", iso_error_to_msg(res)); "Image write error");
iso_ring_buffer_writer_close(target->buffer, 1); iso_ring_buffer_writer_close(target->buffer, 1);
pthread_exit(NULL); pthread_exit(NULL);
} }
@ -1038,7 +1038,7 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts, Ecma119Image **img)
ret = pthread_create(&(target->wthread), &(target->th_attr), ret = pthread_create(&(target->wthread), &(target->th_attr),
write_function, (void *) target); write_function, (void *) target);
if (ret != 0) { if (ret != 0) {
iso_msg_submit(target->image->id, ISO_THREAD_ERROR, iso_msg_submit(target->image->id, ISO_THREAD_ERROR, 0,
"Cannot create writer thread"); "Cannot create writer thread");
ret = ISO_THREAD_ERROR; ret = ISO_THREAD_ERROR;
goto target_cleanup; goto target_cleanup;
@ -1069,7 +1069,7 @@ static int bs_read(struct burn_source *bs, unsigned char *buf, int size)
return size; return size;
} else if (ret < 0) { } else if (ret < 0) {
/* error */ /* error */
iso_msg_submit(t->image->id, ISO_BUF_READ_ERROR, NULL); iso_msg_submit(t->image->id, ISO_BUF_READ_ERROR, ret, NULL);
return -1; return -1;
} else { } else {
/* EOF */ /* EOF */

View File

@ -208,7 +208,7 @@ int create_image(IsoImage *image, const char *image_path,
boot_media_type = 3; /* 2.88 meg diskette */ boot_media_type = 3; /* 2.88 meg diskette */
break; break;
default: default:
iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID, iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID, 0,
"Invalid image size %d Kb. Must be one of 1.2, 1.44" "Invalid image size %d Kb. Must be one of 1.2, 1.44"
"or 2.88 Mb", iso_stream_get_size(stream) / 1024); "or 2.88 Mb", iso_stream_get_size(stream) / 1024);
return ISO_BOOT_IMAGE_NOT_VALID; return ISO_BOOT_IMAGE_NOT_VALID;
@ -227,21 +227,21 @@ int create_image(IsoImage *image, const char *image_path,
/* read the MBR on disc and get the type of the partition */ /* read the MBR on disc and get the type of the partition */
ret = iso_stream_open(stream); ret = iso_stream_open(stream);
if (ret < 0) { if (ret < 0) {
iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID, iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID, ret,
"Can't open image file."); "Can't open image file.");
return ret; return ret;
} }
ret = iso_stream_read(stream, &mbr, sizeof(mbr)); ret = iso_stream_read(stream, &mbr, sizeof(mbr));
iso_stream_close(stream); iso_stream_close(stream);
if (ret != sizeof(mbr)) { if (ret != sizeof(mbr)) {
iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID, iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID, 0,
"Can't read MBR from image file."); "Can't read MBR from image file.");
return ret < 0 ? ret : ISO_FILE_READ_ERROR; return ret < 0 ? ret : ISO_FILE_READ_ERROR;
} }
/* check valid MBR signature */ /* check valid MBR signature */
if ( mbr.sign1 != 0x55 || mbr.sign2 != 0xAA ) { if ( mbr.sign1 != 0x55 || mbr.sign2 != 0xAA ) {
iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID, iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID, 0,
"Invalid MBR. Wrong signature."); "Invalid MBR. Wrong signature.");
return ISO_BOOT_IMAGE_NOT_VALID; return ISO_BOOT_IMAGE_NOT_VALID;
} }
@ -252,7 +252,7 @@ int create_image(IsoImage *image, const char *image_path,
if (mbr.partition[i].type != 0) { if (mbr.partition[i].type != 0) {
/* it's an used partition */ /* it's an used partition */
if (used_partition != -1) { if (used_partition != -1) {
iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID, iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID, 0,
"Invalid MBR. At least 2 partitions: %d and " "Invalid MBR. At least 2 partitions: %d and "
"%d, are being used\n", used_partition, i); "%d, are being used\n", used_partition, i);
return ISO_BOOT_IMAGE_NOT_VALID; return ISO_BOOT_IMAGE_NOT_VALID;
@ -772,7 +772,7 @@ int patch_boot_image(uint8_t *buf, Ecma119Image *t, size_t imgsize)
size_t offset; size_t offset;
if (imgsize < 64) { if (imgsize < 64) {
return iso_msg_submit(t->image->id, ISO_ISOLINUX_CANT_PATCH, return iso_msg_submit(t->image->id, ISO_ISOLINUX_CANT_PATCH, 0,
"Isolinux image too small. We won't patch it."); "Isolinux image too small. We won't patch it.");
} }
@ -789,7 +789,7 @@ int patch_boot_image(uint8_t *buf, Ecma119Image *t, size_t imgsize)
} }
if (offset != imgsize) { if (offset != imgsize) {
/* file length not multiple of 4 */ /* file length not multiple of 4 */
return iso_msg_submit(t->image->id, ISO_ISOLINUX_CANT_PATCH, return iso_msg_submit(t->image->id, ISO_ISOLINUX_CANT_PATCH, 0,
"Unexpected isolinux image length. Patch might not work."); "Unexpected isolinux image length. Patch might not work.");
} }

View File

@ -272,8 +272,8 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
* 0's to image * 0's to image
*/ */
char *name = iso_stream_get_name(file->stream); char *name = iso_stream_get_name(file->stream);
res = iso_msg_submit(t->image->id, res, "File \"%s\" can't be " res = iso_msg_submit(t->image->id, res, res, "File \"%s\" can't be"
"opened (error %d). Filling with 0s.", name, res); " opened (error %d). Filling with 0s.", name, res);
free(name); free(name);
if (res < 0) { if (res < 0) {
return res; /* aborted due to error severity */ return res; /* aborted due to error severity */
@ -305,11 +305,11 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
char *name = iso_stream_get_name(file->stream); char *name = iso_stream_get_name(file->stream);
if (res < 0) { if (res < 0) {
/* error */ /* error */
res = iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE, res = iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE, res,
"Read error in file %s.", name); "Read error in file %s.", name);
} else { } else {
/* eof */ /* eof */
res = iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE, res = iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE, 0,
"Premature end of file %s.", name); "Premature end of file %s.", name);
} }
free(name); free(name);
@ -319,8 +319,8 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
} }
/* fill with 0s */ /* fill with 0s */
iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE, iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE, 0,
"Filling with 0"); "Filling with 0");
memset(buffer, 0, BLOCK_SIZE); memset(buffer, 0, BLOCK_SIZE);
while (b++ < nblocks) { while (b++ < nblocks) {
res = iso_write(t, buffer, BLOCK_SIZE); res = iso_write(t, buffer, BLOCK_SIZE);

View File

@ -713,7 +713,7 @@ char *get_name(_ImageFsData *fsdata, const char *str, size_t len)
if (ret == 1) { if (ret == 1) {
return name; return name;
} else { } else {
ret = iso_msg_submit(fsdata->msgid, ISO_FILENAME_WRONG_CHARSET, ret = iso_msg_submit(fsdata->msgid, ISO_FILENAME_WRONG_CHARSET, ret,
"Charset conversion error. Can't convert %s from %s to %s", "Charset conversion error. Can't convert %s from %s to %s",
str, fsdata->input_charset, fsdata->local_charset); str, fsdata->input_charset, fsdata->local_charset);
if (ret < 0) { if (ret < 0) {
@ -776,7 +776,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
/* check for unsupported multiextend */ /* check for unsupported multiextend */
if (record->flags[0] & 0x80) { if (record->flags[0] & 0x80) {
iso_msg_submit(fsdata->msgid, ISO_UNSUPPORTED_ECMA119, iso_msg_submit(fsdata->msgid, ISO_UNSUPPORTED_ECMA119, 0,
"Unsupported image. This image makes use of Multi-Extend" "Unsupported image. This image makes use of Multi-Extend"
" features, that are not supported at this time. If you " " features, that are not supported at this time. If you "
"need support for that, please request us this feature."); "need support for that, please request us this feature.");
@ -785,7 +785,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
/* check for unsupported interleaved mode */ /* check for unsupported interleaved mode */
if (record->file_unit_size[0] || record->interleave_gap_size[0]) { if (record->file_unit_size[0] || record->interleave_gap_size[0]) {
iso_msg_submit(fsdata->msgid, ISO_UNSUPPORTED_ECMA119, iso_msg_submit(fsdata->msgid, ISO_UNSUPPORTED_ECMA119, 0,
"Unsupported image. This image has at least one file recorded " "Unsupported image. This image has at least one file recorded "
"in interleaved mode. We don't support this mode, as we think " "in interleaved mode. We don't support this mode, as we think "
"it's not used. If you're reading this, then we're wrong :) " "it's not used. If you're reading this, then we're wrong :) "
@ -798,7 +798,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
* if we don't support them, it is easy to ignore them. * if we don't support them, it is easy to ignore them.
*/ */
if (record->len_xa[0]) { if (record->len_xa[0]) {
iso_msg_submit(fsdata->msgid, ISO_UNSUPPORTED_ECMA119, iso_msg_submit(fsdata->msgid, ISO_UNSUPPORTED_ECMA119, 0,
"Unsupported image. This image has at least one file with " "Unsupported image. This image has at least one file with "
"Extended Attributes, that are not supported"); "Extended Attributes, that are not supported");
return ISO_UNSUPPORTED_ECMA119; return ISO_UNSUPPORTED_ECMA119;
@ -834,20 +834,20 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
ret = read_rr_PX(sue, &atts); ret = read_rr_PX(sue, &atts);
if (ret < 0) { if (ret < 0) {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret,
"Invalid PX entry"); "Invalid PX entry");
} }
} else if (SUSP_SIG(sue, 'T', 'F')) { } else if (SUSP_SIG(sue, 'T', 'F')) {
ret = read_rr_TF(sue, &atts); ret = read_rr_TF(sue, &atts);
if (ret < 0) { if (ret < 0) {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret,
"Invalid TF entry"); "Invalid TF entry");
} }
} else if (SUSP_SIG(sue, 'N', 'M')) { } else if (SUSP_SIG(sue, 'N', 'M')) {
if (name != NULL && namecont == 0) { if (name != NULL && namecont == 0) {
/* ups, RR standard violation */ /* ups, RR standard violation */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, 0,
"New NM entry found without previous" "New NM entry found without previous"
"CONTINUE flag. Ignored"); "CONTINUE flag. Ignored");
continue; continue;
@ -855,13 +855,13 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
ret = read_rr_NM(sue, &name, &namecont); ret = read_rr_NM(sue, &name, &namecont);
if (ret < 0) { if (ret < 0) {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret,
"Invalid NM entry"); "Invalid NM entry");
} }
} else if (SUSP_SIG(sue, 'S', 'L')) { } else if (SUSP_SIG(sue, 'S', 'L')) {
if (linkdest != NULL && linkdestcont == 0) { if (linkdest != NULL && linkdestcont == 0) {
/* ups, RR standard violation */ /* ups, RR standard violation */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, 0,
"New SL entry found without previous" "New SL entry found without previous"
"CONTINUE flag. Ignored"); "CONTINUE flag. Ignored");
continue; continue;
@ -869,7 +869,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
ret = read_rr_SL(sue, &linkdest, &linkdestcont); ret = read_rr_SL(sue, &linkdest, &linkdestcont);
if (ret < 0) { if (ret < 0) {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret,
"Invalid SL entry"); "Invalid SL entry");
} }
} else if (SUSP_SIG(sue, 'R', 'E')) { } else if (SUSP_SIG(sue, 'R', 'E')) {
@ -890,7 +890,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
*/ */
relocated_dir = iso_read_bb(sue->data.CL.child_loc, 4, NULL); relocated_dir = iso_read_bb(sue->data.CL.child_loc, 4, NULL);
if (relocated_dir == 0) { if (relocated_dir == 0) {
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, 0,
"Invalid SL entry, no child location"); "Invalid SL entry, no child location");
break; break;
} }
@ -898,12 +898,12 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
ret = read_rr_PN(sue, &atts); ret = read_rr_PN(sue, &atts);
if (ret < 0) { if (ret < 0) {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN, ret,
"Invalid PN entry"); "Invalid PN entry");
} }
} else if (SUSP_SIG(sue, 'S', 'F')) { } else if (SUSP_SIG(sue, 'S', 'F')) {
ret = iso_msg_submit(fsdata->msgid, ISO_UNSUPPORTED_RR, ret = iso_msg_submit(fsdata->msgid, ISO_UNSUPPORTED_RR, 0,
"Sparse files not supported."); "Sparse files not supported.");
break; break;
} else if (SUSP_SIG(sue, 'R', 'R')) { } else if (SUSP_SIG(sue, 'R', 'R')) {
/* TODO I've seen this RR on mkisofs images. what's this? */ /* TODO I've seen this RR on mkisofs images. what's this? */
@ -915,7 +915,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
*/ */
if (parent != NULL) { if (parent != NULL) {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, 0,
"SP entry found in a directory entry other " "SP entry found in a directory entry other "
"than '.' entry of root node"); "than '.' entry of root node");
} }
@ -927,13 +927,13 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
*/ */
if (parent != NULL) { if (parent != NULL) {
/* notify and continue */ /* notify and continue */
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, 0,
"ER entry found in a directory entry other " "ER entry found in a directory entry other "
"than '.' entry of root node"); "than '.' entry of root node");
} }
continue; continue;
} else { } else {
ret = iso_msg_submit(fsdata->msgid, ISO_SUSP_UNHANDLED, ret = iso_msg_submit(fsdata->msgid, ISO_SUSP_UNHANDLED, 0,
"Unhandled SUSP entry %c%c.", sue->sig[0], sue->sig[1]); "Unhandled SUSP entry %c%c.", sue->sig[0], sue->sig[1]);
} }
} }
@ -946,16 +946,17 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
/* error was already submitted above */ /* error was already submitted above */
iso_msg_debug(fsdata->msgid, "Error parsing RR entries"); iso_msg_debug(fsdata->msgid, "Error parsing RR entries");
} else if (!relocated_dir && atts.st_mode == (mode_t) 0 ) { } else if (!relocated_dir && atts.st_mode == (mode_t) 0 ) {
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, "Mandatory Rock " ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, 0, "Mandatory "
"Ridge PX entry is not present or it contains invalid values."); "Rock Ridge PX entry is not present or it "
"contains invalid values.");
} else { } else {
/* ensure both name and link dest are finished */ /* ensure both name and link dest are finished */
if (namecont != 0) { if (namecont != 0) {
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, 0,
"Incomplete RR name, last NM entry continues"); "Incomplete RR name, last NM entry continues");
} }
if (linkdestcont != 0) { if (linkdestcont != 0) {
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, 0,
"Incomplete link destination, last SL entry continues"); "Incomplete link destination, last SL entry continues");
} }
} }
@ -974,8 +975,9 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
if (ret < 0) { if (ret < 0) {
/* its just a hint message */ /* its just a hint message */
ret = iso_msg_submit(fsdata->msgid, ISO_FILENAME_WRONG_CHARSET, ret = iso_msg_submit(fsdata->msgid, ISO_FILENAME_WRONG_CHARSET,
"Charset conversion error. Can't convert %s from %s to %s", ret, "Charset conversion error. Can't "
name, fsdata->input_charset, fsdata->local_charset); "convert %s from %s to %s", name,
fsdata->input_charset, fsdata->local_charset);
free(newname); free(newname);
if (ret < 0) { if (ret < 0) {
free(name); free(name);
@ -995,8 +997,9 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
fsdata->local_charset, &newlinkdest); fsdata->local_charset, &newlinkdest);
if (ret < 0) { if (ret < 0) {
ret = iso_msg_submit(fsdata->msgid, ISO_FILENAME_WRONG_CHARSET, ret = iso_msg_submit(fsdata->msgid, ISO_FILENAME_WRONG_CHARSET,
"Charset conversion error. Can't convert %s from %s to %s", ret, "Charset conversion error. Can't "
linkdest, fsdata->input_charset, fsdata->local_charset); "convert %s from %s to %s", name,
fsdata->input_charset, fsdata->local_charset);
free(newlinkdest); free(newlinkdest);
if (ret < 0) { if (ret < 0) {
free(name); free(name);
@ -1029,14 +1032,14 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
if (record->len_fi[0] == 1 && record->file_id[0] == 0) { if (record->len_fi[0] == 1 && record->file_id[0] == 0) {
/* "." entry, we can call this for root node, so... */ /* "." entry, we can call this for root node, so... */
if (!(atts.st_mode & S_IFDIR)) { if (!(atts.st_mode & S_IFDIR)) {
return iso_msg_submit(fsdata->msgid, ISO_WRONG_ECMA119, return iso_msg_submit(fsdata->msgid, ISO_WRONG_ECMA119, 0,
"Wrong ISO file name. \".\" not dir"); "Wrong ISO file name. \".\" not dir");
} }
} else { } else {
name = get_name(fsdata, (char*)record->file_id, record->len_fi[0]); name = get_name(fsdata, (char*)record->file_id, record->len_fi[0]);
if (name == NULL) { if (name == NULL) {
return iso_msg_submit(fsdata->msgid, ISO_WRONG_ECMA119, return iso_msg_submit(fsdata->msgid, ISO_WRONG_ECMA119, 0,
"Can't retrieve file name"); "Can't retrieve file name");
} }
@ -1119,7 +1122,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
/* TODO #00014 : more sanity checks to ensure dir record info is valid */ /* TODO #00014 : more sanity checks to ensure dir record info is valid */
if (S_ISLNK(atts.st_mode) && (linkdest == NULL)) { if (S_ISLNK(atts.st_mode) && (linkdest == NULL)) {
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, 0,
"Link without destination."); "Link without destination.");
free(name); free(name);
return ret; return ret;
@ -1443,7 +1446,7 @@ int read_root_susp_entries(_ImageFsData *data, uint32_t block)
|| sue->data.SP.ef[0] != 0xEF) { || sue->data.SP.ef[0] != 0xEF) {
susp_iter_free(iter); susp_iter_free(iter);
return iso_msg_submit(data->msgid, ISO_UNSUPPORTED_SUSP, return iso_msg_submit(data->msgid, ISO_UNSUPPORTED_SUSP, 0,
"SUSP SP system use entry seems to be wrong. " "SUSP SP system use entry seems to be wrong. "
"Ignoring Rock Ridge Extensions."); "Ignoring Rock Ridge Extensions.");
} }
@ -1479,7 +1482,7 @@ int read_root_susp_entries(_ImageFsData *data, uint32_t block)
if (SUSP_SIG(sue, 'E', 'R')) { if (SUSP_SIG(sue, 'E', 'R')) {
if (data->rr_version) { if (data->rr_version) {
ret = iso_msg_submit(data->msgid, ISO_SUSP_MULTIPLE_ER, ret = iso_msg_submit(data->msgid, ISO_SUSP_MULTIPLE_ER, 0,
"More than one ER has found. This is not supported. " "More than one ER has found. This is not supported. "
"It will be ignored, but can cause problems. " "It will be ignored, but can cause problems. "
"Please notify us about this."); "Please notify us about this.");
@ -1508,7 +1511,7 @@ int read_root_susp_entries(_ImageFsData *data, uint32_t block)
"Suitable Rock Ridge ER found. Version 1.12."); "Suitable Rock Ridge ER found. Version 1.12.");
data->rr_version = RR_EXT_112; data->rr_version = RR_EXT_112;
} else { } else {
ret = iso_msg_submit(data->msgid, ISO_SUSP_MULTIPLE_ER, ret = iso_msg_submit(data->msgid, ISO_SUSP_MULTIPLE_ER, 0,
"Not Rock Ridge ER found.\n" "Not Rock Ridge ER found.\n"
"That will be ignored, but can cause problems in " "That will be ignored, but can cause problems in "
"image reading. Please notify us about this"); "image reading. Please notify us about this");
@ -1604,14 +1607,14 @@ int read_el_torito_boot_catalog(_ImageFsData *data, uint32_t block)
if ( (ve->header_id[0] != 1) || (ve->key_byte1[0] != 0x55) if ( (ve->header_id[0] != 1) || (ve->key_byte1[0] != 0x55)
|| (ve->key_byte2[0] != 0xAA) ) { || (ve->key_byte2[0] != 0xAA) ) {
return iso_msg_submit(data->msgid, ISO_WRONG_EL_TORITO, return iso_msg_submit(data->msgid, ISO_WRONG_EL_TORITO, 0,
"Wrong or damaged El-Torito Catalog. El-Torito info " "Wrong or damaged El-Torito Catalog. El-Torito info "
"will be ignored."); "will be ignored.");
} }
/* check for a valid platform */ /* check for a valid platform */
if (ve->platform_id[0] != 0) { if (ve->platform_id[0] != 0) {
return iso_msg_submit(data->msgid, ISO_UNSUPPORTED_EL_TORITO, return iso_msg_submit(data->msgid, ISO_UNSUPPORTED_EL_TORITO, 0,
"Unsupported El-Torito platform. Only 80x86 is " "Unsupported El-Torito platform. Only 80x86 is "
"supported. El-Torito info will be ignored."); "supported. El-Torito info will be ignored.");
} }
@ -1721,7 +1724,8 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
|| strncmp((char*)vol->boot_sys_id, || strncmp((char*)vol->boot_sys_id,
"EL TORITO SPECIFICATION", 23)) { "EL TORITO SPECIFICATION", 23)) {
ret = iso_msg_submit(data->msgid, ISO_UNSUPPORTED_EL_TORITO, ret = iso_msg_submit(data->msgid,
ISO_UNSUPPORTED_EL_TORITO, 0,
"Unsupported Boot Vol. Desc. Only El-Torito " "Unsupported Boot Vol. Desc. Only El-Torito "
"Specification, Version 1.0 Volume " "Specification, Version 1.0 Volume "
"Descriptors are supported. Ignoring boot info"); "Descriptors are supported. Ignoring boot info");
@ -1768,7 +1772,7 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
data->evd_root_block = iso_read_bb(root->block, 4, NULL); data->evd_root_block = iso_read_bb(root->block, 4, NULL);
/* TODO #00021 : handle RR info in ISO 9660:1999 tree */ /* TODO #00021 : handle RR info in ISO 9660:1999 tree */
} else { } else {
ret = iso_msg_submit(data->msgid, ISO_UNSUPPORTED_VD, ret = iso_msg_submit(data->msgid, ISO_UNSUPPORTED_VD, 0,
"Unsupported Sup. Vol. Desc found."); "Unsupported Sup. Vol. Desc found.");
if (ret < 0) { if (ret < 0) {
goto fs_cleanup; goto fs_cleanup;
@ -1783,7 +1787,7 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
*/ */
break; break;
default: default:
ret = iso_msg_submit(data->msgid, ISO_UNSUPPORTED_VD, ret = iso_msg_submit(data->msgid, ISO_UNSUPPORTED_VD, 0,
"Ignoring Volume descriptor %x.", buffer[0]); "Ignoring Volume descriptor %x.", buffer[0]);
if (ret < 0) { if (ret < 0) {
goto fs_cleanup; goto fs_cleanup;
@ -1896,7 +1900,7 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
if (fsdata->eltorito && data->block == fsdata->catblock) { if (fsdata->eltorito && data->block == fsdata->catblock) {
if (image->bootcat->node != NULL) { if (image->bootcat->node != NULL) {
ret = iso_msg_submit(image->id, ISO_EL_TORITO_WARN, ret = iso_msg_submit(image->id, ISO_EL_TORITO_WARN, 0,
"More than one catalog node has been found. " "More than one catalog node has been found. "
"We can continue, but that could lead to " "We can continue, but that could lead to "
"problems"); "problems");
@ -1955,7 +1959,7 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
if (fsdata->eltorito && data->block == fsdata->imgblock) { if (fsdata->eltorito && data->block == fsdata->imgblock) {
/* it is boot image node */ /* it is boot image node */
if (image->bootcat->image->image != NULL) { if (image->bootcat->image->image != NULL) {
ret = iso_msg_submit(image->id, ISO_EL_TORITO_WARN, ret = iso_msg_submit(image->id, ISO_EL_TORITO_WARN, 0,
"More than one image node has been found."); "More than one image node has been found.");
if (ret < 0) { if (ret < 0) {
free(name); free(name);

View File

@ -19,7 +19,7 @@ int iso_message_id = LIBISO_MSGS_ORIGIN_IMAGE_BASE;
/** /**
* Threshold for aborting. * Threshold for aborting.
*/ */
int abort_threshold = LIBISO_MSGS_SEV_ERROR; int abort_threshold = LIBISO_MSGS_SEV_HINT;
#define MAX_MSG_LEN 4096 #define MAX_MSG_LEN 4096
@ -60,7 +60,7 @@ const char *iso_error_to_msg(int errcode)
return "TODO"; return "TODO";
} }
int iso_msg_submit(int imgid, int errcode, const char *fmt, ...) int iso_msg_submit(int imgid, int errcode, int causedby, const char *fmt, ...)
{ {
char msg[MAX_MSG_LEN]; char msg[MAX_MSG_LEN];
va_list ap; va_list ap;
@ -80,7 +80,13 @@ int iso_msg_submit(int imgid, int errcode, const char *fmt, ...)
libiso_msgs_submit(libiso_msgr, imgid, errcode, ISO_ERR_SEV(errcode), libiso_msgs_submit(libiso_msgr, imgid, errcode, ISO_ERR_SEV(errcode),
ISO_ERR_PRIO(errcode), msg, 0, 0); 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) {
return ISO_CANCELED;
}
}
if (ISO_ERR_SEV(errcode) >= abort_threshold) { if (ISO_ERR_SEV(errcode) >= abort_threshold) {
return ISO_CANCELED; return ISO_CANCELED;
} else { } else {

View File

@ -32,11 +32,16 @@ void iso_msg_debug(int imgid, const char *fmt, ...);
const char *iso_error_to_msg(int errcode); const char *iso_error_to_msg(int errcode);
/** /**
* TODO add caused by!!
* *
* @param errcode
* The error code.
* @param causedby
* Error that was caused the errcode. If this error is a FATAL error,
* < 0 will be returned in any case. Use 0 if there is no previous
* cause for the error.
* @return * @return
* 1 on success, < 0 if function must abort asap. * 1 on success, < 0 if function must abort asap.
*/ */
int iso_msg_submit(int imgid, int errcode, const char *fmt, ...); int iso_msg_submit(int imgid, int errcode, int causedby, const char *fmt, ...);
#endif /*MESSAGES_H_*/ #endif /*MESSAGES_H_*/

View File

@ -104,7 +104,7 @@ int susp_iter_next(SuspIterator *iter, struct susp_sys_user_entry **sue)
if (entry->len_sue[0] == 0) { if (entry->len_sue[0] == 0) {
/* a wrong image with this lead us to a infinity loop */ /* a wrong image with this lead us to a infinity loop */
iso_msg_submit(iter->msgid, ISO_WRONG_RR, iso_msg_submit(iter->msgid, ISO_WRONG_RR, 0,
"Damaged RR/SUSP information."); "Damaged RR/SUSP information.");
return ISO_WRONG_RR; return ISO_WRONG_RR;
} }
@ -115,7 +115,7 @@ int susp_iter_next(SuspIterator *iter, struct susp_sys_user_entry **sue)
/* Continuation entry */ /* Continuation entry */
if (iter->ce_len) { if (iter->ce_len) {
int ret; int ret;
ret = iso_msg_submit(iter->msgid, ISO_UNSUPPORTED_SUSP, ret = iso_msg_submit(iter->msgid, ISO_UNSUPPORTED_SUSP, 0,
"More than one CE System user entry has found in a single " "More than one CE System user entry has found in a single "
"System Use field or continuation area. This breaks SUSP " "System Use field or continuation area. This breaks SUSP "
"standard and it's not supported. Ignoring last CE. Maybe " "standard and it's not supported. Ignoring last CE. Maybe "

View File

@ -522,7 +522,7 @@ int iso_add_dir_src_rec(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
if (ret <= 0) { if (ret <= 0) {
if (ret < 0) { if (ret < 0) {
/* error reading dir */ /* error reading dir */
ret = iso_msg_submit(image->id, ret, "Error reading dir"); ret = iso_msg_submit(image->id, ret, ret, "Error reading dir");
} }
break; break;
} }
@ -581,8 +581,8 @@ int iso_add_dir_src_rec(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
} }
ret = builder->create_node(builder, image, file, &new); ret = builder->create_node(builder, image, file, &new);
if (ret < 0) { if (ret < 0) {
ret = iso_msg_submit(image->id, ISO_FILE_CANT_ADD, ret = iso_msg_submit(image->id, ISO_FILE_CANT_ADD, ret,
"Error %d when adding file %s", ret, path); "Error when adding file %s", path);
goto dir_rec_continue; goto dir_rec_continue;
} else { } else {
iso_msg_debug(image->id, "Adding file %s", path); iso_msg_debug(image->id, "Adding file %s", path);