Replace per Image messenger with a global one, and use image id instead.
This commit is contained in:
parent
88eea232aa
commit
df5aa263ec
@ -94,12 +94,13 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
iso_init();
|
||||
iso_set_msgs_severities("NEVER", "ALL", "");
|
||||
result = iso_image_new("volume_id", &image);
|
||||
if (result < 0) {
|
||||
printf ("Error creating image\n");
|
||||
return 1;
|
||||
}
|
||||
iso_image_set_msgs_severities(image, "NEVER", "ALL", "");
|
||||
|
||||
result = iso_tree_add_dir_rec(image, iso_image_get_root(image), argv[1]);
|
||||
if (result < 0) {
|
||||
@ -130,5 +131,6 @@ int main(int argc, char **argv)
|
||||
free(ecma119->input_charset);
|
||||
free(ecma119);
|
||||
iso_image_unref(image);
|
||||
iso_finish();
|
||||
return 0;
|
||||
}
|
||||
|
@ -126,13 +126,19 @@ int main(int argc, char **argv)
|
||||
if (!fd) {
|
||||
err(1, "error opening output file");
|
||||
}
|
||||
|
||||
result = iso_init();
|
||||
if (result < 0) {
|
||||
printf ("Can't initialize libisofs\n");
|
||||
return 1;
|
||||
}
|
||||
iso_set_msgs_severities("NEVER", "ALL", "");
|
||||
|
||||
result = iso_image_new(volid, &image);
|
||||
if (result < 0) {
|
||||
printf ("Error creating image\n");
|
||||
return 1;
|
||||
}
|
||||
iso_image_set_msgs_severities(image, "NEVER", "ALL", "");
|
||||
iso_tree_set_follow_symlinks(image, 0);
|
||||
iso_tree_set_ignore_hidden(image, 0);
|
||||
iso_tree_set_ignore_special(image, 0);
|
||||
@ -171,5 +177,6 @@ int main(int argc, char **argv)
|
||||
free(burn_src);
|
||||
|
||||
iso_image_unref(image);
|
||||
iso_finish();
|
||||
return 0;
|
||||
}
|
||||
|
@ -64,6 +64,7 @@ int main(int argc, char **argv)
|
||||
0, /* block */
|
||||
0, /* norock */
|
||||
0, /* nojoliet */
|
||||
0, /* noiso1999 */
|
||||
0, /* preferjoliet */
|
||||
0, /* uid; */
|
||||
0, /* gid; */
|
||||
@ -75,6 +76,9 @@ int main(int argc, char **argv)
|
||||
usage(argv);
|
||||
return 1;
|
||||
}
|
||||
|
||||
iso_init();
|
||||
iso_set_msgs_severities("NEVER", "ALL", "");
|
||||
|
||||
/* create the image context */
|
||||
result = iso_image_new("volume_id", &image);
|
||||
@ -82,7 +86,6 @@ int main(int argc, char **argv)
|
||||
printf ("Error creating image\n");
|
||||
return 1;
|
||||
}
|
||||
iso_image_set_msgs_severities(image, "NEVER", "ALL", "");
|
||||
iso_tree_set_follow_symlinks(image, 0);
|
||||
iso_tree_set_ignore_hidden(image, 0);
|
||||
iso_tree_set_stop_on_error(image, 0);
|
||||
@ -214,6 +217,7 @@ int main(int argc, char **argv)
|
||||
exit_cleanup:;
|
||||
burn_drive_release(drives[0].drive, 0);
|
||||
burn_finish();
|
||||
iso_finish();
|
||||
|
||||
exit(ret);
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ int main(int argc, char **argv)
|
||||
1, /* level */
|
||||
1, /* rockridge */
|
||||
0, /* joliet */
|
||||
0, /* iso1999 */
|
||||
0, /* omit_version_numbers */
|
||||
0, /* allow_deep_paths */
|
||||
0, /* allow_longer_paths */
|
||||
@ -58,6 +59,7 @@ int main(int argc, char **argv)
|
||||
0, /* block */
|
||||
0, /* norock */
|
||||
0, /* nojoliet */
|
||||
0, /* noiso1999 */
|
||||
0, /* preferjoliet */
|
||||
0, /* uid; */
|
||||
0, /* gid; */
|
||||
@ -74,6 +76,9 @@ int main(int argc, char **argv)
|
||||
if (!fd) {
|
||||
err(1, "error opening output file");
|
||||
}
|
||||
|
||||
iso_init();
|
||||
iso_set_msgs_severities("NEVER", "ALL", "");
|
||||
|
||||
/* create the data source to accesss previous image */
|
||||
result = iso_data_source_new_from_file(argv[1], &src);
|
||||
@ -88,7 +93,6 @@ int main(int argc, char **argv)
|
||||
printf ("Error creating image\n");
|
||||
return 1;
|
||||
}
|
||||
iso_image_set_msgs_severities(image, "NEVER", "ALL", "");
|
||||
iso_tree_set_follow_symlinks(image, 0);
|
||||
iso_tree_set_ignore_hidden(image, 0);
|
||||
iso_tree_set_stop_on_error(image, 0);
|
||||
@ -123,5 +127,6 @@ int main(int argc, char **argv)
|
||||
free(burn_src);
|
||||
|
||||
iso_image_unref(image);
|
||||
iso_finish();
|
||||
return 0;
|
||||
}
|
||||
|
@ -76,6 +76,9 @@ int main(int argc, char **argv)
|
||||
if (!fd) {
|
||||
err(1, "error opening output file");
|
||||
}
|
||||
|
||||
iso_init();
|
||||
iso_set_msgs_severities("NEVER", "ALL", "");
|
||||
|
||||
/* create the data source to accesss previous image */
|
||||
result = iso_data_source_new_from_file(argv[3], &src);
|
||||
@ -90,7 +93,6 @@ int main(int argc, char **argv)
|
||||
printf ("Error creating image\n");
|
||||
return 1;
|
||||
}
|
||||
iso_image_set_msgs_severities(image, "NEVER", "ALL", "");
|
||||
iso_tree_set_follow_symlinks(image, 0);
|
||||
iso_tree_set_ignore_hidden(image, 0);
|
||||
iso_tree_set_stop_on_error(image, 0);
|
||||
@ -128,5 +130,6 @@ int main(int argc, char **argv)
|
||||
free(burn_src);
|
||||
|
||||
iso_image_unref(image);
|
||||
iso_finish();
|
||||
return 0;
|
||||
}
|
||||
|
@ -10,7 +10,6 @@
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
|
||||
#include "messages.h"
|
||||
#include "libisofs.h"
|
||||
#include "fs_image.h"
|
||||
|
||||
@ -111,7 +110,6 @@ int main(int argc, char **argv)
|
||||
IsoImageFilesystem *fs;
|
||||
IsoDataSource *src;
|
||||
IsoFileSource *root;
|
||||
struct libiso_msgs *messenger;
|
||||
struct iso_read_opts opts = {
|
||||
0, /* block */
|
||||
0, /* norock */
|
||||
@ -129,13 +127,8 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
result = libiso_msgs_new(&messenger, 0);
|
||||
if (result <= 0) {
|
||||
printf ("Can't create messenger\n");
|
||||
return 1;
|
||||
}
|
||||
libiso_msgs_set_severities(messenger, LIBISO_MSGS_SEV_NEVER,
|
||||
LIBISO_MSGS_SEV_ALL, "", 0);
|
||||
iso_init();
|
||||
iso_set_msgs_severities("NEVER", "ALL", "");
|
||||
|
||||
result = iso_data_source_new_from_file(argv[1], &src);
|
||||
if (result < 0) {
|
||||
@ -143,7 +136,7 @@ int main(int argc, char **argv)
|
||||
return 1;
|
||||
}
|
||||
|
||||
result = iso_image_filesystem_new(src, &opts, messenger, &fs);
|
||||
result = iso_image_filesystem_new(src, &opts, 1, &fs);
|
||||
if (result < 0) {
|
||||
printf ("Error creating filesystem\n");
|
||||
return 1;
|
||||
@ -176,6 +169,6 @@ int main(int argc, char **argv)
|
||||
fs->close(fs);
|
||||
iso_filesystem_unref((IsoFilesystem*)fs);
|
||||
iso_data_source_unref(src);
|
||||
libiso_msgs_destroy(&messenger, 0);
|
||||
iso_finish();
|
||||
return 0;
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "libisofs.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@ -35,7 +36,7 @@ print_dir(IsoDir *dir, int level)
|
||||
int i;
|
||||
IsoDirIter *iter;
|
||||
IsoNode *node;
|
||||
char sp[level * 2 + 1];
|
||||
char *sp = alloca(level * 2 + 1);
|
||||
|
||||
for (i = 0; i < level * 2; i += 2) {
|
||||
sp[i] = '|';
|
||||
@ -80,14 +81,15 @@ int main(int argc, char **argv)
|
||||
printf ("You need to specify a valid path\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
iso_init();
|
||||
iso_set_msgs_severities("NEVER", "ALL", "");
|
||||
|
||||
result = iso_image_new("volume_id", &image);
|
||||
if (result < 0) {
|
||||
printf ("Error creating image\n");
|
||||
return 1;
|
||||
}
|
||||
iso_image_set_msgs_severities(image, "NEVER", "ALL", "");
|
||||
|
||||
result = iso_tree_add_dir_rec(image, iso_image_get_root(image), argv[1]);
|
||||
if (result < 0) {
|
||||
|
@ -202,13 +202,12 @@ int ecma119_writer_compute_data_blocks(IsoImageWriter *writer)
|
||||
target = writer->target;
|
||||
|
||||
/* compute position of directories */
|
||||
iso_msg_debug(target->image->messenger,
|
||||
"Computing position of dir structure");
|
||||
iso_msg_debug(target->image->id, "Computing position of dir structure");
|
||||
target->ndirs = 0;
|
||||
calc_dir_pos(target, target->root);
|
||||
|
||||
/* compute length of pathlist */
|
||||
iso_msg_debug(target->image->messenger, "Computing length of pathlist");
|
||||
iso_msg_debug(target->image->id, "Computing length of pathlist");
|
||||
path_table_size = calc_path_table_size(target->root);
|
||||
|
||||
/* compute location for path tables */
|
||||
@ -313,7 +312,7 @@ int ecma119_writer_write_vol_desc(IsoImageWriter *writer)
|
||||
t = writer->target;
|
||||
image = t->image;
|
||||
|
||||
iso_msg_debug(image->messenger, "Write Primary Volume Descriptor");
|
||||
iso_msg_debug(image->id, "Write Primary Volume Descriptor");
|
||||
|
||||
memset(&vol, 0, sizeof(struct ecma119_pri_vol_desc));
|
||||
|
||||
@ -550,7 +549,7 @@ int write_path_tables(Ecma119Image *t)
|
||||
size_t i, j, cur;
|
||||
Ecma119Node **pathlist;
|
||||
|
||||
iso_msg_debug(t->image->messenger, "Writing ISO Path tables");
|
||||
iso_msg_debug(t->image->id, "Writing ISO Path tables");
|
||||
|
||||
/* allocate temporal pathlist */
|
||||
pathlist = malloc(sizeof(void*) * t->ndirs);
|
||||
@ -638,8 +637,7 @@ int ecma119_writer_create(Ecma119Image *target)
|
||||
/* add this writer to image */
|
||||
target->writers[target->nwriters++] = writer;
|
||||
|
||||
iso_msg_debug(target->image->messenger,
|
||||
"Creating low level ECMA-119 tree...");
|
||||
iso_msg_debug(target->image->id, "Creating low level ECMA-119 tree...");
|
||||
ret = ecma119_tree_create(target);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
@ -740,7 +738,7 @@ void *write_function(void *arg)
|
||||
IsoImageWriter *writer;
|
||||
|
||||
Ecma119Image *target = (Ecma119Image*)arg;
|
||||
iso_msg_debug(target->image->messenger, "Starting image writing...");
|
||||
iso_msg_debug(target->image->id, "Starting image writing...");
|
||||
|
||||
target->bytes_written = (off_t) 0;
|
||||
target->percent_written = 0;
|
||||
@ -755,7 +753,7 @@ void *write_function(void *arg)
|
||||
}
|
||||
|
||||
/* write volume descriptors, one per writer */
|
||||
iso_msg_debug(target->image->messenger, "Write volume descriptors");
|
||||
iso_msg_debug(target->image->id, "Write volume descriptors");
|
||||
for (i = 0; i < target->nwriters; ++i) {
|
||||
writer = target->writers[i];
|
||||
res = writer->write_vol_desc(writer);
|
||||
@ -792,7 +790,7 @@ void *write_function(void *arg)
|
||||
pthread_exit(NULL);
|
||||
|
||||
write_error: ;
|
||||
iso_msg_fatal(target->image->messenger, LIBISO_WRITE_ERROR,
|
||||
iso_msg_fatal(target->image->id, LIBISO_WRITE_ERROR,
|
||||
"Image write error, code %d", res);
|
||||
iso_ring_buffer_writer_close(target->buffer, 1);
|
||||
pthread_exit(NULL);
|
||||
@ -997,7 +995,7 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts, Ecma119Image **img)
|
||||
writer = target->writers[i];
|
||||
ret = writer->write_vol_desc(writer);
|
||||
if (ret < 0) {
|
||||
iso_msg_debug(target->image->messenger,
|
||||
iso_msg_debug(target->image->id,
|
||||
"Error writing overwrite volume descriptors");
|
||||
goto target_cleanup;
|
||||
}
|
||||
@ -1010,7 +1008,7 @@ int ecma119_image_new(IsoImage *src, Ecma119WriteOpts *opts, Ecma119Image **img)
|
||||
/* copy the volume descriptors to the overwrite buffer... */
|
||||
ret = iso_ring_buffer_read(target->buffer, buf, voldesc_size);
|
||||
if (ret < 0) {
|
||||
iso_msg_debug(target->image->messenger,
|
||||
iso_msg_debug(target->image->id,
|
||||
"Error reading overwrite volume descriptors");
|
||||
goto target_cleanup;
|
||||
}
|
||||
@ -1039,7 +1037,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->messenger, LIBISO_THREAD_ERROR,
|
||||
iso_msg_fatal(target->image->id, LIBISO_THREAD_ERROR,
|
||||
"Cannot create writer thread");
|
||||
ret = ISO_THREAD_ERROR;
|
||||
goto target_cleanup;
|
||||
@ -1070,8 +1068,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->messenger, LIBISO_READ_ERROR,
|
||||
"Error reading buffer");
|
||||
iso_msg_fatal(t->image->id, LIBISO_READ_ERROR, "Error reading buffer");
|
||||
return -1;
|
||||
} else {
|
||||
/* EOF */
|
||||
@ -1095,8 +1092,8 @@ static void bs_free_data(struct burn_source *bs)
|
||||
/* wait until writer thread finishes */
|
||||
pthread_join(target->wthread, NULL);
|
||||
|
||||
iso_msg_debug(target->image->messenger, "Writer thread joined");
|
||||
iso_msg_debug(target->image->messenger,
|
||||
iso_msg_debug(target->image->id, "Writer thread joined");
|
||||
iso_msg_debug(target->image->id,
|
||||
"Ring buffer was %d times full and %d times empty",
|
||||
iso_ring_buffer_get_times_full(target->buffer),
|
||||
iso_ring_buffer_get_times_empty(target->buffer));
|
||||
@ -1174,8 +1171,8 @@ int iso_write(Ecma119Image *target, void *buf, size_t count)
|
||||
|
||||
/* only report in 5% chunks */
|
||||
if (percent >= target->percent_written + 5) {
|
||||
iso_msg_debug(target->image->messenger,
|
||||
"Processed %u of %u KB (%d %%)", kbw, kbt, percent);
|
||||
iso_msg_debug(target->image->id, "Processed %u of %u KB (%d %%)",
|
||||
kbw, kbt, percent);
|
||||
target->percent_written = percent;
|
||||
}
|
||||
}
|
||||
|
@ -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->messenger, "Can't convert %s", iso->name);
|
||||
iso_msg_debug(img->image->id, "Can't convert %s", iso->name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -163,7 +163,7 @@ 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->messenger, LIBISO_FILE_IGNORED,
|
||||
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;
|
||||
@ -298,13 +298,13 @@ 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->messenger, LIBISO_FILE_IGNORED,
|
||||
iso_msg_note(image->image->id, LIBISO_FILE_IGNORED,
|
||||
"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->messenger, LIBISO_FILE_IGNORED,
|
||||
iso_msg_note(image->image->id, LIBISO_FILE_IGNORED,
|
||||
"File \"%s\" can't be added, because path length "
|
||||
"is greater than 255 characters", iso->name);
|
||||
free(iso_name);
|
||||
@ -321,7 +321,7 @@ 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->messenger, LIBISO_FILE_IGNORED,
|
||||
iso_msg_note(image->image->id, LIBISO_FILE_IGNORED,
|
||||
"File \"%s\" ignored. Symlinks need RockRidge extensions.",
|
||||
iso->name);
|
||||
ret = 0;
|
||||
@ -332,7 +332,7 @@ 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->messenger, LIBISO_FILE_IGNORED,
|
||||
iso_msg_note(image->image->id, LIBISO_FILE_IGNORED,
|
||||
"File \"%s\" ignored. Special files need RockRidge extensions.",
|
||||
iso->name);
|
||||
ret = 0;
|
||||
@ -343,7 +343,7 @@ 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->messenger, LIBISO_FILE_IGNORED,
|
||||
iso_msg_note(image->image->id, LIBISO_FILE_IGNORED,
|
||||
"El-Torito catalog found on a image without El-Torito.",
|
||||
iso->name);
|
||||
ret = 0;
|
||||
@ -571,7 +571,7 @@ int mangle_single_dir(Ecma119Image *img, Ecma119Node *dir, int max_file_len,
|
||||
ret = ISO_MEM_ERROR;
|
||||
goto mangle_cleanup;
|
||||
}
|
||||
iso_msg_debug(img->image->messenger,
|
||||
iso_msg_debug(img->image->id,
|
||||
"\"%s\" renamed to \"%s\"",
|
||||
children[k]->iso_name, new);
|
||||
|
||||
@ -822,10 +822,10 @@ int ecma119_tree_create(Ecma119Image *img)
|
||||
}
|
||||
img->root = root;
|
||||
|
||||
iso_msg_debug(img->image->messenger, "Sorting the low level tree...");
|
||||
iso_msg_debug(img->image->id, "Sorting the low level tree...");
|
||||
sort_tree(root);
|
||||
|
||||
iso_msg_debug(img->image->messenger, "Mangling names...");
|
||||
iso_msg_debug(img->image->id, "Mangling names...");
|
||||
ret = mangle_tree(img, 1);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
|
@ -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->messenger, LIBISO_EL_TORITO_WRONG_IMG,
|
||||
iso_msg_sorry(image->id, LIBISO_EL_TORITO_WRONG_IMG,
|
||||
"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->messenger, LIBISO_EL_TORITO_WRONG_IMG,
|
||||
iso_msg_sorry(image->id, LIBISO_EL_TORITO_WRONG_IMG,
|
||||
"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->messenger, LIBISO_EL_TORITO_WRONG_IMG,
|
||||
iso_msg_sorry(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->messenger, LIBISO_EL_TORITO_WRONG_IMG,
|
||||
iso_msg_sorry(image->id, LIBISO_EL_TORITO_WRONG_IMG,
|
||||
"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->messenger, LIBISO_EL_TORITO_WRONG_IMG,
|
||||
iso_msg_sorry(image->id, LIBISO_EL_TORITO_WRONG_IMG,
|
||||
"Invalid MBR. At least 2 partitions: %d and "
|
||||
"%d, are being used\n", used_partition, i);
|
||||
return ISO_BOOT_IMAGE_NOT_VALID;
|
||||
@ -746,7 +746,7 @@ int eltorito_writer_write_vol_desc(IsoImageWriter *writer)
|
||||
t = writer->target;
|
||||
cat = t->catalog;
|
||||
|
||||
iso_msg_debug(t->image->messenger, "Write El-Torito boot record");
|
||||
iso_msg_debug(t->image->id, "Write El-Torito boot record");
|
||||
|
||||
memset(&vol, 0, sizeof(struct ecma119_boot_rec_vol_desc));
|
||||
vol.vol_desc_type[0] = 0;
|
||||
@ -769,7 +769,7 @@ void patch_boot_image(uint8_t *buf, Ecma119Image *t, size_t imgsize)
|
||||
size_t offset;
|
||||
|
||||
if (imgsize < 64) {
|
||||
iso_msg_warn(t->image->messenger, LIBISO_ISOLINUX_CANT_PATCH,
|
||||
iso_msg_warn(t->image->id, LIBISO_ISOLINUX_CANT_PATCH,
|
||||
"Isolinux image too small. We won't patch it.");
|
||||
return;
|
||||
}
|
||||
@ -787,7 +787,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->messenger, LIBISO_ISOLINUX_CANT_PATCH,
|
||||
iso_msg_warn(t->image->id, LIBISO_ISOLINUX_CANT_PATCH,
|
||||
"Unexpected isolinux image length. Patch might not work.");
|
||||
}
|
||||
|
||||
|
@ -253,7 +253,7 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
|
||||
t = writer->target;
|
||||
filelist = writer->data;
|
||||
|
||||
iso_msg_debug(t->image->messenger, "Writing Files...");
|
||||
iso_msg_debug(t->image->id, "Writing Files...");
|
||||
|
||||
i = 0;
|
||||
while ((file = filelist[i++]) != NULL) {
|
||||
@ -272,7 +272,7 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
|
||||
* 0's to image
|
||||
*/
|
||||
char *name = iso_stream_get_name(file->stream);
|
||||
iso_msg_sorry(t->image->messenger, LIBISO_FILE_CANT_WRITE,
|
||||
iso_msg_sorry(t->image->id, LIBISO_FILE_CANT_WRITE,
|
||||
"File \"%s\" can't be opened. Filling with 0s.", name);
|
||||
free(name);
|
||||
memset(buffer, 0, BLOCK_SIZE);
|
||||
@ -302,17 +302,17 @@ int filesrc_writer_write_data(IsoImageWriter *writer)
|
||||
char *name = iso_stream_get_name(file->stream);
|
||||
if (res < 0) {
|
||||
/* error */
|
||||
iso_msg_sorry(t->image->messenger, LIBISO_FILE_CANT_WRITE,
|
||||
iso_msg_sorry(t->image->id, LIBISO_FILE_CANT_WRITE,
|
||||
"Read error in file %s.", name);
|
||||
} else {
|
||||
/* eof */
|
||||
iso_msg_sorry(t->image->messenger, LIBISO_FILE_CANT_WRITE,
|
||||
iso_msg_sorry(t->image->id, LIBISO_FILE_CANT_WRITE,
|
||||
"Premature end of file %s.", name);
|
||||
}
|
||||
free(name);
|
||||
|
||||
/* fill with 0s */
|
||||
iso_msg_sorry(t->image->messenger, LIBISO_FILE_CANT_WRITE,
|
||||
iso_msg_sorry(t->image->id, LIBISO_FILE_CANT_WRITE,
|
||||
"Filling with 0");
|
||||
memset(buffer, 0, BLOCK_SIZE);
|
||||
while (b++ < nblocks) {
|
||||
|
109
src/fs_image.c
109
src/fs_image.c
@ -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;
|
||||
}
|
||||
|
@ -44,8 +44,7 @@ struct Iso_Image_Filesystem
|
||||
};
|
||||
|
||||
int iso_image_filesystem_new(IsoDataSource *src, struct iso_read_opts *opts,
|
||||
struct libiso_msgs *messenger,
|
||||
IsoImageFilesystem **fs);
|
||||
int msgid, IsoImageFilesystem **fs);
|
||||
|
||||
const char *iso_image_fs_get_volset_id(IsoImageFilesystem *fs);
|
||||
|
||||
|
14
src/image.c
14
src/image.c
@ -57,27 +57,16 @@ int iso_image_new(const char *name, IsoImage **image)
|
||||
return ISO_MEM_ERROR;
|
||||
}
|
||||
|
||||
/* create message messenger */
|
||||
res = libiso_msgs_new(&img->messenger, 0);
|
||||
if (res <= 0) {
|
||||
iso_node_builder_unref(img->builder);
|
||||
iso_filesystem_unref(img->fs);
|
||||
free(img);
|
||||
return ISO_MEM_ERROR;
|
||||
}
|
||||
libiso_msgs_set_severities(img->messenger, LIBISO_MSGS_SEV_NEVER,
|
||||
LIBISO_MSGS_SEV_FATAL, name, 0);
|
||||
|
||||
/* fill image fields */
|
||||
res = iso_node_new_root(&img->root);
|
||||
if (res < 0) {
|
||||
libiso_msgs_destroy(&img->messenger, 0);
|
||||
iso_node_builder_unref(img->builder);
|
||||
iso_filesystem_unref(img->fs);
|
||||
free(img);
|
||||
return res;
|
||||
}
|
||||
img->refcount = 1;
|
||||
img->id = iso_message_id++;
|
||||
|
||||
if (name != NULL) {
|
||||
img->volset_id = strdup(name);
|
||||
@ -105,7 +94,6 @@ void iso_image_unref(IsoImage *image)
|
||||
if (--image->refcount == 0) {
|
||||
/* we need to free the image */
|
||||
iso_node_unref((IsoNode*)image->root);
|
||||
libiso_msgs_destroy(&image->messenger, 0);
|
||||
iso_node_builder_unref(image->builder);
|
||||
iso_filesystem_unref(image->fs);
|
||||
el_torito_boot_catalog_free(image->bootcat);
|
||||
|
@ -108,8 +108,8 @@ struct Iso_Image
|
||||
/* el-torito boot catalog */
|
||||
struct el_torito_boot_catalog *bootcat;
|
||||
|
||||
/* message messenger for the image */
|
||||
struct libiso_msgs *messenger;
|
||||
/* image identifier, for message origin identifier */
|
||||
int id;
|
||||
|
||||
/**
|
||||
* Default filesystem to use when adding files to the image tree.
|
||||
|
@ -34,7 +34,7 @@ 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->messenger, LIBISO_CHARSET_ERROR,
|
||||
iso_msg_sorry(t->image->id, LIBISO_CHARSET_ERROR,
|
||||
"Charset conversion error. Can't convert %s from %s to %s",
|
||||
str, t->input_charset, t->output_charset);
|
||||
|
||||
@ -108,7 +108,7 @@ 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->messenger, LIBISO_FILE_IGNORED,
|
||||
iso_msg_note(t->image->id, LIBISO_FILE_IGNORED,
|
||||
"File \"%s\" can't be added to image because is "
|
||||
"greater than 4GB", iso->name);
|
||||
free(n);
|
||||
@ -171,7 +171,7 @@ int create_tree(Ecma119Image *t, IsoNode *iso, Iso1999Node **tree, int pathlen)
|
||||
iso_name = get_iso1999_name(t, iso->name);
|
||||
max_path = pathlen + 1 + (iso_name ? strlen(iso_name): 0);
|
||||
if (!t->allow_longer_paths && max_path > 255) {
|
||||
iso_msg_note(t->image->messenger, LIBISO_FILE_IGNORED,
|
||||
iso_msg_note(t->image->id, LIBISO_FILE_IGNORED,
|
||||
"File \"%s\" can't be added to ISO 9660:1999 tree, "
|
||||
"because its path length is larger than 255", iso->name);
|
||||
free(iso_name);
|
||||
@ -216,7 +216,7 @@ 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->messenger, LIBISO_FILE_IGNORED,
|
||||
iso_msg_note(t->image->id, LIBISO_FILE_IGNORED,
|
||||
"El-Torito catalog found on a image without El-Torito.",
|
||||
iso->name);
|
||||
ret = 0;
|
||||
@ -224,7 +224,7 @@ int create_tree(Ecma119Image *t, IsoNode *iso, Iso1999Node **tree, int pathlen)
|
||||
break;
|
||||
case LIBISO_SYMLINK:
|
||||
case LIBISO_SPECIAL:
|
||||
iso_msg_note(t->image->messenger, LIBISO_FILE_IGNORED,
|
||||
iso_msg_note(t->image->id, LIBISO_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);
|
||||
@ -296,10 +296,10 @@ int iso1999_tree_create(Ecma119Image *t)
|
||||
/* the ISO 9660:1999 tree is stored in Ecma119Image target */
|
||||
t->iso1999_root = root;
|
||||
|
||||
iso_msg_debug(t->image->messenger, "Sorting the ISO 9660:1999 tree...");
|
||||
iso_msg_debug(t->image->id, "Sorting the ISO 9660:1999 tree...");
|
||||
sort_tree(root);
|
||||
|
||||
//iso_msg_debug(t->image->messenger, "Mangling ISO 9660:1999 names...");
|
||||
//iso_msg_debug(t->image->id, "Mangling ISO 9660:1999 names...");
|
||||
// FIXME ret = mangle_tree(t, 1);
|
||||
|
||||
return ISO_SUCCESS;
|
||||
@ -408,14 +408,13 @@ int iso1999_writer_compute_data_blocks(IsoImageWriter *writer)
|
||||
t = writer->target;
|
||||
|
||||
/* compute position of directories */
|
||||
iso_msg_debug(t->image->messenger,
|
||||
iso_msg_debug(t->image->id,
|
||||
"Computing position of ISO 9660:1999 dir structure");
|
||||
t->iso1999_ndirs = 0;
|
||||
calc_dir_pos(t, t->iso1999_root);
|
||||
|
||||
/* compute length of pathlist */
|
||||
iso_msg_debug(t->image->messenger,
|
||||
"Computing length of ISO 9660:1999 pathlist");
|
||||
iso_msg_debug(t->image->id, "Computing length of ISO 9660:1999 pathlist");
|
||||
path_table_size = calc_path_table_size(t->iso1999_root);
|
||||
|
||||
/* compute location for path tables */
|
||||
@ -507,7 +506,7 @@ int iso1999_writer_write_vol_desc(IsoImageWriter *writer)
|
||||
t = writer->target;
|
||||
image = t->image;
|
||||
|
||||
iso_msg_debug(image->messenger, "Write Enhanced Vol Desc (ISO 9660:1999)");
|
||||
iso_msg_debug(image->id, "Write Enhanced Vol Desc (ISO 9660:1999)");
|
||||
|
||||
memset(&vol, 0, sizeof(struct ecma119_sup_vol_desc));
|
||||
|
||||
@ -700,7 +699,7 @@ int write_path_tables(Ecma119Image *t)
|
||||
size_t i, j, cur;
|
||||
Iso1999Node **pathlist;
|
||||
|
||||
iso_msg_debug(t->image->messenger, "Writing ISO 9660:1999 Path tables");
|
||||
iso_msg_debug(t->image->id, "Writing ISO 9660:1999 Path tables");
|
||||
|
||||
/* allocate temporal pathlist */
|
||||
pathlist = malloc(sizeof(void*) * t->iso1999_ndirs);
|
||||
@ -783,7 +782,7 @@ int iso1999_writer_create(Ecma119Image *target)
|
||||
writer->data = NULL;
|
||||
writer->target = target;
|
||||
|
||||
iso_msg_debug(target->image->messenger,
|
||||
iso_msg_debug(target->image->id,
|
||||
"Creating low level ISO 9660:1999 tree...");
|
||||
ret = iso1999_tree_create(target);
|
||||
if (ret < 0) {
|
||||
|
28
src/joliet.c
28
src/joliet.c
@ -32,7 +32,7 @@ int get_joliet_name(Ecma119Image *t, IsoNode *iso, uint16_t **name)
|
||||
|
||||
ret = str2ucs(t->input_charset, iso->name, &ucs_name);
|
||||
if (ret < 0) {
|
||||
iso_msg_debug(t->image->messenger, "Can't convert %s", iso->name);
|
||||
iso_msg_debug(t->image->id, "Can't convert %s", iso->name);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -112,7 +112,7 @@ 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->messenger, LIBISO_FILE_IGNORED,
|
||||
iso_msg_note(t->image->id, LIBISO_FILE_IGNORED,
|
||||
"File \"%s\" can't be added to image because is "
|
||||
"greater than 4GB", iso->name);
|
||||
free(joliet);
|
||||
@ -182,7 +182,7 @@ int create_tree(Ecma119Image *t, IsoNode *iso, JolietNode **tree, int pathlen)
|
||||
* Wow!! Joliet is even more restrictive than plain ISO-9660,
|
||||
* that allows up to 255 bytes!!
|
||||
*/
|
||||
iso_msg_note(t->image->messenger, LIBISO_FILE_IGNORED,
|
||||
iso_msg_note(t->image->id, LIBISO_FILE_IGNORED,
|
||||
"File \"%s\" can't be added to Joliet tree, because "
|
||||
"its path length is larger than 240", iso->name);
|
||||
free(jname);
|
||||
@ -227,7 +227,7 @@ 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->messenger, LIBISO_FILE_IGNORED,
|
||||
iso_msg_note(t->image->id, LIBISO_FILE_IGNORED,
|
||||
"El-Torito catalog found on a image without El-Torito.",
|
||||
iso->name);
|
||||
ret = 0;
|
||||
@ -235,7 +235,7 @@ int create_tree(Ecma119Image *t, IsoNode *iso, JolietNode **tree, int pathlen)
|
||||
break;
|
||||
case LIBISO_SYMLINK:
|
||||
case LIBISO_SPECIAL:
|
||||
iso_msg_note(t->image->messenger, LIBISO_JOLIET_WRONG_FILE_TYPE,
|
||||
iso_msg_note(t->image->id, LIBISO_JOLIET_WRONG_FILE_TYPE,
|
||||
"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;
|
||||
@ -297,10 +297,10 @@ int joliet_tree_create(Ecma119Image *t)
|
||||
/* the Joliet tree is stored in Ecma119Image target */
|
||||
t->joliet_root = root;
|
||||
|
||||
iso_msg_debug(t->image->messenger, "Sorting the Joliet tree...");
|
||||
iso_msg_debug(t->image->id, "Sorting the Joliet tree...");
|
||||
sort_tree(root);
|
||||
|
||||
//iso_msg_debug(t->image->messenger, "Mangling Joliet names...");
|
||||
//iso_msg_debug(t->image->id, "Mangling Joliet names...");
|
||||
// FIXME ret = mangle_tree(t, 1);
|
||||
|
||||
return ISO_SUCCESS;
|
||||
@ -412,13 +412,12 @@ int joliet_writer_compute_data_blocks(IsoImageWriter *writer)
|
||||
t = writer->target;
|
||||
|
||||
/* compute position of directories */
|
||||
iso_msg_debug(t->image->messenger,
|
||||
"Computing position of Joliet dir structure");
|
||||
iso_msg_debug(t->image->id, "Computing position of Joliet dir structure");
|
||||
t->joliet_ndirs = 0;
|
||||
calc_dir_pos(t, t->joliet_root);
|
||||
|
||||
/* compute length of pathlist */
|
||||
iso_msg_debug(t->image->messenger, "Computing length of Joliet pathlist");
|
||||
iso_msg_debug(t->image->id, "Computing length of Joliet pathlist");
|
||||
path_table_size = calc_path_table_size(t->joliet_root);
|
||||
|
||||
/* compute location for path tables */
|
||||
@ -543,7 +542,7 @@ int joliet_writer_write_vol_desc(IsoImageWriter *writer)
|
||||
t = writer->target;
|
||||
image = t->image;
|
||||
|
||||
iso_msg_debug(image->messenger, "Write SVD for Joliet");
|
||||
iso_msg_debug(image->id, "Write SVD for Joliet");
|
||||
|
||||
memset(&vol, 0, sizeof(struct ecma119_sup_vol_desc));
|
||||
|
||||
@ -740,7 +739,7 @@ int write_path_tables(Ecma119Image *t)
|
||||
size_t i, j, cur;
|
||||
JolietNode **pathlist;
|
||||
|
||||
iso_msg_debug(t->image->messenger, "Writing Joliet Path tables");
|
||||
iso_msg_debug(t->image->id, "Writing Joliet Path tables");
|
||||
|
||||
/* allocate temporal pathlist */
|
||||
pathlist = malloc(sizeof(void*) * t->joliet_ndirs);
|
||||
@ -820,11 +819,10 @@ int joliet_writer_create(Ecma119Image *target)
|
||||
writer->write_vol_desc = joliet_writer_write_vol_desc;
|
||||
writer->write_data = joliet_writer_write_data;
|
||||
writer->free_data = joliet_writer_free_data;
|
||||
writer->data = NULL; //TODO store joliet tree here
|
||||
writer->data = NULL;
|
||||
writer->target = target;
|
||||
|
||||
iso_msg_debug(target->image->messenger,
|
||||
"Creating low level Joliet tree...");
|
||||
iso_msg_debug(target->image->id, "Creating low level Joliet tree...");
|
||||
ret = joliet_tree_create(target);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
|
@ -399,6 +399,17 @@ struct iso_read_image_features
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
/**
|
||||
* Initialize libisofs. You must call this before any usage of the library.
|
||||
* @return 1 on success, < 0 on error
|
||||
*/
|
||||
int iso_init();
|
||||
|
||||
/**
|
||||
* Finalize libisofs.
|
||||
*/
|
||||
void iso_finish();
|
||||
|
||||
/**
|
||||
* Create a new image, empty.
|
||||
*
|
||||
@ -1330,11 +1341,10 @@ int iso_ring_buffer_get_status(struct burn_source *b, size_t *size,
|
||||
#define ISO_MSGS_MESSAGE_LEN 4096
|
||||
|
||||
/**
|
||||
* Control queueing and stderr printing of messages from a given IsoImage.
|
||||
* Control queueing and stderr printing of messages from libisofs.
|
||||
* Severity may be one of "NEVER", "FATAL", "SORRY", "WARNING", "HINT",
|
||||
* "NOTE", "UPDATE", "DEBUG", "ALL".
|
||||
*
|
||||
* @param image The image
|
||||
* @param queue_severity Gives the minimum limit for messages to be queued.
|
||||
* Default: "NEVER". If you queue messages then you
|
||||
* must consume them by iso_msgs_obtain().
|
||||
@ -1343,10 +1353,11 @@ int iso_ring_buffer_get_status(struct burn_source *b, size_t *size,
|
||||
* @param print_id A text prefix to be printed before the message.
|
||||
* @return >0 for success, <=0 for error
|
||||
*/
|
||||
int iso_image_set_msgs_severities(IsoImage *img, char *queue_severity,
|
||||
char *print_severity, char *print_id);
|
||||
int iso_set_msgs_severities(char *queue_severity, char *print_severity,
|
||||
char *print_id);
|
||||
|
||||
/**
|
||||
* Obtain the oldest pending message from a IsoImage message queue which has at
|
||||
* Obtain the oldest pending libisofs message from the queue which has at
|
||||
* least the given minimum_severity. This message and any older message of
|
||||
* lower severity will get discarded from the queue and is then lost forever.
|
||||
*
|
||||
@ -1354,7 +1365,6 @@ int iso_image_set_msgs_severities(IsoImage *img, char *queue_severity,
|
||||
* "NOTE", "UPDATE", "DEBUG", "ALL". To call with minimum_severity "NEVER"
|
||||
* will discard the whole queue.
|
||||
*
|
||||
* @param image The image whose messages we want to obtain
|
||||
* @param error_code Will become a unique error code as listed in messages.h
|
||||
* @param msg_text Must provide at least ISO_MSGS_MESSAGE_LEN bytes.
|
||||
* @param os_errno Will become the eventual errno related to the message
|
||||
@ -1362,18 +1372,17 @@ int iso_image_set_msgs_severities(IsoImage *img, char *queue_severity,
|
||||
* should provide at least 80 bytes.
|
||||
* @return 1 if a matching item was found, 0 if not, <0 for severe errors
|
||||
*/
|
||||
int iso_image_obtain_msgs(IsoImage *image, char *minimum_severity,
|
||||
int *error_code, char msg_text[], int *os_errno,
|
||||
char severity[]);
|
||||
int iso_obtain_msgs(char *minimum_severity, int *error_code,
|
||||
char msg_text[], int *os_errno, char severity[]);
|
||||
|
||||
/**
|
||||
* Return the messenger object handle used by the given image. This handle
|
||||
* Return the messenger object handle used by libisofs. This handle
|
||||
* may be used by related libraries to their own compatible
|
||||
* messenger objects and thus to direct their messages to the libisofs
|
||||
* message queue. See also: libburn, API function burn_set_messenger().
|
||||
*
|
||||
* @return the handle. Do only use with compatible
|
||||
*/
|
||||
void *iso_image_get_messenger(IsoImage *image);
|
||||
void *iso_get_messenger();
|
||||
|
||||
#endif /*LIBISO_LIBISOFS_H_*/
|
||||
|
@ -12,11 +12,31 @@
|
||||
|
||||
#include "libisofs.h"
|
||||
#include "messages.h"
|
||||
#include "image.h"
|
||||
#include "error.h"
|
||||
|
||||
int iso_message_id = LIBISO_MSGS_ORIGIN_IMAGE_BASE;
|
||||
|
||||
#define MAX_MSG_LEN 4096
|
||||
|
||||
void iso_msg_debug(IsoMessenger *msgr, const char *fmt, ...)
|
||||
struct libiso_msgs *libiso_msgr = NULL;
|
||||
|
||||
int iso_init()
|
||||
{
|
||||
if (libiso_msgr == NULL) {
|
||||
if (libiso_msgs_new(&libiso_msgr, 0) <= 0)
|
||||
return ISO_ERROR;
|
||||
}
|
||||
libiso_msgs_set_severities(libiso_msgr, LIBISO_MSGS_SEV_NEVER,
|
||||
LIBISO_MSGS_SEV_FATAL, "libisofs: ", 0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void iso_finish()
|
||||
{
|
||||
libiso_msgs_destroy(&libiso_msgr, 0);
|
||||
}
|
||||
|
||||
void iso_msg_debug(int imgid, const char *fmt, ...)
|
||||
{
|
||||
char msg[MAX_MSG_LEN];
|
||||
va_list ap;
|
||||
@ -25,11 +45,11 @@ void iso_msg_debug(IsoMessenger *msgr, const char *fmt, ...)
|
||||
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
libiso_msgs_submit(msgr, -1, 0x00000002, LIBISO_MSGS_SEV_DEBUG,
|
||||
libiso_msgs_submit(libiso_msgr, imgid, 0x00000002, LIBISO_MSGS_SEV_DEBUG,
|
||||
LIBISO_MSGS_PRIO_ZERO, msg, 0, 0);
|
||||
}
|
||||
|
||||
void iso_msg_note(IsoMessenger *msgr, int error_code, const char *fmt, ...)
|
||||
void iso_msg_note(int imgid, int error_code, const char *fmt, ...)
|
||||
{
|
||||
char msg[MAX_MSG_LEN];
|
||||
va_list ap;
|
||||
@ -38,11 +58,11 @@ void iso_msg_note(IsoMessenger *msgr, int error_code, const char *fmt, ...)
|
||||
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
libiso_msgs_submit(msgr, -1, error_code, LIBISO_MSGS_SEV_NOTE,
|
||||
libiso_msgs_submit(libiso_msgr, imgid, error_code, LIBISO_MSGS_SEV_NOTE,
|
||||
LIBISO_MSGS_PRIO_MEDIUM, msg, 0, 0);
|
||||
}
|
||||
|
||||
void iso_msg_hint(IsoMessenger *msgr, int error_code, const char *fmt, ...)
|
||||
void iso_msg_hint(int imgid, int error_code, const char *fmt, ...)
|
||||
{
|
||||
char msg[MAX_MSG_LEN];
|
||||
va_list ap;
|
||||
@ -51,11 +71,11 @@ void iso_msg_hint(IsoMessenger *msgr, int error_code, const char *fmt, ...)
|
||||
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
libiso_msgs_submit(msgr, -1, error_code, LIBISO_MSGS_SEV_HINT,
|
||||
libiso_msgs_submit(libiso_msgr, imgid, error_code, LIBISO_MSGS_SEV_HINT,
|
||||
LIBISO_MSGS_PRIO_MEDIUM, msg, 0, 0);
|
||||
}
|
||||
|
||||
void iso_msg_warn(IsoMessenger *msgr, int error_code, const char *fmt, ...)
|
||||
void iso_msg_warn(int imgid, int error_code, const char *fmt, ...)
|
||||
{
|
||||
char msg[MAX_MSG_LEN];
|
||||
va_list ap;
|
||||
@ -64,11 +84,11 @@ void iso_msg_warn(IsoMessenger *msgr, int error_code, const char *fmt, ...)
|
||||
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
libiso_msgs_submit(msgr, -1, error_code, LIBISO_MSGS_SEV_WARNING,
|
||||
libiso_msgs_submit(libiso_msgr, imgid, error_code, LIBISO_MSGS_SEV_WARNING,
|
||||
LIBISO_MSGS_PRIO_MEDIUM, msg, 0, 0);
|
||||
}
|
||||
|
||||
void iso_msg_sorry(IsoMessenger *msgr, int error_code, const char *fmt, ...)
|
||||
void iso_msg_sorry(int imgid, int error_code, const char *fmt, ...)
|
||||
{
|
||||
char msg[MAX_MSG_LEN];
|
||||
va_list ap;
|
||||
@ -77,11 +97,11 @@ void iso_msg_sorry(IsoMessenger *msgr, int error_code, const char *fmt, ...)
|
||||
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
libiso_msgs_submit(msgr, -1, error_code, LIBISO_MSGS_SEV_SORRY,
|
||||
libiso_msgs_submit(libiso_msgr, imgid, error_code, LIBISO_MSGS_SEV_SORRY,
|
||||
LIBISO_MSGS_PRIO_HIGH, msg, 0, 0);
|
||||
}
|
||||
|
||||
void iso_msg_fatal(IsoMessenger *msgr, int error_code, const char *fmt, ...)
|
||||
void iso_msg_fatal(int imgid, int error_code, const char *fmt, ...)
|
||||
{
|
||||
char msg[MAX_MSG_LEN];
|
||||
va_list ap;
|
||||
@ -90,7 +110,7 @@ void iso_msg_fatal(IsoMessenger *msgr, int error_code, const char *fmt, ...)
|
||||
vsnprintf(msg, MAX_MSG_LEN, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
libiso_msgs_submit(msgr, -1, error_code, LIBISO_MSGS_SEV_FATAL,
|
||||
libiso_msgs_submit(libiso_msgr, imgid, error_code, LIBISO_MSGS_SEV_FATAL,
|
||||
LIBISO_MSGS_PRIO_HIGH, msg, 0, 0);
|
||||
}
|
||||
|
||||
@ -107,8 +127,8 @@ void iso_msg_fatal(IsoMessenger *msgr, int error_code, const char *fmt, ...)
|
||||
* @param print_id A text prefix to be printed before the message.
|
||||
* @return >0 for success, <=0 for error
|
||||
*/
|
||||
int iso_image_set_msgs_severities(IsoImage *img, char *queue_severity,
|
||||
char *print_severity, char *print_id)
|
||||
int iso_set_msgs_severities(char *queue_severity, char *print_severity,
|
||||
char *print_id)
|
||||
{
|
||||
int ret, queue_sevno, print_sevno;
|
||||
|
||||
@ -118,15 +138,13 @@ int iso_image_set_msgs_severities(IsoImage *img, char *queue_severity,
|
||||
ret = libiso_msgs__text_to_sev(print_severity, &print_sevno, 0);
|
||||
if (ret <= 0)
|
||||
return 0;
|
||||
ret = libiso_msgs_set_severities(img->messenger, queue_sevno, print_sevno,
|
||||
ret = libiso_msgs_set_severities(libiso_msgr, queue_sevno, print_sevno,
|
||||
print_id, 0);
|
||||
if (ret <= 0)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
#define ISO_MSGS_MESSAGE_LEN 4096
|
||||
|
||||
/**
|
||||
* Obtain the oldest pending libisofs message from the queue which has at
|
||||
* least the given minimum_severity. This message and any older message of
|
||||
@ -143,21 +161,17 @@ int iso_image_set_msgs_severities(IsoImage *img, char *queue_severity,
|
||||
* should provide at least 80 bytes.
|
||||
* @return 1 if a matching item was found, 0 if not, <0 for severe errors
|
||||
*/
|
||||
int iso_image_obtain_msgs(IsoImage *img, char *minimum_severity,
|
||||
int *error_code, char msg_text[], int *os_errno,
|
||||
char severity[])
|
||||
int iso_obtain_msgs(char *minimum_severity, int *error_code,
|
||||
char msg_text[], int *os_errno, char severity[])
|
||||
{
|
||||
int ret, minimum_sevno, sevno, priority;
|
||||
char *textpt, *sev_name;
|
||||
struct libiso_msgs_item *item= NULL;
|
||||
|
||||
if (img == NULL)
|
||||
return 0;
|
||||
|
||||
ret = libiso_msgs__text_to_sev(minimum_severity, &minimum_sevno, 0);
|
||||
if (ret <= 0)
|
||||
return 0;
|
||||
ret = libiso_msgs_obtain(img->messenger, &item, minimum_sevno,
|
||||
ret = libiso_msgs_obtain(libiso_msgr, &item, minimum_sevno,
|
||||
LIBISO_MSGS_PRIO_ZERO, 0);
|
||||
if (ret <= 0)
|
||||
goto ex;
|
||||
@ -179,12 +193,19 @@ int iso_image_obtain_msgs(IsoImage *img, char *minimum_severity,
|
||||
|
||||
ret = 1;
|
||||
ex: ;
|
||||
libiso_msgs_destroy_item(img->messenger, &item, 0);
|
||||
libiso_msgs_destroy_item(libiso_msgr, &item, 0);
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *iso_image_get_messenger(IsoImage *img)
|
||||
/**
|
||||
* Return the messenger object handle used by libisofs. This handle
|
||||
* may be used by related libraries to their own compatible
|
||||
* messenger objects and thus to direct their messages to the libisofs
|
||||
* message queue. See also: libburn, API function burn_set_messenger().
|
||||
*
|
||||
* @return the handle. Do only use with compatible
|
||||
*/
|
||||
void *iso_get_messenger()
|
||||
{
|
||||
return img->messenger;
|
||||
return libiso_msgr;
|
||||
}
|
||||
|
||||
|
@ -15,6 +15,12 @@
|
||||
|
||||
#include "libiso_msgs.h"
|
||||
|
||||
/**
|
||||
* Take and increment this variable to get a valid identifier for message
|
||||
* origin.
|
||||
*/
|
||||
extern int iso_message_id;
|
||||
|
||||
/** File cannot be added to image (ignored) */
|
||||
#define LIBISO_FILE_IGNORED 0x00030100
|
||||
/** File cannot be writing to image (ignored) */
|
||||
@ -79,16 +85,16 @@
|
||||
|
||||
typedef struct libiso_msgs IsoMessenger;
|
||||
|
||||
void iso_msg_debug(IsoMessenger *msgr, const char *fmt, ...);
|
||||
void iso_msg_debug(int imgid, const char *fmt, ...);
|
||||
|
||||
void iso_msg_note(IsoMessenger *msgr, int error_code, const char *fmt, ...);
|
||||
void iso_msg_note(int imgid, int error_code, const char *fmt, ...);
|
||||
|
||||
void iso_msg_hint(IsoMessenger *msgr, int error_code, const char *fmt, ...);
|
||||
void iso_msg_hint(int imgid, int error_code, const char *fmt, ...);
|
||||
|
||||
void iso_msg_warn(IsoMessenger *msgr, int error_code, const char *fmt, ...);
|
||||
void iso_msg_warn(int imgid, int error_code, const char *fmt, ...);
|
||||
|
||||
void iso_msg_sorry(IsoMessenger *msgr, int error_code, const char *fmt, ...);
|
||||
void iso_msg_sorry(int imgid, int error_code, const char *fmt, ...);
|
||||
|
||||
void iso_msg_fatal(IsoMessenger *msgr, int error_code, const char *fmt, ...);
|
||||
void iso_msg_fatal(int imgid, int error_code, const char *fmt, ...);
|
||||
|
||||
#endif /*MESSAGES_H_*/
|
||||
|
@ -265,7 +265,7 @@ 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->messenger, LIBISO_CHARSET_ERROR,
|
||||
iso_msg_sorry(t->image->id, LIBISO_CHARSET_ERROR,
|
||||
"Charset conversion error. Can't convert %s from %s to %s",
|
||||
str, t->input_charset, t->output_charset);
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
#define LIBISO_ROCKRIDGE_H
|
||||
|
||||
#include "ecma119.h"
|
||||
#include "messages.h"
|
||||
|
||||
#define SUSP_SIG(entry, a, b) ((entry->sig[0] == a) && (entry->sig[1] == b))
|
||||
|
||||
@ -202,7 +201,7 @@ typedef struct susp_iterator SuspIterator;
|
||||
|
||||
SuspIterator *
|
||||
susp_iter_new(IsoDataSource *src, struct ecma119_dir_record *record,
|
||||
uint8_t len_skp, IsoMessenger *msgr);
|
||||
uint8_t len_skp, int msgid);
|
||||
|
||||
/**
|
||||
* Get the next SUSP System User Entry using given iterator.
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "util.h"
|
||||
#include "rockridge.h"
|
||||
#include "error.h"
|
||||
#include "messages.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
@ -27,7 +28,7 @@ struct susp_iterator
|
||||
int pos;
|
||||
int size;
|
||||
IsoDataSource *src;
|
||||
IsoMessenger *msgr;
|
||||
int msgid;
|
||||
|
||||
/* block and offset for next continuation area */
|
||||
uint32_t ce_block;
|
||||
@ -41,7 +42,7 @@ struct susp_iterator
|
||||
|
||||
SuspIterator*
|
||||
susp_iter_new(IsoDataSource *src, struct ecma119_dir_record *record,
|
||||
uint8_t len_skp, IsoMessenger *msgr)
|
||||
uint8_t len_skp, int msgid)
|
||||
{
|
||||
int pad = (record->len_fi[0] + 1) % 2;
|
||||
struct susp_iterator *iter = malloc(sizeof(struct susp_iterator));
|
||||
@ -53,7 +54,7 @@ susp_iter_new(IsoDataSource *src, struct ecma119_dir_record *record,
|
||||
iter->pos = len_skp; /* 0 in most cases */
|
||||
iter->size = record->len_dr[0] - record->len_fi[0] - 33 - pad;
|
||||
iter->src = src;
|
||||
iter->msgr = msgr;
|
||||
iter->msgid = msgid;
|
||||
|
||||
iter->ce_len = 0;
|
||||
iter->buffer = NULL;
|
||||
@ -103,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->msgr, LIBISO_RR_ERROR,
|
||||
iso_msg_sorry(iter->msgid, LIBISO_RR_ERROR,
|
||||
"Damaged RR/SUSP information.");
|
||||
return ISO_WRONG_RR;
|
||||
}
|
||||
@ -113,7 +114,7 @@ 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->msgr, LIBISO_RR_ERROR, "More than one CE "
|
||||
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.");
|
||||
|
15
src/tree.c
15
src/tree.c
@ -510,7 +510,7 @@ int iso_add_dir_src_rec(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
|
||||
result = iso_file_source_open(dir);
|
||||
if (result < 0) {
|
||||
char *path = iso_file_source_get_path(dir);
|
||||
iso_msg_debug(image->messenger, "Can't open dir %s", path);
|
||||
iso_msg_debug(image->id, "Can't open dir %s", path);
|
||||
free(path);
|
||||
return result;
|
||||
}
|
||||
@ -526,16 +526,16 @@ int iso_add_dir_src_rec(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
|
||||
path = iso_file_source_get_path(file);
|
||||
|
||||
if (check_excludes(image, path)) {
|
||||
iso_msg_debug(image->messenger, "Skipping excluded file %s", path);
|
||||
iso_msg_debug(image->id, "Skipping excluded file %s", path);
|
||||
action = 2;
|
||||
} else if (check_hidden(image, name)) {
|
||||
iso_msg_debug(image->messenger, "Skipping hidden file %s", path);
|
||||
iso_msg_debug(image->id, "Skipping hidden file %s", path);
|
||||
action = 2;
|
||||
} else if (check_special(image, file)) {
|
||||
iso_msg_debug(image->messenger, "Skipping special file %s", path);
|
||||
iso_msg_debug(image->id, "Skipping special file %s", path);
|
||||
action = 2;
|
||||
} else {
|
||||
iso_msg_debug(image->messenger, "Adding file %s", path);
|
||||
iso_msg_debug(image->id, "Adding file %s", path);
|
||||
action = 1;
|
||||
}
|
||||
free(path);
|
||||
@ -571,7 +571,7 @@ int iso_add_dir_src_rec(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
|
||||
result = builder->create_node(builder, image, file, &new);
|
||||
if (result < 0) {
|
||||
char *path = iso_file_source_get_path(file);
|
||||
iso_msg_note(image->messenger, LIBISO_FILE_IGNORED,
|
||||
iso_msg_note(image->id, LIBISO_FILE_IGNORED,
|
||||
"Error %d when adding file %s", result, path);
|
||||
free(path);
|
||||
|
||||
@ -620,8 +620,7 @@ int iso_add_dir_src_rec(IsoImage *image, IsoDir *parent, IsoFileSource *dir)
|
||||
|
||||
if (result < 0) {
|
||||
/* error reading dir, should never occur */
|
||||
iso_msg_sorry(image->messenger, LIBISO_CANT_READ_FILE,
|
||||
"Error reading dir");
|
||||
iso_msg_sorry(image->id, LIBISO_CANT_READ_FILE, "Error reading dir");
|
||||
action = result;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user