Unified · Split
| @@ -399,7 +399,9 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file, · 398 unmodified lines | ||
| 399 | 399 | static gid_t gid; |
| 400 | 400 | static const char *user_name, *group_name; |
| 401 | 401 | static char lastname[MAXPATHLEN]; |
| 402 | +#ifdef SUPPORT_HARD_LINKS | |
| 402 | 403 | int first_hlink_ndx = -1; |
| 404 | +#endif | |
| 403 | 405 | int l1, l2; |
| 404 | 406 | int xflags; |
| 405 | 407 | |
| @@ -472,6 +474,12 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file, · 66 unmodified lines | ||
| 472 | 474 | np->data = (void*)(long)(first_ndx + ndx + 1); |
| 473 | 475 | xflags |= XMIT_HLINK_FIRST; |
| 474 | 476 | } |
| 477 | + if (DEBUG_GTE(HLINK, 1)) { | |
| 478 | + rprintf(FINFO, "found %s dev:inode %s:%s (#%ld)\n", | |
| 479 | + xflags & XMIT_HLINK_FIRST ? "first" : "matching", | |
| 480 | + big_num(tmp_dev, 0), big_num(tmp_ino, 0), | |
| 481 | + (long)np->data - 1); | |
| 482 | + } | |
| 475 | 483 | } else { |
| 476 | 484 | if (tmp_dev == dev) { |
| 477 | 485 | if (protocol_version >= 28) |
| @@ -518,11 +526,16 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file, · 40 unmodified lines | ||
| 518 | 526 | write_byte(f, l2); |
| 519 | 527 | write_buf(f, fname + l1, l2); |
| 520 | 528 | |
| 529 | +#ifdef SUPPORT_HARD_LINKS | |
| 521 | 530 | if (first_hlink_ndx >= 0) { |
| 522 | 531 | write_varint(f, first_hlink_ndx); |
| 523 | − if (first_hlink_ndx >= first_ndx) | |
| 532 | + if (first_hlink_ndx >= first_ndx) { | |
| 533 | + if (DEBUG_GTE(HLINK, 2)) | |
| 534 | + rprintf(FINFO, "sending abbr. entry\n"); | |
| 524 | 535 | goto the_end; |
| 536 | + } | |
| 525 | 537 | } |
| 538 | +#endif | |
| 526 | 539 | |
| 527 | 540 | write_varlong30(f, F_LENGTH(file), 3); |
| 528 | 541 | if (!(xflags & XMIT_SAME_TIME)) { |
| @@ -609,7 +622,9 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file, · 80 unmodified lines | ||
| 609 | 622 | write_buf(f, sum, checksum_len); |
| 610 | 623 | } |
| 611 | 624 | |
| 625 | +#ifdef SUPPORT_HARD_LINKS | |
| 612 | 626 | the_end: |
| 627 | +#endif | |
| 613 | 628 | strlcpy(lastname, fname, MAXPATHLEN); |
| 614 | 629 | |
| 615 | 630 | if (S_ISREG(mode) || S_ISLNK(mode)) |
| @@ -713,6 +728,11 @@ static struct file_struct *recv_file_entry(struct file_list *flist, · 97 unmodified lines | ||
| 713 | 728 | first_hlink_ndx, flist->ndx_start + flist->used); |
| 714 | 729 | exit_cleanup(RERR_PROTOCOL); |
| 715 | 730 | } |
| 731 | + if (DEBUG_GTE(HLINK, 2)) { | |
| 732 | + rprintf(FINFO, "hard-link reference #%d (%sabbr.)\n", | |
| 733 | + first_hlink_ndx, | |
| 734 | + first_hlink_ndx >= flist->ndx_start ? "" : "un"); | |
| 735 | + } | |
| 716 | 736 | if (first_hlink_ndx >= flist->ndx_start) { |
| 717 | 737 | struct file_struct *first = flist->files[first_hlink_ndx - flist->ndx_start]; |
| 718 | 738 | file_length = F_LENGTH(first); |
| @@ -41,7 +41,7 @@ struct hashtable *hashtable_create(int size, int key64) · 40 unmodified lines | ||
| 41 | 41 | tbl->size = size; |
| 42 | 42 | tbl->entries = 0; |
| 43 | 43 | tbl->node_size = node_size; |
| 44 | − tbl->key64 = key64; | |
| 44 | + tbl->key64 = (short)key64; | |
| 45 | 45 | |
| 46 | 46 | return tbl; |
| 47 | 47 | } |
| @@ -68,8 +68,14 @@ struct ht_int64_node *idev_find(int64 dev, int64 ino) · 67 unmodified lines | ||
| 68 | 68 | if (!dev_node || dev_node->key != dev) { |
| 69 | 69 | /* We keep a separate hash table of inodes for every device. */ |
| 70 | 70 | dev_node = hashtable_find(dev_tbl, dev, 1); |
| 71 | − if (!(tbl = dev_node->data)) | |
| 71 | + if (!(tbl = dev_node->data)) { | |
| 72 | 72 | tbl = dev_node->data = hashtable_create(512, SIZEOF_INT64 == 8); |
| 73 | + if (DEBUG_GTE(HLINK, 1)) { | |
| 74 | + rprintf(FINFO, | |
| 75 | + "created inode hashtable for dev %s\n", | |
| 76 | + big_num(dev, 0)); | |
| 77 | + } | |
| 78 | + } | |
| 73 | 79 | } else |
| 74 | 80 | tbl = dev_node->data; |
| 75 | 81 | |
| @@ -551,7 +551,7 @@ struct hashtable { · 550 unmodified lines | ||
| 551 | 551 | void *nodes; |
| 552 | 552 | int32 size, entries; |
| 553 | 553 | uint32 node_size; |
| 554 | − int key64; | |
| 554 | + short key64; | |
| 555 | 555 | }; |
| 556 | 556 | |
| 557 | 557 | struct ht_int32_node { |
| @@ -33,11 +33,11 @@ ln "$name2" "$name3" || fail "Can't create hardlink" · 32 unmodified lines | ||
| 33 | 33 | cp "$name2" "$name4" || fail "Can't copy file" |
| 34 | 34 | cat $srcdir/*.c >"$fromdir/text" |
| 35 | 35 | |
| 36 | −checkit "$RSYNC -aHivv '$fromdir/' '$todir/'" "$fromdir" "$todir" | |
| 36 | +checkit "$RSYNC -aHivv --debug=hlink5 '$fromdir/' '$todir/'" "$fromdir" "$todir" | |
| 37 | 37 | |
| 38 | 38 | echo "extra extra" >>"$todir/name1" |
| 39 | 39 | |
| 40 | −checkit "$RSYNC -aHivv --no-whole-file '$fromdir/' '$todir/'" "$fromdir" "$todir" | |
| 40 | +checkit "$RSYNC -aHivv --debug=hlink5 --no-whole-file '$fromdir/' '$todir/'" "$fromdir" "$todir" | |
| 41 | 41 | |
| 42 | 42 | # Add a new link in a new subdirectory to test that we don't try to link |
| 43 | 43 | # the files before the directory gets created. We also create a bunch of |
| @@ -56,27 +56,27 @@ done · 12 unmodified lines | ||
| 56 | 56 | ln "$name1" "$fromdir/subdir/down/deep/new-file" |
| 57 | 57 | rm "$todir/text" |
| 58 | 58 | |
| 59 | −checkit "$RSYNC -aHivve '$SSH' --rsync-path='$RSYNC' '$fromdir/' localhost:'$todir/'" "$fromdir" "$todir" | |
| 59 | +checkit "$RSYNC -aHivve '$SSH' --debug=hlink5 --rsync-path='$RSYNC' '$fromdir/' localhost:'$todir/'" "$fromdir" "$todir" | |
| 60 | 60 | |
| 61 | 61 | # Do some duplicate copies using --link-dest and --copy-dest to test that |
| 62 | 62 | # we hard-link all locally-inherited items. |
| 63 | −checkit "$RSYNC -aHivv --link-dest='$todir' '$fromdir/' '$chkdir/'" "$todir" "$chkdir" | |
| 63 | +checkit "$RSYNC -aHivv --debug=hlink5 --link-dest='$todir' '$fromdir/' '$chkdir/'" "$todir" "$chkdir" | |
| 64 | 64 | |
| 65 | 65 | rm -rf "$chkdir" |
| 66 | −checkit "$RSYNC -aHivv --copy-dest='$todir' '$fromdir/' '$chkdir/'" "$fromdir" "$chkdir" | |
| 66 | +checkit "$RSYNC -aHivv --debug=hlink5 --copy-dest='$todir' '$fromdir/' '$chkdir/'" "$fromdir" "$chkdir" | |
| 67 | 67 | |
| 68 | 68 | # Create a hard link that has only one part in the hierarchy. |
| 69 | 69 | echo "This is another file" >"$fromdir/solo" |
| 70 | 70 | ln "$fromdir/solo" "$chkdir/solo" || fail "Can't create hardlink" |
| 71 | 71 | |
| 72 | 72 | # Make sure that the checksum data doesn't slide due to an HLINK_BUMP() change. |
| 73 | −$RSYNC -aHivc "$fromdir/" "$chkdir/" | tee "$outfile" | |
| 73 | +$RSYNC -aHivc --debug=hlink5 "$fromdir/" "$chkdir/" | tee "$outfile" | |
| 74 | 74 | grep solo "$outfile" && test_fail "Erroneous copy of solo file occurred!" |
| 75 | 75 | |
| 76 | 76 | # Make sure there's nothing wrong with sending a single file with -H |
| 77 | 77 | # enabled (this has broken twice so far, so we need this test). |
| 78 | 78 | rm -rf "$todir" |
| 79 | −$RSYNC -aHivv "$name1" "$todir/" | |
| 79 | +$RSYNC -aHivv --debug=hlink5 "$name1" "$todir/" | |
| 80 | 80 | diff $diffopt "$name1" "$todir" || test_fail "solo copy of name1 failed" |
| 81 | 81 | |
| 82 | 82 | # The script would have aborted on error, so getting here means we've won. |