New -error_behavior behavior occasion "file_extraction"
This commit is contained in:
parent
0465f55485
commit
2745faabd2
@ -2,7 +2,7 @@
|
||||
.\" First parameter, NAME, should be all caps
|
||||
.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
|
||||
.\" other parameters are allowed: see man(7), man(1)
|
||||
.TH XORRISO 1 "Aug 22, 2008"
|
||||
.TH XORRISO 1 "Aug 24, 2008"
|
||||
.\" Please adjust this date whenever revising the manpage.
|
||||
.\"
|
||||
.\" Some roff macros, for reference:
|
||||
@ -57,6 +57,8 @@ Can perform multi-session tasks as emulation of mkisofs and cdrecord.
|
||||
.br
|
||||
Can restore files from ISO image to disk filesystem (see osirrox).
|
||||
.br
|
||||
Can check media for damages and copy readable blocks to disk.
|
||||
.br
|
||||
Scans for optical drives, blanks re-useable optical media.
|
||||
.br
|
||||
Reads its instructions from command line arguments, dialog, and batch files.
|
||||
@ -1428,10 +1430,11 @@ of xorriso begin. Only "-report_about" with dash "-" is recognized that way.
|
||||
.TP
|
||||
\fB\-error_behavior\fR occasion behavior
|
||||
Control the program behavior at problem event occasions.
|
||||
For now this applies to occasions "image_loading" which is given while
|
||||
an image tree is read from the input device, and to "file_extraction" which
|
||||
is given with osirrox options like -extract.
|
||||
.br
|
||||
For now this applies only to occasion "image_loading" which is given while
|
||||
an image tree is read from the input device. There are three behaviors
|
||||
available:
|
||||
With "image_loading" there are three behaviors available:
|
||||
.br
|
||||
"best_effort" goes on with reading after events with severity below FAILURE
|
||||
if the threshold of option -abort_on allows this.
|
||||
@ -1441,6 +1444,11 @@ It issues an own FAILURE event.
|
||||
.br
|
||||
"fatal" acts like "failure" but issues the own event as FATAL.
|
||||
This is the default.
|
||||
.br
|
||||
With occasion "file_extraction" there are two behaviors:
|
||||
.br
|
||||
"keep" maintains incompletely extracted files on disk. "delete" removes
|
||||
files which encountered errors during content extraction.
|
||||
.TP
|
||||
.B Dialog mode control:
|
||||
.TP
|
||||
@ -2458,7 +2466,21 @@ Avoid to eventually create /home/thomas/restored without rwx-permission.
|
||||
-extract /personal_mail /home/thomas/restored/personal_mail
|
||||
.br
|
||||
-rollback_end
|
||||
.SS
|
||||
.B Try to retrieve as many blocks as possible from a damaged media
|
||||
.br
|
||||
\fB$\fR xorriso -abort_on NEVER -indev /dev/sr0 \\
|
||||
.br
|
||||
-check_media time_limit=1800 report=blocks_files \\
|
||||
.br
|
||||
data_to="$HOME"/dvd_copy sector_map="$HOME"/dvd_copy.map --
|
||||
.br
|
||||
This can be repeated several times, eventually with -eject or with other
|
||||
-indev drives. See the human readable part of "$HOME"/dvd_copy.map for
|
||||
addresses which can be used on "$HOME"/dvd_copy with mount option sbsector=.
|
||||
.br
|
||||
If you want to make the newest session the default mount session, you
|
||||
may add option "patch_lba0=on" to the final -check_media run.
|
||||
.SH FILES
|
||||
.SS
|
||||
.B Startup files:
|
||||
|
@ -3377,6 +3377,7 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
|
||||
m->errfile_log[0]= 0;
|
||||
m->errfile_fp= NULL;
|
||||
m->img_read_error_mode= 2; /* abort faulty image reading with FATAL */
|
||||
m->extract_error_mode= 1; /* keep extracted files after read error */
|
||||
strcpy(m->return_with_text, "SORRY");
|
||||
Xorriso__text_to_sev(m->return_with_text, &m->return_with_severity, 0);
|
||||
m->return_with_value= 32;
|
||||
@ -4663,6 +4664,13 @@ int Xorriso_status(struct XorrisO *xorriso, char *filter, FILE *fp, int flag)
|
||||
else if(xorriso->img_read_error_mode==2)
|
||||
treatment= "fatal";
|
||||
sprintf(line,"-error_behavior image_loading %s\n", treatment);
|
||||
if(!(is_default && no_defaults))
|
||||
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
||||
is_default= (xorriso->extract_error_mode == 1);
|
||||
treatment= "keep";
|
||||
if(xorriso->extract_error_mode == 2)
|
||||
treatment= "delete";
|
||||
sprintf(line,"-error_behavior file_extraction %s\n", treatment);
|
||||
if(!(is_default && no_defaults))
|
||||
Xorriso_status_result(xorriso,filter,fp,flag&2);
|
||||
|
||||
@ -8899,7 +8907,8 @@ int Xorriso_spotlist_to_sectormap(struct XorrisO *xorriso,
|
||||
if(((off_t) (*map)->sectors) * ((off_t) (*map)->sector_size) >
|
||||
((off_t) list_sectors) * ((off_t) sector_size))
|
||||
list_sectors= (((off_t) (*map)->sectors) *
|
||||
((off_t) (*map)->sector_size)) / sector_size + 1;
|
||||
((off_t) (*map)->sector_size)) / ((off_t) sector_size)
|
||||
+ 1;
|
||||
}
|
||||
ret= Sectorbitmap_new(&m, list_sectors, sector_size, 0);
|
||||
if(ret <= 0)
|
||||
@ -10619,12 +10628,20 @@ int Xorriso_option_error_behavior(struct XorrisO *xorriso,
|
||||
else if(strcmp(behavior, "fatal")==0 || strcmp(behavior, "FATAL")==0)
|
||||
xorriso->img_read_error_mode= 2;
|
||||
else {
|
||||
unknown_behavior:;
|
||||
sprintf(xorriso->info_text,
|
||||
"-error_behavior: with 'image_loading': unknown behavior '%s'",
|
||||
behavior);
|
||||
"-error_behavior: with '%s': unknown behavior '%s'",
|
||||
occasion, behavior);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
return(0);
|
||||
}
|
||||
} else if(strcmp(occasion, "file_extraction")==0) {
|
||||
if(strcmp(behavior, "keep")==0)
|
||||
xorriso->extract_error_mode= 1;
|
||||
else if(strcmp(behavior, "delete")==0)
|
||||
xorriso->extract_error_mode= 2;
|
||||
else
|
||||
goto unknown_behavior;
|
||||
} else {
|
||||
sprintf(xorriso->info_text, "-error_behavior: unknown occasion '%s'",
|
||||
occasion);
|
||||
@ -13989,7 +14006,7 @@ next_command:;
|
||||
if(xorriso->add_plainly>1)
|
||||
goto add_plain_argument;
|
||||
unknown_option:;
|
||||
sprintf(xorriso->info_text, "=== Not a known option:\n === '%s'\n",
|
||||
sprintf(xorriso->info_text, "Not a known option: '%s'\n",
|
||||
original_cmd);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
{ret= 0; goto eval_any_problems;}
|
||||
|
@ -98,10 +98,7 @@ Operates on an existing ISO image or creates a new one.
|
||||
Copies files from filesystem into the ISO image.
|
||||
</LI>
|
||||
<LI>
|
||||
Renames or deletes file objects in the ISO image.
|
||||
</LI>
|
||||
<LI>
|
||||
Changes file properties in the ISO image.
|
||||
Changes file properties, renames or deletes file objects in the ISO image.
|
||||
</LI>
|
||||
<LI>
|
||||
Updates ISO subtrees incrementally to match given disk subtrees.
|
||||
@ -116,6 +113,11 @@ Can perform multi-session tasks as emulation of mkisofs and cdrecord.
|
||||
<LI>
|
||||
Can restore single files and whole trees from ISO image to disk filesystem.
|
||||
</LI>
|
||||
<!--
|
||||
<LI>
|
||||
Can check media for damages and copy readable blocks to disk.
|
||||
</LI>
|
||||
-->
|
||||
<LI>
|
||||
Scans for optical drives, blanks re-useable optical media, formats media.
|
||||
</LI>
|
||||
|
@ -254,6 +254,7 @@ struct XorrisO { /* the global context of xorriso */
|
||||
FILE *errfile_fp;
|
||||
|
||||
int img_read_error_mode; /* 0=best_effort , 1=failure , 2=fatal */
|
||||
int extract_error_mode; /* 0=(not yet: best_effort) , 1=keep , 2=delete */
|
||||
|
||||
char return_with_text[20];
|
||||
int return_with_severity;
|
||||
|
@ -1 +1 @@
|
||||
#define Xorriso_timestamP "2008.08.24.095531"
|
||||
#define Xorriso_timestamP "2008.08.24.100552"
|
||||
|
@ -2556,7 +2556,8 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
||||
char *img_path, char *disk_path,
|
||||
off_t offset, off_t bytes, int flag)
|
||||
{
|
||||
int ret= 0, write_fd= -1, wanted, wret, open_flags;
|
||||
int ret= 0, write_fd= -1, wanted, wret, open_flags, l_errno= 0;
|
||||
int target_deleted= 0;
|
||||
char *what= "[unknown filetype]", sfe[5*SfileadrL], sfe2[5*SfileadrL];
|
||||
char buf[32*1024], type_text[5], temp_path[SfileadrL];
|
||||
char *link_target, *open_path_pt;
|
||||
@ -2570,6 +2571,7 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
||||
if(LIBISO_ISDIR(node)) {
|
||||
what= "directory";
|
||||
ret= mkdir(disk_path, 0777);
|
||||
l_errno= errno;
|
||||
|
||||
} else if(LIBISO_ISREG(node)) {
|
||||
what= "regular file";
|
||||
@ -2585,6 +2587,7 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
||||
"Restore offset demanded. But filesystem path leads to non-data file %s",
|
||||
Text_shellsafe(disk_path, sfe, 0));
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
|
||||
l_errno= 0;
|
||||
goto cannot_restore;
|
||||
}
|
||||
} else {
|
||||
@ -2613,6 +2616,7 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
||||
if(offset==0 || !(flag&2))
|
||||
open_flags|= O_EXCL;
|
||||
write_fd= open(open_path_pt, open_flags, S_IRUSR|S_IWUSR);
|
||||
l_errno= errno;
|
||||
if(write_fd==-1)
|
||||
goto cannot_restore;
|
||||
}
|
||||
@ -2621,6 +2625,7 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
||||
if(bytes<size)
|
||||
todo= size= bytes;
|
||||
seek_ret= lseek(write_fd, offset, SEEK_SET);
|
||||
l_errno= errno;
|
||||
if(seek_ret == -1) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Cannot address byte %.f in filesystem path %s",
|
||||
@ -2658,9 +2663,13 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
||||
}
|
||||
close(write_fd);
|
||||
write_fd= -1;
|
||||
if(todo > 0 && xorriso->extract_error_mode == 2) {
|
||||
unlink(open_path_pt);
|
||||
target_deleted= 1;
|
||||
}
|
||||
Xorriso_iso_file_close(xorriso, &data_stream, 0);
|
||||
data_stream= NULL;
|
||||
if(temp_path==open_path_pt) {
|
||||
if(temp_path==open_path_pt && !target_deleted) {
|
||||
ret= rename(temp_path, disk_path);
|
||||
if(ret==-1) {
|
||||
sprintf(xorriso->info_text,
|
||||
@ -2672,12 +2681,14 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
||||
ret= 0; goto ex;
|
||||
}
|
||||
}
|
||||
ret= (todo==0);
|
||||
ret= -(todo > 0);
|
||||
l_errno= 0;
|
||||
|
||||
} else if(LIBISO_ISLNK(node)) {
|
||||
what= "symbolic link";
|
||||
link_target= (char *) iso_symlink_get_dest((IsoSymlink *) node);
|
||||
ret= symlink(link_target, disk_path);
|
||||
l_errno= errno;
|
||||
|
||||
} else if(LIBISO_ISCHR(node)) {
|
||||
what= "character device";
|
||||
@ -2703,6 +2714,7 @@ probably_damaged:;
|
||||
ret= 0; goto ex;
|
||||
}
|
||||
ret= mknod(disk_path, mode, dev);
|
||||
l_errno= errno;
|
||||
|
||||
} else if(LIBISO_ISBLK(node)) {
|
||||
what= "block device";
|
||||
@ -2715,11 +2727,13 @@ probably_damaged:;
|
||||
if(dev == (dev_t) 1)
|
||||
goto probably_damaged;
|
||||
ret= mknod(disk_path, mode, dev);
|
||||
l_errno= errno;
|
||||
|
||||
} else if(LIBISO_ISFIFO(node)) {
|
||||
what= "named pipe";
|
||||
mode= S_IFIFO | 0777;
|
||||
ret= mknod(disk_path, mode, dev);
|
||||
l_errno= errno;
|
||||
|
||||
} else if(LIBISO_ISSOCK(node)) {
|
||||
what= "unix socket";
|
||||
@ -2737,7 +2751,7 @@ cannot_restore:;
|
||||
sprintf(xorriso->info_text,
|
||||
"Cannot restore %s to disk filesystem: %s",
|
||||
what, Text_shellsafe(img_path, sfe, 0));
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, l_errno, "FAILURE", 0);
|
||||
ret= 0; goto ex;
|
||||
}
|
||||
|
||||
@ -2747,8 +2761,11 @@ restore_properties:;
|
||||
else
|
||||
ret= Xorriso_restore_properties(xorriso, disk_path, node, flag&1);
|
||||
ex:;
|
||||
if(write_fd>0)
|
||||
if(write_fd >= 0) {
|
||||
close(write_fd);
|
||||
if(ret <= 0 && xorriso->extract_error_mode == 2)
|
||||
unlink(open_path_pt);
|
||||
}
|
||||
if(data_stream!=NULL)
|
||||
Xorriso_iso_file_close(xorriso, &data_stream, 0);
|
||||
return(ret);
|
||||
|
Loading…
Reference in New Issue
Block a user