|
|
|
@ -599,6 +599,50 @@ int Sfile_scale(double value, char *result, int siz, double thresh, int flag) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Sfile_off_t_text(char text[80], off_t num, int flag) |
|
|
|
|
{ |
|
|
|
|
char *tpt; |
|
|
|
|
off_t hnum, scale= 1; |
|
|
|
|
int digits= 0, d, i; |
|
|
|
|
|
|
|
|
|
tpt= text; |
|
|
|
|
hnum= num; |
|
|
|
|
if(hnum<0) { |
|
|
|
|
*(tpt++)= '-'; |
|
|
|
|
hnum= -num; |
|
|
|
|
} |
|
|
|
|
if(hnum<0) { /* it can stay nastily persistent */ |
|
|
|
|
strcpy(text, "_overflow_"); |
|
|
|
|
return(0); |
|
|
|
|
} |
|
|
|
|
for(i= 0; i<23; i++) { /* good for up to 70 bit = 10 exp 21.07... */ |
|
|
|
|
if(hnum==0) |
|
|
|
|
break; |
|
|
|
|
hnum/= 10; |
|
|
|
|
if(hnum) |
|
|
|
|
scale*= 10; |
|
|
|
|
} |
|
|
|
|
if(i==0) { |
|
|
|
|
strcpy(text, "0"); |
|
|
|
|
return(1); |
|
|
|
|
} |
|
|
|
|
if(i==23) { |
|
|
|
|
strcpy(text, "_overflow_"); |
|
|
|
|
return(0); |
|
|
|
|
} |
|
|
|
|
digits= i; |
|
|
|
|
hnum= num; |
|
|
|
|
for(; i>0; i--) { |
|
|
|
|
d= hnum/scale; |
|
|
|
|
tpt[digits-i]= '0'+d; |
|
|
|
|
hnum= hnum%scale; |
|
|
|
|
scale/= 10; |
|
|
|
|
} |
|
|
|
|
tpt[digits]= 0; |
|
|
|
|
return(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Sfile_destroy_argv(int *argc, char ***argv, int flag) |
|
|
|
|
{ |
|
|
|
|
int i; |
|
|
|
@ -2856,6 +2900,27 @@ int Splitpart__parse(char *name, int *partno, int *total_parts, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int Splitpart__compose(char *adr, int partno, int total_parts, |
|
|
|
|
off_t offset, off_t bytes, off_t total_bytes, int flag) |
|
|
|
|
{ |
|
|
|
|
sprintf(adr, "part_%d_of_%d_at_", partno, total_parts); |
|
|
|
|
if((offset % (1024*1024))==0 && offset>0) { |
|
|
|
|
Sfile_off_t_text(adr+strlen(adr), offset / (1024*1024), 0); |
|
|
|
|
strcat(adr, "m"); |
|
|
|
|
} else |
|
|
|
|
Sfile_off_t_text(adr+strlen(adr), offset, 0); |
|
|
|
|
strcat(adr, "_with_");
|
|
|
|
|
if((bytes % (1024*1024))==0) { |
|
|
|
|
Sfile_off_t_text(adr+strlen(adr), bytes / (1024*1024), 0); |
|
|
|
|
strcat(adr, "m"); |
|
|
|
|
} else |
|
|
|
|
Sfile_off_t_text(adr+strlen(adr), bytes, 0); |
|
|
|
|
strcat(adr, "_of_"); |
|
|
|
|
Sfile_off_t_text(adr+strlen(adr), total_bytes, 0); |
|
|
|
|
return(1); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* ---------------------------- End SplitparT ------------------------- */ |
|
|
|
|
|
|
|
|
|
/* ------------------------------- Xorriso -------------------------------- */ |
|
|
|
@ -7525,14 +7590,14 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter, |
|
|
|
|
int compare_result, char *disk_path, |
|
|
|
|
char *iso_rr_path, int flag) |
|
|
|
|
{ |
|
|
|
|
int ret, deleted= 0, is_split= 0, i; |
|
|
|
|
int ret, deleted= 0, is_split= 0, i, loop_count; |
|
|
|
|
char sfe[5*SfileadrL]; |
|
|
|
|
struct stat stbuf; |
|
|
|
|
struct SplitparT *split_parts= NULL; |
|
|
|
|
int split_count= 0; |
|
|
|
|
char part_path[SfileadrL], *part_name; |
|
|
|
|
int partno, total_parts; |
|
|
|
|
off_t offset, bytes, total_bytes; |
|
|
|
|
int partno, total_parts, new_total_parts; |
|
|
|
|
off_t offset, bytes, total_bytes, disk_size, first_bytes; |
|
|
|
|
|
|
|
|
|
if(compare_result&((1<<11)|(1<<13))) { |
|
|
|
|
/* cannot open regular disk file, early eof of disk file */ |
|
|
|
@ -7546,7 +7611,7 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter, |
|
|
|
|
is_split= !!(compare_result & (1<<17)); |
|
|
|
|
|
|
|
|
|
/* <<< */ |
|
|
|
|
if(is_split) { |
|
|
|
|
if(0 && is_split) { |
|
|
|
|
sprintf(xorriso->info_text, "Split file cannot be updated yet: %s\n", |
|
|
|
|
Text_shellsafe(iso_rr_path, sfe, 0)); |
|
|
|
|
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "WARNING", 1); |
|
|
|
@ -7567,12 +7632,8 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter, |
|
|
|
|
sprintf(xorriso->info_text, "Deleted and re-added "); |
|
|
|
|
|
|
|
|
|
} else if(compare_result&(1)) { |
|
|
|
|
delete:; |
|
|
|
|
/* disk_adr not existing */ |
|
|
|
|
|
|
|
|
|
/* ??? SPLIT : Shall i recognize a splitfile without disk file ?
|
|
|
|
|
Does it make any difference ? |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
ret= Xorriso_rmi(xorriso, boss_iter, (off_t) 0, iso_rr_path, 1); |
|
|
|
|
deleted= 1; |
|
|
|
|
sprintf(xorriso->info_text, "Deleted "); |
|
|
|
@ -7587,31 +7648,58 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter, |
|
|
|
|
&split_parts, &split_count, &stbuf, 0); |
|
|
|
|
if(ret<=0) |
|
|
|
|
{ret= -1; goto ex;} /* (should not happen) */ |
|
|
|
|
for(i= 0; i<split_count; i++) { |
|
|
|
|
Splitparts_get(split_parts, i, &part_name, &partno, &total_parts, |
|
|
|
|
&offset, &bytes, &total_bytes, 0); |
|
|
|
|
strcpy(part_path, iso_rr_path); |
|
|
|
|
if(Sfile_add_to_path(part_path, part_name, 0)<=0) { |
|
|
|
|
Xorriso_much_too_long(xorriso, |
|
|
|
|
strlen(iso_rr_path)+strlen(part_path)+1, 2); |
|
|
|
|
{ret= -1; goto ex;} |
|
|
|
|
ret= lstat(disk_path, &stbuf); |
|
|
|
|
if(ret==-1) |
|
|
|
|
goto delete; |
|
|
|
|
disk_size= stbuf.st_size; |
|
|
|
|
Splitparts_get(split_parts, 0, &part_name, &partno, &total_parts, |
|
|
|
|
&offset, &first_bytes, &total_bytes, 0); |
|
|
|
|
new_total_parts= disk_size/first_bytes; |
|
|
|
|
if(disk_size % first_bytes) |
|
|
|
|
new_total_parts++; |
|
|
|
|
|
|
|
|
|
loop_count= split_count; |
|
|
|
|
/* If disk file grew over part limit and all parts are present:
|
|
|
|
|
add new parts */ |
|
|
|
|
if(new_total_parts > total_parts && split_count == total_parts) |
|
|
|
|
loop_count= new_total_parts; |
|
|
|
|
|
|
|
|
|
for(i= 0; i<loop_count; i++) { |
|
|
|
|
if(i<split_count) { |
|
|
|
|
/* Delete old part */ |
|
|
|
|
Splitparts_get(split_parts, i, &part_name, &partno, &total_parts, |
|
|
|
|
&offset, &bytes, &total_bytes, 0); |
|
|
|
|
strcpy(part_path, iso_rr_path); |
|
|
|
|
if(Sfile_add_to_path(part_path, part_name, 0)<=0) { |
|
|
|
|
Xorriso_much_too_long(xorriso, |
|
|
|
|
strlen(iso_rr_path)+strlen(part_path)+1, 2); |
|
|
|
|
{ret= -1; goto ex;} |
|
|
|
|
} |
|
|
|
|
ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, part_path, 1); |
|
|
|
|
if(ret<=0) |
|
|
|
|
goto ex; |
|
|
|
|
} else { |
|
|
|
|
partno= i+1; |
|
|
|
|
offset= i*first_bytes; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* Delete old part, just in case the name changes */ |
|
|
|
|
ret= Xorriso_rmi(xorriso, NULL, (off_t) 0, part_path, 1); |
|
|
|
|
if(ret<=0) |
|
|
|
|
goto ex; |
|
|
|
|
/* overwrite by new parts resp. delete from directory */ |
|
|
|
|
if(disk_size<=offset) |
|
|
|
|
continue; |
|
|
|
|
/* Insert new part */ |
|
|
|
|
if(strlen(part_path)+160>SfileadrL) { |
|
|
|
|
Xorriso_much_too_long(xorriso, strlen(part_path)+160, 2); |
|
|
|
|
ret= 0; goto ex; |
|
|
|
|
} |
|
|
|
|
Splitpart__compose(part_path+strlen(iso_rr_path)+1, partno, |
|
|
|
|
new_total_parts, offset, first_bytes, disk_size, 0); |
|
|
|
|
ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, part_path, |
|
|
|
|
offset, bytes, 2|(flag&4)); |
|
|
|
|
offset, bytes, 2|(flag&4)|8); |
|
|
|
|
if(ret<=0) |
|
|
|
|
goto ex; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* >>> ??? if disk file grew over part limit : add part ? */; |
|
|
|
|
|
|
|
|
|
/* >>> copy file attributes to iso_rr_path */; |
|
|
|
|
|
|
|
|
|
/* Copy file attributes to iso_rr_path, augment r-perms by x-perms */ |
|
|
|
|
ret= Xorriso_copy_properties(xorriso, disk_path, iso_rr_path, 2);
|
|
|
|
|
if(ret<=0) |
|
|
|
|
goto ex; |
|
|
|
|
} else
|
|
|
|
|
ret= Xorriso_graft_in(xorriso, boss_iter, disk_path, iso_rr_path, |
|
|
|
|
(off_t) 0, (off_t) 0, 2|(flag&4)); |
|
|
|
@ -7638,9 +7726,10 @@ int Xorriso_update_interpreter(struct XorrisO *xorriso, void *boss_iter, |
|
|
|
|
if(ret<=0) |
|
|
|
|
goto ex; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/* >>> copy file attributes to iso_rr_path */; |
|
|
|
|
|
|
|
|
|
/* Copy file attributes to iso_rr_path, augment r-perms by x-perms */ |
|
|
|
|
ret= Xorriso_copy_properties(xorriso, disk_path, iso_rr_path, 2);
|
|
|
|
|
if(ret<=0) |
|
|
|
|
goto ex; |
|
|
|
|
} else |
|
|
|
|
ret= Xorriso_copy_properties(xorriso, disk_path, iso_rr_path, 0);
|
|
|
|
|
sprintf(xorriso->info_text, "Adjusted attributes of "); |
|
|
|
@ -8547,7 +8636,7 @@ ex:; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* >>> SPLIT : proposed target format
|
|
|
|
|
/* SPLIT : proposed target format
|
|
|
|
|
|
|
|
|
|
part_{partno}_of_{total_parts}_at_{offset}_with_{bytes}_of_{total_bytes} |
|
|
|
|
*/ |
|
|
|
|