|
|
|
@ -436,6 +436,11 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
|
|
|
|
dev_t dev= 0; |
|
|
|
|
struct stat stbuf; |
|
|
|
|
struct utimbuf utime_buffer; |
|
|
|
|
IsoImage *volume; |
|
|
|
|
IsoBoot *bootcat; |
|
|
|
|
uint32_t lba; |
|
|
|
|
char *catcontent = NULL; |
|
|
|
|
off_t catsize; |
|
|
|
|
|
|
|
|
|
Xorriso_alloc_meM(buf, char, buf_size); |
|
|
|
|
Xorriso_alloc_meM(temp_path, char, SfileadrL); |
|
|
|
@ -445,12 +450,16 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
|
|
|
|
ret= mkdir(disk_path, 0777); |
|
|
|
|
l_errno= errno; |
|
|
|
|
|
|
|
|
|
} else if(LIBISO_ISREG(node)) { |
|
|
|
|
what= "regular file"; |
|
|
|
|
ret= Xorriso_iso_file_open(xorriso, img_path, (void *) node, &data_stream, |
|
|
|
|
1); |
|
|
|
|
if(ret<=0) |
|
|
|
|
goto ex; |
|
|
|
|
} else if(LIBISO_ISREG(node) || ISO_NODE_IS_BOOTCAT(node)) { |
|
|
|
|
if(ISO_NODE_IS_BOOTCAT(node)) { |
|
|
|
|
what= "boot catalog"; |
|
|
|
|
} else { |
|
|
|
|
what= "regular file"; |
|
|
|
|
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(ret == -1 && errno == EACCES && (flag & 128)) |
|
|
|
@ -497,7 +506,17 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
|
|
|
|
if(write_fd==-1) |
|
|
|
|
goto cannot_restore; |
|
|
|
|
} |
|
|
|
|
todo= size= iso_file_get_size((IsoFile *) node); |
|
|
|
|
if(ISO_NODE_IS_BOOTCAT(node)) { |
|
|
|
|
ret= Xorriso_get_volume(xorriso, &volume, 0); |
|
|
|
|
if(ret<=0) |
|
|
|
|
goto ex; |
|
|
|
|
ret= iso_image_get_bootcat(volume, &bootcat, &lba, &catcontent, &catsize); |
|
|
|
|
if(ret < 0) |
|
|
|
|
goto ex; |
|
|
|
|
todo= size= catsize; |
|
|
|
|
} else { |
|
|
|
|
todo= size= iso_file_get_size((IsoFile *) node); |
|
|
|
|
} |
|
|
|
|
if(flag&2) { |
|
|
|
|
if(bytes<size) |
|
|
|
|
todo= size= bytes; |
|
|
|
@ -516,7 +535,13 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
|
|
|
|
wanted= buf_size; |
|
|
|
|
if(wanted>todo) |
|
|
|
|
wanted= todo; |
|
|
|
|
ret= Xorriso_iso_file_read(xorriso, data_stream, buf, wanted, 0); |
|
|
|
|
if(ISO_NODE_IS_BOOTCAT(node)) { |
|
|
|
|
ret= todo; |
|
|
|
|
buf_pt= catcontent; |
|
|
|
|
} else { |
|
|
|
|
ret= Xorriso_iso_file_read(xorriso, data_stream, buf, wanted, 0); |
|
|
|
|
buf_pt= buf; |
|
|
|
|
} |
|
|
|
|
if(ret<=0) { |
|
|
|
|
if(xorriso->extract_error_mode == 0 && |
|
|
|
|
Xorriso_is_plain_image_file(xorriso, node, "", 0)) { |
|
|
|
@ -547,13 +572,12 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
read_count+= ret; |
|
|
|
|
buf_pt= buf; |
|
|
|
|
|
|
|
|
|
if(img_offset > read_count - ret) { |
|
|
|
|
/* skip the desired amount of bytes */ |
|
|
|
|
if(read_count <= img_offset) |
|
|
|
|
continue; |
|
|
|
|
buf_pt= buf + (img_offset - (read_count - ret)); |
|
|
|
|
buf_pt= buf_pt + (img_offset - (read_count - ret)); |
|
|
|
|
ret= read_count - img_offset; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -584,7 +608,8 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
|
|
|
|
|
unlink(open_path_pt); |
|
|
|
|
target_deleted= 1; |
|
|
|
|
} |
|
|
|
|
Xorriso_iso_file_close(xorriso, &data_stream, 0); |
|
|
|
|
if(! ISO_NODE_IS_BOOTCAT(node)) |
|
|
|
|
Xorriso_iso_file_close(xorriso, &data_stream, 0); |
|
|
|
|
data_stream= NULL; |
|
|
|
|
if(temp_path==open_path_pt && !target_deleted) { |
|
|
|
|
ret= rename(temp_path, disk_path); |
|
|
|
@ -663,11 +688,10 @@ probably_damaged:;
|
|
|
|
|
goto ignored; |
|
|
|
|
|
|
|
|
|
} else { |
|
|
|
|
if(ISO_NODE_IS_BOOTCAT(node)) |
|
|
|
|
what= "boot catalog"; |
|
|
|
|
sprintf(xorriso->info_text, "Cannot restore file type '%s'", what); |
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0); |
|
|
|
|
ret= 0; goto ex; |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
if(ret == -1 && l_errno == EACCES && (flag & 128)) |
|
|
|
|
{ret= 4; goto ex;} |
|
|
|
@ -695,8 +719,11 @@ ex:;
|
|
|
|
|
} |
|
|
|
|
Xorriso_free_meM(buf); |
|
|
|
|
Xorriso_free_meM(temp_path); |
|
|
|
|
if(catcontent != NULL) |
|
|
|
|
free(catcontent); |
|
|
|
|
if(data_stream!=NULL) |
|
|
|
|
Xorriso_iso_file_close(xorriso, &data_stream, 0); |
|
|
|
|
Xorriso_process_msg_queues(xorriso,0); |
|
|
|
|
return(ret); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|