X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/6e69cff118cf6533854052d90295fdc7d117511d..ab304c268c7d3bece093eb65b0dcf1fd579988ae:/hlink.c diff --git a/hlink.c b/hlink.c index 45366366..3826ce52 100644 --- a/hlink.c +++ b/hlink.c @@ -57,9 +57,7 @@ void init_hard_links(struct file_list *flist) if (hlink_list) free(hlink_list); - if (!(hlink_list = - (struct file_struct *) malloc(sizeof(hlink_list[0]) * - flist->count))) + if (!(hlink_list = new_array(struct file_struct, flist->count))) out_of_memory("init_hard_links"); for (i = 0; i < flist->count; i++) @@ -97,14 +95,21 @@ int check_hard_link(struct file_struct *file) low = mid + 1; } + /* XXX: To me this looks kind of dodgy -- why do we use [low] + * here and [low-1] below? -- mbp */ if (hlink_compare(&hlink_list[low], file) != 0) return 0; if (low > 0 && S_ISREG(hlink_list[low - 1].mode) && file->dev == hlink_list[low - 1].dev && - file->inode == hlink_list[low - 1].inode) + file->inode == hlink_list[low - 1].inode) { + if (verbose >= 2) { + rprintf(FINFO, "check_hard_link: \"%s\" is a hard link to file %d, \"%s\"\n", + f_name(file), low-1, f_name(&hlink_list[low-1])); + } return 1; + } #endif return 0; @@ -152,8 +157,13 @@ static void hard_link_one(int i) } #endif -/* create any hard links in the flist */ -void do_hard_links(struct file_list *flist) + + +/** + * Create any hard links in the global hlink_list. They were put + * there by running init_hard_links on the filelist. + **/ +void do_hard_links(void) { #if SUPPORT_HARD_LINKS int i;