Replaced some large local variables by other means in xorriso/read_run.c

master
Thomas Schmitt 12 years ago
parent 6c6a0770a4
commit 230a0d6e19
  1. 304
      xorriso/read_run.c
  2. 2
      xorriso/xorriso_timestamp.h

@ -59,24 +59,26 @@ int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname,
void *node_pt, void **stream, int flag)
{
int ret;
char eff_path[SfileadrL];
char *eff_path= NULL;
IsoNode *node= NULL;
IsoFile *filenode= NULL;
IsoStream *iso_stream= NULL, *input_stream;
Xorriso_alloc_meM(eff_path, char, SfileadrL);
*stream= NULL;
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);
goto ex;
}
if(!LIBISO_ISREG(node)) {
sprintf(xorriso->info_text,
"Given path does not lead to a regular data file in the image");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
filenode= (IsoFile *) node;
@ -86,7 +88,7 @@ int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname,
sprintf(xorriso->info_text,
"Could not obtain source stream of file in the image for reading");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
if(flag & 2) {
/* Dig out the most original stream */
@ -101,14 +103,14 @@ int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname,
sprintf(xorriso->info_text,
"The data production of the file in the image is one-time only");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
ret= iso_stream_open(iso_stream);
if(ret<0) {
sprintf(xorriso->info_text,
"Could not open data file in the image for reading");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
Xorriso_process_msg_queues(xorriso,0);
*stream= iso_stream;
@ -125,7 +127,10 @@ int Xorriso_iso_file_open(struct XorrisO *xorriso, char *pathname,
}
#endif
return(1);
ret= 1;
ex:;
Xorriso_free_meM(eff_path);
return(ret);
}
@ -249,7 +254,6 @@ int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path,
uid_t uid;
gid_t gid;
struct utimbuf utime_buffer;
char sfe[5*SfileadrL];
struct stat stbuf;
size_t num_attrs= 0, *value_lengths= NULL;
char **names= NULL, **values= NULL;
@ -257,8 +261,8 @@ int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path,
ret= lstat(disk_path, &stbuf);
if(ret==-1) {
sprintf(xorriso->info_text,
"Cannot obtain properties of disk file %s",
Text_shellsafe(disk_path, sfe, 0));
"Cannot obtain properties of disk file ");
Text_shellsafe(disk_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
{ret= 0; goto ex;}
}
@ -282,8 +286,8 @@ int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path,
values, 0);
if(ret < 0) {
sprintf(xorriso->info_text,
"Cannot change ACL or xattr of disk file %s",
Text_shellsafe(disk_path, sfe, 0));
"Cannot change ACL or xattr of disk file ");
Text_shellsafe(disk_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
{ret= 0; goto ex;}
}
@ -311,8 +315,8 @@ int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path,
ret= chmod(disk_path, mode);
if(ret==-1) {
sprintf(xorriso->info_text,
"Cannot change access permissions of disk file %s",
Text_shellsafe(disk_path, sfe, 0));
"Cannot change access permissions of disk file ");
Text_shellsafe(disk_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
{ret= 0; goto ex;}
}
@ -329,8 +333,8 @@ int Xorriso_restore_properties(struct XorrisO *xorriso, char *disk_path,
ret= utime(disk_path,&utime_buffer);
if(ret==-1) {
sprintf(xorriso->info_text,
"Cannot change atime, mtime of disk file %s",
Text_shellsafe(disk_path, sfe, 0));
"Cannot change atime, mtime of disk file ");
Text_shellsafe(disk_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
{ret= 0; goto ex;}
}
@ -350,50 +354,58 @@ int Xorriso_restore_implicit_properties(struct XorrisO *xorriso,
char *full_disk_path, char *disk_path, char *full_img_path, int flag)
{
int ret, nfic, ndc, nfdc, d, i;
char nfi[SfileadrL], nd[SfileadrL], nfd[SfileadrL], *cpt;
char sfe[5*SfileadrL];
char *nfi= NULL, *nd= NULL, *nfd= NULL, *cpt;
struct stat stbuf;
IsoNode *node;
Xorriso_alloc_meM(nfi, char, SfileadrL);
Xorriso_alloc_meM(nd, char, SfileadrL);
Xorriso_alloc_meM(nfd, char, SfileadrL);
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, full_disk_path, nfd,
1|2|4);
if(ret<=0)
return(ret);
goto ex;
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, nd, 1|2);
if(ret<=0)
return(ret);
goto ex;
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, full_img_path, nfi,
1|2);
if(ret<=0)
return(ret);
goto ex;
nfdc= Sfile_count_components(nfd, 0);
ndc= Sfile_count_components(nd, 0);
nfic= Sfile_count_components(nfi, 0);
d= nfdc-ndc;
if(d<0)
return(-1);
{ret= -1; goto ex;}
if(d>nfic)
return(0);
{ret= 0; goto ex;}
for(i= 0; i<d; i++) {
cpt= strrchr(nfi, '/');
if(cpt==NULL)
return(-1); /* should not happen */
{ret= -1; goto ex;} /* should not happen */
*cpt= 0;
}
if(nfi[0]==0)
strcpy(nfi, "/");
ret= Xorriso_fake_stbuf(xorriso, nfi, &stbuf, &node, 0);
if(ret<=0)
return(0);
{ret= 0; goto ex;}
ret= Xorriso_restore_properties(xorriso, nd, node, ((flag>>1)&3));
if(ret<=0)
return(ret);
sprintf(xorriso->info_text,
"Restored properties for %s", Text_shellsafe(nd, sfe, 0));
sprintf(xorriso->info_text+strlen(xorriso->info_text),
" from %s", Text_shellsafe(nfi, sfe, 0));
goto ex;
sprintf(xorriso->info_text, "Restored properties for ");
Text_shellsafe(nd, xorriso->info_text, 1);
strcat(xorriso->info_text, " from ");
Text_shellsafe(nfi, xorriso->info_text, 1 | 2);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
return(1);
ret= 1;
ex:;
Xorriso_free_meM(nfi);
Xorriso_free_meM(nd);
Xorriso_free_meM(nfd);
return(ret);
}
@ -414,9 +426,9 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
int flag)
{
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], *buf_pt;
int target_deleted= 0, buf_size= 32 * 1024;
char *what= "[unknown filetype]";
char *buf= NULL, type_text[5], *temp_path= NULL, *buf_pt;
char *link_target, *open_path_pt= NULL;
off_t todo= 0, size, seek_ret, last_p_count= 0, already_done, read_count= 0;
void *data_stream= NULL;
@ -425,6 +437,9 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
struct stat stbuf;
struct utimbuf utime_buffer;
Xorriso_alloc_meM(buf, char, buf_size);
Xorriso_alloc_meM(temp_path, char, SfileadrL);
if(LIBISO_ISDIR(node)) {
what= "directory";
ret= mkdir(disk_path, 0777);
@ -443,8 +458,8 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
if(flag&2) {
if(ret!=-1 && !S_ISREG(stbuf.st_mode)) {
sprintf(xorriso->info_text,
"Restore offset demanded. But filesystem path leads to non-data file %s",
Text_shellsafe(disk_path, sfe, 0));
"Restore offset demanded. But filesystem path leads to non-data file ");
Text_shellsafe(disk_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
l_errno= 0;
goto cannot_restore;
@ -490,14 +505,15 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
l_errno= errno;
if(seek_ret == -1) {
sprintf(xorriso->info_text,
"Cannot address byte %.f in filesystem path %s",
(double) disk_offset, Text_shellsafe(open_path_pt, sfe, 0));
"Cannot address byte %.f in filesystem path ",
(double) disk_offset);
Text_shellsafe(open_path_pt, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
goto cannot_restore;
}
}
while(todo>0) {
wanted= sizeof(buf);
wanted= buf_size;
if(wanted>todo)
wanted= todo;
ret= Xorriso_iso_file_read(xorriso, data_stream, buf, wanted, 0);
@ -509,8 +525,10 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
already_done= (size - todo) / (off_t) 2048;
already_done*= (off_t) 2048;
sprintf(xorriso->info_text,
"Starting best_effort handling on ISO file %s at byte %.f",
Text_shellsafe(img_path, sfe, 0), (double) already_done);
"Starting best_effort handling on ISO file ");
Text_shellsafe(img_path, xorriso->info_text, 1);
sprintf(xorriso->info_text + strlen(xorriso->info_text),
" at byte %.f", (double) already_done);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
ret= Xorriso_read_file_data(xorriso, node, img_path, open_path_pt,
already_done, already_done, size - already_done, 2);
@ -522,8 +540,8 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
todo= -1;
}
if(ret <= 0) {
sprintf(xorriso->info_text, "Cannot read all bytes from ISO file %s",
Text_shellsafe(img_path, sfe, 0));
sprintf(xorriso->info_text, "Cannot read all bytes from ISO file ");
Text_shellsafe(img_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
}
break;
@ -553,8 +571,8 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
}
if(wret != ret) {
sprintf(xorriso->info_text,
"Cannot write all bytes to disk filesystem path %s",
Text_shellsafe(open_path_pt, sfe, 0));
"Cannot write all bytes to disk filesystem path ");
Text_shellsafe(open_path_pt, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
break;
}
@ -571,10 +589,10 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
if(temp_path==open_path_pt && !target_deleted) {
ret= rename(temp_path, disk_path);
if(ret==-1) {
sprintf(xorriso->info_text,
"Cannot rename temporary path %s to final disk path %s",
Text_shellsafe(temp_path, sfe, 0),
Text_shellsafe(disk_path, sfe2, 0));
sprintf(xorriso->info_text, "Cannot rename temporary path ");
Text_shellsafe(temp_path, xorriso->info_text, 1);
strcat(xorriso->info_text, " to final disk path ");
Text_shellsafe(disk_path, xorriso->info_text, 1 | 2);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
unlink(temp_path);
ret= 0; goto ex;
@ -594,8 +612,10 @@ int Xorriso_tree_restore_node(struct XorrisO *xorriso, IsoNode *node,
if(xorriso->allow_restore!=2) {
ignored:;
if(!(flag&4)) {
sprintf(xorriso->info_text, "Ignored file type: %s %s = %s", what,
Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0));
sprintf(xorriso->info_text, "Ignored file type: %s ", what);
Text_shellsafe(img_path, xorriso->info_text, 1);
strcat(xorriso->info_text, " = ");
Text_shellsafe(disk_path, xorriso->info_text, 1 | 2);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
}
{ret= 2; goto ex;}
@ -607,8 +627,10 @@ ignored:;
if(dev == (dev_t) 1) {
probably_damaged:;
sprintf(xorriso->info_text,
"Most probably damaged device file not restored: mknod %s %s 0 1",
Text_shellsafe(disk_path, sfe, 0), LIBISO_ISCHR(node) ? "c" : "b");
"Most probably damaged device file not restored: mknod ");
Text_shellsafe(disk_path, xorriso->info_text, 1);
sprintf(xorriso->info_text + strlen(xorriso->info_text),
" %s 0 1", LIBISO_ISCHR(node) ? "c" : "b");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
ret= 0; goto ex;
}
@ -652,8 +674,8 @@ probably_damaged:;
if(ret==-1) {
cannot_restore:;
sprintf(xorriso->info_text,
"Cannot restore %s to disk filesystem: %s",
what, Text_shellsafe(img_path, sfe, 0));
"Cannot restore %s to disk filesystem: ", what);
Text_shellsafe(img_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, l_errno, "FAILURE", 0);
ret= 0; goto ex;
}
@ -671,6 +693,8 @@ ex:;
if(ret <= 0 && xorriso->extract_error_mode == 2 && open_path_pt != NULL)
unlink(open_path_pt);
}
Xorriso_free_meM(buf);
Xorriso_free_meM(temp_path);
if(data_stream!=NULL)
Xorriso_iso_file_close(xorriso, &data_stream, 0);
return(ret);
@ -689,7 +713,7 @@ int Xorriso_restore_overwrite(struct XorrisO *xorriso,
struct stat *stbuf, int flag)
{
int ret;
char sfe[5*SfileadrL], sfe2[5*SfileadrL], type_text[5];
char type_text[5];
Xorriso_process_msg_queues(xorriso,0);
if(xorriso->do_overwrite==1 ||
@ -706,18 +730,22 @@ int Xorriso_restore_overwrite(struct XorrisO *xorriso,
if(ret<=0)
return(ret);
if(ret==3) {
sprintf(xorriso->info_text, "User revoked restoring of (ISO) file: %s",
Text_shellsafe(img_path, sfe, 0));
sprintf(xorriso->info_text, "User revoked restoring of (ISO) file: ");
Text_shellsafe(img_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
return(3*!!(flag&16));
}
return(1);
}
Xorriso_msgs_submit(xorriso, 0, nominal_path, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,
"While restoring %s : %s exists and may not be overwritten",
Text_shellsafe(nominal_path, sfe, 0), strcmp(nominal_path, path)==0 ?
"file object" : Text_shellsafe(path, sfe2, 0));
sprintf(xorriso->info_text, "While restoring ");
Text_shellsafe(nominal_path, xorriso->info_text, 1);
strcat(xorriso->info_text, " : ");
if(strcmp(nominal_path, path) == 0)
strcat(xorriso->info_text, "file object");
else
Text_shellsafe(path, xorriso->info_text, 1 | 2);
strcat(xorriso->info_text, " exists and may not be overwritten");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
@ -766,21 +794,24 @@ int Xorriso_restore_prefix_hl(struct XorrisO *xorriso, IsoNode *node,
char *disk_path, int node_idx, int flag)
{
int ret, min_hl, max_hl, i, link_sibling= 0, hflag;
char old_path[SfileadrL], img_path[SfileadrL];
char *old_path= NULL, *img_path= NULL;
struct Xorriso_lsT *img_prefixes= NULL, *disk_prefixes= NULL;
Xorriso_alloc_meM(old_path, char, SfileadrL);
Xorriso_alloc_meM(img_path, char, SfileadrL);
ret= Xorriso_search_hardlinks(xorriso, node, &node_idx, &min_hl, &max_hl,
2 | 4);
if(ret < 0)
return(ret);
goto ex;
if(ret == 0 || min_hl == max_hl)
return(0);
{ret= 0; goto ex;}
for(i= min_hl; i < node_idx; i++) {
link_sibling= 1;
ret= Xorriso_path_from_node(xorriso, xorriso->node_array[i], img_path, 0);
if(ret < 0)
return(ret);
goto ex;
if(ret == 0)
continue; /* Node is deleted from tree (Should not happen here) */
hflag= 1;
@ -796,13 +827,17 @@ int Xorriso_restore_prefix_hl(struct XorrisO *xorriso, IsoNode *node,
ret= Xorriso_make_restore_path(xorriso, &img_prefixes, &disk_prefixes,
img_path, old_path, hflag);
if(ret <= 0)
return(ret);
goto ex;
ret= Xorriso_restore_make_hl(xorriso, old_path, disk_path,
!!xorriso->do_auto_chmod);
if(ret > 0)
return(1);
{ret= 1; goto ex;}
}
return(link_sibling << 2);
ret= link_sibling << 2;
ex:;
Xorriso_free_meM(old_path);
Xorriso_free_meM(img_path);
return(ret);
}
@ -862,13 +897,14 @@ int Xorriso_restore_disk_object(struct XorrisO *xorriso,
int ret, i, split_count= 0, partno, total_parts, leaf_is_split= 0;
int record_hl_path= 0, node_idx, cannot_register= 0;
off_t total_bytes, was_byte_count;
char *part_name, part_path[SfileadrL], *img_path_pt;
char sfe[5*SfileadrL], sfe2[5*SfileadrL];
char *part_name, *part_path= NULL, *img_path_pt;
IsoImage *volume;
IsoNode *part_node, *first_part_node= NULL;
struct SplitparT *split_parts= NULL;
struct stat stbuf;
Xorriso_alloc_meM(part_path, char, SfileadrL);
ret= Xorriso_get_volume(xorriso, &volume, 0);
if(ret<=0)
goto ex;
@ -954,8 +990,10 @@ int Xorriso_restore_disk_object(struct XorrisO *xorriso,
ret= Xorriso_restore_properties(xorriso, disk_path, node, 2 | !!(flag&64));
if(ret<=0) {
restoring_failed:;
sprintf(xorriso->info_text, "Restoring failed: %s = %s",
Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0));
sprintf(xorriso->info_text, "Restoring failed: ");
Text_shellsafe(img_path, xorriso->info_text, 1);
strcat(xorriso->info_text, " = ");
Text_shellsafe(disk_path, xorriso->info_text, 1 | 2);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "SORRY", 0);
{ret= 0; goto ex;}
}
@ -979,6 +1017,7 @@ went_well:;
ex:;
if(split_parts!=NULL)
Splitparts_destroy(&split_parts, split_count, 0);
Xorriso_free_meM(part_path);
if(ret > 0 && cannot_register)
ret= 0;
return(ret);
@ -1361,15 +1400,19 @@ int Xorriso_restore(struct XorrisO *xorriso,
off_t offset, off_t bytes, int flag)
{
IsoImage *volume;
char path[SfileadrL], *apt, *npt, sfe[5*SfileadrL];
char *path= NULL, *apt, *npt;
IsoNode *node= NULL;
int done= 0, is_dir= 0, ret, source_is_dir, stbuf_ret, hret;
int dir_create= 0, node_count= 0, node_register= 0;
int dir_create= 0, node_count= 0, node_register= 0, path_size;
int leaf_is_split= 0, source_is_split= 0, new_dir_made= 0;
struct stat stbuf;
struct PermiteM *perm_stack_mem;
perm_stack_mem= xorriso->perm_stack;
path_size= SfileadrL;
Xorriso_alloc_meM(path, char, path_size);
switch((flag >> 7) & 3) {
case 1: dir_create= 1;
break; case 2: node_register= 1;
@ -1397,8 +1440,8 @@ int Xorriso_restore(struct XorrisO *xorriso,
if(ret<=0)
goto ex;
strncpy(path, disk_path, sizeof(path)-1);
path[sizeof(path)-1]= 0;
strncpy(path, disk_path, path_size - 1);
path[path_size - 1]= 0;
apt= npt= path;
if(!(flag&1)) {
@ -1427,8 +1470,8 @@ int Xorriso_restore(struct XorrisO *xorriso,
Xorriso_process_msg_queues(xorriso,0);
Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,
"Cannot determine attributes of (ISO) source file %s",
Text_shellsafe(img_path, sfe, 0));
"Cannot determine attributes of (ISO) source file ");
Text_shellsafe(img_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
ret= 0; goto ex;
}
@ -1536,6 +1579,7 @@ ex:;
2 | !!(flag&64));
if(hret<=0 && hret<ret)
ret= hret;
Xorriso_free_meM(path);
return(ret);
}
@ -1544,12 +1588,15 @@ int Xorriso_restore_node_array(struct XorrisO *xorriso, int flag)
{
int i, ret, was_failure= 0, fret, hflag, stbuf_ret, faulty_family= 0;
struct PermiteM *perm_stack_mem;
char img_path[SfileadrL], disk_path[SfileadrL];
char *img_path= NULL, *disk_path= NULL;
IsoNode *node;
struct Xorriso_lsT *img_prefixes= NULL, *disk_prefixes= NULL;
perm_stack_mem= xorriso->perm_stack;
Xorriso_alloc_meM(img_path, char, SfileadrL);
Xorriso_alloc_meM(disk_path, char, SfileadrL);
Xorriso_sort_node_array(xorriso, 0);
disk_path[0]= 0;
@ -1639,6 +1686,8 @@ was_problem:;
ret= 1;
ex:;
Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, 0);
Xorriso_free_meM(img_path);
Xorriso_free_meM(disk_path);
return(ret);
}
@ -1649,45 +1698,52 @@ int Xorriso_paste_in(struct XorrisO *xorriso, char *disk_path,
off_t startbyte, off_t bytecount, char *iso_rr_path, int flag)
{
int ret;
char eff_source[SfileadrL], eff_dest[SfileadrL], sfe[SfileadrL*5];
char *eff_source= NULL, *eff_dest= NULL;
struct stat stbuf;
IsoNode *node;
Xorriso_alloc_meM(eff_source, char, SfileadrL);
Xorriso_alloc_meM(eff_dest, char, SfileadrL);
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, disk_path, eff_dest,
2|4);
if(ret<=0)
return(ret);
goto ex;
ret= Xorriso_path_is_excluded(xorriso, disk_path, !(flag&1));
if(ret!=0)
return(0);
{ret= 0; goto ex;}
ret= stat(eff_dest, &stbuf);
if(ret!=-1 && !S_ISREG(stbuf.st_mode)) {
Xorriso_msgs_submit(xorriso, 0, eff_dest, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,
"-paste_in: DISK file %s exists and is not a data file",
Text_shellsafe(eff_source, sfe, 0));
sprintf(xorriso->info_text, "-paste_in: DISK file ");
Text_shellsafe(eff_source, xorriso->info_text, 1);
strcat(xorriso->info_text, " exists and is not a data file");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, iso_rr_path,
eff_source, 2);
if(ret<=0)
return(ret);
goto ex;
ret= Xorriso_fake_stbuf(xorriso, eff_source, &stbuf, &node, 4);
if(ret<=0)
return(0);
{ret= 0; goto ex;}
if(!S_ISREG(stbuf.st_mode)) {
Xorriso_msgs_submit(xorriso, 0, eff_dest, 0, "ERRFILE", 0);
sprintf(xorriso->info_text, "-paste_in: ISO file %s is not a data file",
Text_shellsafe(eff_source, sfe, 0));
sprintf(xorriso->info_text, "-paste_in: ISO file ");
Text_shellsafe(eff_source, xorriso->info_text, 1);
strcat(xorriso->info_text, " is not a data file");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
/* >>> eventually obtain parameters from file name */;
ret= Xorriso_restore(xorriso, eff_source, eff_dest, startbyte, bytecount, 8);
ex:;
Xorriso_free_meM(eff_source);
Xorriso_free_meM(eff_dest);
return(ret);
}
@ -1698,31 +1754,34 @@ int Xorriso_extract_cut(struct XorrisO *xorriso,
{
int ret, stbuf_ret, read_raw;
double mem_lut= 0.0;
char eff_img_path[SfileadrL], eff_disk_path[SfileadrL], sfe[SfileadrL*5];
char *eff_img_path= NULL, *eff_disk_path= NULL;
IsoImage *volume;
IsoNode *node;
Xorriso_alloc_meM(eff_img_path, char, SfileadrL);
Xorriso_alloc_meM(eff_disk_path, char, SfileadrL);
ret= Xorriso_get_volume(xorriso, &volume, 0);
if(ret<=0)
return(ret);
goto ex;
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi,
img_path, eff_img_path, 0);
if(ret<=0)
return(ret);
goto ex;
ret= Xorriso_node_from_path(xorriso, volume, eff_img_path, &node, 0);
if(ret<=0)
return(ret);
goto ex;
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx,
disk_path, eff_disk_path, 2 | 4);
if(ret<=0)
return(ret);
goto ex;
Xorriso_pacifier_reset(xorriso, 0);
mem_lut= xorriso->last_update_time;
ret= Xorriso_handle_collision(xorriso, node, img_path, eff_disk_path,
disk_path, &stbuf_ret, 0);
if(ret<=0 || ret==3)
return(0);
{ret= 0; goto ex;}
/* If it is a non-filtered stream from the ISO image
and img_offset is a multiple of 2048
@ -1730,10 +1789,11 @@ int Xorriso_extract_cut(struct XorrisO *xorriso,
*/
if(!LIBISO_ISREG(node)) {
Xorriso_msgs_submit(xorriso, 0, eff_disk_path, 0, "ERRFILE", 0);
sprintf(xorriso->info_text, "-extract_cut: ISO file %s is not a data file",
Text_shellsafe(eff_img_path, sfe, 0));
sprintf(xorriso->info_text, "-extract_cut: ISO file ");
Text_shellsafe(eff_img_path, xorriso->info_text, 1);
strcat(xorriso->info_text, " is not a data file");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
read_raw= 0;
if((img_offset % 2048) == 0) {
@ -1745,22 +1805,26 @@ int Xorriso_extract_cut(struct XorrisO *xorriso,
ret= Xorriso_read_file_data(xorriso, node, eff_img_path, eff_disk_path,
img_offset, (off_t) 0, bytes, 0);
if(ret<=0)
return(ret);
goto ex;
} else {
ret= Xorriso_tree_restore_node(xorriso, node, eff_img_path, img_offset,
eff_disk_path, (off_t) 0, bytes, 2 | 8);
if(ret<=0)
return(ret);
goto ex;
}
ret= Xorriso_restore_properties(xorriso, eff_disk_path, node, 0);
if(ret<=0)
return(ret);
goto ex;
if(mem_lut != xorriso->last_update_time)
Xorriso_pacifier_callback(xorriso, "sectors examined",
xorriso->pacifier_count, 0, "", 1);
return(1);
ret= 1;
ex:;
Xorriso_free_meM(eff_img_path);
Xorriso_free_meM(eff_disk_path);
return(ret);
}
@ -1775,7 +1839,6 @@ int Xorriso_read_file_data(struct XorrisO *xorriso, IsoNode *node,
int lba, count, blocks, quality, spot, bad_extract= 0;
off_t size= 0, file_base_bytes= 0, file_processed_bytes= 0, img_adr;
off_t new_file_base_bytes, upto_file_bytes, start_byte= 0;
char sfe[5*SfileadrL];
struct SpotlisT *spotlist= NULL;
struct CheckmediajoB *job= NULL;
@ -1793,9 +1856,10 @@ int Xorriso_read_file_data(struct XorrisO *xorriso, IsoNode *node,
0);
if(ret <= 0) {
Xorriso_process_msg_queues(xorriso,0);
sprintf(xorriso->info_text,
"File object %s is currently not a data file from the loaded image",
Text_shellsafe(img_path, sfe, 0));
sprintf(xorriso->info_text, "File object ");
Text_shellsafe(img_path, xorriso->info_text, 1);
strcat(xorriso->info_text,
" is currently not a data file from the loaded image");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
goto ex;
}
@ -1853,8 +1917,8 @@ int Xorriso_read_file_data(struct XorrisO *xorriso, IsoNode *node,
if(ret <= 0)
goto ex;
if (ret == 2) {
sprintf(xorriso->info_text, "Attempt aborted to extract data from %s",
Text_shellsafe(img_path, sfe, 0));
sprintf(xorriso->info_text, "Attempt aborted to extract data from ");
Text_shellsafe(img_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
ret= 0; goto ex;
}
@ -1878,9 +1942,10 @@ int Xorriso_read_file_data(struct XorrisO *xorriso, IsoNode *node,
* (off_t) 2048;
}
if(i < lba_count) {
sprintf(xorriso->info_text, "Bad extract : %14.f , %14.f , %s\n",
(double) start_byte, ((double) blocks) * 2048.0,
Text_shellsafe(disk_path, sfe, 0));
sprintf(xorriso->info_text, "Bad extract : %14.f , %14.f , ",
(double) start_byte, ((double) blocks) * 2048.0);
Text_shellsafe(disk_path, xorriso->info_text, 1);
strcat(xorriso->info_text, "\n");
Xorriso_info(xorriso, 0);
bad_extract= 1;
}
@ -1914,14 +1979,16 @@ ex:;
int Xorriso_check_md5(struct XorrisO *xorriso, void *in_node, char *path,
int flag)
{
int ret, wanted, rret;
int ret, wanted, rret, buffer_size= 64 * 1024;
IsoImage *image;
IsoNode *node;
IsoFile *file;
char node_md5[16], data_md5[16], buffer[64 * 1024];
char node_md5[16], data_md5[16], *buffer= NULL;
void *stream= NULL, *ctx= NULL;
off_t todo;
Xorriso_alloc_meM(buffer, char, 64 * 1024);
node= (IsoNode *) in_node;
if(node == NULL) {
ret= Xorriso_get_node_by_path(xorriso, path, NULL, &node, 0);
@ -1962,10 +2029,10 @@ int Xorriso_check_md5(struct XorrisO *xorriso, void *in_node, char *path,
goto ex;
todo= iso_stream_get_size(stream);
while(todo > 0) {
if(todo < sizeof(buffer))
if(todo < buffer_size)
wanted= todo;
else
wanted= sizeof(buffer);
wanted= buffer_size;
rret = Xorriso_iso_file_read(xorriso, stream, buffer, wanted, 0);
if(rret <= 0)
{ret= -1; goto ex;}
@ -2013,6 +2080,7 @@ ex:;
Xorriso_iso_file_close(xorriso, &stream, 0);
if(ctx != NULL)
iso_md5_end(&ctx, data_md5);
Xorriso_free_meM(buffer);
if(ret < 0) {
if(ret == -2)
sprintf(xorriso->result_line, "Aborted at: ");

@ -1 +1 @@
#define Xorriso_timestamP "2011.05.07.105142"
#define Xorriso_timestamP "2011.05.07.165758"

Loading…
Cancel
Save