With -extract : made hardlink registration combinable with sort_lba
This commit is contained in:
@@ -3927,17 +3927,24 @@ int Xorriso_restore_overwrite(struct XorrisO *xorriso,
|
||||
|
||||
/* @param flag bit0= do not accept hln_targets[i] != NULL as *node_idx
|
||||
bit1= use *node_idx as found index rather than searching it
|
||||
bit2= with bit1: use xorriso->node_array rather than hln_array
|
||||
*/
|
||||
int Xorriso_search_hardlinks(struct XorrisO *xorriso, IsoNode *node,
|
||||
int *node_idx, int *min_hl, int *max_hl, int flag)
|
||||
{
|
||||
int idx, ret, i;
|
||||
void *np;
|
||||
int idx, ret, i, node_count;
|
||||
void *np, **node_array;
|
||||
|
||||
node_array= xorriso->hln_array;
|
||||
node_count= xorriso->hln_count;
|
||||
*min_hl= *max_hl= -1;
|
||||
np= node;
|
||||
if(flag & 2) {
|
||||
idx= *node_idx;
|
||||
if(flag & 4) {
|
||||
node_array= xorriso->node_array;
|
||||
node_count= xorriso->node_counter;
|
||||
}
|
||||
} else {
|
||||
*node_idx= -1;
|
||||
ret= Xorriso_search_in_hln_array(xorriso, np, &idx, 0);
|
||||
@@ -3945,11 +3952,11 @@ int Xorriso_search_hardlinks(struct XorrisO *xorriso, IsoNode *node,
|
||||
return(ret);
|
||||
}
|
||||
for(i= idx - 1; i >= 0 ; i--)
|
||||
if(Xorriso__findi_sorted_ino_cmp(&(xorriso->hln_array[i]), &np) != 0)
|
||||
if(Xorriso__findi_sorted_ino_cmp(&(node_array[i]), &np) != 0)
|
||||
break;
|
||||
*min_hl= i + 1;
|
||||
for(i= idx + 1; i < xorriso->hln_count; i++)
|
||||
if(Xorriso__findi_sorted_ino_cmp(&(xorriso->hln_array[i]), &np) != 0)
|
||||
for(i= idx + 1; i < node_count; i++)
|
||||
if(Xorriso__findi_sorted_ino_cmp(&(node_array[i]), &np) != 0)
|
||||
break;
|
||||
*max_hl= i - 1;
|
||||
|
||||
@@ -3957,8 +3964,8 @@ int Xorriso_search_hardlinks(struct XorrisO *xorriso, IsoNode *node,
|
||||
if(flag & 2)
|
||||
return(1);
|
||||
for(i= *min_hl; i <= *max_hl; i++)
|
||||
if(xorriso->hln_array[i] == np) {
|
||||
if((flag & 1) && xorriso->hln_targets != NULL)
|
||||
if(node_array[i] == np) {
|
||||
if((flag & 1) && xorriso->hln_targets != NULL && !(flag & 4))
|
||||
if(xorriso->hln_targets[i] != NULL)
|
||||
continue;
|
||||
*node_idx= i;
|
||||
@@ -3994,7 +4001,7 @@ int Xorriso_restore_target_hl(struct XorrisO *xorriso, IsoNode *node,
|
||||
}
|
||||
link_sibling= 1;
|
||||
ret= Xorriso_restore_make_hl(xorriso, xorriso->hln_targets[i], disk_path,
|
||||
0);
|
||||
!!xorriso->do_auto_chmod);
|
||||
if(ret > 0)
|
||||
return(1);
|
||||
}
|
||||
@@ -4015,7 +4022,7 @@ int Xorriso_restore_prefix_hl(struct XorrisO *xorriso, IsoNode *node,
|
||||
struct Xorriso_lsT *img_prefixes= NULL, *disk_prefixes= NULL;
|
||||
|
||||
ret= Xorriso_search_hardlinks(xorriso, node, &node_idx, &min_hl, &max_hl,
|
||||
1 | 2);
|
||||
2 | 4);
|
||||
if(ret < 0)
|
||||
return(ret);
|
||||
if(ret == 0 || min_hl == max_hl)
|
||||
@@ -4042,7 +4049,8 @@ int Xorriso_restore_prefix_hl(struct XorrisO *xorriso, IsoNode *node,
|
||||
img_path, old_path, hflag);
|
||||
if(ret <= 0)
|
||||
return(ret);
|
||||
ret= Xorriso_restore_make_hl(xorriso, old_path, disk_path, 1);
|
||||
ret= Xorriso_restore_make_hl(xorriso, old_path, disk_path,
|
||||
!!xorriso->do_auto_chmod);
|
||||
if(ret > 0)
|
||||
return(1);
|
||||
}
|
||||
@@ -4168,10 +4176,10 @@ int Xorriso_restore_disk_object(struct XorrisO *xorriso,
|
||||
|
||||
img_path_pt= img_path;
|
||||
|
||||
if(!((xorriso->ino_behavior & 4) || (flag & (1 || 16)) ||
|
||||
LIBISO_ISDIR(node))) {
|
||||
if(!((xorriso->ino_behavior & 4) || (flag & (1 | 16)) || LIBISO_ISDIR(node))){
|
||||
/* Try to restore as hardlink */
|
||||
ret= Xorriso_restore_target_hl(xorriso, node, disk_path, &node_idx, 0);
|
||||
ret= Xorriso_restore_target_hl(xorriso, node, disk_path, &node_idx,
|
||||
!!xorriso->do_auto_chmod);
|
||||
if(ret < 0) {
|
||||
goto ex;
|
||||
} else if(ret & 1) {
|
||||
@@ -4823,8 +4831,10 @@ int Xorriso_restore_node_array(struct XorrisO *xorriso, int flag)
|
||||
&stbuf_ret, 64);
|
||||
if(ret<=0 || ret==3)
|
||||
goto was_problem;
|
||||
|
||||
if(i > 0 && !(xorriso->ino_behavior & 4)) {
|
||||
if(xorriso->hln_array != NULL && !(xorriso->ino_behavior & 16)) {
|
||||
/* Eventual lookup of hardlinks will be done in
|
||||
Xorriso_restore_disk_object() */;
|
||||
} else if(i > 0 && !(xorriso->ino_behavior & 4)) {
|
||||
if(Xorriso__findi_sorted_ino_cmp(&(xorriso->node_array[i-1]),
|
||||
&(xorriso->node_array[i])) == 0) {
|
||||
if(faulty_family) {
|
||||
@@ -4853,7 +4863,8 @@ int Xorriso_restore_node_array(struct XorrisO *xorriso, int flag)
|
||||
}
|
||||
|
||||
ret= Xorriso_restore_disk_object(xorriso, img_path, node, disk_path,
|
||||
(off_t) 0, (off_t) 0, 4 | 128);
|
||||
(off_t) 0, (off_t) 0,
|
||||
4 | (xorriso->ino_behavior & 16) | 128);
|
||||
if(ret<=0)
|
||||
goto was_problem;
|
||||
if(ret == 4) {
|
||||
@@ -4862,7 +4873,7 @@ int Xorriso_restore_node_array(struct XorrisO *xorriso, int flag)
|
||||
if(ret < 0)
|
||||
goto ex;
|
||||
ret= Xorriso_restore_disk_object(xorriso, img_path, node, disk_path,
|
||||
(off_t) 0, (off_t) 0, 4);
|
||||
(off_t) 0, (off_t) 0, 4 | (xorriso->ino_behavior & 16));
|
||||
if(ret<=0)
|
||||
goto was_problem;
|
||||
Permstack_pop(&(xorriso->perm_stack), perm_stack_mem, xorriso, 0);
|
||||
|
Reference in New Issue
Block a user