Showing a better link count with -hardlinks on -lsl

This commit is contained in:
Thomas Schmitt 2009-07-23 10:36:36 +00:00
parent 04a4ddd038
commit 0136c7bab9
3 changed files with 41 additions and 86 deletions

View File

@ -16539,6 +16539,12 @@ no_memory:;
patterns[i]= argv[i + *idx];
}
}
if((flag & 1) && !(xorriso->ino_behavior & 1)) {
ret= Xorriso_make_hln_array(xorriso, 0); /* for stbuf.st_nlink */
if(ret < 0)
return(ret);
}
if(flag&2) {
ret= Xorriso_ls_filev(xorriso, xorriso->wdi, nump, argv + (*idx), mem,
flag&(1|4|8));

View File

@ -1 +1 @@
#define Xorriso_timestamP "2009.07.23.103339"
#define Xorriso_timestamP "2009.07.23.103728"

View File

@ -99,6 +99,9 @@ int Xorriso_path_from_lba(struct XorrisO *xorriso, IsoNode *node, int lba,
int Xorriso__node_lba_cmp(const void *node1, const void *node2);
int Xorriso_search_hardlinks(struct XorrisO *xorriso, IsoNode *node,
int *node_idx, int *min_hl, int *max_hl, int flag);
#define LIBISO_ISDIR(node) (iso_node_get_type(node) == LIBISO_DIR)
#define LIBISO_ISREG(node) (iso_node_get_type(node) == LIBISO_FILE)
@ -384,20 +387,6 @@ int Xorriso__get_di(IsoNode *node, dev_t *dev, ino_t *ino, int flag)
i_end= i + vpt[i] + 1;
for(i++; i < i_end && i < value_length; i++)
*ino= ((*ino) << 8) | vpt[i];
#ifdef NIX
/* <<< */
if(*ino > 10000000 || *ino < 0) {
fprintf(stderr,
"xorriso_DEBUG: name= '%s' , vl= %lu , i_end= %d\n",
iso_node_get_name(node), (unsigned long) value_length, i_end);
fprintf(stderr, " ");
for(i= 0; i < value_length; i++)
fprintf(stderr, " %-3.3u", (unsigned int) vpt[i]);
fprintf(stderr, "\n");
}
#endif
free(value);
return(1);
}
@ -2163,7 +2152,7 @@ int Xorriso_pacifier_loop(struct XorrisO *xorriso, struct burn_drive *drive,
current_time-start_time);
else
sprintf(xorriso->info_text,
"Thank you for being patient for %.f seconds",
"Thank you for being patient. Working since %.f seconds.",
current_time-start_time);
Xorriso_msgs_submit(xorriso, 0, xorriso->info_text, 0, "UPDATE", 0);
@ -2420,11 +2409,14 @@ int Xorriso_node_get_dev(struct XorrisO *xorriso, IsoNode *node,
bit1= add extra block for size estimation
bit2= complain loudely if path is missing in image
bit3= stbuf is to be used without eventual ACL
bit4= try to obtain a better st_nlink count if hardlinks
are enabled
*/
int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf,
IsoNode **node, int flag)
{
int ret;
int ret, min_hl, max_hl, node_idx, i;
char img_path[SfileadrL];
IsoImage *volume;
memset((char *) stbuf, 0, sizeof(struct stat));
@ -2467,6 +2459,7 @@ int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf,
/* >>> With directories this should be : number of subdirs + 2 */
/* >>> ??? How to obtain RR hardlink number for other types ? */
/* This may get overriden farther down */
stbuf->st_nlink= 1;
stbuf->st_uid= iso_node_get_uid(*node);
@ -2485,6 +2478,27 @@ int Xorriso_fake_stbuf(struct XorrisO *xorriso, char *path, struct stat *stbuf,
stbuf->st_atime= iso_node_get_atime(*node);
stbuf->st_mtime= iso_node_get_mtime(*node);
stbuf->st_ctime= iso_node_get_ctime(*node);
if(LIBISO_ISDIR(*node) || (xorriso->ino_behavior & 1) || (!(flag & 16)) ||
xorriso->hln_array == NULL)
return(1);
/* Try to obtain a better link count */
ret= Xorriso_search_hardlinks(xorriso, *node, &node_idx, &min_hl, &max_hl, 0);
if(ret < 0)
return(ret);
if(ret > 0 && node_idx >= 0) {
for(i= min_hl; i <= max_hl; i++) {
if(i == node_idx)
continue;
/* Check whether node is still valid */
ret= Xorriso_path_from_node(xorriso, xorriso->hln_array[i], img_path, 0);
if(ret < 0)
return(ret);
if(ret > 0)
stbuf->st_nlink++;
}
}
return(1);
}
@ -2709,7 +2723,6 @@ int Xorriso_add_tree(struct XorrisO *xorriso, IsoDir *dir,
{
IsoImage *volume;
IsoNode *node;
IsoSymlink *iso_symlink;
int ret, target_is_dir, source_is_dir, source_is_link, fret, was_failure= 0;
int do_not_dive, target_is_split= 0;
struct DirseQ *dirseq= NULL;
@ -2886,34 +2899,9 @@ cannot_lstat:;
}
if(node==NULL) {
/* A90516 : <<< iso_tree_add_new_symlink does not record the disk inode
number.
So now iso_tree_add_new_node() must take care of symlinks.
*/
if(0 && S_ISLNK(stbuf.st_mode)) {
/* ??? NG : A80107 : is this solved now ? */
/* <<< One should rather change libisofs so that iso_tree_add_node()
adds a disk_link as RR link, if RR is enabled */
ret= iso_tree_add_new_symlink(dir, img_name, link_target, &iso_symlink);
node= (IsoNode *) iso_symlink;
if(ret>0) {
ret= Xorriso_transfer_properties(xorriso, &stbuf, srcpt, node, 2 | 4);
if(ret<=0)
goto was_problem;
} else {
Xorriso_report_iso_error(xorriso, stbuf_src, ret,
"Cannot create symbolic link", 0, "FAILURE", 1|2);
{ret= 0; goto was_problem;}
}
} else {
ret= Xorriso_tree_graft_node(xorriso, volume, dir, srcpt, img_name,
"", img_path, (off_t) 0, (off_t) 0,
&node, 0);
}
ret= Xorriso_tree_graft_node(xorriso, volume, dir, srcpt, img_name,
"", img_path, (off_t) 0, (off_t) 0,
&node, 0);
}
if(node==NULL) {
Xorriso_process_msg_queues(xorriso,0);
@ -6588,7 +6576,7 @@ int Xorriso_ls_filev(struct XorrisO *xorriso, char *wd,
ret= Xorriso_make_abs_adr(xorriso, wd, filev[i], path, 1|2|4);
if(ret<=0)
continue;
ret= Xorriso_fake_stbuf(xorriso, path, &stbuf, &node, (flag&4)>>1);
ret= Xorriso_fake_stbuf(xorriso, path, &stbuf, &node, ((flag&4) >> 1) | 16);
if(ret<=0)
continue;
if(LIBISO_ISDIR(node) && !(flag&(4|8))) {
@ -11368,12 +11356,7 @@ int Xorriso_set_filter(struct XorrisO *xorriso, void *in_node,
ret= 0; goto ex;
}
/* <<< Adding a filter is an initial image change only if node in
old image and indev!=outdev
xorriso->volset_change_pending= 1;
*/
ret= filter_ret;
ex:;
if(old_name != NULL)
free(old_name);
@ -11877,12 +11860,6 @@ int Xorriso_hardlink_update(struct XorrisO *xorriso, int *compare_result,
dev_t old_dev;
ino_t old_ino;
#ifdef Xorriso_hardlink_update_direcT
/* <<< */
int node_result;
char node_path[SfileadrL];
#endif
if(xorriso->di_array == NULL)
return(1);
follow_links= xorriso->do_follow_links ||
@ -11983,35 +11960,7 @@ int Xorriso_hardlink_update(struct XorrisO *xorriso, int *compare_result,
}
#endif /* Xorriso_hardlink_update_debuG */
#ifdef Xorriso_hardlink_update_direcT
/* <<< */
/* Is the alleged sibling still a valid mirror of disk_path ? */
ret= Xorriso_path_from_node(xorriso, xorriso->di_array[i], node_path, 0);
if(ret < 0)
goto ex;
if(ret == 0)
continue; /* Node is deleted from tree */
node_result= 0;
ret= Xorriso_compare_2_files(xorriso, disk_path, node_path, "",
&node_result, 2 | follow_links | (7 << 29));
if(ret >= 0) {
/* Overwrite sibling if it would *not* be overwritten by itself.
(If it would be overwritten then it might be not a valid hardlink
sibling.) */
ret= Xorriso_update_interpreter(xorriso, NULL, node_result, disk_path,
node_path, 1 | 4);
if(ret < 0)
goto ex;
}
#else /* Xorriso_hardlink_update_direcT */
xorriso->di_do_widen[i / 8]|= 1 << (i % 8);
#endif /* ! Xorriso_hardlink_update_direcT */
}
ret= 1;