Skip to content

Commit

Permalink
Avoid a double-increment of a file's st_dev value
Browse files Browse the repository at this point in the history
while supporting older rsyncs that send dev == 0.
  • Loading branch information
Wayne Davison committed May 29, 2010
1 parent db22e58 commit 130cdd0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions flist.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ int flist_eof = 0; /* all the file-lists are now known */
* will survive just long enough to be used by send_file_entry(). */
static dev_t tmp_rdev;
#ifdef SUPPORT_HARD_LINKS
static int64 tmp_dev, tmp_ino;
static int64 tmp_dev = -1, tmp_ino;
#endif
static char tmp_sum[MAX_DIGEST_LEN];

Expand Down Expand Up @@ -508,7 +508,7 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
xflags |= XMIT_MOD_NSEC;

#ifdef SUPPORT_HARD_LINKS
if (tmp_dev != 0) {
if (tmp_dev != -1) {
if (protocol_version >= 30) {
struct ht_int64_node *np = idev_find(tmp_dev, tmp_ino);
first_hlink_ndx = (int32)(long)np->data - 1;
Expand Down Expand Up @@ -641,7 +641,7 @@ static void send_file_entry(int f, const char *fname, struct file_struct *file,
#endif

#ifdef SUPPORT_HARD_LINKS
if (tmp_dev != 0 && protocol_version < 30) {
if (tmp_dev != -1 && protocol_version < 30) {
if (protocol_version < 26) {
/* 32-bit dev_t and ino_t */
write_int(f, (int32)dev);
Expand Down Expand Up @@ -1341,10 +1341,10 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
if (protocol_version >= 28
? (!S_ISDIR(st.st_mode) && st.st_nlink > 1)
: S_ISREG(st.st_mode)) {
tmp_dev = (int64)st.st_dev + 1;
tmp_dev = (int64)st.st_dev;
tmp_ino = (int64)st.st_ino;
} else
tmp_dev = 0;
tmp_dev = -1;
}
#endif

Expand Down

0 comments on commit 130cdd0

Please sign in to comment.