Made use of ISO_ERR_SEV() and ISO_ERR_PRIO()

This commit is contained in:
Thomas Schmitt 2008-02-03 13:16:18 +00:00
parent 0ce9be5c2d
commit eca39c33e0
6 changed files with 245 additions and 46 deletions

View File

@ -638,3 +638,81 @@ int isoburn_get_fifo_status(struct burn_drive *d, int *size, int *free_bytes,
}
/* <<< to be replaced by libburn-0.4.3 API call burn_sev_to_text().
This is a copy of libdax_msgs__sev_to_text() which is not exposed
by the API of of libburn-0.4.2 . As soon as xorriso gets based on
libburn-0.4.4 this redundancy is to be removed.
It is safe, nevertheless, because the severity codes are eternal.
*/
#define LIBDAX_MSGS_SEV_ALL 0x00000000
#define LIBDAX_MSGS_SEV_DEBUG 0x10000000
#define LIBDAX_MSGS_SEV_UPDATE 0x20000000
#define LIBDAX_MSGS_SEV_NOTE 0x30000000
#define LIBDAX_MSGS_SEV_HINT 0x40000000
#define LIBDAX_MSGS_SEV_WARNING 0x50000000
#define LIBDAX_MSGS_SEV_SORRY 0x60000000
#define LIBDAX_MSGS_SEV_FAILURE 0x68000000
#define LIBDAX_MSGS_SEV_FATAL 0x70000000
#define LIBDAX_MSGS_SEV_ABORT 0x71000000
#define LIBDAX_MSGS_SEV_NEVER 0x7fffffff
int isoburn__sev_to_text(int severity, char **severity_name,
int flag)
{
if(flag&1) {
*severity_name= "NEVER\nABORT\nFATAL\nFAILURE\nSORRY\nWARNING\nHINT\nNOTE\nUPDATE\nDEBUG\nALL";
return(1);
}
*severity_name= "";
if(severity>=LIBDAX_MSGS_SEV_NEVER)
*severity_name= "NEVER";
else if(severity>=LIBDAX_MSGS_SEV_ABORT)
*severity_name= "ABORT";
else if(severity>=LIBDAX_MSGS_SEV_FATAL)
*severity_name= "FATAL";
else if(severity>=LIBDAX_MSGS_SEV_FAILURE)
*severity_name= "FAILURE";
else if(severity>=LIBDAX_MSGS_SEV_SORRY)
*severity_name= "SORRY";
else if(severity>=LIBDAX_MSGS_SEV_WARNING)
*severity_name= "WARNING";
else if(severity>=LIBDAX_MSGS_SEV_HINT)
*severity_name= "HINT";
else if(severity>=LIBDAX_MSGS_SEV_NOTE)
*severity_name= "NOTE";
else if(severity>=LIBDAX_MSGS_SEV_UPDATE)
*severity_name= "UPDATE";
else if(severity>=LIBDAX_MSGS_SEV_DEBUG)
*severity_name= "DEBUG";
else if(severity>=LIBDAX_MSGS_SEV_ALL)
*severity_name= "ALL";
else {
*severity_name= "";
return(0);
}
return(1);
}
int isoburn_report_iso_error(int iso_error_code, char msg_text[], int os_errno,
char min_severity[], int flag)
{
int error_code, iso_sev, min_sev, ret;
char *sev_text_pt, *msg_text_pt= NULL;
error_code= 0x00050000 | ISO_ERR_CODE(iso_error_code);
if(iso_error_code<0)
msg_text_pt= (char *) iso_error_to_msg(iso_error_code);
if(msg_text_pt==NULL)
msg_text_pt= msg_text;
iso_sev= ISO_ERR_SEV(iso_error_code);
sev_text_pt= min_severity;
burn_text_to_sev(min_severity, &min_sev, 0);
if(min_sev < iso_sev)
/* >>> with libburn-0.4.4 do: burn_sev_to_text(iso_sev, &sev_text_pt, 0); */
isoburn__sev_to_text(iso_sev, &sev_text_pt, 0);
ret= burn_msgs_submit(error_code, msg_text_pt, os_errno, sev_text_pt, NULL);
return(ret);
}

View File

@ -80,8 +80,10 @@ int isoburn_new(struct isoburn **objpt, int flag)
o->prev= NULL;
o->next= NULL;
ret= iso_image_new("ISOIMAGE", &o->image);
if(ret<0)
if(ret<0) {
isoburn_report_iso_error(ret, "Cannot create image", 0, "FATAL", 0);
goto failed;
}
isoburn_link(o, isoburn_list_start, 1);
return(1);
failed:;
@ -285,8 +287,10 @@ int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc,
}
ret = iso_write_opts_new(&wopts, 0);
if (ret < 0)
goto ex;
if (ret < 0) {
isoburn_report_iso_error(ret, "Cannot create iso_write_opts", 0, "FATAL",0);
goto ex;
}
iso_write_opts_set_iso_level(wopts, opts->level);
iso_write_opts_set_rockridge(wopts, opts->rockridge);
iso_write_opts_set_joliet(wopts, opts->joliet);
@ -330,8 +334,10 @@ int isoburn_prepare_disc_aux(struct burn_drive *d, struct burn_disc **disc,
}
ret = iso_image_create_burn_source(o->image, wopts, &wsrc);
if (ret < 0)
if (ret < 0) {
isoburn_report_iso_error(ret, "Cannot create burn source", 0, "FAILURE", 0);
{ret= -1; goto ex;}
}
/* TODO check return values for failure. propertly clean-up on error */

View File

@ -36,8 +36,6 @@ struct isoburn {
struct isoburn *next;
/* --- My part --- */
/* Start address as given by image examination (bytes, not blocks) */
off_t min_start_byte;
@ -62,8 +60,6 @@ struct isoburn {
int wrote_well;
/* --- Vreixo's part --- */
/* Buffered ISO head from media (should that become part of
ecma119_read_opts ?) */
uint8_t target_iso_head[65536];
@ -102,6 +98,20 @@ int isoburn_find_by_drive(struct isoburn **pt, struct burn_drive *d, int flag);
/* Non API inner interfaces */
/* Submit a libisofs error to the libburn messenger. An application message
reader shall recognize the error code range and attribute it to the
libisofs message channel to which one cannot submit via API.
@param iso_error_code return value <= 0 from a libisofs API call.
@param default_msg_text is to be put out if iso_error_code leads to no
error message
@param os_errno operating system errno, submit 0 if none is known
@param min_severity minimum severity, might be be increased if libisofs
error severity surpasses min_severity.
@param flag Bitfield, submit 0 for now
*/
int isoburn_report_iso_error(int iso_error_code, char default_msg_text[],
int os_errno, char min_severity[], int flag);
/* Calls from burn_wrap.c into isofs_wrap.c */
int isoburn_start_emulation(struct isoburn *o, int flag);

View File

@ -143,14 +143,18 @@ int isoburn_read_image(struct burn_drive *d,
return -1;
/* create a new image */
ret = iso_image_new("ISOIMAGE", image);
if (ret < 0)
if (ret < 0) {
isoburn_report_iso_error(ret, "Cannot create image", 0, "FATAL", 0);
return ret;
}
} else {
/* Blank new image for the drive */
iso_image_unref(o->image);
ret = iso_image_new("ISOIMAGE", &o->image);
if (ret < 0)
if (ret < 0) {
isoburn_report_iso_error(ret, "Cannot create image", 0, "FATAL", 0);
return ret;
}
if (image) {
*image = o->image;
iso_image_ref(*image); /*protects object from premature free*/
@ -173,8 +177,10 @@ int isoburn_read_image(struct burn_drive *d,
/* create the data source */
ret = iso_read_opts_new(&ropts, 0);
if (ret < 0)
if (ret < 0) {
isoburn_report_iso_error(ret, "Cannot create write opts", 0, "FATAL", 0);
return ret;
}
/* Important: do not return until iso_read_opts_free() */
iso_read_opts_set_start_block(ropts, ms_block);
iso_read_opts_set_no_rockridge(ropts, read_opts->norock);
@ -190,11 +196,13 @@ int isoburn_read_image(struct burn_drive *d,
ret = iso_image_import(o->image, ds, ropts, &features);
iso_read_opts_free(ropts);
iso_data_source_unref(ds);
if (ret < 0)
if (ret < 0) {
isoburn_report_iso_error(ret, "Cannot import image", 0, "FAILURE", 0);
return ret;
}
/* Important: do not return until free(features) */
if (image) {
if (image!=NULL) {
*image = o->image;
iso_image_ref(*image); /*protects object from premature free*/
}

View File

@ -1 +1 @@
#define Xorriso_timestamP "2008.02.02.181200"
#define Xorriso_timestamP "2008.02.03.131525"

View File

@ -161,14 +161,8 @@ LIBISOBURN_MISCONFIGURATION_ = 0;
return(-1);
}
if(reason[0]) {
sprintf(xorriso->info_text, "%s", reason);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
}
xorriso->libs_are_started= 1;
queue_sev= "DEBUG";
if(xorriso->library_msg_direct_print) {
@ -189,6 +183,11 @@ LIBISOBURN_MISCONFIGURATION_ = 0;
burn_set_signal_handling(handler_prefix, NULL, 0);
Xorriso_process_msg_queues(xorriso,0);
if(reason[0]) {
sprintf(xorriso->info_text, "%s", reason);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
}
sprintf(xorriso->info_text, "Library startup done.\n");
Xorriso_info(xorriso, 0);
free(handler_prefix);
@ -235,6 +234,87 @@ int Xorriso_get_drive_handles(struct XorrisO *xorriso,
}
/* <<< to be replaced by libburn-0.4.3 API call burn_sev_to_text().
This is a copy of libdax_msgs__sev_to_text() which is not exposed
by the API of of libburn-0.4.2 . As soon as xorriso gets based on
libburn-0.4.4 this redundancy is to be removed.
It is safe, nevertheless, because the severity codes are eternal.
*/
#define LIBDAX_MSGS_SEV_ALL 0x00000000
#define LIBDAX_MSGS_SEV_DEBUG 0x10000000
#define LIBDAX_MSGS_SEV_UPDATE 0x20000000
#define LIBDAX_MSGS_SEV_NOTE 0x30000000
#define LIBDAX_MSGS_SEV_HINT 0x40000000
#define LIBDAX_MSGS_SEV_WARNING 0x50000000
#define LIBDAX_MSGS_SEV_SORRY 0x60000000
#define LIBDAX_MSGS_SEV_FAILURE 0x68000000
#define LIBDAX_MSGS_SEV_FATAL 0x70000000
#define LIBDAX_MSGS_SEV_ABORT 0x71000000
#define LIBDAX_MSGS_SEV_NEVER 0x7fffffff
int Xorriso__sev_to_text(int severity, char **severity_name,
int flag)
{
if(flag&1) {
*severity_name= "NEVER\nABORT\nFATAL\nFAILURE\nSORRY\nWARNING\nHINT\nNOTE\nUPDATE\nDEBUG\nALL";
return(1);
}
*severity_name= "";
if(severity>=LIBDAX_MSGS_SEV_NEVER)
*severity_name= "NEVER";
else if(severity>=LIBDAX_MSGS_SEV_ABORT)
*severity_name= "ABORT";
else if(severity>=LIBDAX_MSGS_SEV_FATAL)
*severity_name= "FATAL";
else if(severity>=LIBDAX_MSGS_SEV_FAILURE)
*severity_name= "FAILURE";
else if(severity>=LIBDAX_MSGS_SEV_SORRY)
*severity_name= "SORRY";
else if(severity>=LIBDAX_MSGS_SEV_WARNING)
*severity_name= "WARNING";
else if(severity>=LIBDAX_MSGS_SEV_HINT)
*severity_name= "HINT";
else if(severity>=LIBDAX_MSGS_SEV_NOTE)
*severity_name= "NOTE";
else if(severity>=LIBDAX_MSGS_SEV_UPDATE)
*severity_name= "UPDATE";
else if(severity>=LIBDAX_MSGS_SEV_DEBUG)
*severity_name= "DEBUG";
else if(severity>=LIBDAX_MSGS_SEV_ALL)
*severity_name= "ALL";
else {
*severity_name= "";
return(0);
}
return(1);
}
/* @param flag bit0=report libisofs error text */
int Xorriso_report_iso_error(struct XorrisO *xorriso,
int iso_error_code, char msg_text[], int os_errno,
char min_severity[], int flag)
{
int error_code, iso_sev, min_sev, ret;
char *sev_text_pt, *msg_text_pt= NULL;
error_code= 0x00050000 | ISO_ERR_CODE(iso_error_code);
if(flag&1)
msg_text_pt= (char *) iso_error_to_msg(iso_error_code);
if(msg_text_pt==NULL)
msg_text_pt= msg_text;
iso_sev= ISO_ERR_SEV(iso_error_code);
sev_text_pt= min_severity;
burn_text_to_sev(min_severity, &min_sev, 0);
if(min_sev < iso_sev)
/* >>> with libburn-0.4.4 do: burn_sev_to_text(iso_sev, &sev_text_pt, 0); */
Xorriso__sev_to_text(iso_sev, &sev_text_pt, 0);
ret= Xorriso_msgs_submit(xorriso, error_code, msg_text_pt,
os_errno, sev_text_pt, 0);
return(ret);
}
/* @param flag bit0= suppress DEBUG messages */
int Xorriso_set_image_severities(struct XorrisO *xorriso, int flag)
{
@ -298,7 +378,7 @@ int Xorriso_create_empty_iso(struct XorrisO *xorriso, int flag)
isoburn_ropt_destroy(&ropts, 0);
if(ret<=0) {
sprintf(xorriso->info_text, "Failed to create new empty ISO image object");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
Xorriso_report_iso_error(xorriso, ret, xorriso->info_text, 0, "FATAL", 0);
return(-1);
}
xorriso->in_volset_handle= (void *) volset;
@ -1191,12 +1271,18 @@ cannot_lstat:;
ret= Xorriso_transfer_properties(xorriso, &stbuf, node, 0);
if(ret<=0)
goto was_problem;
} else
} else {
Xorriso_report_iso_error(xorriso, ret, "Cannot create symbolic link",
0, "SORRY", 1);
{ret= 0; goto was_problem;}
}
} else {
ret= iso_tree_add_node(volume, dir, srcpt, &node);
if(ret<0)
if(ret<0) {
Xorriso_report_iso_error(xorriso, ret, "Cannot add node to tree",
0, "SORRY", 1);
goto was_problem;
}
}
}
if(node==NULL) {
@ -1392,6 +1478,8 @@ handle_path_node:;
ret= iso_tree_add_new_dir(dir, apt, &hdir);
if(ret<0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, ret, "Cannot create directory",
0, "SORRY", 1);
sprintf(xorriso->info_text,
"While grafting '%s' : could not insert '%s'", img_path, path);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
@ -1422,6 +1510,8 @@ attach_source:;
ret= iso_tree_add_node(volume, dir, disk_path, &node);
if(ret<0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, ret, "Cannot create node",
0, "SORRY", 1);
sprintf(xorriso->info_text, "Grafting failed: %s = %s",
Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
@ -1452,7 +1542,7 @@ int Xorriso__text_to_sev(char *severity_name, int *severity_number, int flag)
int Xorriso_process_msg_queues(struct XorrisO *xorriso, int flag)
{
int ret, error_code= 0, os_errno= 0, count= 0, pass, imgid;
int ret, error_code= 0, os_errno= 0, count= 0, pass, imgid, tunneled;
char severity[80];
if(!xorriso->libs_are_started)
@ -1462,13 +1552,15 @@ int Xorriso_process_msg_queues(struct XorrisO *xorriso, int flag)
if(pass==0)
ret= iso_obtain_msgs("ALL", &error_code, &imgid,
xorriso->info_text, severity);
else
else {
ret= burn_msgs_obtain("ALL", &error_code, xorriso->info_text, &os_errno,
severity);
tunneled= (error_code>=0x00050000 && error_code<0x00060000);
}
if(ret<=0)
break;
Xorriso_msgs_submit(xorriso, error_code, xorriso->info_text, os_errno,
severity, (pass+1)<<2);
severity, ((pass&&!tunneled)+1)<<2);
count++;
}
}
@ -1889,6 +1981,17 @@ int Xorriso_format_media(struct XorrisO *xorriso, int flag)
}
int Xorriso_cannot_create_iter(struct XorrisO *xorriso, int iso_error,int flag)
{
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, iso_error, "Cannot create iter", 0,
"FATAL", 1);
sprintf(xorriso->info_text, "Cannot create IsoDirIter object");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
return(1);
}
/* @param boss_iter If not NULL then this is an iterator suitable for
iso_dir_iter_remove() which is then to be used instead
of iso_node_remove().
@ -1959,8 +2062,7 @@ int Xorriso_rmi(struct XorrisO *xorriso, void *boss_iter,
Xorriso_process_msg_queues(xorriso,0);
if(ret<0) {
cannot_create_iter:;
sprintf(xorriso->info_text, "Cannot create IsoDirIter object");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
Xorriso_cannot_create_iter(xorriso, ret, 0);
ret= -1; goto ex;
}
pl= strlen(path);
@ -2077,7 +2179,8 @@ dir_not_removed:;
} else
ret= iso_node_remove(victim_node);
Xorriso_process_msg_queues(xorriso,0);
if(ret==-1) {
if(ret<0) {
Xorriso_report_iso_error(xorriso, ret, "Cannot remove node", 0, "FATAL", 1);
sprintf(xorriso->info_text,
"Internal failure to remove %s from loaded ISO image",
Text_shellsafe(path, sfe, 0));
@ -2141,8 +2244,7 @@ int Xorriso_sorted_node_array(struct XorrisO *xorriso,
ret= iso_dir_get_children(dir_node, &iter);
if(ret<0) {
sprintf(xorriso->info_text, "Cannot create IsoDirIter object");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
Xorriso_cannot_create_iter(xorriso, ret, 0);
return(-1);
}
@ -2198,9 +2300,7 @@ int Xorriso_show_du_subs(struct XorrisO *xorriso, IsoDir *dir_node,
ret= iso_dir_get_children(dir_node, &iter);
if(ret<0) {
cannot_create_iter:;
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text, "Cannot obtain ISO directory iterator");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
Xorriso_cannot_create_iter(xorriso, ret, 0);
{ret= -1; goto ex;}
}
for(i= 0; iso_dir_iter_next(iter, &node) == 1; ) {
@ -2404,9 +2504,7 @@ int Xorriso_sorted_dir_i(struct XorrisO *xorriso, IsoDir *dir_node,
ret= iso_dir_get_children(dir_node, &iter);
if(ret<0) {
cannot_iter:;
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text, "Cannot obtain ISO directory iterator");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
Xorriso_cannot_create_iter(xorriso, ret, 0);
{ret= -1; goto ex;}
}
mem= 0;
@ -2616,9 +2714,7 @@ wdi_is_not_a_dir:;
ret= iso_dir_get_children(dir_node, &iter);
if(ret<0) {
cannot_create_iter:;
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text, "Cannot obtain ISO directory iterator");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
Xorriso_cannot_create_iter(xorriso, ret, 0);
{ret= -1; goto ex;}
}
Xorriso_process_msg_queues(xorriso,0);
@ -2803,6 +2899,7 @@ int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest, int flag)
ret= iso_node_take(node);
if(ret<0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, 0, "Cannot take", 0, "FATAL", 1);
sprintf(xorriso->info_text,
"Internal error on rename: failed to take node");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
@ -2811,6 +2908,7 @@ int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest, int flag)
ret= iso_dir_add_node(dest_dir, node, 0);
if(ret<0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, 0, "Cannot add", 0, "FATAL", 1);
sprintf(xorriso->info_text,
"Internal error on rename: failed to insert node");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
@ -2825,8 +2923,11 @@ int Xorriso_rename(struct XorrisO *xorriso, char *origin, char *dest, int flag)
old_leafname= (char *) iso_node_get_name(node);
if(strcmp(leafname, old_leafname)!=0)
ret= iso_node_set_name(node, leafname);
else
ret= 1;
if(ret<0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, 0, "Cannot set name", 0, "FATAL", 1);
sprintf(xorriso->info_text, "Internal error on rename: failed to set name");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
return(-1);
@ -2908,9 +3009,7 @@ int Xorriso_obtain_pattern_files_i(
ret= iso_dir_get_children(dir, &iter);
if(ret<0) {
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text, "Cannot obtain ISO directory iterator");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
Xorriso_cannot_create_iter(xorriso, ret, 0);
{ret= -1; goto ex;}
}
while(iso_dir_iter_next(iter, &node) == 1) {
@ -3274,9 +3373,7 @@ int Xorriso_findi(struct XorrisO *xorriso, struct FindjoB *job,
ret= iso_dir_get_children(dir_node, &iter);
if(ret<0) {
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text, "Cannot obtain ISO directory iterator");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
Xorriso_cannot_create_iter(xorriso, ret, 0);
{ret= -1; goto ex;}
}
while(iso_dir_iter_next(iter, &node) == 1 && !xorriso->request_to_abort) {