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

master
Thomas Schmitt 12 years ago
parent 11e0b38dbb
commit 153b41c64d

@ -120,16 +120,18 @@ int Xorriso_graft_split(struct XorrisO *xorriso, IsoImage *volume,
IsoNode *part_node;
int partno, total_parts;
off_t offset;
char part_name[SfileadrL], sfe[5*SfileadrL];
char *part_name= NULL;
Xorriso_alloc_meM(part_name, char, SfileadrL);
ret= iso_tree_add_new_dir(dir, img_name, &new_dir);
if(ret<0)
return(ret);
goto ex;
*node= (IsoNode *) new_dir;
if(xorriso->update_flags & 1) {
ret= Xorriso_mark_update_merge(xorriso, img_name, node, 1);
if(ret <= 0)
return(0);
{ret= 0; goto ex;}
}
total_parts= size / xorriso->split_size;
if(size % xorriso->split_size)
@ -144,12 +146,15 @@ int Xorriso_graft_split(struct XorrisO *xorriso, IsoImage *volume,
offset, xorriso->split_size,
&part_node, 8);
if(ret<=0)
return(ret);
goto ex;
}
sprintf(xorriso->info_text, "Split into %d parts: %s",
total_parts, Text_shellsafe(nominal_target, sfe, 0));
sprintf(xorriso->info_text, "Split into %d parts: ", total_parts);
Text_shellsafe(nominal_target, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
return(1);
ret= 1;
ex:;
Xorriso_free_meM(part_name);
return(ret);
}
@ -168,7 +173,7 @@ int Xorriso_tree_graft_node(struct XorrisO *xorriso, IsoImage *volume,
{
int ret, stbuf_valid= 0;
struct stat stbuf;
char sfe[5*SfileadrL], *namept;
char *namept;
off_t size= 0;
if(lstat(disk_path, &stbuf) != -1) {
@ -179,9 +184,10 @@ int Xorriso_tree_graft_node(struct XorrisO *xorriso, IsoImage *volume,
if(flag&8) {
if(cut_size > xorriso->file_size_limit && xorriso->file_size_limit > 0) {
sprintf(xorriso->info_text,
"File piece exceeds size limit of %.f bytes: %.f from %s\n",
(double) xorriso->file_size_limit, (double) cut_size,
Text_shellsafe(disk_path, sfe, 0));
"File piece exceeds size limit of %.f bytes: %.f from ",
(double) xorriso->file_size_limit, (double) cut_size);
Text_shellsafe(disk_path, xorriso->info_text, 1);
strcat(xorriso->info_text, "\n");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
}
@ -198,9 +204,10 @@ int Xorriso_tree_graft_node(struct XorrisO *xorriso, IsoImage *volume,
goto ex;
} else if(size > xorriso->file_size_limit && xorriso->file_size_limit > 0) {
sprintf(xorriso->info_text,
"File exceeds size limit of %.f bytes: %s\n",
(double) xorriso->file_size_limit,
Text_shellsafe(disk_path, sfe, 0));
"File exceeds size limit of %.f bytes: ",
(double) xorriso->file_size_limit);
Text_shellsafe(disk_path, xorriso->info_text, 1);
strcat(xorriso->info_text, "\n");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
} else {
@ -619,45 +626,48 @@ int Xorriso_copy_implicit_properties(struct XorrisO *xorriso, IsoDir *dir,
char *full_img_path, char *img_path, char *full_disk_path, int flag)
{
int ret, nfic, nic, nfdc, d, i, hide_attrs;
char nfi[SfileadrL], ni[SfileadrL], nfd[SfileadrL], *cpt;
char sfe[5*SfileadrL];
char *nfi= NULL, *ni= NULL, *nfd= NULL, *cpt;
struct stat stbuf;
Xorriso_alloc_meM(nfi, char, SfileadrL);
Xorriso_alloc_meM(ni, char, SfileadrL);
Xorriso_alloc_meM(nfd, char, SfileadrL);
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, full_img_path, nfi,
1|2);
if(ret<=0)
return(ret);
goto ex;
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, img_path, ni, 1|2);
if(ret<=0)
return(ret);
goto ex;
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdx, full_disk_path, nfd,
1|2|4);
if(ret<=0)
return(ret);
goto ex;
nfic= Sfile_count_components(nfi, 0);
nic= Sfile_count_components(ni, 0);
nfdc= Sfile_count_components(nfd, 0);
d= nfic-(flag&1)-nic;
if(d<0)
return(-1);
{ret= -1; goto ex;}
if(d>nfdc)
return(0);
{ret= 0; goto ex;}
for(i= 0; i<d; i++) {
cpt= strrchr(nfd, '/');
if(cpt==NULL)
return(-1); /* should not happen */
{ret= -1; goto ex;} /* should not happen */
*cpt= 0;
}
if(nfd[0]==0)
strcpy(nfd, "/");
if(stat(nfd, &stbuf)==-1)
return(0);
{ret= 0; goto ex;}
Xorriso_transfer_properties(xorriso, &stbuf, nfd, (IsoNode *) dir,
((flag&1) && d==0) | 4 | 32);
sprintf(xorriso->info_text,
"Copied properties for %s", Text_shellsafe(ni, sfe, 0));
sprintf(xorriso->info_text+strlen(xorriso->info_text),
" from %s", Text_shellsafe(nfd, sfe, 0));
sprintf(xorriso->info_text, "Copied properties for ");
Text_shellsafe(ni, xorriso->info_text, 1);
sprintf(xorriso->info_text+strlen(xorriso->info_text), " from ");
Text_shellsafe(nfd, xorriso->info_text, 1);
if(!((flag&1) && d==0))
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
@ -666,15 +676,20 @@ int Xorriso_copy_implicit_properties(struct XorrisO *xorriso, IsoDir *dir,
hide_attrs= 0;
ret= Xorriso_path_is_hidden(xorriso, nfd, 0);
if(ret<0)
return(ret);
goto ex;
if(ret>=0) {
/* Hide dir */
ret= Xorriso_set_hidden(xorriso, (void *) dir, "", ret, 0);
if(ret <= 0)
return(ret);
goto ex;
}
}
return(1);
ret= 1;
ex:
Xorriso_free_meM(nfi);
Xorriso_free_meM(ni);
Xorriso_free_meM(nfd);
return(ret);
}
@ -726,8 +741,8 @@ int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter,
off_t offset, off_t cut_size, int flag)
{
IsoImage *volume;
char path[SfileadrL], *apt, *npt, *cpt, sfe[5*SfileadrL], sfe2[5*SfileadrL];
char *disk_path_pt, resolved_disk_path[SfileadrL];
char *path= NULL, *apt, *npt, *cpt;
char *disk_path_pt, *resolved_disk_path= NULL;
IsoDir *dir= NULL, *hdir;
IsoNode *node;
int done= 0, is_dir= 0, l, ret, source_is_dir, resolve_link= 0;
@ -743,27 +758,30 @@ int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter,
#endif
#endif
Xorriso_alloc_meM(path, char, SfileadrL);
Xorriso_alloc_meM(resolved_disk_path, char, SfileadrL);
hide_attrs= (flag >> 8) & 3;
if (disk_path == NULL && !(flag & 1)) {
Xorriso_msgs_submit(xorriso, 0,
"Program error: Xorriso_graft_in(): disk_path == NULL && !(flag & 1)",
0, "ABORT", 0);
return(-1);
{ret= -1; goto ex;}
}
if (disk_path == NULL) {
disk_path= "";
} else {
ret= Xorriso_path_is_excluded(xorriso, disk_path, !(flag&4));
if(ret<0)
return(ret);
goto ex;
if(ret>0)
return(3*!!(flag&16));
{ret= 3*!!(flag&16); goto ex;}
/* Check for mkisofs-style hidings */
if(hide_attrs != 3) {
ret= Xorriso_path_is_hidden(xorriso, disk_path, 0);
if(ret<0)
return(ret);
goto ex;
if(ret>=0)
hide_attrs|= ret;
}
@ -783,21 +801,23 @@ int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter,
if(disk_path[0])
Xorriso_msgs_submit(xorriso, 0, disk_path, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,
"Unsupported relative addressing in iso_rr_path %s",
Text_shellsafe(img_path, sfe, 0));
if(disk_path[0])
sprintf(xorriso->info_text + strlen(xorriso->info_text),
" (disk: %s)", Text_shellsafe(disk_path, sfe, 0));
"Unsupported relative addressing in iso_rr_path ");
Text_shellsafe(img_path, xorriso->info_text, 1);
if(disk_path[0]) {
strcat(xorriso->info_text, " (disk: ");
Text_shellsafe(disk_path, xorriso->info_text, 1);
strcat(xorriso->info_text, ")");
}
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
ret= Xorriso_get_volume(xorriso, &volume, 0);
if(ret<=0)
return(ret);
goto ex;
strncpy(path, img_path, sizeof(path)-1);
path[sizeof(path)-1]= 0;
strncpy(path, img_path, SfileadrL - 1);
path[SfileadrL - 1]= 0;
apt= npt= path;
if(!(flag&1)) {
@ -820,10 +840,10 @@ int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter,
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",
Text_shellsafe(disk_path, sfe, 0));
"Cannot determine attributes of source file ");
Text_shellsafe(disk_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
if(S_ISDIR(stbuf.st_mode)) {
is_dir= 1;
@ -834,11 +854,13 @@ int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter,
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.",
Text_shellsafe(disk_path, sfe, 0), Text_shellsafe(img_path, sfe2, 0));
sprintf(xorriso->info_text, "Source ");
Text_shellsafe(disk_path, xorriso->info_text, 1);
strcat(xorriso->info_text, " is not a directory. Target ");
Text_shellsafe(img_path, xorriso->info_text, 1);
strcat(xorriso->info_text, " would be.");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
}
}
@ -849,7 +871,7 @@ int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter,
sprintf(xorriso->info_text,
"While grafting '%s' : no root node available", img_path);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
return(0);
{ret= 0; goto ex;}
}
for(npt= apt; !done; apt= npt+1) {
npt= strchr(apt, '/');
@ -883,7 +905,7 @@ int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter,
disk_path[0] ? disk_path : img_path,
(!!source_is_dir) | (flag & (16 | 64 | 128)));
if(ret <= 0 || ret == 3)
return(ret);
goto ex;
if(ret == 1 && node != NULL)
dir= (IsoDir *) node;
} else
@ -899,12 +921,12 @@ int Xorriso_graft_in(struct XorrisO *xorriso, void *boss_iter,
sprintf(xorriso->info_text,
"While grafting '%s' : could not insert '%s'", img_path, path);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
if(xorriso->update_flags & 1) {
ret= Xorriso_mark_update_merge(xorriso, path, (IsoNode *) hdir, 1);
if(ret <= 0)
return(0);
{ret= 0; goto ex;}
}
dir= hdir;
@ -934,13 +956,13 @@ attach_source:;
ret= Xorriso_add_tree(xorriso, dir, img_path, disk_path, NULL,
flag & (2 | 64 | 128));
if(ret<=0)
return(ret);
goto ex;
}
} else {
if(resolve_link) {
ret= Xorriso_resolve_link(xorriso, disk_path, resolved_disk_path, 0);
if(ret<=0)
return(ret);
goto ex;
disk_path_pt= resolved_disk_path;
} else
disk_path_pt= disk_path;
@ -954,16 +976,18 @@ attach_source:;
disk_path[0] ? disk_path : img_path,
(flag & (16 | 64 | 128)));
if(ret <= 0 || ret == 3)
return(ret);
goto ex;
ret= Xorriso_tree_graft_node(xorriso, volume, dir, disk_path_pt, apt,
disk_path, img_path, offset, cut_size,
&node, (flag & 8) | (hide_attrs << 8));
}
if(ret<=0) {
sprintf(xorriso->info_text, "Grafting failed: %s = %s",
Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0));
sprintf(xorriso->info_text, "Grafting failed: ");
Text_shellsafe(img_path, xorriso->info_text, 1);
strcat(xorriso->info_text, " = ");
Text_shellsafe(disk_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
Xorriso_set_change_pending(xorriso, 0);
iso_node_set_name(node, apt);
@ -990,7 +1014,7 @@ attach_source:;
disk_path[0] ? disk_path : img_path,
(!!source_is_dir) | (flag & (16 | 64 | 128)));
if(ret <= 0 || ret == 3)
return(ret);
goto ex;
if(ret == 2)
goto handle_path_node;
@ -1011,13 +1035,15 @@ attach_source:;
ret= Xorriso_rmi(xorriso, boss_iter, (off_t) 0, path,
1 | 8 | (flag & 64));
if(ret<=0)
return(ret);
goto ex;
if(ret==3) {
sprintf(xorriso->info_text, "User revoked adding of: %s",
disk_path[0] ? Text_shellsafe(disk_path, sfe, 0)
: Text_shellsafe(img_path, sfe, 0));
sprintf(xorriso->info_text, "User revoked adding of: ");
if(disk_path[0])
Text_shellsafe(disk_path, xorriso->info_text, 1);
else
Text_shellsafe(img_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
return(3*!!(flag&16));
{ret= 3*!!(flag&16); goto ex;}
}
node= NULL;
goto handle_path_node;
@ -1029,7 +1055,7 @@ attach_source:;
"While grafting '%s' : '%s' exists and may not be overwritten",
img_path, path);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
#endif /* ! Xorriso_graft_handle_collisioN */
@ -1049,12 +1075,12 @@ handle_path_node:;
sprintf(xorriso->info_text,
"While grafting '%s' : could not insert '%s'", img_path, path);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
if(xorriso->update_flags & 1) {
ret= Xorriso_mark_update_merge(xorriso, path, (IsoNode *) hdir, 1);
if(ret <= 0)
return(0);
{ret= 0; goto ex;}
}
dir= hdir;
@ -1081,13 +1107,13 @@ attach_source:;
ret= Xorriso_add_tree(xorriso, dir, img_path, disk_path, NULL,
flag & (2 | 64 | 128));
if(ret<=0)
return(ret);
goto ex;
}
} else {
if(resolve_link) {
ret= Xorriso_resolve_link(xorriso, disk_path, resolved_disk_path, 0);
if(ret<=0)
return(ret);
goto ex;
disk_path_pt= resolved_disk_path;
} else
disk_path_pt= disk_path;
@ -1096,10 +1122,12 @@ attach_source:;
disk_path, img_path, offset, cut_size,
&node, (flag&8) | (hide_attrs << 8));
if(ret<=0) {
sprintf(xorriso->info_text, "Grafting failed: %s = %s",
Text_shellsafe(img_path,sfe,0), Text_shellsafe(disk_path,sfe2,0));
sprintf(xorriso->info_text, "Grafting failed: ");
Text_shellsafe(img_path, xorriso->info_text, 1);
strcat(xorriso->info_text, " = ");
Text_shellsafe(disk_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
Xorriso_set_change_pending(xorriso, 0);
iso_node_set_name(node, apt);
@ -1118,7 +1146,11 @@ attach_source:;
}
Xorriso_process_msg_queues(xorriso,0);
return(1+!!is_dir);
ret= 1+!!is_dir;
ex:;
Xorriso_free_meM(path);
Xorriso_free_meM(resolved_disk_path);
return(ret);
}
@ -1128,23 +1160,26 @@ int Xorriso_cut_out(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;
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_source,
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;}
if(lstat(eff_source, &stbuf)==-1) {
Xorriso_msgs_submit(xorriso, 0, eff_source, 0, "ERRFILE", 0);
sprintf(xorriso->info_text, "-cut_out: Cannot determine type of %s",
Text_shellsafe(eff_source, sfe, 0));
sprintf(xorriso->info_text, "-cut_out: Cannot determine type of ");
Text_shellsafe(eff_source, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
if((stbuf.st_mode&S_IFMT) == S_IFLNK) {
@ -1153,10 +1188,10 @@ int Xorriso_cut_out(struct XorrisO *xorriso, char *disk_path,
if(stat(eff_source, &stbuf)==-1) {
Xorriso_msgs_submit(xorriso, 0, eff_source, 0, "ERRFILE", 0);
sprintf(xorriso->info_text,
"-cut_out: Cannot determine link target type of %s",
Text_shellsafe(eff_source, sfe, 0));
"-cut_out: Cannot determine link target type of ");
Text_shellsafe(eff_source, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "FAILURE",0);
return(0);
{ret= 0; goto ex;}
}
}
if(S_ISREG(stbuf.st_mode)) {
@ -1166,24 +1201,28 @@ int Xorriso_cut_out(struct XorrisO *xorriso, char *disk_path,
"-cut_out: Byte offset %.f larger than file size %.f",
(double) startbyte, (double) stbuf.st_size);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, errno, "SORRY", 0);
return(0);
{ret= 0; goto ex;}
}
} else {
unsupported_type:;
Xorriso_msgs_submit(xorriso, 0, eff_source, 0, "ERRFILE", 0);
sprintf(xorriso->info_text, "-cut_out: Unsupported file type (%s) with %s",
Ftypetxt(stbuf.st_mode, 0), Text_shellsafe(eff_source, sfe, 0));
sprintf(xorriso->info_text, "-cut_out: Unsupported file type (%s) with ",
Ftypetxt(stbuf.st_mode, 0));
Text_shellsafe(eff_source, xorriso->info_text, 1);
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_dest,
2);
if(ret<=0)
return(ret);
goto ex;
ret= Xorriso_graft_in(xorriso, NULL, eff_source, eff_dest,
startbyte, bytecount, 8);
ex:;
Xorriso_free_meM(eff_source);
Xorriso_free_meM(eff_dest);
return(ret);
}
@ -1196,32 +1235,37 @@ unsupported_type:;
int Xorriso_mkdir(struct XorrisO *xorriso, char *path, int flag)
{
int ret;
char eff_path[SfileadrL], sfe[5*SfileadrL];
char *eff_path= NULL;
Xorriso_alloc_meM(eff_path, char, SfileadrL);
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 1);
if(ret<0)
return(-2);
{ret= -2; goto ex;}
if(ret>0) {
if(ret == 2 && (flag & 2))
return(0);
sprintf(xorriso->info_text,"-mkdir: Address already existing %s",
Text_shellsafe(eff_path, sfe, 0));
{ret= 0; goto ex;}
sprintf(xorriso->info_text,"-mkdir: Address already existing ");
Text_shellsafe(eff_path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0,
(ret==2 ? "WARNING" : "FAILURE"), 0);
return(-1+(ret==2));
{ret= -1 + (ret == 2); goto ex;}
}
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, path, eff_path, 2);
if(ret<0)
return(-2);
{ret= -2; goto ex;}
ret= Xorriso_graft_in(xorriso, NULL, NULL, eff_path, (off_t) 0, (off_t) 0, 1);
if(ret<=0)
return(-2);
{ret= -2; goto ex;}
if(!(flag&1)) {
sprintf(xorriso->info_text, "Created directory in ISO image: %s\n",
Text_shellsafe(eff_path,sfe,0));
sprintf(xorriso->info_text, "Created directory in ISO image: ");
Text_shellsafe(eff_path, xorriso->info_text, 1);
Xorriso_info(xorriso, 0);
}
return(1);
ret= 1;
ex:;
Xorriso_free_meM(eff_path);
return(ret);
}
@ -1485,16 +1529,15 @@ int Xorriso_overwrite_dest(struct XorrisO *xorriso, void *boss_iter,
int flag)
{
int ret;
char sfe[5*SfileadrL];
if(dest_ret==2 && xorriso->do_overwrite!=1) {
sprintf(xorriso->info_text, "%s: May not overwrite directory: %s",
activity, Text_shellsafe(eff_dest, sfe, 0));
sprintf(xorriso->info_text, "%s: May not overwrite directory: ", activity);
Text_shellsafe(eff_dest, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
} else if (dest_ret==1 && !xorriso->do_overwrite) {
sprintf(xorriso->info_text, "%s: May not overwite: %s",
activity, Text_shellsafe(eff_dest, sfe, 0));
sprintf(xorriso->info_text, "%s: May not overwite: ", activity);
Text_shellsafe(eff_dest, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
} else if(dest_ret>0) {
@ -1502,8 +1545,8 @@ int Xorriso_overwrite_dest(struct XorrisO *xorriso, void *boss_iter,
if(ret<=0)
return(0);
if(ret==3) {
sprintf(xorriso->info_text, "%s: User revoked removal of: %s",
activity, Text_shellsafe(eff_dest, sfe, 0));
sprintf(xorriso->info_text, "%s: User revoked removal of: ", activity);
Text_shellsafe(eff_dest, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "NOTE", 0);
return(0);
}
@ -1519,12 +1562,16 @@ int Xorriso_rename(struct XorrisO *xorriso, void *boss_iter,
char *origin, char *dest, int flag)
{
int ret, ol, dest_ret;
char sfe[5*SfileadrL], eff_dest[SfileadrL], dir_adr[SfileadrL], *cpt;
char *leafname, eff_origin[SfileadrL], sfe2[5*SfileadrL], *old_leafname;
char *eff_dest= NULL, *dir_adr= NULL, *cpt;
char *leafname, *eff_origin= NULL, *old_leafname;
IsoImage *volume;
IsoDir *origin_dir, *dest_dir;
IsoNode *node, *iso_node;
Xorriso_alloc_meM(eff_dest, char, SfileadrL);
Xorriso_alloc_meM(dir_adr, char, SfileadrL);
Xorriso_alloc_meM(eff_origin, char, SfileadrL);
#ifndef Libisofs_iso_dir_iter_sufficienT
/* Ticket 127: A80301 - A80302
I do not not deem IsoDirIter safe for node list manipulations.
@ -1533,23 +1580,23 @@ int Xorriso_rename(struct XorrisO *xorriso, void *boss_iter,
*/
if(boss_iter!=NULL) {
sprintf(xorriso->info_text,
"Program error: Xorriso_rename() was requested to delete iterated node %s",
Text_shellsafe(origin, sfe, 0));
"Program error: Xorriso_rename() was requested to delete iterated node ");
Text_shellsafe(origin, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
return(-1);
{ret= -1; goto ex;}
}
#endif /* Libisofs_iso_dir_iter_sufficienT */
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, origin, eff_origin, 0);
if(ret<=0)
return(ret);
goto ex;
dest_ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, dest, eff_dest,1);
if(dest_ret<0)
return(dest_ret);
{ret= dest_ret; goto ex;}
if(dest_ret==0) { /* obtain eff_dest address despite it does not exist */
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, dest, eff_dest, 2);
if(ret<=0)
return(ret);
goto ex;
}
/* Prevent that destination is a subordinate of origin
@ -1558,26 +1605,28 @@ int Xorriso_rename(struct XorrisO *xorriso, void *boss_iter,
if(ol==0) {
sprintf(xorriso->info_text, "May not rename root directory");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
} else if(strcmp(eff_origin, eff_dest)==0) {
sprintf(xorriso->info_text, "Ignored attempt to rename %s to itself",
Text_shellsafe(eff_origin,sfe,0));
sprintf(xorriso->info_text, "Ignored attempt to rename ");
Text_shellsafe(eff_origin, xorriso->info_text, 1);
strcat(xorriso->info_text, " to itself");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 0);
return(0);
{ret= 0; goto ex;}
} else if(strncmp(eff_origin, eff_dest, ol)==0 &&
(eff_dest[ol]==0 || eff_dest[ol]=='/')) {
sprintf(xorriso->info_text,
"May not rename %s to its own sub address %s",
Text_shellsafe(eff_origin,sfe,0), Text_shellsafe(eff_dest,sfe2,0));
sprintf(xorriso->info_text, "May not rename ");
Text_shellsafe(eff_origin, xorriso->info_text, 1);
strcat(xorriso->info_text, " to its own sub address ");
Text_shellsafe(eff_dest, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
/* Check whether destination exists and may be not overwriteable */
ret= Xorriso_overwrite_dest(xorriso, boss_iter,
eff_dest, dest_ret, "Renaming", 0);
if(ret <= 0)
return(ret);
goto ex;
/* Ensure existence of destination directory */
strcpy(dir_adr, eff_dest);
@ -1589,13 +1638,13 @@ int Xorriso_rename(struct XorrisO *xorriso, void *boss_iter,
ret= Xorriso_graft_in(xorriso, boss_iter, NULL, dir_adr,
(off_t) 0, (off_t) 0, 1);
if(ret<=0)
return(ret);
goto ex;
}
/* Move node */
ret= Xorriso_get_volume(xorriso, &volume, 0);
if(ret<=0)
return(ret);
goto ex;
Xorriso_node_from_path(xorriso, volume, dir_adr, &iso_node, 0);
dest_dir= (IsoDir *) iso_node;
strcpy(dir_adr, eff_origin);
@ -1611,7 +1660,7 @@ int Xorriso_rename(struct XorrisO *xorriso, void *boss_iter,
sprintf(xorriso->info_text,
"Internal error on rename: confirmed node turns out as NULL");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
return(-1);
{ret= -1; goto ex;}
}
ret= iso_node_take(node);
if(ret<0) {
@ -1620,7 +1669,7 @@ int Xorriso_rename(struct XorrisO *xorriso, void *boss_iter,
sprintf(xorriso->info_text,
"Internal error on rename: failed to take node");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
return(-1);
{ret= -1; goto ex;}
}
leafname= strrchr(eff_dest, '/');
if(leafname==NULL)
@ -1637,7 +1686,7 @@ int Xorriso_rename(struct XorrisO *xorriso, void *boss_iter,
Xorriso_process_msg_queues(xorriso,0);
Xorriso_report_iso_error(xorriso, eff_dest, 0, "Cannot set name", 0,
"FAILURE", 1);
return(-1);
{ret= -1; goto ex;}
}
Xorriso_process_msg_queues(xorriso,0);
ret= iso_dir_add_node(dest_dir, node, 0);
@ -1647,9 +1696,14 @@ int Xorriso_rename(struct XorrisO *xorriso, void *boss_iter,
sprintf(xorriso->info_text,
"Internal error on rename: failed to insert node");
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FATAL", 0);
return(-1);
{ret= -1; goto ex;}
}
return(1);
ret= 1;
ex:;
Xorriso_free_meM(eff_dest);
Xorriso_free_meM(dir_adr);
Xorriso_free_meM(eff_origin);
return(ret);
}
@ -1664,6 +1718,7 @@ int Xorriso_cannot_clone(struct XorrisO *xorriso, char *eff_origin,
return(0);
}
/* @param flag bit0= for iso_tree_clone() : merge directories
bit1= do not issue NOTE message
*/
@ -1671,26 +1726,30 @@ int Xorriso_clone_tree(struct XorrisO *xorriso, void *boss_iter,
char *origin, char *dest, int flag)
{
int ret, dest_ret, l;
char eff_dest[SfileadrL], eff_origin[SfileadrL], dir_adr[SfileadrL];
char *eff_dest= NULL, *eff_origin= NULL, *dir_adr= NULL;
char *leafname;
IsoImage *volume;
IsoDir *new_parent;
IsoNode *origin_node, *dir_node, *new_node;
Xorriso_alloc_meM(eff_dest, char, SfileadrL);
Xorriso_alloc_meM(eff_origin, char, SfileadrL);
Xorriso_alloc_meM(dir_adr, char, SfileadrL);
ret= Xorriso_get_volume(xorriso, &volume, 0);
if(ret <= 0)
return(ret);
goto ex;
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, origin, eff_origin, 0);
if(ret<=0)
return(ret);
goto ex;
ret= Xorriso_node_from_path(xorriso, volume, eff_origin, &origin_node, 0);
if(ret <= 0)
return(ret);
goto ex;
dest_ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, dest, eff_dest,1);
if(dest_ret<0)
return(dest_ret);
{ret= dest_ret; goto ex;}
if(dest_ret > 0) {
if(eff_dest[0] == 0)
strcpy(eff_dest, "/");
@ -1698,12 +1757,12 @@ int Xorriso_clone_tree(struct XorrisO *xorriso, void *boss_iter,
"Cloning: Copy address already exists: ");
Text_shellsafe(eff_dest, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
} else {
/* obtain eff_dest address despite it does not exist */
ret= Xorriso_normalize_img_path(xorriso, xorriso->wdi, dest, eff_dest, 2);
if(ret<=0)
return(ret);
goto ex;
}
/* Obtain parent path and leaf name */
@ -1720,7 +1779,7 @@ int Xorriso_clone_tree(struct XorrisO *xorriso, void *boss_iter,
if (leafname[0] == 0) {
Xorriso_msgs_submit(xorriso, 0, "Empty file name as clone destination",
0, "FAILURE", 0);
return(0);
{ret= 0; goto ex;}
}
} else {
*leafname= 0;
@ -1730,20 +1789,20 @@ int Xorriso_clone_tree(struct XorrisO *xorriso, void *boss_iter,
ret= Xorriso_graft_in(xorriso, boss_iter, NULL, dir_adr,
(off_t) 0, (off_t) 0, 1);
if(ret <= 0)
return(ret);
goto ex;
}
}
ret= Xorriso_node_from_path(xorriso, volume, dir_adr, &dir_node, 0);
if(ret <= 0)
return(ret);
goto ex;
new_parent= (IsoDir *) dir_node;
ret = iso_tree_clone(origin_node, new_parent, leafname, &new_node, flag & 1);
Xorriso_process_msg_queues(xorriso,0);
if(ret < 0) {
Xorriso_cannot_clone(xorriso, eff_origin, eff_dest, ret, 0);
return(0);
{ret= 0; goto ex;}
}
Xorriso_set_change_pending(xorriso, 0);
if(!(flag & 2)) {
@ -1754,7 +1813,12 @@ int Xorriso_clone_tree(struct XorrisO *xorriso, void *boss_iter,
strcat(xorriso->info_text, "\n");
Xorriso_info(xorriso, 0);
}
return(1);
ret= 1;
ex:;
Xorriso_free_meM(eff_dest);
Xorriso_free_meM(eff_origin);
Xorriso_free_meM(dir_adr);
return(ret);
}
@ -1762,21 +1826,24 @@ int Xorriso_clone_under(struct XorrisO *xorriso, char *origin, char *dest,
int flag)
{
int ret, pass;
char eff_dest[SfileadrL], eff_origin[SfileadrL], *namept;
char *eff_dest= NULL, *eff_origin= NULL, *namept;
IsoDir *origin_dir, *dest_dir;
IsoDirIter *iter= NULL;
IsoNode *origin_node, *new_node;
IsoImage *volume;
Xorriso_alloc_meM(eff_dest, char, SfileadrL);
Xorriso_alloc_meM(eff_origin, char, SfileadrL);
ret= Xorriso_get_volume(xorriso, &volume, 0);
if(ret <= 0)
return(ret);
goto ex;
ret= Xorriso_dir_from_path(xorriso, "Copy source", origin, &origin_dir, 0);
if(ret <= 0)
return(ret);
goto ex;
ret= Xorriso_dir_from_path(xorriso, "Copy destination", dest, &dest_dir, 0);
if(ret <= 0)
return(ret);
goto ex;
for(pass= 0; pass < 2; pass++) {
ret= iso_dir_get_children(origin_dir, &iter);
@ -1817,6 +1884,8 @@ int Xorriso_clone_under(struct XorrisO *xorriso, char *origin, char *dest,
ex:;
if(iter != NULL)
iso_dir_iter_free(iter);
Xorriso_free_meM(eff_dest);
Xorriso_free_meM(eff_origin);
Xorriso_process_msg_queues(xorriso,0);
return(ret);
}
@ -1828,21 +1897,26 @@ int Xorriso_set_st_mode(struct XorrisO *xorriso, char *in_path,
mode_t mode= 0;
int ret;
IsoNode *node;
char sfe[5*SfileadrL], path[SfileadrL];
char *path= NULL;
Xorriso_alloc_meM(path, char, SfileadrL);
ret= Xorriso_get_node_by_path(xorriso, in_path, path, &node, 0);
if(ret<=0)
return(ret);
goto ex;
mode= iso_node_get_permissions(node);
mode= (mode & mode_and) | mode_or;
iso_node_set_permissions(node, mode);
iso_node_set_ctime(node, time(NULL));
sprintf(xorriso->info_text,"Permissions now: %-5.5o %s",
(unsigned int) (mode & 0xffff), Text_shellsafe(path, sfe, 0));
sprintf(xorriso->info_text,"Permissions now: %-5.5o ",
(unsigned int) (mode & 0xffff));
Text_shellsafe(path, xorriso->info_text, 1);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "DEBUG", 0);
Xorriso_set_change_pending(xorriso, 0);
Xorriso_process_msg_queues(xorriso,0);
return(1);
ret= 1;
ex:;
Xorriso_free_meM(path);
return(ret);
}
@ -2104,14 +2178,16 @@ int Xorriso_widen_hardlink(struct XorrisO *xorriso, void * boss_iter,
int flag)
{
int ret= 0, idx, low, high, i, do_widen= 0, compare_result= 0;
char disk_path[SfileadrL];
char *disk_path;
Xorriso_alloc_meM(disk_path, char, SfileadrL);
/* Lookup all di_array instances of node */
if(LIBISO_ISDIR(node))
return(3);
{ret= 3; goto ex;}
ret= Xorriso_search_di_range(xorriso, node, &idx, &low, &high, 2);
if(ret <= 0)
return(3);
{ret= 3; goto ex;}
/* Check and reset di_do_widen bits */
for(i= low; i <= high; i++) {
if(node != xorriso->di_array[i]) /* might be NULL */
@ -2121,22 +2197,24 @@ int Xorriso_widen_hardlink(struct XorrisO *xorriso, void * boss_iter,
xorriso->di_do_widen[i / 8]&= ~(1 << (i % 8));
}
if(idx < 0 || !do_widen)
return(3);
{ret= 3; goto ex;}
ret= Xorriso_pfx_disk_path(xorriso, abs_path, iso_prefix, disk_prefix,
disk_path, 0);
if(ret <= 0)
return(ret);
goto ex;
ret= Sfile_type(disk_path, 1);
if(ret < 0)
return(3); /* does not exist on disk */
{ret= 3; goto ex;} /* does not exist on disk */
/* >>> compare_result bit17 = is_split */;
ret= Xorriso_update_interpreter(xorriso, boss_iter, NULL,
compare_result, disk_path, abs_path, 1);
if(ret <= 0)
return(ret);
goto ex;
ex:;
Xorriso_free_meM(disk_path);
return(ret);
}
@ -2323,7 +2401,7 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
gid_t group= 0;
time_t date= 0;
mode_t mode_or= 0, mode_and= ~1;
char *target, *text_2, sfe[5*SfileadrL], *iso_prefix, md5[16], *basename;
char *target, *text_2, *iso_prefix, md5[16], *basename;
struct FindjoB *subjob;
struct stat dir_stbuf, stbuf;
@ -2462,7 +2540,8 @@ int Xorriso_findi_action(struct XorrisO *xorriso, struct FindjoB *job,
} else if(action == 43) { /* clear_merge */
ret= Xorriso_mark_update_merge(xorriso, show_path, node, 2 | 4);
} else { /* includes : 15 in_iso */
sprintf(xorriso->result_line, "%s\n", Text_shellsafe(show_path, sfe, 0));
Text_shellsafe(show_path, xorriso->result_line, 0);
strcat(xorriso->result_line, "\n");
Xorriso_result(xorriso, 0);
ret= 1;
}
@ -2481,13 +2560,15 @@ int Exprtest_match_disk_name(struct XorrisO *xorriso, struct ExprtesT *ftest,
{
int ret;
char disk_path[SfileadrL], *npt;
char *disk_path= NULL, *npt;
regmatch_t name_match;
void *arg2;
Xorriso_alloc_meM(disk_path, char, SfileadrL);
ret= Xorriso_retrieve_disk_path(xorriso, node, disk_path, 0);
if(ret <= 0)
return(0);
{ret= 0; goto ex;}
arg2= ftest->arg2;
npt= strrchr(disk_path, '/');
if(npt != NULL)
@ -2495,7 +2576,9 @@ int Exprtest_match_disk_name(struct XorrisO *xorriso, struct ExprtesT *ftest,
else
npt= disk_path;
ret= regexec(arg2, npt, 1, &name_match, 0);
return !ret;
ex:;
Xorriso_free_meM(disk_path);
return(!ret);
}
@ -2973,9 +3056,11 @@ int Xorriso_findi_sorted(struct XorrisO *xorriso, struct FindjoB *job,
struct FindjoB array_job, *proxy_job= NULL, *hindmost= NULL, *hmboss= NULL;
struct stat dir_stbuf;
IsoNode *node;
char abs_path[SfileadrL];
char *abs_path= NULL;
off_t mem_needed= 0;
Xorriso_alloc_meM(abs_path, char, SfileadrL);
array_job.start_path= NULL;
if(job->action == 14 || job->action == 17)
@ -3094,6 +3179,7 @@ ex:;
hmboss->subjob= hindmost;
if(array_job.start_path != NULL)
free(array_job.start_path);
Xorriso_free_meM(abs_path);
return(ret);
}

@ -1 +1 @@
#define Xorriso_timestamP "2011.05.03.115226"
#define Xorriso_timestamP "2011.05.04.151605"

Loading…
Cancel
Save