Unified · Split
| @@ -399,7 +399,9 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file, · 398 unmodified lines | |||
| 399 | static gid_t gid; | 399 | static gid_t gid; |
| 400 | static const char *user_name, *group_name; | 400 | static const char *user_name, *group_name; |
| 401 | static char lastname[MAXPATHLEN]; | 401 | static char lastname[MAXPATHLEN]; |
| 402 | #ifdef SUPPORT_HARD_LINKS | ||
| 402 | int first_hlink_ndx = -1; | 403 | int first_hlink_ndx = -1; |
| 404 | #endif | ||
| 403 | int l1, l2; | 405 | int l1, l2; |
| 404 | int xflags; | 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 | np->data = (void*)(long)(first_ndx + ndx + 1); | 474 | np->data = (void*)(long)(first_ndx + ndx + 1); |
| 473 | xflags |= XMIT_HLINK_FIRST; | 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 | } else { | 483 | } else { |
| 476 | if (tmp_dev == dev) { | 484 | if (tmp_dev == dev) { |
| 477 | if (protocol_version >= 28) | 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 | write_byte(f, l2); | 526 | write_byte(f, l2); |
| 519 | write_buf(f, fname + l1, l2); | 527 | write_buf(f, fname + l1, l2); |
| 520 | 528 | ||
| 529 | #ifdef SUPPORT_HARD_LINKS | ||
| 521 | if (first_hlink_ndx >= 0) { | 530 | if (first_hlink_ndx >= 0) { |
| 522 | write_varint(f, first_hlink_ndx); | 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 | goto the_end; | 535 | goto the_end; |
| 536 | } | ||
| 525 | } | 537 | } |
| 538 | #endif | ||
| 526 | 539 | ||
| 527 | write_varlong30(f, F_LENGTH(file), 3); | 540 | write_varlong30(f, F_LENGTH(file), 3); |
| 528 | if (!(xflags & XMIT_SAME_TIME)) { | 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 | write_buf(f, sum, checksum_len); | 622 | write_buf(f, sum, checksum_len); |
| 610 | } | 623 | } |
| 611 | 624 | ||
| 625 | #ifdef SUPPORT_HARD_LINKS | ||
| 612 | the_end: | 626 | the_end: |
| 627 | #endif | ||
| 613 | strlcpy(lastname, fname, MAXPATHLEN); | 628 | strlcpy(lastname, fname, MAXPATHLEN); |
| 614 | 629 | ||
| 615 | if (S_ISREG(mode) || S_ISLNK(mode)) | 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 | first_hlink_ndx, flist->ndx_start + flist->used); | 728 | first_hlink_ndx, flist->ndx_start + flist->used); |
| 714 | exit_cleanup(RERR_PROTOCOL); | 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 | if (first_hlink_ndx >= flist->ndx_start) { | 736 | if (first_hlink_ndx >= flist->ndx_start) { |
| 717 | struct file_struct *first = flist->files[first_hlink_ndx - flist->ndx_start]; | 737 | struct file_struct *first = flist->files[first_hlink_ndx - flist->ndx_start]; |
| 718 | file_length = F_LENGTH(first); | 738 | file_length = F_LENGTH(first); |
| @@ -41,7 +41,7 @@ struct hashtable *hashtable_create(int size, int key64) · 40 unmodified lines | |||
| 41 | tbl->size = size; | 41 | tbl->size = size; |
| 42 | tbl->entries = 0; | 42 | tbl->entries = 0; |
| 43 | tbl->node_size = node_size; | 43 | tbl->node_size = node_size; |
| 44 | tbl->key64 = key64; | 44 | tbl->key64 = (short)key64; |
| 45 | 45 | ||
| 46 | return tbl; | 46 | return tbl; |
| 47 | } | 47 | } |
| @@ -68,8 +68,14 @@ struct ht_int64_node *idev_find(int64 dev, int64 ino) · 67 unmodified lines | |||
| 68 | if (!dev_node || dev_node->key != dev) { | 68 | if (!dev_node || dev_node->key != dev) { |
| 69 | /* We keep a separate hash table of inodes for every device. */ | 69 | /* We keep a separate hash table of inodes for every device. */ |
| 70 | dev_node = hashtable_find(dev_tbl, dev, 1); | 70 | dev_node = hashtable_find(dev_tbl, dev, 1); |
| 71 | if (!(tbl = dev_node->data)) | 71 | if (!(tbl = dev_node->data)) { |
| 72 | tbl = dev_node->data = hashtable_create(512, SIZEOF_INT64 == 8); | 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 | } else | 79 | } else |
| 74 | tbl = dev_node->data; | 80 | tbl = dev_node->data; |
| 75 | 81 | ||
| @@ -551,7 +551,7 @@ struct hashtable { · 550 unmodified lines | |||
| 551 | void *nodes; | 551 | void *nodes; |
| 552 | int32 size, entries; | 552 | int32 size, entries; |
| 553 | uint32 node_size; | 553 | uint32 node_size; |
| 554 | int key64; | 554 | short key64; |
| 555 | }; | 555 | }; |
| 556 | 556 | ||
| 557 | struct ht_int32_node { | 557 | struct ht_int32_node { |
| @@ -33,11 +33,11 @@ ln "$name2" "$name3" || fail "Can't create hardlink" · 32 unmodified lines | |||
| 33 | cp "$name2" "$name4" || fail "Can't copy file" | 33 | cp "$name2" "$name4" || fail "Can't copy file" |
| 34 | cat $srcdir/*.c >"$fromdir/text" | 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 | echo "extra extra" >>"$todir/name1" | 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 | # Add a new link in a new subdirectory to test that we don't try to link | 42 | # Add a new link in a new subdirectory to test that we don't try to link |
| 43 | # the files before the directory gets created. We also create a bunch of | 43 | # the files before the directory gets created. We also create a bunch of |
| @@ -56,27 +56,27 @@ done · 12 unmodified lines | |||
| 56 | ln "$name1" "$fromdir/subdir/down/deep/new-file" | 56 | ln "$name1" "$fromdir/subdir/down/deep/new-file" |
| 57 | rm "$todir/text" | 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 | # Do some duplicate copies using --link-dest and --copy-dest to test that | 61 | # Do some duplicate copies using --link-dest and --copy-dest to test that |
| 62 | # we hard-link all locally-inherited items. | 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 | rm -rf "$chkdir" | 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 | # Create a hard link that has only one part in the hierarchy. | 68 | # Create a hard link that has only one part in the hierarchy. |
| 69 | echo "This is another file" >"$fromdir/solo" | 69 | echo "This is another file" >"$fromdir/solo" |
| 70 | ln "$fromdir/solo" "$chkdir/solo" || fail "Can't create hardlink" | 70 | ln "$fromdir/solo" "$chkdir/solo" || fail "Can't create hardlink" |
| 71 | 71 | ||
| 72 | # Make sure that the checksum data doesn't slide due to an HLINK_BUMP() change. | 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 | grep solo "$outfile" && test_fail "Erroneous copy of solo file occurred!" | 74 | grep solo "$outfile" && test_fail "Erroneous copy of solo file occurred!" |
| 75 | 75 | ||
| 76 | # Make sure there's nothing wrong with sending a single file with -H | 76 | # Make sure there's nothing wrong with sending a single file with -H |
| 77 | # enabled (this has broken twice so far, so we need this test). | 77 | # enabled (this has broken twice so far, so we need this test). |
| 78 | rm -rf "$todir" | 78 | rm -rf "$todir" |
| 79 | $RSYNC -aHivv "$name1" "$todir/" | 79 | $RSYNC -aHivv --debug=hlink5 "$name1" "$todir/" |
| 80 | diff $diffopt "$name1" "$todir" || test_fail "solo copy of name1 failed" | 80 | diff $diffopt "$name1" "$todir" || test_fail "solo copy of name1 failed" |
| 81 | 81 | ||
| 82 | # The script would have aborted on error, so getting here means we've won. | 82 | # The script would have aborted on error, so getting here means we've won. |