Replace per Image messenger with a global one, and use image id instead.

This commit is contained in:
Vreixo Formoso
2008-01-19 02:48:12 +01:00
parent 88eea232aa
commit df5aa263ec
24 changed files with 254 additions and 223 deletions

View File

@ -67,7 +67,7 @@ typedef struct
gid_t gid; /**< Default uid when no RR */
mode_t mode; /**< Default mode when no RR (only permissions) */
struct libiso_msgs *messenger;
int msgid;
char *input_charset; /**< Input charset for RR names */
char *local_charset; /**< For RR names, will be set to the locale one */
@ -342,7 +342,7 @@ int read_dir(ImageFileSourceData *data)
if (data->parent == NULL && record->len_fi[0] == 8
&& !strncmp((char*)record->file_id, "RR_MOVED", 8)) {
iso_msg_debug(fsdata->messenger, "Skipping RR_MOVE entry.");
iso_msg_debug(fsdata->msgid, "Skipping RR_MOVE entry.");
tlen += record->len_dr[0];
pos += record->len_dr[0];
@ -713,7 +713,7 @@ char *get_name(_ImageFsData *fsdata, const char *str, size_t len)
if (ret == 1) {
return name;
} else {
iso_msg_sorry(fsdata->messenger, LIBISO_CHARSET_ERROR,
iso_msg_sorry(fsdata->msgid, LIBISO_CHARSET_ERROR,
"Charset conversion error. Can't convert %s from %s to %s",
str, fsdata->input_charset, fsdata->local_charset);
/* fallback */
@ -773,7 +773,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
/* check for unsupported multiextend */
if (record->flags[0] & 0x80) {
iso_msg_fatal(fsdata->messenger, LIBISO_IMG_UNSUPPORTED,
iso_msg_fatal(fsdata->msgid, LIBISO_IMG_UNSUPPORTED,
"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 +782,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->messenger, LIBISO_IMG_UNSUPPORTED,
iso_msg_fatal(fsdata->msgid, LIBISO_IMG_UNSUPPORTED,
"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 +795,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->messenger, LIBISO_IMG_UNSUPPORTED,
iso_msg_fatal(fsdata->msgid, LIBISO_IMG_UNSUPPORTED,
"Unsupported image. This image has at least one file with "
"Extended Attributes, that are not supported");
return ISO_UNSUPPORTED_ECMA119;
@ -816,7 +816,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
iter = susp_iter_new(fsdata->src, record, fsdata->len_skp,
fsdata->messenger);
fsdata->msgid);
if (iter == NULL) {
return ISO_MEM_ERROR;
}
@ -831,20 +831,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->messenger, LIBISO_RR_ERROR,
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
"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->messenger, LIBISO_RR_WARNING,
iso_msg_warn(fsdata->msgid, LIBISO_RR_WARNING,
"Invalid TF entry");
}
} else if (SUSP_SIG(sue, 'N', 'M')) {
if (name != NULL && namecont == 0) {
/* ups, RR standard violation */
iso_msg_warn(fsdata->messenger, LIBISO_RR_WARNING,
iso_msg_warn(fsdata->msgid, LIBISO_RR_WARNING,
"New NM entry found without previous"
"CONTINUE flag. Ignored");
continue;
@ -852,13 +852,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->messenger, LIBISO_RR_WARNING,
iso_msg_warn(fsdata->msgid, LIBISO_RR_WARNING,
"Invalid NM entry");
}
} else if (SUSP_SIG(sue, 'S', 'L')) {
if (linkdest != NULL && linkdestcont == 0) {
/* ups, RR standard violation */
iso_msg_warn(fsdata->messenger, LIBISO_RR_WARNING,
iso_msg_warn(fsdata->msgid, LIBISO_RR_WARNING,
"New SL entry found without previous"
"CONTINUE flag. Ignored");
continue;
@ -866,7 +866,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->messenger, LIBISO_RR_WARNING,
iso_msg_warn(fsdata->msgid, LIBISO_RR_WARNING,
"Invalid SL entry");
}
} else if (SUSP_SIG(sue, 'R', 'E')) {
@ -887,7 +887,7 @@ 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->messenger, LIBISO_RR_ERROR,
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
"Invalid SL entry, no child location");
ret = ISO_WRONG_RR;
break;
@ -896,11 +896,11 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
ret = read_rr_PN(sue, &atts);
if (ret < 0) {
/* notify and continue */
iso_msg_sorry(fsdata->messenger, LIBISO_RR_ERROR,
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
"Invalid PN entry");
}
} else if (SUSP_SIG(sue, 'S', 'F')) {
iso_msg_sorry(fsdata->messenger, LIBISO_RR_UNSUPPORTED,
iso_msg_sorry(fsdata->msgid, LIBISO_RR_UNSUPPORTED,
"Sparse files not supported.");
ret = ISO_UNSUPPORTED_RR;
break;
@ -914,7 +914,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
*/
if (parent != NULL) {
/* notify and continue */
iso_msg_sorry(fsdata->messenger, LIBISO_RR_ERROR,
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
"SP entry found in a directory entry other "
"than '.' entry of root node");
}
@ -926,13 +926,13 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
*/
if (parent != NULL) {
/* notify and continue */
iso_msg_sorry(fsdata->messenger, LIBISO_RR_ERROR,
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
"ER entry found in a directory entry other "
"than '.' entry of root node");
}
continue;
} else {
iso_msg_hint(fsdata->messenger, LIBISO_SUSP_UNHANLED,
iso_msg_hint(fsdata->msgid, LIBISO_SUSP_UNHANLED,
"Unhandled SUSP entry %c%c.", sue->sig[0], sue->sig[1]);
}
}
@ -942,21 +942,21 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
/* check for RR problems */
if (ret < 0) {
iso_msg_sorry(fsdata->messenger, LIBISO_RR_ERROR,
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
"Error parsing RR entries");
} else if (!relocated_dir && atts.st_mode == (mode_t) 0 ) {
iso_msg_sorry(fsdata->messenger, LIBISO_RR_ERROR, "Mandatory Rock "
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR, "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->messenger, LIBISO_RR_ERROR,
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
"Incomplete RR name, last NM entry continues");
ret = ISO_WRONG_RR;
}
if (linkdestcont != 0) {
iso_msg_sorry(fsdata->messenger, LIBISO_RR_ERROR,
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
"Incomplete link destination, last SL entry continues");
ret = ISO_WRONG_RR;
}
@ -974,7 +974,7 @@ 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->messenger, LIBISO_CHARSET_ERROR,
iso_msg_sorry(fsdata->msgid, LIBISO_CHARSET_ERROR,
"Charset conversion error. Can't convert %s from %s to %s",
name, fsdata->input_charset, fsdata->local_charset);
free(newname);
@ -991,7 +991,7 @@ 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->messenger, LIBISO_CHARSET_ERROR,
iso_msg_sorry(fsdata->msgid, LIBISO_CHARSET_ERROR,
"Charset conversion error. Can't convert %s from %s to %s",
linkdest, fsdata->input_charset, fsdata->local_charset);
free(newlinkdest);
@ -1022,7 +1022,7 @@ 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->messenger, LIBISO_WRONG_IMG,
iso_msg_sorry(fsdata->msgid, LIBISO_WRONG_IMG,
"Wrong ISO file name. \".\" not dir");
return ISO_WRONG_ECMA119;
}
@ -1030,7 +1030,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
name = get_name(fsdata, (char*)record->file_id, record->len_fi[0]);
if (name == NULL) {
iso_msg_sorry(fsdata->messenger, LIBISO_WRONG_IMG,
iso_msg_sorry(fsdata->msgid, LIBISO_WRONG_IMG,
"Can't retrieve file name");
return ISO_WRONG_ECMA119;
}
@ -1114,7 +1114,7 @@ int iso_file_source_new_ifs(IsoImageFilesystem *fs, IsoFileSource *parent,
//TODO more sanity checks!!
if (S_ISLNK(atts.st_mode) && (linkdest == NULL)) {
iso_msg_sorry(fsdata->messenger, LIBISO_RR_ERROR,
iso_msg_sorry(fsdata->msgid, LIBISO_RR_ERROR,
"Link without destination.");
free(name);
return ISO_WRONG_RR;
@ -1413,7 +1413,7 @@ int read_root_susp_entries(_ImageFsData *data, uint32_t block)
* In that case, we need to set info->len_skp to 15!!
*/
iter = susp_iter_new(data->src, record, data->len_skp, data->messenger);
iter = susp_iter_new(data->src, record, data->len_skp, data->msgid);
if (iter == NULL) {
return ISO_MEM_ERROR;
}
@ -1425,7 +1425,7 @@ int read_root_susp_entries(_ImageFsData *data, uint32_t block)
susp_iter_free(iter);
return ret;
} else if (ret == 0 || !SUSP_SIG(sue, 'S', 'P') ) {
iso_msg_debug(data->messenger, "SUSP/RR is not being used.");
iso_msg_debug(data->msgid, "SUSP/RR is not being used.");
susp_iter_free(iter);
return ISO_SUCCESS;
}
@ -1434,13 +1434,13 @@ 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->messenger, LIBISO_SUSP_WRONG, "SUSP SP system use "
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;
}
iso_msg_debug(data->messenger, "SUSP/RR is being used.");
iso_msg_debug(data->msgid, "SUSP/RR is being used.");
/*
* The LEN_SKP field, defined in IEEE 1281, SUSP. 5.3, specifies the
@ -1469,7 +1469,7 @@ int read_root_susp_entries(_ImageFsData *data, uint32_t block)
if (SUSP_SIG(sue, 'E', 'R')) {
if (data->rr_version) {
iso_msg_warn(data->messenger, LIBISO_SUSP_MULTIPLE_ER,
iso_msg_warn(data->msgid, LIBISO_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.");
@ -1482,7 +1482,7 @@ int read_root_susp_entries(_ImageFsData *data, uint32_t block)
if ( sue->data.ER.len_id[0] == 10 &&
!strncmp((char*)sue->data.ER.ext_id, "RRIP_1991A", 10) ) {
iso_msg_debug(data->messenger,
iso_msg_debug(data->msgid,
"Suitable Rock Ridge ER found. Version 1.10.");
data->rr_version = RR_EXT_110;
@ -1491,12 +1491,12 @@ int read_root_susp_entries(_ImageFsData *data, uint32_t block)
|| (sue->data.ER.len_id[0] == 9 &&
!strncmp((char*)sue->data.ER.ext_id, "IEEE_1282", 9)) ) {
iso_msg_debug(data->messenger,
iso_msg_debug(data->msgid,
"Suitable Rock Ridge ER found. Version 1.12.");
data->rr_version = RR_EXT_112;
//TODO check also version?
} else {
iso_msg_warn(data->messenger, LIBISO_SUSP_MULTIPLE_ER,
iso_msg_warn(data->msgid, LIBISO_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");
@ -1585,7 +1585,7 @@ 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->messenger, LIBISO_EL_TORITO_WRONG,
iso_msg_sorry(data->msgid, LIBISO_EL_TORITO_WRONG,
"Wrong or damaged El-Torito Catalog. El-Torito info "
"will be ignored.");
return ISO_WRONG_EL_TORITO;
@ -1593,7 +1593,7 @@ int read_el_torito_boot_catalog(_ImageFsData *data, uint32_t block)
/* check for a valid platform */
if (ve->platform_id[0] != 0) {
iso_msg_hint(data->messenger, LIBISO_EL_TORITO_UNHANLED,
iso_msg_hint(data->msgid, LIBISO_EL_TORITO_UNHANLED,
"Unsupported El-Torito platform. Only 80x86 is "
"supported. El-Torito info will be ignored.");
return ISO_WRONG_EL_TORITO;
@ -1618,8 +1618,7 @@ int read_el_torito_boot_catalog(_ImageFsData *data, uint32_t block)
}
int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
struct libiso_msgs *messenger,
IsoImageFilesystem **fs)
int msgid, IsoImageFilesystem **fs)
{
int ret;
uint32_t block;
@ -1654,7 +1653,7 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
data->gid = opts->gid;
data->uid = opts->uid;
data->mode = opts->mode & ~S_IFMT;
data->messenger = messenger;
data->msgid = msgid;
setlocale(LC_CTYPE, "");
data->local_charset = strdup(nl_langinfo(CODESET));
@ -1705,7 +1704,7 @@ 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->messenger, LIBISO_BOOT_VD_UNHANLED,
iso_msg_hint(data->msgid, LIBISO_BOOT_VD_UNHANLED,
"Unsupported Boot Vol. Desc. Only El-Torito "
"Specification, Version 1.0 Volume "
"Descriptors are supported. Ignoring boot info");
@ -1729,7 +1728,7 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
sup->esc_sequences[2] == 0x45) ) {
/* it's a Joliet Sup. Vol. Desc. */
iso_msg_debug(data->messenger, "Found Joliet extensions");
iso_msg_debug(data->msgid, "Found Joliet extensions");
data->joliet = 1;
root = (struct ecma119_dir_record*)sup->root_dir_record;
data->svd_root_block = iso_read_bb(root->block, 4, NULL);
@ -1744,14 +1743,14 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
* It is an Enhanced Volume Descriptor, image is an
* ISO 9660:1999
*/
iso_msg_debug(data->messenger, "Found ISO 9660:1999");
iso_msg_debug(data->msgid, "Found ISO 9660:1999");
data->iso1999 = 1;
root = (struct ecma119_dir_record*)sup->root_dir_record;
data->evd_root_block = iso_read_bb(root->block, 4, NULL);
//TODO an ISO 9660:1999 tree can also have RR extensions.
// What about this?
} else {
iso_msg_hint(data->messenger, LIBISO_UNSUPPORTED_VD,
iso_msg_hint(data->msgid, LIBISO_UNSUPPORTED_VD,
"Unsupported Sup. Vol. Desc found.");
}
}
@ -1763,7 +1762,7 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
*/
break;
default:
iso_msg_hint(data->messenger, LIBISO_UNSUPPORTED_VD,
iso_msg_hint(data->msgid, LIBISO_UNSUPPORTED_VD,
"Ignoring Volume descriptor %x.", buffer[0]);
break;
}
@ -1788,29 +1787,29 @@ int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
/* RR extensions are available */
if (!opts->nojoliet && opts->preferjoliet && data->joliet) {
/* if user prefers joliet, that is used */
iso_msg_debug(data->messenger, "Reading Joliet extensions.");
iso_msg_debug(data->msgid, "Reading Joliet extensions.");
data->input_charset = strdup("UCS-2BE");
data->rr = RR_EXT_NO;
data->iso_root_block = data->svd_root_block;
} else {
/* RR will be used */
iso_msg_debug(data->messenger, "Reading Rock Ridge extensions.");
iso_msg_debug(data->msgid, "Reading Rock Ridge extensions.");
data->iso_root_block = data->pvd_root_block;
}
} else {
/* RR extensions are not available */
if (!opts->nojoliet && data->joliet) {
/* joliet will be used */
iso_msg_debug(data->messenger, "Reading Joliet extensions.");
iso_msg_debug(data->msgid, "Reading Joliet extensions.");
data->input_charset = strdup("UCS-2BE");
data->iso_root_block = data->svd_root_block;
} else if (!opts->noiso1999 && data->iso1999) {
/* we will read ISO 9660:1999 */
iso_msg_debug(data->messenger, "Reading ISO-9660:1999 tree.");
iso_msg_debug(data->msgid, "Reading ISO-9660:1999 tree.");
data->iso_root_block = data->evd_root_block;
} else {
/* default to plain iso */
iso_msg_debug(data->messenger, "Reading plain ISO-9660 tree.");
iso_msg_debug(data->msgid, "Reading plain ISO-9660 tree.");
data->iso_root_block = data->pvd_root_block;
data->input_charset = strdup("ASCII");
}
@ -1873,7 +1872,7 @@ 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->messenger, LIBISO_EL_TORITO_UNHANLED,
iso_msg_hint(image->id, LIBISO_EL_TORITO_UNHANLED,
"More than one catalog node has been found. "
"We will continue, but that could lead to "
"problems");
@ -1929,8 +1928,8 @@ 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->messenger, LIBISO_EL_TORITO_UNHANLED,
"More than one image node has been found. ");
iso_msg_hint(image->id, LIBISO_EL_TORITO_UNHANLED,
"More than one image node has been found. ");
} else {
/* and set the image node */
image->bootcat->image->image = file;
@ -2130,7 +2129,7 @@ int iso_image_import(IsoImage *image, IsoDataSource *src,
return ISO_NULL_POINTER;
}
ret = iso_image_filesystem_new(src, opts, image->messenger, &fs);
ret = iso_image_filesystem_new(src, opts, image->id, &fs);
if (ret < 0) {
return ret;
}