Producing ERRFILE messages where appropriate

This commit is contained in:
2008-02-22 11:49:57 +00:00
parent 1f01e954d4
commit 5fe8ac9f7f
4 changed files with 76 additions and 18 deletions

View File

@ -316,7 +316,9 @@ int Xorriso__text_to_sev(char *severity_name, int *severity_number, int flag)
}
/* @param flag bit0=report libisofs error text */
/* @param flag bit0= report libisofs error text
bit1= victim is disk_path
*/
int Xorriso_report_iso_error(struct XorrisO *xorriso, char *victim,
int iso_error_code, char msg_text[], int os_errno,
char min_severity[], int flag)
@ -324,6 +326,10 @@ int Xorriso_report_iso_error(struct XorrisO *xorriso, char *victim,
int error_code, iso_sev, min_sev, ret;
char *sev_text_pt, *msg_text_pt= NULL;
char sfe[6*SfileadrL];
static int sorry_sev= -1;
if(sorry_sev<0)
Xorriso__text_to_sev("SORRY", &sorry_sev, 0);
error_code= iso_error_get_code(iso_error_code);
if(error_code < 0x00030000 || error_code >= 0x00040000)
@ -334,6 +340,9 @@ int Xorriso_report_iso_error(struct XorrisO *xorriso, char *victim,
if(msg_text_pt==NULL)
msg_text_pt= msg_text;
iso_sev= iso_error_get_severity(iso_error_code);
if(iso_sev >= sorry_sev && (flag & 2) && victim[0])
Xorriso_msgs_submit(xorriso, 0, victim, 0, "ERRFILE", 0);
sev_text_pt= min_severity;
Xorriso__text_to_sev(min_severity, &min_sev, 0);
if(min_sev < iso_sev)
@ -1449,6 +1458,7 @@ int Xorriso_add_tree(struct XorrisO *xorriso, IsoDir *dir,
}
if(ret==0) {
cannot_open_dir:;
Xorriso_msgs_submit(xorriso, 0, disk_dir_path, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,"Cannot open as source directory: %s",
Text_shellsafe(disk_dir_path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
@ -1487,6 +1497,7 @@ cannot_open_dir:;
stbuf_src= srcpt;
if(lstat(srcpt, &stbuf)==-1) {
cannot_lstat:;
Xorriso_msgs_submit(xorriso, 0, srcpt, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,
"Cannot determine attributes of source file %s",
Text_shellsafe(srcpt, sfe, 0));
@ -1525,8 +1536,9 @@ cannot_lstat:;
#ifdef NIX
} else if(!(S_ISREG(stbuf.st_mode) || S_ISLNK(stbuf.st_mode))) {
Xorriso_msgs_submit(xorriso, 0, stbuf_src, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,"Source file %s %s non-supported file type",
Text_shellsafe(disk_path, sfe, 0),
Text_shellsafe(srcpt, sfe, 0),
source_is_link ? "leads to" : "is of");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto was_problem;
@ -1556,9 +1568,10 @@ cannot_lstat:;
}
node= NULL;
} else {
Xorriso_msgs_submit(xorriso, 0, srcpt, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,
"While grafting %s : file object exists and may not be overwritten",
Text_shellsafe(img_path,sfe,0));
"While grafting %s : file object exists and may not be overwritten by %s",
Text_shellsafe(img_path,sfe,0), Text_shellsafe(stbuf_src,sfe2,0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto was_problem;
}
@ -1580,22 +1593,23 @@ cannot_lstat:;
goto was_problem;
} else {
Xorriso_report_iso_error(xorriso, stbuf_src, ret,
"Cannot create symbolic link", 0, "FAILURE", 1);
"Cannot create symbolic link", 0, "FAILURE", 1|2);
{ret= 0; goto was_problem;}
}
} else {
ret= iso_tree_add_node(volume, dir, srcpt, &node);
if(ret<0) {
Xorriso_report_iso_error(xorriso, stbuf_src, ret,
"Cannot add node to tree", 0, "FAILURE", 1);
"Cannot add node to tree", 0, "FAILURE", 1|2);
goto was_problem;
}
}
}
if(node==NULL) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_msgs_submit(xorriso, 0, stbuf_src, 0, "ERRFILE", 0);
sprintf(xorriso->info_text, "Grafting failed: %s = %s",
Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0));
Text_shellsafe(img_path,sfe,0), Text_shellsafe(stbuf_src,sfe2,0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret=0; goto was_problem;
}
@ -1726,8 +1740,10 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
break;
}
if(cpt!=NULL) {
Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,
"Unsupported relative addressing in iso_rr_path '%s'", img_path);
"Unsupported relative addressing in iso_rr_path %s (disk: %s)",
Text_shellsafe(img_path, sfe, 0), Text_shellsafe(disk_path, sfe2, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
return(0);
}
@ -1747,8 +1763,10 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
ret= lstat(disk_path, &stbuf);
if(ret == -1) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,
"Cannot determine attributes of source file '%s'",disk_path);
"Cannot determine attributes of source file %s",
Text_shellsafe(disk_path, sfe, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
return(0);
}
@ -1758,6 +1776,7 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
#ifdef NIX
} else if(!(S_ISREG(stbuf.st_mode) || S_ISLNK(stbuf.st_mode))) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,
"Source file '%s' is of non-supported file type", disk_path);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
@ -1770,9 +1789,10 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
if(img_path[l-1]=='/')
l= 0;
if(l==0) {
Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,
"Source '%s' is not a directory. Target '%s' would be.",
disk_path, img_path);
"Source '%s' is not a directory. Target '%s' would be.",
Text_shellsafe(disk_path, sfe, 0), Text_shellsafe(img_path, sfe2, 0));
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
@ -1824,6 +1844,7 @@ int Xorriso_graft_in(struct XorrisO *xorriso, char *disk_path, char *img_path,
goto handle_path_node;
}
Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,
"While grafting '%s' : '%s' exists and may not be overwritten",
img_path, path);
@ -1838,6 +1859,7 @@ handle_path_node:;
ret= iso_tree_add_new_dir(dir, apt, &hdir);
if(ret<0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0);
Xorriso_report_iso_error(xorriso, img_path, ret,
"Cannot create directory", 0, "FAILURE", 1);
sprintf(xorriso->info_text,
@ -1878,6 +1900,7 @@ attach_source:;
ret= iso_tree_add_node(volume, dir, disk_path, &node);
if(ret<0) {
Xorriso_process_msg_queues(xorriso,0);
Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0);
Xorriso_report_iso_error(xorriso, img_path, ret, "Cannot create node",
0, "FAILURE", 1);
sprintf(xorriso->info_text, "Grafting failed: %s = %s",
@ -1927,6 +1950,8 @@ int Xorriso_process_msg_queues(struct XorrisO *xorriso, int flag)
if(error_code==0x5ff73 || error_code==0x3ff73 ||
error_code==0x3feb9 || error_code==0x3feb2)
strcpy(severity, "MISHAP");
else if(error_code==0x51001)
strcpy(severity, "ERRFILE");
Xorriso_msgs_submit(xorriso, error_code, xorriso->info_text, os_errno,
severity, ((pass+tunneled)+1)<<2);
@ -3873,14 +3898,16 @@ int Xorriso_set_abort_severity(struct XorrisO *xorriso, int flag)
int ret;
/* <<< On MISHAP use FAILURE as abort severity known to libisofs.
On ERRFILE use NEVER.
The pacifier loop will care for canceling libburn on MISHAP
and thus also cancel the image generation.
with libisofs-0.6.4 this should not be necessary
*/
if((flag&1) && strcmp(xorriso->abort_on_text, "MISHAP")==0)
ret= iso_set_abort_severity("FAILURE");
else if((flag&1) && strcmp(xorriso->abort_on_text, "ERRFILE")==0)
ret= iso_set_abort_severity("NEVER");
else
ret= iso_set_abort_severity(xorriso->abort_on_text);
return(ret>=0);
}