Wider scope of hardlink reconstruction with extract operations
This commit is contained in:
@ -5392,11 +5392,15 @@ int Xorriso_new(struct XorrisO ** xorriso,char *progname, int flag)
|
||||
m->node_counter= 0;
|
||||
m->node_array_size= 0;
|
||||
m->node_array= NULL;
|
||||
m->node_targets= NULL;
|
||||
m->node_targets_availmem= 0;
|
||||
m->node_disk_prefixes= NULL;
|
||||
m->node_img_prefixes= NULL;
|
||||
|
||||
m->hln_count= 0;
|
||||
m->hln_array= NULL;
|
||||
m->hln_targets= NULL;
|
||||
|
||||
m->node_targets_availmem= 0;
|
||||
|
||||
m->di_count= 0;
|
||||
m->di_array= NULL;
|
||||
|
||||
@ -5486,6 +5490,7 @@ int Xorriso_destroy(struct XorrisO **xorriso, int flag)
|
||||
Xorriso_lst_destroy_all(&(m->drive_greylist), 0);
|
||||
Xorriso_lst_destroy_all(&(m->drive_whitelist), 0);
|
||||
Xorriso_destroy_node_array(m, 0);
|
||||
Xorriso_destroy_hln_array(m, 0);
|
||||
Xorriso_destroy_di_array(m, 0);
|
||||
|
||||
Xorriso_detach_libraries(m, flag&1);
|
||||
@ -12931,7 +12936,8 @@ int Xorriso_restore_sorted(struct XorrisO *xorriso, int count,
|
||||
int i, ret, with_node_array= 0, hflag= 0, hret;
|
||||
|
||||
if(xorriso->do_restore_sort_lba ||
|
||||
!((xorriso->ino_behavior & 4) || (flag & 1))) {
|
||||
!((xorriso->ino_behavior & 4) || (flag & 1) ||
|
||||
xorriso->hln_array != NULL)) {
|
||||
/* Count affected nodes */
|
||||
Xorriso_destroy_node_array(xorriso, 0);
|
||||
for(i= 0; i < count; i++) {
|
||||
@ -12978,6 +12984,21 @@ int Xorriso_restore_sorted(struct XorrisO *xorriso, int count,
|
||||
goto ex;
|
||||
}
|
||||
}
|
||||
|
||||
if(xorriso->hln_array == NULL && !xorriso->do_restore_sort_lba) {
|
||||
/* Unsorted restore is desired and no long term hln array was installed:
|
||||
Take over node array as hln array for this single run. */
|
||||
Xorriso_sort_node_array(xorriso, 0);
|
||||
xorriso->hln_array= xorriso->node_array;
|
||||
xorriso->node_array= NULL;
|
||||
xorriso->node_array_size= 0;
|
||||
xorriso->hln_count= xorriso->node_counter;
|
||||
xorriso->node_counter= 0;
|
||||
/* Allocate new hln_targets array */
|
||||
ret= Xorriso_new_hln_array(xorriso, xorriso->temp_mem_limit, 1);
|
||||
if(ret<=0)
|
||||
goto ex;
|
||||
}
|
||||
}
|
||||
|
||||
/* Perform restore operations */
|
||||
@ -12986,8 +13007,6 @@ int Xorriso_restore_sorted(struct XorrisO *xorriso, int count,
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
} else {
|
||||
if(with_node_array)
|
||||
Xorriso_sort_node_array(xorriso, 0);
|
||||
for(i= 0; i < count; i++) {
|
||||
if(src_array[i] == NULL || tgt_array[i] == NULL)
|
||||
continue;
|
||||
@ -14401,7 +14420,7 @@ ex:;
|
||||
int Xorriso_option_cpx(struct XorrisO *xorriso, int argc, char **argv,
|
||||
int *idx, int flag)
|
||||
{
|
||||
int i, ret, is_dir= 0, was_failure= 0, fret, end_idx_dummy;
|
||||
int i, ret, is_dir= 0, was_failure= 0, fret, end_idx_dummy, was_hln_array;
|
||||
char eff_origin[SfileadrL], eff_dest[SfileadrL];
|
||||
char dest_dir[SfileadrL], leafname[SfileadrL], sfe[5*SfileadrL];
|
||||
char **eff_src_array= NULL, **eff_tgt_array= NULL;
|
||||
@ -14410,6 +14429,7 @@ int Xorriso_option_cpx(struct XorrisO *xorriso, int argc, char **argv,
|
||||
char **optv= NULL;
|
||||
struct stat stbuf;
|
||||
|
||||
was_hln_array= (xorriso->hln_array != NULL);
|
||||
ret= Xorriso_cpmv_args(xorriso, "-cp*x", argc, argv, idx,
|
||||
&optc, &optv, eff_dest, 1|4);
|
||||
if(ret<=0)
|
||||
@ -14519,6 +14539,8 @@ ex:;
|
||||
Sfile_destroy_argv(&i, &eff_tgt_array, 0);
|
||||
Xorriso_opt_args(xorriso, "-cp*x",
|
||||
argc, argv, *idx, &end_idx_dummy, &optc, &optv, 256);
|
||||
if(!was_hln_array)
|
||||
Xorriso_destroy_hln_array(xorriso, 0);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -14962,9 +14984,10 @@ int Xorriso_option_external_filter(struct XorrisO *xorriso,
|
||||
int Xorriso_option_extract(struct XorrisO *xorriso, char *iso_path,
|
||||
char *disk_path, int flag)
|
||||
{
|
||||
int ret;
|
||||
int ret, was_hln_array;
|
||||
char eff_origin[SfileadrL], eff_dest[SfileadrL], *ipth, *eopt[1], *edpt[1];
|
||||
|
||||
was_hln_array= (xorriso->hln_array != NULL);
|
||||
if(xorriso->allow_restore <= 0) {
|
||||
sprintf(xorriso->info_text,
|
||||
"-extract: image-to-disk copies are not enabled by option -osirrox");
|
||||
@ -15009,6 +15032,8 @@ int Xorriso_option_extract(struct XorrisO *xorriso, char *iso_path,
|
||||
ex:;
|
||||
if(!(flag & (4 | 32)))
|
||||
Xorriso_destroy_node_array(xorriso, 0);
|
||||
if(!was_hln_array)
|
||||
Xorriso_destroy_hln_array(xorriso, 0);
|
||||
return(ret);
|
||||
}
|
||||
|
||||
@ -15667,11 +15692,19 @@ int Xorriso_option_hardlinks(struct XorrisO *xorriso, char *mode, int flag)
|
||||
Xorriso_destroy_di_array(xorriso, 0);
|
||||
} else if(strcmp(mode, "start_update") == 0) {
|
||||
xorriso->ino_behavior&= ~(1 | 2 | 4 | 8);
|
||||
ret= Xorriso_make_di_array(xorriso, 0);
|
||||
ret= Xorriso_make_di_array(xorriso, 1);
|
||||
if(ret <= 0)
|
||||
return(ret);
|
||||
} else if(strcmp(mode, "end_update") == 0) {
|
||||
Xorriso_destroy_di_array(xorriso, 0);
|
||||
} else if(strcmp(mode, "start_extract") == 0) {
|
||||
xorriso->do_restore_sort_lba= 0;
|
||||
xorriso->ino_behavior&= ~(1 | 2 | 4);
|
||||
ret= Xorriso_make_hln_array(xorriso, 1);
|
||||
if(ret <= 0)
|
||||
return(ret);
|
||||
} else if(strcmp(mode, "end_extract") == 0) {
|
||||
Xorriso_destroy_hln_array(xorriso, 0);
|
||||
} else {
|
||||
sprintf(xorriso->info_text, "-hardlinks: unknown mode '%s'", mode);
|
||||
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "FAILURE", 0);
|
||||
@ -15734,9 +15767,11 @@ int Xorriso_option_help(struct XorrisO *xorriso, int flag)
|
||||
" -local_charset name",
|
||||
" Override system assumption of the local character set name.",
|
||||
" -hardlinks \"on\"|\"off\"|\"start_update\"|\"end_update\"|\"without_update\"",
|
||||
" \"start_extract\"|\"end_extract\"",
|
||||
" Enable resp. disable recording and restoring of hard links,",
|
||||
" or prepare for -update_r, or release prepared memory, or",
|
||||
" disable hardlink detection with -update_r.",
|
||||
" resp. prepare for -update_r, resp. release prepared memory,",
|
||||
" resp. disable hardlink detection with -update_r, resp.",
|
||||
" prepare for -extract, resp. release prepared memory.",
|
||||
" -acl \"on\"|\"off\"",
|
||||
" Enable resp. disable reading and writing of ACLs.",
|
||||
" -xattr \"on\"|\"off\"",
|
||||
@ -16623,7 +16658,7 @@ int Xorriso_option_map(struct XorrisO *xorriso, char *disk_path,
|
||||
int Xorriso_option_map_l(struct XorrisO *xorriso, int argc, char **argv,
|
||||
int *idx, int flag)
|
||||
{
|
||||
int ret, end_idx, optc= 0, was_failure= 1, i, fret, mode;
|
||||
int ret, end_idx, optc= 0, was_failure= 1, i, fret, mode, made_hln_array= 0;
|
||||
int ns_flag= 2|4, nt_flag= 2, opt_args_flag= 2, made_di_array= 0;
|
||||
char source_prefix[SfileadrL], target_prefix[SfileadrL], *cmd, **optv= NULL;
|
||||
char eff_source[SfileadrL], eff_target[SfileadrL], *source_pt, *s_wd, *t_wd;
|
||||
@ -16679,6 +16714,14 @@ int Xorriso_option_map_l(struct XorrisO *xorriso, int argc, char **argv,
|
||||
}
|
||||
for(i= 0; i < optc; i++)
|
||||
eff_src_array[i]= eff_tgt_array[i]= NULL;
|
||||
if(xorriso->hln_array == NULL &&
|
||||
!(xorriso->do_restore_sort_lba || (xorriso->ino_behavior & 4))) {
|
||||
/* Create all-image node array sorted by iso image inode number */
|
||||
ret= Xorriso_make_hln_array(xorriso, 1);
|
||||
if(ret <= 0)
|
||||
goto ex;
|
||||
made_hln_array= (xorriso->hln_array == NULL);
|
||||
}
|
||||
}
|
||||
if(mode == 2 && !((xorriso->ino_behavior & 2) || (flag & 16) ||
|
||||
xorriso->di_array != NULL)) {
|
||||
@ -16768,6 +16811,8 @@ ex:;
|
||||
(*idx)= end_idx;
|
||||
if(made_di_array)
|
||||
Xorriso_destroy_di_array(xorriso, 0);
|
||||
if(made_hln_array)
|
||||
Xorriso_destroy_hln_array(xorriso, 0);
|
||||
Xorriso_opt_args(xorriso, cmd, argc, argv, *idx, &end_idx, &optc, &optv, 256);
|
||||
if(ret<=0)
|
||||
return(ret);
|
||||
|
Reference in New Issue
Block a user