Fixed several bugs with restorie operations
This commit is contained in:
@ -1253,6 +1253,7 @@ int Xorriso_node_from_path(struct XorrisO *xorriso, IsoImage *volume,
|
||||
bit4= (with bit2) determine type of disk file eff_path
|
||||
and return 0 if not existing
|
||||
bit5= (with bit3) this is not a parameter
|
||||
bit6= insist in having an ISO image, even with bits1+2
|
||||
@return -1 = faulty path format, 0 = not found ,
|
||||
1 = found simple node , 2 = found directory
|
||||
*/
|
||||
@ -1265,6 +1266,12 @@ int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *wd,
|
||||
IsoNode *node= NULL;
|
||||
char path[SfileadrL], *apt, *npt, sfe[5*SfileadrL], *cpt;
|
||||
|
||||
if((flag&64) || !(flag&2)) {
|
||||
ret= Xorriso_get_volume(xorriso, &volume, 0);
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
eff_path[0]= 0;
|
||||
if(img_path[0]==0) {
|
||||
if(flag&8)
|
||||
@ -1272,12 +1279,6 @@ int Xorriso_normalize_img_path(struct XorrisO *xorriso, char *wd,
|
||||
return(2); /* root directory */
|
||||
}
|
||||
|
||||
if(!(flag&2)) {
|
||||
ret= Xorriso_get_volume(xorriso, &volume, 0);
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
}
|
||||
|
||||
apt= npt= path;
|
||||
if(img_path[0]!='/') {
|
||||
strcpy(path, wd);
|
||||
@ -1473,7 +1474,7 @@ int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf,
|
||||
}
|
||||
|
||||
|
||||
/* @param flag >>> bit0= follow links (i.e. stat() rather than lstat()
|
||||
/* @param flag >>> bit0= follow links (i.e. stat() rather than lstat()
|
||||
bit1= do not return -2 on severe errors
|
||||
bit2= complain loudely if path is missing in image
|
||||
*/
|
||||
@ -1621,6 +1622,8 @@ ex:;
|
||||
"Cannot add node to tree", 0, "FAILURE", 1|2);
|
||||
return(ret);
|
||||
}
|
||||
if(LIBISO_ISREG(*node))
|
||||
xorriso->pacifier_byte_count+= iso_file_get_size((IsoFile *) *node);
|
||||
return(1);
|
||||
}
|
||||
|
||||
@ -2469,6 +2472,7 @@ int Xorriso_restore_implicit_properties(struct XorrisO *xorriso,
|
||||
bit1= offset and bytes is valid for writing to regular file
|
||||
bit2= This is not a parameter. Do not report if ignored
|
||||
bit3= do not restore properties
|
||||
bit4= issue pacifier messages with long lasting copying
|
||||
@return <0 severe error , 0 failure , 1 success ,
|
||||
2 regularly not installed (disallowed device, UNIX domain socket)
|
||||
*/
|
||||
@ -2480,7 +2484,7 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
||||
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;
|
||||
off_t todo, size, seek_ret;
|
||||
off_t todo, size, seek_ret, last_p_count= 0;
|
||||
void *data_stream= NULL;
|
||||
mode_t mode;
|
||||
dev_t dev= 0;
|
||||
@ -2493,13 +2497,10 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
||||
|
||||
} else if(LIBISO_ISREG(node)) {
|
||||
what= "regular file";
|
||||
|
||||
/* >>> need to exploit node rather than img_path */
|
||||
ret= Xorriso_iso_file_open(xorriso, img_path, &data_stream, 0);
|
||||
|
||||
ret= Xorriso_iso_file_open(xorriso, img_path, (void *) node, &data_stream,
|
||||
1);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
|
||||
open_path_pt= disk_path;
|
||||
ret= stat(open_path_pt, &stbuf);
|
||||
if(flag&2) {
|
||||
@ -2560,8 +2561,17 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
||||
if(ret<=0)
|
||||
break;
|
||||
wret= write(write_fd, buf, ret);
|
||||
if(wret>=0)
|
||||
if(wret>=0) {
|
||||
todo-= wret;
|
||||
xorriso->pacifier_byte_count+= wret;
|
||||
if((flag&16) &&
|
||||
xorriso->pacifier_byte_count - last_p_count >= 128*1024) {
|
||||
Xorriso_pacifier_callback(xorriso, "files restored",
|
||||
xorriso->pacifier_count,
|
||||
xorriso->pacifier_total, "", 2|4);
|
||||
last_p_count= xorriso->pacifier_byte_count;
|
||||
}
|
||||
}
|
||||
if(wret != ret) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Cannot write all bytes to disk filesystem path %s",
|
||||
@ -2728,7 +2738,7 @@ int Xorriso_restore_disk_object(struct XorrisO *xorriso,
|
||||
off_t offset, off_t bytes, int flag)
|
||||
{
|
||||
int ret, i, split_count= 0, partno, total_parts, leaf_is_split= 0;
|
||||
off_t total_bytes;
|
||||
off_t total_bytes, was_byte_count;
|
||||
char *part_name, part_path[SfileadrL], *img_path_pt;
|
||||
char sfe[5*SfileadrL], sfe2[5*SfileadrL];
|
||||
IsoImage *volume;
|
||||
@ -2739,6 +2749,8 @@ int Xorriso_restore_disk_object(struct XorrisO *xorriso,
|
||||
ret= Xorriso_get_volume(xorriso, &volume, 0);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
|
||||
was_byte_count= xorriso->pacifier_byte_count;
|
||||
|
||||
if(LIBISO_ISDIR(node) && xorriso->do_concat_split)
|
||||
leaf_is_split= Xorriso_identify_split(xorriso, img_path, node,
|
||||
@ -2763,8 +2775,8 @@ int Xorriso_restore_disk_object(struct XorrisO *xorriso,
|
||||
if(offset+bytes>total_bytes)
|
||||
bytes= total_bytes-offset;
|
||||
ret= Xorriso_tree_restore_node(xorriso, part_node, part_path, disk_path,
|
||||
offset, bytes,
|
||||
(!!(flag&64)) | 2 | (flag&4) | 8);
|
||||
offset, bytes,
|
||||
(!!(flag&64)) | 2 | (flag&4) | 8 | ( 16 * !(flag&2)));
|
||||
if(ret<=0)
|
||||
goto restoring_failed;
|
||||
}
|
||||
@ -2788,8 +2800,8 @@ int Xorriso_restore_disk_object(struct XorrisO *xorriso,
|
||||
img_path_pt= img_path;
|
||||
|
||||
ret= Xorriso_tree_restore_node(xorriso, node, img_path_pt, disk_path,
|
||||
offset, bytes,
|
||||
(flag&(4|8)) | (!!(flag&64)) | ((flag&1)<<1));
|
||||
offset, bytes,
|
||||
(flag&(4|8)) | (!!(flag&64)) | ((flag&1)<<1) | ( 16 * !(flag&2)));
|
||||
if(ret>0 && (flag&8))
|
||||
ret= Xorriso_restore_properties(xorriso, disk_path, node, 2 | !!(flag&64));
|
||||
if(ret<=0) {
|
||||
@ -2803,10 +2815,10 @@ restoring_failed:;
|
||||
{ret= 3; goto ex;}
|
||||
went_well:;
|
||||
xorriso->pacifier_count++;
|
||||
if(xorriso->pacifier_count%100 && !(flag&2))
|
||||
if(!(flag&2))
|
||||
Xorriso_pacifier_callback(xorriso, "files restored",
|
||||
xorriso->pacifier_count,
|
||||
xorriso->pacifier_total, "", 0);
|
||||
xorriso->pacifier_total, "", 4);
|
||||
ret= 1;
|
||||
ex:;
|
||||
if(split_parts!=NULL)
|
||||
@ -3221,11 +3233,9 @@ int Xorriso_restore(struct XorrisO *xorriso,
|
||||
if(ret==-1) {
|
||||
Xorriso_process_msg_queues(xorriso,0);
|
||||
Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0);
|
||||
Xorriso_report_iso_error(xorriso, disk_path, ret,
|
||||
"Cannot create disk directory", 0, "FAILURE", 1);
|
||||
sprintf(xorriso->info_text,
|
||||
"While restoring '%s' : could not insert '%s'", disk_path, path);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
|
||||
{ret= 0; goto ex;}
|
||||
}
|
||||
if(!done) {
|
||||
@ -3235,7 +3245,7 @@ int Xorriso_restore(struct XorrisO *xorriso,
|
||||
}
|
||||
new_dir_made= 1;
|
||||
} else if(source_is_dir && !source_is_split) {
|
||||
Xorriso_auto_chmod(xorriso, disk_path, 0);
|
||||
Xorriso_auto_chmod(xorriso, path, 0);
|
||||
}
|
||||
if(done) {
|
||||
attach_source:;
|
||||
@ -6071,7 +6081,7 @@ int Xorriso_get_profile(struct XorrisO *xorriso, int *profile_number,
|
||||
|
||||
|
||||
int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname,
|
||||
void **stream, int flag)
|
||||
void *node_pt, void **stream, int flag)
|
||||
{
|
||||
int ret;
|
||||
char eff_path[SfileadrL];
|
||||
@ -6087,9 +6097,13 @@ int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname,
|
||||
#endif
|
||||
|
||||
*stream= NULL;
|
||||
ret= Xorriso_get_node_by_path(xorriso, pathname, eff_path, &node, 0);
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
if(flag&1) {
|
||||
node= (IsoNode *) node_pt;
|
||||
} else {
|
||||
ret= Xorriso_get_node_by_path(xorriso, pathname, eff_path, &node, 0);
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
}
|
||||
if(!LIBISO_ISREG(node)) {
|
||||
sprintf(xorriso->info_text,
|
||||
"Given path does not lead to a regular data file in the image");
|
||||
|
Reference in New Issue
Block a user