Replace message functions with new infraestructure that supports abort
on error.
This commit is contained in:
parent
1070fe4cc6
commit
6964f02308
@ -114,6 +114,9 @@ int iso_ring_buffer_new(size_t size, IsoRingBuffer **rbuf)
|
||||
|
||||
void iso_ring_buffer_free(IsoRingBuffer *buf)
|
||||
{
|
||||
if (buf == NULL) {
|
||||
return;
|
||||
}
|
||||
free(buf->buf);
|
||||
pthread_mutex_destroy(&buf->mutex);
|
||||
pthread_cond_destroy(&buf->empty);
|
||||
|
@ -791,8 +791,8 @@ void *write_function(void *arg)
|
||||
pthread_exit(NULL);
|
||||
|
||||
write_error: ;
|
||||
iso_msg_fatal(target->image->id, LIBISO_WRITE_ERROR,
|
||||
"Image write error, code %d", res);
|
||||
iso_msg_submit(target->image->id, ISO_WRITE_ERROR,
|
||||
"Image write error: %s", iso_error_to_msg(res));
|
||||
iso_ring_buffer_writer_close(target->buffer, 1);
|
||||
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),
|
||||
write_function, (void *) target);
|
||||
if (ret != 0) {
|
||||
iso_msg_fatal(target->image->id, LIBISO_THREAD_ERROR,
|
||||
iso_msg_submit(target->image->id, ISO_THREAD_ERROR,
|
||||
"Cannot create writer thread");
|
||||
ret = ISO_THREAD_ERROR;
|
||||
goto target_cleanup;
|
||||
@ -1069,7 +1069,7 @@ static int bs_read(struct burn_source *bs, unsigned char *buf, int size)
|
||||
return size;
|
||||
} else if (ret < 0) {
|
||||
/* error */
|
||||
iso_msg_fatal(t->image->id, LIBISO_READ_ERROR, "Error reading buffer");
|
||||
iso_msg_submit(t->image->id, ISO_BUF_READ_ERROR, NULL);
|
||||
return -1;
|
||||
} else {
|
||||
/* EOF */
|
||||
|
@ -35,7 +35,7 @@ int get_iso_name(Ecma119Image *img, IsoNode *iso, char **name)
|
||||
|
||||
ret = str2ascii(img->input_charset, iso->name, &ascii_name);
|
||||
if (ret < 0) {
|
||||
iso_msg_debug(img->image->id, "Can't convert %s", iso->name);
|
||||
iso_msg_submit(img->image->id, ret, "Can't convert %s", iso->name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -163,10 +163,9 @@ int create_file(Ecma119Image *img, IsoFile *iso, Ecma119Node **node)
|
||||
|
||||
size = iso_stream_get_size(iso->stream);
|
||||
if (size > (off_t)0xffffffff) {
|
||||
iso_msg_note(img->image->id, LIBISO_FILE_IGNORED,
|
||||
"File \"%s\" can't be added to image because is "
|
||||
"greater than 4GB", iso->node.name);
|
||||
return 0;
|
||||
return iso_msg_submit(img->image->id, ISO_FILE_TOO_BIG,
|
||||
"File \"%s\" can't be added to image because "
|
||||
"is greater than 4GB", iso->node.name);
|
||||
}
|
||||
|
||||
ret = iso_file_src_create(img, iso, &src);
|
||||
@ -298,17 +297,15 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
|
||||
max_path = pathlen + 1 + (iso_name ? strlen(iso_name) : 0);
|
||||
if (!image->rockridge) {
|
||||
if ((iso->type == LIBISO_DIR && depth > 8) && !image->allow_deep_paths) {
|
||||
iso_msg_note(image->image->id, LIBISO_FILE_IGNORED,
|
||||
free(iso_name);
|
||||
return iso_msg_submit(image->image->id, ISO_FILE_IMGPATH_WRONG,
|
||||
"File \"%s\" can't be added, because directory depth "
|
||||
"is greater than 8.", iso->name);
|
||||
free(iso_name);
|
||||
return 0;
|
||||
} else if (max_path > 255 && !image->allow_longer_paths) {
|
||||
iso_msg_note(image->image->id, LIBISO_FILE_IGNORED,
|
||||
free(iso_name);
|
||||
return iso_msg_submit(image->image->id, ISO_FILE_IMGPATH_WRONG,
|
||||
"File \"%s\" can't be added, because path length "
|
||||
"is greater than 255 characters", iso->name);
|
||||
free(iso_name);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
@ -321,10 +318,9 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
|
||||
ret = create_symlink(image, (IsoSymlink*)iso, &node);
|
||||
} else {
|
||||
/* symlinks are only supported when RR is enabled */
|
||||
iso_msg_note(image->image->id, LIBISO_FILE_IGNORED,
|
||||
ret = iso_msg_submit(image->image->id, ISO_FILE_IGNORED,
|
||||
"File \"%s\" ignored. Symlinks need RockRidge extensions.",
|
||||
iso->name);
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
case LIBISO_SPECIAL:
|
||||
@ -332,10 +328,9 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
|
||||
ret = create_special(image, (IsoSpecial*)iso, &node);
|
||||
} else {
|
||||
/* symlinks are only supported when RR is enabled */
|
||||
iso_msg_note(image->image->id, LIBISO_FILE_IGNORED,
|
||||
ret = iso_msg_submit(image->image->id, ISO_FILE_IGNORED,
|
||||
"File \"%s\" ignored. Special files need RockRidge extensions.",
|
||||
iso->name);
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
case LIBISO_BOOT:
|
||||
@ -343,10 +338,9 @@ int create_tree(Ecma119Image *image, IsoNode *iso, Ecma119Node **tree,
|
||||
ret = create_boot_cat(image, (IsoBoot*)iso, &node);
|
||||
} else {
|
||||
/* log and ignore */
|
||||
iso_msg_note(image->image->id, LIBISO_FILE_IGNORED,
|
||||
ret = iso_msg_submit(image->image->id, ISO_FILE_IGNORED,
|
||||
"El-Torito catalog found on a image without El-Torito.",
|
||||
iso->name);
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
case LIBISO_DIR:
|
||||
@ -571,8 +565,7 @@ int mangle_single_dir(Ecma119Image *img, Ecma119Node *dir, int max_file_len,
|
||||
ret = ISO_OUT_OF_MEM;
|
||||
goto mangle_cleanup;
|
||||
}
|
||||
iso_msg_debug(img->image->id,
|
||||
"\"%s\" renamed to \"%s\"",
|
||||
iso_msg_debug(img->image->id, "\"%s\" renamed to \"%s\"",
|
||||
children[k]->iso_name, new);
|
||||
|
||||
iso_htable_remove_ptr(table, children[k]->iso_name, NULL);
|
||||
|
@ -208,7 +208,7 @@ int create_image(IsoImage *image, const char *image_path,
|
||||
boot_media_type = 3; /* 2.88 meg diskette */
|
||||
break;
|
||||
default:
|
||||
iso_msg_sorry(image->id, LIBISO_EL_TORITO_WRONG_IMG,
|
||||
iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID,
|
||||
"Invalid image size %d Kb. Must be one of 1.2, 1.44"
|
||||
"or 2.88 Mb", iso_stream_get_size(stream) / 1024);
|
||||
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 */
|
||||
ret = iso_stream_open(stream);
|
||||
if (ret < 0) {
|
||||
iso_msg_sorry(image->id, LIBISO_EL_TORITO_WRONG_IMG,
|
||||
iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID,
|
||||
"Can't open image file.");
|
||||
return ret;
|
||||
}
|
||||
ret = iso_stream_read(stream, &mbr, sizeof(mbr));
|
||||
iso_stream_close(stream);
|
||||
if (ret != sizeof(mbr)) {
|
||||
iso_msg_sorry(image->id, LIBISO_EL_TORITO_WRONG_IMG,
|
||||
iso_msg_submit(image->id, LIBISO_EL_TORITO_WRONG_IMG,
|
||||
"Can't read MBR from image file.");
|
||||
return ret < 0 ? ret : ISO_FILE_READ_ERROR;
|
||||
}
|
||||
|
||||
/* check valid MBR signature */
|
||||
if ( mbr.sign1 != 0x55 || mbr.sign2 != 0xAA ) {
|
||||
iso_msg_sorry(image->id, LIBISO_EL_TORITO_WRONG_IMG,
|
||||
iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID,
|
||||
"Invalid MBR. Wrong signature.");
|
||||
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) {
|
||||
/* it's an used partition */
|
||||
if (used_partition != -1) {
|
||||
iso_msg_sorry(image->id, LIBISO_EL_TORITO_WRONG_IMG,
|
||||
iso_msg_submit(image->id, ISO_BOOT_IMAGE_NOT_VALID,
|
||||
"Invalid MBR. At least 2 partitions: %d and "
|
||||
"%d, are being used\n", used_partition, i);
|
||||
return ISO_BOOT_IMAGE_NOT_VALID;
|
||||
@ -760,18 +760,20 @@ int eltorito_writer_write_vol_desc(IsoImageWriter *writer)
|
||||
|
||||
/**
|
||||
* Patch an isolinux boot image.
|
||||
*
|
||||
* @return
|
||||
* 1 on success, 0 error (but continue), < 0 error
|
||||
*/
|
||||
static
|
||||
void patch_boot_image(uint8_t *buf, Ecma119Image *t, size_t imgsize)
|
||||
int patch_boot_image(uint8_t *buf, Ecma119Image *t, size_t imgsize)
|
||||
{
|
||||
struct boot_info_table *info;
|
||||
uint32_t checksum;
|
||||
size_t offset;
|
||||
|
||||
if (imgsize < 64) {
|
||||
iso_msg_warn(t->image->id, LIBISO_ISOLINUX_CANT_PATCH,
|
||||
return iso_msg_submit(t->image->id, ISO_ISOLINUX_CANT_PATCH,
|
||||
"Isolinux image too small. We won't patch it.");
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&info, 0, sizeof(info));
|
||||
@ -787,7 +789,7 @@ void patch_boot_image(uint8_t *buf, Ecma119Image *t, size_t imgsize)
|
||||
}
|
||||
if (offset != imgsize) {
|
||||
/* file length not multiple of 4 */
|
||||
iso_msg_warn(t->image->id, LIBISO_ISOLINUX_CANT_PATCH,
|
||||
return iso_msg_submit(t->image->id, LIBISO_ISOLINUX_CANT_PATCH,
|
||||
"Unexpected isolinux image length. Patch might not work.");
|
||||
}
|
||||
|
||||
@ -798,6 +800,7 @@ void patch_boot_image(uint8_t *buf, Ecma119Image *t, size_t imgsize)
|
||||
iso_lsb(info->bi_file, t->bootimg->block, 4);
|
||||
iso_lsb(info->bi_length, imgsize, 4);
|
||||
iso_lsb(info->bi_csum, checksum, 4);
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
static
|
||||
@ -838,7 +841,10 @@ int eltorito_writer_write_data(IsoImageWriter *writer)
|
||||
}
|
||||
|
||||
/* ok, patch the read buffer */
|
||||
patch_boot_image(buf, t, size);
|
||||
ret = patch_boot_image(buf, t, size);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* replace the original stream with a memory stream that reads from
|
||||
* the patched buffer */
|
||||
|
55
src/error.h
55
src/error.h
@ -76,11 +76,17 @@
|
||||
#define ISO_INTERRUPTED 0xF030FFF9
|
||||
|
||||
/** Invalid parameter value (ERROR,HIGH, -8) */
|
||||
#define ISO_WRONG_ARG_VALUE 0xF030FFF8
|
||||
#define ISO_WRONG_ARG_VALUE 0xEA30FFF8
|
||||
|
||||
/** Can't create a needed thread (FATAL,HIGH, -9) */
|
||||
#define ISO_THREAD_ERROR 0xF030FFF7
|
||||
|
||||
/** Write error (ERROR,HIGH, -10) */
|
||||
#define ISO_WRITE_ERROR 0xEA30FFF6
|
||||
|
||||
/** Buffer read error (ERROR,HIGH, -11) */
|
||||
#define ISO_BUF_READ_ERROR 0xEA30FFF5
|
||||
|
||||
/** Trying to add to a dir a node already added to a dir (ERROR,HIGH, -64) */
|
||||
#define ISO_NODE_ALREADY_ADDED 0xEA30FFC0
|
||||
|
||||
@ -135,8 +141,26 @@
|
||||
/** Can't seek to specified location (ERROR,HIGH, -138) */
|
||||
#define ISO_FILE_SEEK_ERROR 0xEA30FF76
|
||||
|
||||
/* will be a NOTE message */
|
||||
/* #define ISO_FILE_TOO_BIG -139 */
|
||||
/** 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 0xC020FF74
|
||||
|
||||
/* File can't be added to the tree (WARNING,MEDIUM, -143) */
|
||||
#define ISO_FILE_CANT_ADD 0xD020FF73
|
||||
|
||||
/**
|
||||
* File path break specification constraints and will be ignored
|
||||
* (HINT,MEDIUM, -141)
|
||||
*/
|
||||
#define ISO_FILE_IMGPATH_WRONG 0xC020FF73
|
||||
|
||||
/** Charset conversion error (ERROR,HIGH, -256) */
|
||||
#define ISO_CHARSET_CONV_ERROR 0xEA30FF00
|
||||
@ -168,9 +192,30 @@
|
||||
#define ISO_UNSUPPORTED_ECMA119 0xEA30FEBC
|
||||
|
||||
/** Wrong or damaged El-Torito catalog (SORRY,HIGH, -325) */
|
||||
#define ISO_WRONG_EL_TORITO 0xEA30FEBB
|
||||
#define ISO_WRONG_EL_TORITO 0xE030FEBB
|
||||
|
||||
/** Unsupported El-Torito feature (SORRY,HIGH, -326) */
|
||||
#define ISO_UNSUPPORTED_EL_TORITO 0xEA30FEBA
|
||||
#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_ERROR_H_*/
|
||||
|
@ -272,9 +272,12 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
|
||||
* 0's to image
|
||||
*/
|
||||
char *name = iso_stream_get_name(file->stream);
|
||||
iso_msg_sorry(t->image->id, LIBISO_FILE_CANT_WRITE, "File \"%s\" "
|
||||
"can't be opened (error %d). Filling with 0s.", name, res);
|
||||
res = iso_msg_submit(t->image->id, res, "File \"%s\" can't be "
|
||||
"opened (error %d). Filling with 0s.", name, res);
|
||||
free(name);
|
||||
if (res < 0) {
|
||||
return res; /* aborted due to error severity */
|
||||
}
|
||||
memset(buffer, 0, BLOCK_SIZE);
|
||||
for (b = 0; b < nblocks; ++b) {
|
||||
res = iso_write(t, buffer, BLOCK_SIZE);
|
||||
@ -302,17 +305,21 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
|
||||
char *name = iso_stream_get_name(file->stream);
|
||||
if (res < 0) {
|
||||
/* error */
|
||||
iso_msg_sorry(t->image->id, LIBISO_FILE_CANT_WRITE,
|
||||
"Read error in file %s.", name);
|
||||
res = iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE,
|
||||
"Read error in file %s.", name);
|
||||
} else {
|
||||
/* eof */
|
||||
iso_msg_sorry(t->image->id, LIBISO_FILE_CANT_WRITE,
|
||||
res = iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE,
|
||||
"Premature end of file %s.", name);
|
||||
}
|
||||
free(name);
|
||||
|
||||
if (res < 0) {
|
||||
return res; /* aborted due error severity */
|
||||
}
|
||||
|
||||
/* fill with 0s */
|
||||
iso_msg_sorry(t->image->id, LIBISO_FILE_CANT_WRITE,
|
||||
iso_msg_submit(t->image->id, ISO_FILE_CANT_WRITE,
|
||||
"Filling with 0");
|
||||
memset(buffer, 0, BLOCK_SIZE);
|
||||
while (b++ < nblocks) {
|
||||
|
170
src/fs_image.c
170
src/fs_image.c
@ -713,9 +713,12 @@ char *get_name(_ImageFsData *fsdata, const char *str, size_t len)
|
||||
if (ret == 1) {
|
||||
return name;
|
||||
} else {
|
||||
iso_msg_sorry(fsdata->msgid, LIBISO_CHARSET_ERROR,
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_FILENAME_WRONG_CHARSET,
|
||||
"Charset conversion error. Can't convert %s from %s to %s",
|
||||
str, fsdata->input_charset, fsdata->local_charset);
|
||||
if (ret < 0) {
|
||||
return NULL; /* aborted */
|
||||
}
|
||||
/* fallback */
|
||||
}
|
||||
}
|
||||
@ -773,7 +776,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
|
||||
|
||||
/* check for unsupported multiextend */
|
||||
if (record->flags[0] & 0x80) {
|
||||
iso_msg_fatal(fsdata->msgid, LIBISO_IMG_UNSUPPORTED,
|
||||
iso_msg_submit(fsdata->msgid, ISO_UNSUPPORTED_ECMA119,
|
||||
"Unsupported image. This image makes use of Multi-Extend"
|
||||
" features, that are not supported at this time. If you "
|
||||
"need support for that, please request us this feature.");
|
||||
@ -782,7 +785,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
|
||||
|
||||
/* check for unsupported interleaved mode */
|
||||
if (record->file_unit_size[0] || record->interleave_gap_size[0]) {
|
||||
iso_msg_fatal(fsdata->msgid, LIBISO_IMG_UNSUPPORTED,
|
||||
iso_msg_submit(fsdata->msgid, ISO_UNSUPPORTED_ECMA119,
|
||||
"Unsupported image. This image has at least one file recorded "
|
||||
"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 :) "
|
||||
@ -795,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 (record->len_xa[0]) {
|
||||
iso_msg_fatal(fsdata->msgid, LIBISO_IMG_UNSUPPORTED,
|
||||
iso_msg_submit(fsdata->msgid, ISO_UNSUPPORTED_ECMA119,
|
||||
"Unsupported image. This image has at least one file with "
|
||||
"Extended Attributes, that are not supported");
|
||||
return ISO_UNSUPPORTED_ECMA119;
|
||||
@ -831,20 +834,20 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
|
||||
ret = read_rr_PX(sue, &atts);
|
||||
if (ret < 0) {
|
||||
/* notify and continue */
|
||||
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
|
||||
"Invalid PX entry");
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN,
|
||||
"Invalid PX entry");
|
||||
}
|
||||
} else if (SUSP_SIG(sue, 'T', 'F')) {
|
||||
ret = read_rr_TF(sue, &atts);
|
||||
if (ret < 0) {
|
||||
/* notify and continue */
|
||||
iso_msg_warn(fsdata->msgid, LIBISO_RR_WARNING,
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN,
|
||||
"Invalid TF entry");
|
||||
}
|
||||
} else if (SUSP_SIG(sue, 'N', 'M')) {
|
||||
if (name != NULL && namecont == 0) {
|
||||
/* ups, RR standard violation */
|
||||
iso_msg_warn(fsdata->msgid, LIBISO_RR_WARNING,
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN,
|
||||
"New NM entry found without previous"
|
||||
"CONTINUE flag. Ignored");
|
||||
continue;
|
||||
@ -852,13 +855,13 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
|
||||
ret = read_rr_NM(sue, &name, &namecont);
|
||||
if (ret < 0) {
|
||||
/* notify and continue */
|
||||
iso_msg_warn(fsdata->msgid, LIBISO_RR_WARNING,
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN,
|
||||
"Invalid NM entry");
|
||||
}
|
||||
} else if (SUSP_SIG(sue, 'S', 'L')) {
|
||||
if (linkdest != NULL && linkdestcont == 0) {
|
||||
/* ups, RR standard violation */
|
||||
iso_msg_warn(fsdata->msgid, LIBISO_RR_WARNING,
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN,
|
||||
"New SL entry found without previous"
|
||||
"CONTINUE flag. Ignored");
|
||||
continue;
|
||||
@ -866,7 +869,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
|
||||
ret = read_rr_SL(sue, &linkdest, &linkdestcont);
|
||||
if (ret < 0) {
|
||||
/* notify and continue */
|
||||
iso_msg_warn(fsdata->msgid, LIBISO_RR_WARNING,
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN,
|
||||
"Invalid SL entry");
|
||||
}
|
||||
} else if (SUSP_SIG(sue, 'R', 'E')) {
|
||||
@ -887,22 +890,20 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
|
||||
*/
|
||||
relocated_dir = iso_read_bb(sue->data.CL.child_loc, 4, NULL);
|
||||
if (relocated_dir == 0) {
|
||||
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR,
|
||||
"Invalid SL entry, no child location");
|
||||
ret = ISO_WRONG_RR;
|
||||
break;
|
||||
}
|
||||
} else if (SUSP_SIG(sue, 'P', 'N')) {
|
||||
ret = read_rr_PN(sue, &atts);
|
||||
if (ret < 0) {
|
||||
/* notify and continue */
|
||||
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR_WARN,
|
||||
"Invalid PN entry");
|
||||
}
|
||||
} else if (SUSP_SIG(sue, 'S', 'F')) {
|
||||
iso_msg_sorry(fsdata->msgid, LIBISO_RR_UNSUPPORTED,
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_UNSUPPORTED_RR,
|
||||
"Sparse files not supported.");
|
||||
ret = ISO_UNSUPPORTED_RR;
|
||||
break;
|
||||
} else if (SUSP_SIG(sue, 'R', 'R')) {
|
||||
/* TODO I've seen this RR on mkisofs images. what's this? */
|
||||
@ -914,7 +915,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
|
||||
*/
|
||||
if (parent != NULL) {
|
||||
/* notify and continue */
|
||||
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR,
|
||||
"SP entry found in a directory entry other "
|
||||
"than '.' entry of root node");
|
||||
}
|
||||
@ -926,13 +927,13 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
|
||||
*/
|
||||
if (parent != NULL) {
|
||||
/* notify and continue */
|
||||
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR,
|
||||
"ER entry found in a directory entry other "
|
||||
"than '.' entry of root node");
|
||||
}
|
||||
continue;
|
||||
} else {
|
||||
iso_msg_hint(fsdata->msgid, LIBISO_SUSP_UNHANLED,
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_SUSP_UNHANDLED,
|
||||
"Unhandled SUSP entry %c%c.", sue->sig[0], sue->sig[1]);
|
||||
}
|
||||
}
|
||||
@ -942,23 +943,20 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
|
||||
/* check for RR problems */
|
||||
|
||||
if (ret < 0) {
|
||||
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
|
||||
"Error parsing RR entries");
|
||||
/* error was already submitted above */
|
||||
iso_msg_debug(fsdata->msgid, "Error parsing RR entries");
|
||||
} else if (!relocated_dir && atts.st_mode == (mode_t) 0 ) {
|
||||
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR, "Mandatory Rock "
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR, "Mandatory Rock "
|
||||
"Ridge PX entry is not present or it contains invalid values.");
|
||||
ret = ISO_WRONG_RR;
|
||||
} else {
|
||||
/* ensure both name and link dest are finished */
|
||||
if (namecont != 0) {
|
||||
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR,
|
||||
"Incomplete RR name, last NM entry continues");
|
||||
ret = ISO_WRONG_RR;
|
||||
}
|
||||
if (linkdestcont != 0) {
|
||||
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR,
|
||||
"Incomplete link destination, last SL entry continues");
|
||||
ret = ISO_WRONG_RR;
|
||||
}
|
||||
}
|
||||
|
||||
@ -974,10 +972,15 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
|
||||
ret = strconv(name, fsdata->input_charset, fsdata->local_charset,
|
||||
&newname);
|
||||
if (ret < 0) {
|
||||
iso_msg_sorry(fsdata->msgid, LIBISO_CHARSET_ERROR,
|
||||
/* its just a hint message */
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_FILENAME_WRONG_CHARSET,
|
||||
"Charset conversion error. Can't convert %s from %s to %s",
|
||||
name, fsdata->input_charset, fsdata->local_charset);
|
||||
free(newname);
|
||||
if (ret < 0) {
|
||||
free(name);
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
free(name);
|
||||
name = newname;
|
||||
@ -991,10 +994,14 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
|
||||
ret = strconv(linkdest, fsdata->input_charset,
|
||||
fsdata->local_charset, &newlinkdest);
|
||||
if (ret < 0) {
|
||||
iso_msg_sorry(fsdata->msgid, LIBISO_CHARSET_ERROR,
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_FILENAME_WRONG_CHARSET,
|
||||
"Charset conversion error. Can't convert %s from %s to %s",
|
||||
linkdest, fsdata->input_charset, fsdata->local_charset);
|
||||
free(newlinkdest);
|
||||
if (ret < 0) {
|
||||
free(name);
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
free(linkdest);
|
||||
linkdest = newlinkdest;
|
||||
@ -1022,17 +1029,15 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
|
||||
if (record->len_fi[0] == 1 && record->file_id[0] == 0) {
|
||||
/* "." entry, we can call this for root node, so... */
|
||||
if (!(atts.st_mode & S_IFDIR)) {
|
||||
iso_msg_sorry(fsdata->msgid, LIBISO_WRONG_IMG,
|
||||
return iso_msg_submit(fsdata->msgid, ISO_WRONG_ECMA119,
|
||||
"Wrong ISO file name. \".\" not dir");
|
||||
return ISO_WRONG_ECMA119;
|
||||
}
|
||||
} else {
|
||||
|
||||
name = get_name(fsdata, (char*)record->file_id, record->len_fi[0]);
|
||||
if (name == NULL) {
|
||||
iso_msg_sorry(fsdata->msgid, LIBISO_WRONG_IMG,
|
||||
return iso_msg_submit(fsdata->msgid, ISO_WRONG_ECMA119,
|
||||
"Can't retrieve file name");
|
||||
return ISO_WRONG_ECMA119;
|
||||
}
|
||||
|
||||
/* remove trailing version number */
|
||||
@ -1114,10 +1119,10 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
|
||||
|
||||
/* TODO #00014 : more sanity checks to ensure dir record info is valid */
|
||||
if (S_ISLNK(atts.st_mode) && (linkdest == NULL)) {
|
||||
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
|
||||
"Link without destination.");
|
||||
ret = iso_msg_submit(fsdata->msgid, ISO_WRONG_RR,
|
||||
"Link without destination.");
|
||||
free(name);
|
||||
return ISO_WRONG_RR;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* ok, we can now create the file source */
|
||||
@ -1388,6 +1393,9 @@ void ifs_fs_free(IsoFilesystem *fs)
|
||||
/**
|
||||
* Read the SUSP system user entries of the "." entry of the root directory,
|
||||
* indentifying when Rock Ridge extensions are being used.
|
||||
*
|
||||
* @return
|
||||
* 1 success, 0 ignored, < 0 error
|
||||
*/
|
||||
static
|
||||
int read_root_susp_entries(_ImageFsData *data, uint32_t block)
|
||||
@ -1434,10 +1442,10 @@ int read_root_susp_entries(_ImageFsData *data, uint32_t block)
|
||||
if (sue->version[0] != 1 || sue->data.SP.be[0] != 0xBE
|
||||
|| sue->data.SP.ef[0] != 0xEF) {
|
||||
|
||||
iso_msg_sorry(data->msgid, LIBISO_SUSP_WRONG, "SUSP SP system use "
|
||||
"entry seems to be wrong. Ignoring Rock Ridge Extensions.");
|
||||
susp_iter_free(iter);
|
||||
return ISO_SUCCESS;
|
||||
return iso_msg_submit(data->msgid, ISO_UNSUPPORTED_SUSP,
|
||||
"SUSP SP system use entry seems to be wrong. "
|
||||
"Ignoring Rock Ridge Extensions.");
|
||||
}
|
||||
|
||||
iso_msg_debug(data->msgid, "SUSP/RR is being used.");
|
||||
@ -1471,10 +1479,13 @@ int read_root_susp_entries(_ImageFsData *data, uint32_t block)
|
||||
if (SUSP_SIG(sue, 'E', 'R')) {
|
||||
|
||||
if (data->rr_version) {
|
||||
iso_msg_warn(data->msgid, LIBISO_SUSP_MULTIPLE_ER,
|
||||
ret = iso_msg_submit(data->msgid, ISO_SUSP_MULTIPLE_ER,
|
||||
"More than one ER has found. This is not supported. "
|
||||
"It will be ignored, but can cause problems. "
|
||||
"Please notify us about this.");
|
||||
if (ret < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1497,10 +1508,13 @@ int read_root_susp_entries(_ImageFsData *data, uint32_t block)
|
||||
"Suitable Rock Ridge ER found. Version 1.12.");
|
||||
data->rr_version = RR_EXT_112;
|
||||
} else {
|
||||
iso_msg_warn(data->msgid, LIBISO_SUSP_MULTIPLE_ER,
|
||||
ret = iso_msg_submit(data->msgid, ISO_SUSP_MULTIPLE_ER,
|
||||
"Not Rock Ridge ER found.\n"
|
||||
"That will be ignored, but can cause problems in "
|
||||
"image reading. Please notify us about this");
|
||||
if (ret < 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1567,6 +1581,10 @@ int read_pvm(_ImageFsData *data, uint32_t block)
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* 1 success, 0 ignored, < 0 error
|
||||
*/
|
||||
static
|
||||
int read_el_torito_boot_catalog(_ImageFsData *data, uint32_t block)
|
||||
{
|
||||
@ -1586,18 +1604,16 @@ int read_el_torito_boot_catalog(_ImageFsData *data, uint32_t block)
|
||||
if ( (ve->header_id[0] != 1) || (ve->key_byte1[0] != 0x55)
|
||||
|| (ve->key_byte2[0] != 0xAA) ) {
|
||||
|
||||
iso_msg_sorry(data->msgid, LIBISO_EL_TORITO_WRONG,
|
||||
return iso_msg_submit(data->msgid, ISO_WRONG_EL_TORITO,
|
||||
"Wrong or damaged El-Torito Catalog. El-Torito info "
|
||||
"will be ignored.");
|
||||
return ISO_WRONG_EL_TORITO;
|
||||
}
|
||||
|
||||
/* check for a valid platform */
|
||||
if (ve->platform_id[0] != 0) {
|
||||
iso_msg_hint(data->msgid, LIBISO_EL_TORITO_UNHANLED,
|
||||
return iso_msg_submit(data->msgid, ISO_UNSUPPORTED_EL_TORITO,
|
||||
"Unsupported El-Torito platform. Only 80x86 is "
|
||||
"supported. El-Torito info will be ignored.");
|
||||
return ISO_UNSUPPORTED_EL_TORITO;
|
||||
}
|
||||
|
||||
/* ok, once we are here we assume it is a valid catalog */
|
||||
@ -1705,14 +1721,20 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
|
||||
|| strncmp((char*)vol->boot_sys_id,
|
||||
"EL TORITO SPECIFICATION", 23)) {
|
||||
|
||||
iso_msg_hint(data->msgid, LIBISO_BOOT_VD_UNHANLED,
|
||||
ret = iso_msg_submit(data->msgid, ISO_UNSUPPORTED_EL_TORITO,
|
||||
"Unsupported Boot Vol. Desc. Only El-Torito "
|
||||
"Specification, Version 1.0 Volume "
|
||||
"Descriptors are supported. Ignoring boot info");
|
||||
break;
|
||||
if (ret < 0) {
|
||||
goto fs_cleanup;
|
||||
}
|
||||
break;
|
||||
}
|
||||
data->catblock = iso_read_lsb(vol->boot_catalog, 4);
|
||||
read_el_torito_boot_catalog(data, data->catblock);
|
||||
ret = read_el_torito_boot_catalog(data, data->catblock);
|
||||
if (ret < 0) {
|
||||
goto fs_cleanup;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
@ -1746,8 +1768,11 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
|
||||
data->evd_root_block = iso_read_bb(root->block, 4, NULL);
|
||||
/* TODO #00021 : handle RR info in ISO 9660:1999 tree */
|
||||
} else {
|
||||
iso_msg_hint(data->msgid, LIBISO_UNSUPPORTED_VD,
|
||||
ret = iso_msg_submit(data->msgid, ISO_UNSUPPORTED_VD,
|
||||
"Unsupported Sup. Vol. Desc found.");
|
||||
if (ret < 0) {
|
||||
goto fs_cleanup;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -1758,8 +1783,11 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
|
||||
*/
|
||||
break;
|
||||
default:
|
||||
iso_msg_hint(data->msgid, LIBISO_UNSUPPORTED_VD,
|
||||
ret = iso_msg_submit(data->msgid, ISO_UNSUPPORTED_VD,
|
||||
"Ignoring Volume descriptor %x.", buffer[0]);
|
||||
if (ret < 0) {
|
||||
goto fs_cleanup;
|
||||
}
|
||||
break;
|
||||
}
|
||||
block++;
|
||||
@ -1768,7 +1796,7 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
|
||||
/* 4. check if RR extensions are being used */
|
||||
ret = read_root_susp_entries(data, data->pvd_root_block);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
goto fs_cleanup;
|
||||
}
|
||||
|
||||
/* user doesn't want to read RR extensions */
|
||||
@ -1838,7 +1866,7 @@ static
|
||||
int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
|
||||
IsoFileSource *src, IsoNode **node)
|
||||
{
|
||||
int result;
|
||||
int ret;
|
||||
struct stat info;
|
||||
IsoNode *new;
|
||||
char *name;
|
||||
@ -1853,9 +1881,9 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
|
||||
name = iso_file_source_get_name(src);
|
||||
|
||||
/* get info about source */
|
||||
result = iso_file_source_lstat(src, &info);
|
||||
if (result < 0) {
|
||||
return result;
|
||||
ret = iso_file_source_lstat(src, &info);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
new = NULL;
|
||||
@ -1868,10 +1896,13 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
|
||||
if (fsdata->eltorito && data->block == fsdata->catblock) {
|
||||
|
||||
if (image->bootcat->node != NULL) {
|
||||
iso_msg_hint(image->id, LIBISO_EL_TORITO_UNHANLED,
|
||||
ret = iso_msg_submit(image->id, ISO_EL_TORITO_WARN,
|
||||
"More than one catalog node has been found. "
|
||||
"We will continue, but that could lead to "
|
||||
"We can continue, but that could lead to "
|
||||
"problems");
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
iso_node_unref((IsoNode*)image->bootcat->node);
|
||||
}
|
||||
|
||||
@ -1879,9 +1910,9 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
|
||||
* a regular file */
|
||||
new = calloc(1, sizeof(IsoBoot));
|
||||
if (new == NULL) {
|
||||
result = ISO_OUT_OF_MEM;
|
||||
ret = ISO_OUT_OF_MEM;
|
||||
free(name);
|
||||
return result;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* and set the image node */
|
||||
@ -1892,10 +1923,10 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
|
||||
IsoStream *stream;
|
||||
IsoFile *file;
|
||||
|
||||
result = iso_file_source_stream_new(src, &stream);
|
||||
if (result < 0) {
|
||||
ret = iso_file_source_stream_new(src, &stream);
|
||||
if (ret < 0) {
|
||||
free(name);
|
||||
return result;
|
||||
return ret;
|
||||
}
|
||||
/* take a ref to the src, as stream has taken our ref */
|
||||
iso_file_source_ref(src);
|
||||
@ -1924,8 +1955,13 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
|
||||
if (fsdata->eltorito && data->block == fsdata->imgblock) {
|
||||
/* it is boot image node */
|
||||
if (image->bootcat->image->image != NULL) {
|
||||
iso_msg_hint(image->id, LIBISO_EL_TORITO_UNHANLED,
|
||||
"More than one image node has been found. ");
|
||||
ret = iso_msg_submit(image->id, ISO_EL_TORITO_WARN,
|
||||
"More than one image node has been found.");
|
||||
if (ret < 0) {
|
||||
free(name);
|
||||
iso_stream_unref(stream);
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
/* and set the image node */
|
||||
image->bootcat->image->image = file;
|
||||
@ -1953,10 +1989,10 @@ int image_builder_create_node(IsoNodeBuilder *builder, IsoImage *image,
|
||||
char dest[PATH_MAX];
|
||||
IsoSymlink *link;
|
||||
|
||||
result = iso_file_source_readlink(src, dest, PATH_MAX);
|
||||
if (result < 0) {
|
||||
ret = iso_file_source_readlink(src, dest, PATH_MAX);
|
||||
if (ret < 0) {
|
||||
free(name);
|
||||
return result;
|
||||
return ret;
|
||||
}
|
||||
link = malloc(sizeof(IsoSymlink));
|
||||
if (link == NULL) {
|
||||
|
@ -18,14 +18,19 @@
|
||||
#include <string.h>
|
||||
|
||||
static
|
||||
char *get_iso1999_name(Ecma119Image *t, const char *str)
|
||||
int get_iso1999_name(Ecma119Image *t, const char *str, char **fname)
|
||||
{
|
||||
int ret;
|
||||
char *name;
|
||||
|
||||
if (fname == NULL) {
|
||||
return ISO_ASSERT_FAILURE;
|
||||
}
|
||||
|
||||
if (str == NULL) {
|
||||
/* not an error, can be root node */
|
||||
return NULL;
|
||||
*fname = NULL;
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
if (!strcmp(t->input_charset, t->output_charset)) {
|
||||
@ -34,9 +39,12 @@ char *get_iso1999_name(Ecma119Image *t, const char *str)
|
||||
} else {
|
||||
ret = strconv(str, t->input_charset, t->output_charset, &name);
|
||||
if (ret < 0) {
|
||||
iso_msg_sorry(t->image->id, LIBISO_CHARSET_ERROR,
|
||||
ret = iso_msg_submit(t->image->id, ISO_FILENAME_WRONG_CHARSET,
|
||||
"Charset conversion error. Can't convert %s from %s to %s",
|
||||
str, t->input_charset, t->output_charset);
|
||||
if (ret < 0) {
|
||||
return ret; /* aborted */
|
||||
}
|
||||
|
||||
/* use the original name, it's the best we can do */
|
||||
name = strdup(str);
|
||||
@ -48,7 +56,9 @@ char *get_iso1999_name(Ecma119Image *t, const char *str)
|
||||
name[207] = '\0';
|
||||
}
|
||||
|
||||
return name;
|
||||
*fname = name;
|
||||
|
||||
return ISO_SUCCESS;
|
||||
}
|
||||
|
||||
static
|
||||
@ -108,10 +118,10 @@ int create_node(Ecma119Image *t, IsoNode *iso, Iso1999Node **node)
|
||||
|
||||
size = iso_stream_get_size(file->stream);
|
||||
if (size > (off_t)0xffffffff) {
|
||||
iso_msg_note(t->image->id, LIBISO_FILE_IGNORED,
|
||||
free(n);
|
||||
return iso_msg_submit(t->image->id, ISO_FILE_TOO_BIG,
|
||||
"File \"%s\" can't be added to image because is "
|
||||
"greater than 4GB", iso->name);
|
||||
free(n);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -168,14 +178,17 @@ int create_tree(Ecma119Image *t, IsoNode *iso, Iso1999Node **tree, int pathlen)
|
||||
/* file will be ignored */
|
||||
return 0;
|
||||
}
|
||||
iso_name = get_iso1999_name(t, iso->name);
|
||||
ret = get_iso1999_name(t, iso->name, &iso_name);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
max_path = pathlen + 1 + (iso_name ? strlen(iso_name): 0);
|
||||
if (!t->allow_longer_paths && max_path > 255) {
|
||||
iso_msg_note(t->image->id, LIBISO_FILE_IGNORED,
|
||||
free(iso_name);
|
||||
return iso_msg_submit(t->image->id, ISO_FILE_IMGPATH_WRONG,
|
||||
"File \"%s\" can't be added to ISO 9660:1999 tree, "
|
||||
"because its path length is larger than 255", iso->name);
|
||||
free(iso_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (iso->type) {
|
||||
@ -216,19 +229,17 @@ int create_tree(Ecma119Image *t, IsoNode *iso, Iso1999Node **tree, int pathlen)
|
||||
ret = create_node(t, iso, &node);
|
||||
} else {
|
||||
/* log and ignore */
|
||||
iso_msg_note(t->image->id, LIBISO_FILE_IGNORED,
|
||||
ret = iso_msg_submit(t->image->id, ISO_FILE_IGNORED,
|
||||
"El-Torito catalog found on a image without El-Torito.",
|
||||
iso->name);
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
case LIBISO_SYMLINK:
|
||||
case LIBISO_SPECIAL:
|
||||
iso_msg_note(t->image->id, LIBISO_FILE_IGNORED,
|
||||
ret = iso_msg_submit(t->image->id, ISO_FILE_IGNORED,
|
||||
"Can't add %s to ISO 9660:1999 tree. This kind of files "
|
||||
"can only be added to a Rock Ridget tree. Skipping.",
|
||||
iso->name);
|
||||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
/* should never happen */
|
||||
@ -514,16 +525,16 @@ int iso1999_writer_write_vol_desc(IsoImageWriter *writer)
|
||||
|
||||
memset(&vol, 0, sizeof(struct ecma119_sup_vol_desc));
|
||||
|
||||
vol_id = get_iso1999_name(t, image->volume_id);
|
||||
get_iso1999_name(t, image->volume_id, &vol_id);
|
||||
str2a_char(t->input_charset, image->publisher_id, &pub_id);
|
||||
str2a_char(t->input_charset, image->data_preparer_id, &data_id);
|
||||
volset_id = get_iso1999_name(t, image->volset_id);
|
||||
get_iso1999_name(t, image->volset_id, &volset_id);
|
||||
|
||||
str2a_char(t->input_charset, image->system_id, &system_id);
|
||||
str2a_char(t->input_charset, image->application_id, &application_id);
|
||||
copyright_file_id = get_iso1999_name(t, image->copyright_file_id);
|
||||
abstract_file_id = get_iso1999_name(t, image->abstract_file_id);
|
||||
biblio_file_id = get_iso1999_name(t, image->biblio_file_id);
|
||||
get_iso1999_name(t, image->copyright_file_id, ©right_file_id);
|
||||
get_iso1999_name(t, image->abstract_file_id, &abstract_file_id);
|
||||
get_iso1999_name(t, image->biblio_file_id, &biblio_file_id);
|
||||
|
||||
vol.vol_desc_type[0] = 2;
|
||||
memcpy(vol.std_identifier, "CD001", 5);
|
||||
|
16
src/joliet.c
16
src/joliet.c
@ -112,11 +112,10 @@ int create_node(Ecma119Image *t, IsoNode *iso, JolietNode **node)
|
||||
|
||||
size = iso_stream_get_size(file->stream);
|
||||
if (size > (off_t)0xffffffff) {
|
||||
iso_msg_note(t->image->id, LIBISO_FILE_IGNORED,
|
||||
free(joliet);
|
||||
return iso_msg_submit(t->image->id, ISO_FILE_TOO_BIG,
|
||||
"File \"%s\" can't be added to image because is "
|
||||
"greater than 4GB", iso->name);
|
||||
free(joliet);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = iso_file_src_create(t, file, &src);
|
||||
@ -178,15 +177,14 @@ int create_tree(Ecma119Image *t, IsoNode *iso, JolietNode **tree, int pathlen)
|
||||
}
|
||||
max_path = pathlen + 1 + (jname ? ucslen(jname) * 2 : 0);
|
||||
if (!t->joliet_longer_paths && max_path > 240) {
|
||||
free(jname);
|
||||
/*
|
||||
* Wow!! Joliet is even more restrictive than plain ISO-9660,
|
||||
* that allows up to 255 bytes!!
|
||||
*/
|
||||
iso_msg_note(t->image->id, LIBISO_FILE_IGNORED,
|
||||
return iso_msg_submit(t->image->id, ISO_FILE_IMGPATH_WRONG,
|
||||
"File \"%s\" can't be added to Joliet tree, because "
|
||||
"its path length is larger than 240", iso->name);
|
||||
free(jname);
|
||||
return 0;
|
||||
}
|
||||
|
||||
switch (iso->type) {
|
||||
@ -227,18 +225,16 @@ int create_tree(Ecma119Image *t, IsoNode *iso, JolietNode **tree, int pathlen)
|
||||
ret = create_node(t, iso, &node);
|
||||
} else {
|
||||
/* log and ignore */
|
||||
iso_msg_note(t->image->id, LIBISO_FILE_IGNORED,
|
||||
ret = iso_msg_submit(t->image->id, ISO_FILE_IGNORED,
|
||||
"El-Torito catalog found on a image without El-Torito.",
|
||||
iso->name);
|
||||
ret = 0;
|
||||
}
|
||||
break;
|
||||
case LIBISO_SYMLINK:
|
||||
case LIBISO_SPECIAL:
|
||||
iso_msg_note(t->image->id, LIBISO_JOLIET_WRONG_FILE_TYPE,
|
||||
ret = iso_msg_submit(t->image->id, ISO_FILE_IGNORED,
|
||||
"Can't add %s to Joliet tree. This kind of files can only"
|
||||
" be added to a Rock Ridget tree. Skipping.", iso->name);
|
||||
ret = 0;
|
||||
break;
|
||||
default:
|
||||
/* should never happen */
|
||||
|
@ -16,6 +16,11 @@
|
||||
|
||||
int iso_message_id = LIBISO_MSGS_ORIGIN_IMAGE_BASE;
|
||||
|
||||
/**
|
||||
* Threshold for aborting.
|
||||
*/
|
||||
int abort_threshold = LIBISO_MSGS_SEV_ERROR;
|
||||
|
||||
#define MAX_MSG_LEN 4096
|
||||
|
||||
struct libiso_msgs *libiso_msgr = NULL;
|
||||
@ -49,69 +54,38 @@ void iso_msg_debug(int imgid, const char *fmt, ...)
|
||||
LIBISO_MSGS_PRIO_ZERO, msg, 0, 0);
|
||||
}
|
||||
|
||||
void iso_msg_note(int imgid, int error_code, const char *fmt, ...)
|
||||
const char *iso_error_to_msg(int errcode)
|
||||
{
|
||||
char msg[MAX_MSG_LEN];
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
libiso_msgs_submit(libiso_msgr, imgid, error_code, LIBISO_MSGS_SEV_NOTE,
|
||||
LIBISO_MSGS_PRIO_MEDIUM, msg, 0, 0);
|
||||
/* TODO not implemented yet!!! */
|
||||
return "TODO";
|
||||
}
|
||||
|
||||
void iso_msg_hint(int imgid, int error_code, const char *fmt, ...)
|
||||
int iso_msg_submit(int imgid, int errcode, const char *fmt, ...)
|
||||
{
|
||||
char msg[MAX_MSG_LEN];
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
||||
va_end(ap);
|
||||
/* when called with ISO_CANCELED, we don't need to submit any message */
|
||||
if (errcode == ISO_CANCELED && fmt == NULL) {
|
||||
return ISO_CANCELED;
|
||||
}
|
||||
|
||||
libiso_msgs_submit(libiso_msgr, imgid, error_code, LIBISO_MSGS_SEV_HINT,
|
||||
LIBISO_MSGS_PRIO_MEDIUM, msg, 0, 0);
|
||||
}
|
||||
if (fmt) {
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
||||
va_end(ap);
|
||||
} else {
|
||||
strncpy(msg, iso_error_to_msg(errcode), MAX_MSG_LEN);
|
||||
}
|
||||
|
||||
void iso_msg_warn(int imgid, int error_code, const char *fmt, ...)
|
||||
{
|
||||
char msg[MAX_MSG_LEN];
|
||||
va_list ap;
|
||||
libiso_msgs_submit(libiso_msgr, imgid, errcode, ISO_ERR_SEV(errcode),
|
||||
ISO_ERR_PRIO(errcode), msg, 0, 0);
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
libiso_msgs_submit(libiso_msgr, imgid, error_code, LIBISO_MSGS_SEV_WARNING,
|
||||
LIBISO_MSGS_PRIO_MEDIUM, msg, 0, 0);
|
||||
}
|
||||
|
||||
void iso_msg_sorry(int imgid, int error_code, const char *fmt, ...)
|
||||
{
|
||||
char msg[MAX_MSG_LEN];
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
libiso_msgs_submit(libiso_msgr, imgid, error_code, LIBISO_MSGS_SEV_SORRY,
|
||||
LIBISO_MSGS_PRIO_HIGH, msg, 0, 0);
|
||||
}
|
||||
|
||||
void iso_msg_fatal(int imgid, int error_code, const char *fmt, ...)
|
||||
{
|
||||
char msg[MAX_MSG_LEN];
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
libiso_msgs_submit(libiso_msgr, imgid, error_code, LIBISO_MSGS_SEV_FATAL,
|
||||
LIBISO_MSGS_PRIO_HIGH, msg, 0, 0);
|
||||
if (ISO_ERR_SEV(errcode) >= abort_threshold) {
|
||||
return ISO_CANCELED;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -83,18 +83,22 @@ extern int iso_message_id;
|
||||
/** Unsupported file type for Joliet tree */
|
||||
#define LIBISO_JOLIET_WRONG_FILE_TYPE 0x00030301
|
||||
|
||||
typedef struct libiso_msgs IsoMessenger;
|
||||
|
||||
/**
|
||||
* Submit a debug message.
|
||||
*/
|
||||
void iso_msg_debug(int imgid, const char *fmt, ...);
|
||||
|
||||
void iso_msg_note(int imgid, int error_code, const char *fmt, ...);
|
||||
/**
|
||||
* Get a textual description of an error.
|
||||
*/
|
||||
const char *iso_error_to_msg(int errcode);
|
||||
|
||||
void iso_msg_hint(int imgid, int error_code, const char *fmt, ...);
|
||||
|
||||
void iso_msg_warn(int imgid, int error_code, const char *fmt, ...);
|
||||
|
||||
void iso_msg_sorry(int imgid, int error_code, const char *fmt, ...);
|
||||
|
||||
void iso_msg_fatal(int imgid, int error_code, const char *fmt, ...);
|
||||
/**
|
||||
* TODO add caused by!!
|
||||
*
|
||||
* @return
|
||||
* 1 on success, < 0 if function must abort asap.
|
||||
*/
|
||||
int iso_msg_submit(int imgid, int errcode, const char *fmt, ...);
|
||||
|
||||
#endif /*MESSAGES_H_*/
|
||||
|
@ -265,7 +265,8 @@ char *get_rr_fname(Ecma119Image *t, const char *str)
|
||||
|
||||
ret = strconv(str, t->input_charset, t->output_charset, &name);
|
||||
if (ret < 0) {
|
||||
iso_msg_sorry(t->image->id, LIBISO_CHARSET_ERROR,
|
||||
/* TODO we should check for possible cancelation */
|
||||
iso_msg_submit(t->image->id, ISO_FILENAME_WRONG_CHARSET,
|
||||
"Charset conversion error. Can't convert %s from %s to %s",
|
||||
str, t->input_charset, t->output_charset);
|
||||
|
||||
|
@ -104,7 +104,7 @@ int susp_iter_next(SuspIterator *iter, struct susp_sys_user_entry **sue)
|
||||
|
||||
if (entry->len_sue[0] == 0) {
|
||||
/* a wrong image with this lead us to a infinity loop */
|
||||
iso_msg_sorry(iter->msgid, LIBISO_RR_ERROR,
|
||||
iso_msg_submit(iter->msgid, ISO_WRONG_RR,
|
||||
"Damaged RR/SUSP information.");
|
||||
return ISO_WRONG_RR;
|
||||
}
|
||||
@ -114,10 +114,15 @@ int susp_iter_next(SuspIterator *iter, struct susp_sys_user_entry **sue)
|
||||
if (SUSP_SIG(entry, 'C', 'E')) {
|
||||
/* Continuation entry */
|
||||
if (iter->ce_len) {
|
||||
iso_msg_sorry(iter->msgid, LIBISO_RR_ERROR, "More than one CE "
|
||||
"System user entry has found in a single System Use field or "
|
||||
"continuation area. This breaks SUSP standard and it's not "
|
||||
"supported. Ignoring last CE. Maybe the image is damaged.");
|
||||
int ret;
|
||||
ret = iso_msg_submit(iter->msgid, ISO_UNSUPPORTED_SUSP,
|
||||
"More than one CE System user entry has found in a single "
|
||||
"System Use field or continuation area. This breaks SUSP "
|
||||
"standard and it's not supported. Ignoring last CE. Maybe "
|
||||
"the image is damaged.");
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
} else {
|
||||
iter->ce_block = iso_read_bb(entry->data.CE.block, 4, NULL);
|
||||
iter->ce_off = iso_read_bb(entry->data.CE.offset, 4, NULL);
|
||||
|
@ -522,8 +522,7 @@ int iso_add_dir_src_rec(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
|
||||
if (ret <= 0) {
|
||||
if (ret < 0) {
|
||||
/* error reading dir */
|
||||
iso_msg_sorry(image->id, LIBISO_CANT_READ_FILE,
|
||||
"Error reading dir");
|
||||
ret = iso_msg_submit(image->id, ret, "Error reading dir");
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -582,7 +581,7 @@ int iso_add_dir_src_rec(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
|
||||
}
|
||||
ret = builder->create_node(builder, image, file, &new);
|
||||
if (ret < 0) {
|
||||
iso_msg_note(image->id, LIBISO_FILE_IGNORED,
|
||||
ret = iso_msg_submit(image->id, ISO_FILE_CANT_ADD,
|
||||
"Error %d when adding file %s", ret, path);
|
||||
goto dir_rec_continue;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user