X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/7e4b6b7bc47b8ac00fa295ed60e6e13e28fd1a8a..4abe379c053f78a4f16ab80afa75a0f9be3b319b:/flist.c diff --git a/flist.c b/flist.c index 701fe3bc..688117c9 100644 --- a/flist.c +++ b/flist.c @@ -52,6 +52,7 @@ extern int preserve_devices; extern int preserve_specials; extern int uid_ndx; extern int gid_ndx; +extern int eol_nulls; extern int relative_paths; extern int implied_dirs; extern int file_extra_cnt; @@ -63,6 +64,7 @@ extern int copy_unsafe_links; extern int protocol_version; extern int sanitize_paths; extern struct stats stats; +extern char *filesfrom_host; extern char curr_dir[MAXPATHLEN]; @@ -356,7 +358,7 @@ int push_pathname(const char *dir, int len) return 1; } -static void send_file_entry(int f, struct file_struct *file, int ndx) +static void send_file_entry(int f, struct file_struct *file, int ndx, int first_ndx) { static time_t modtime; static mode_t mode; @@ -462,10 +464,10 @@ static void send_file_entry(int f, struct file_struct *file, int ndx) #ifdef SUPPORT_HARD_LINKS if (tmp_dev != 0) { if (protocol_version >= 30) { - struct idev_node *np = idev_node(tmp_dev, tmp_ino); + struct ht_int64_node *np = idev_find(tmp_dev, tmp_ino); first_hlink_ndx = (int32)(long)np->data - 1; if (first_hlink_ndx < 0) { - np->data = (void*)(long)(ndx + 1); + np->data = (void*)(long)(ndx + first_ndx + 1); xflags |= XMIT_HLINK_FIRST; } xflags |= XMIT_HLINKED; @@ -516,8 +518,9 @@ static void send_file_entry(int f, struct file_struct *file, int ndx) write_buf(f, fname + l1, l2); if (first_hlink_ndx >= 0) { - write_varint30(f, first_hlink_ndx); - goto the_end; + write_varint(f, first_hlink_ndx); + if (first_hlink_ndx >= first_ndx) + goto the_end; } write_varlong30(f, F_LENGTH(file), 3); @@ -705,33 +708,34 @@ static struct file_struct *recv_file_entry(struct file_list *flist, #ifdef SUPPORT_HARD_LINKS if (protocol_version >= 30 && BITS_SETnUNSET(xflags, XMIT_HLINKED, XMIT_HLINK_FIRST)) { - struct file_struct *first; - first_hlink_ndx = read_varint30(f); - if (first_hlink_ndx < 0 || first_hlink_ndx >= flist->used) { + first_hlink_ndx = read_varint(f); + if (first_hlink_ndx < 0 || first_hlink_ndx >= flist->ndx_start + flist->used) { rprintf(FERROR, "hard-link reference out of range: %d (%d)\n", - first_hlink_ndx, flist->used); + first_hlink_ndx, flist->ndx_start + flist->used); exit_cleanup(RERR_PROTOCOL); } - first = flist->files[first_hlink_ndx]; - file_length = F_LENGTH(first); - modtime = first->modtime; - mode = first->mode; - if (uid_ndx) - uid = F_OWNER(first); - if (gid_ndx) - gid = F_GROUP(first); - if ((preserve_devices && IS_DEVICE(mode)) - || (preserve_specials && IS_SPECIAL(mode))) { - uint32 *devp = F_RDEV_P(first); - rdev = MAKEDEV(DEV_MAJOR(devp), DEV_MINOR(devp)); - extra_len += DEV_EXTRA_CNT * EXTRA_LEN; + if (first_hlink_ndx >= flist->ndx_start) { + struct file_struct *first = flist->files[first_hlink_ndx - flist->ndx_start]; + file_length = F_LENGTH(first); + modtime = first->modtime; + mode = first->mode; + if (uid_ndx) + uid = F_OWNER(first); + if (gid_ndx) + gid = F_GROUP(first); + if ((preserve_devices && IS_DEVICE(mode)) + || (preserve_specials && IS_SPECIAL(mode))) { + uint32 *devp = F_RDEV_P(first); + rdev = MAKEDEV(DEV_MAJOR(devp), DEV_MINOR(devp)); + extra_len += DEV_EXTRA_CNT * EXTRA_LEN; + } + if (preserve_links && S_ISLNK(mode)) + linkname_len = strlen(F_SYMLINK(first)) + 1; + else + linkname_len = 0; + goto create_object; } - if (preserve_links && S_ISLNK(mode)) - linkname_len = strlen(F_SYMLINK(first)) + 1; - else - linkname_len = 0; - goto create_object; } #endif @@ -820,7 +824,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist, if (protocol_version < 28 && S_ISREG(mode)) xflags |= XMIT_HLINKED; if (xflags & XMIT_HLINKED) - extra_len += EXTRA_LEN; + extra_len += (inc_recurse+1) * EXTRA_LEN; } #endif @@ -924,8 +928,8 @@ static struct file_struct *recv_file_entry(struct file_list *flist, #ifdef SUPPORT_LINKS if (linkname_len) { bp = (char*)file->basename + basename_len; - if (first_hlink_ndx >= 0) { - struct file_struct *first = flist->files[first_hlink_ndx]; + if (first_hlink_ndx >= flist->ndx_start) { + struct file_struct *first = flist->files[first_hlink_ndx - flist->ndx_start]; memcpy(bp, F_SYMLINK(first), linkname_len); } else read_sbuf(f, bp, linkname_len - 1); @@ -938,10 +942,11 @@ static struct file_struct *recv_file_entry(struct file_list *flist, if (preserve_hard_links && xflags & XMIT_HLINKED) { if (protocol_version >= 30) { F_HL_GNUM(file) = xflags & XMIT_HLINK_FIRST - ? flist->used : first_hlink_ndx; + ? flist->ndx_start + flist->used + : first_hlink_ndx; } else { static int32 cnt = 0; - struct idev_node *np; + struct ht_int64_node *np; int64 ino; int32 ndx; if (protocol_version < 26) { @@ -952,7 +957,7 @@ static struct file_struct *recv_file_entry(struct file_list *flist, dev = read_longint(f); ino = read_longint(f); } - np = idev_node(dev, ino); + np = idev_find(dev, ino); ndx = (int32)(long)np->data - 1; if (ndx < 0) { ndx = cnt++; @@ -970,8 +975,8 @@ static struct file_struct *recv_file_entry(struct file_list *flist, /* Prior to 28, we get a useless set of nulls. */ bp = tmp_sum; } - if (first_hlink_ndx >= 0) { - struct file_struct *first = flist->files[first_hlink_ndx]; + if (first_hlink_ndx >= flist->ndx_start) { + struct file_struct *first = flist->files[first_hlink_ndx - flist->ndx_start]; memcpy(bp, F_SUM(first), checksum_len); } else read_buf(f, bp, checksum_len); @@ -1287,7 +1292,7 @@ static struct file_struct *send_file_name(int f, struct file_list *flist, flist_expand(flist, 1); flist->files[flist->used++] = file; if (f >= 0) { - send_file_entry(f, file, flist->used - 1); + send_file_entry(f, file, flist->used - 1, flist->ndx_start); #ifdef SUPPORT_ACLS if (preserve_acls && !S_ISLNK(file->mode)) { send_acl(&sx, f); @@ -1638,6 +1643,8 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) int64 start_write; int use_ff_fd = 0; int flags, disable_buffering; + int reading_remotely = filesfrom_host != NULL; + int rl_nulls = eol_nulls || reading_remotely; rprintf(FLOG, "building file list\n"); if (show_filelist_p()) @@ -1678,7 +1685,7 @@ struct file_list *send_file_list(int f, int argc, char *argv[]) int is_dot_dir; if (use_ff_fd) { - if (read_filesfrom_line(filesfrom_fd, fbuf) == 0) + if (read_line(filesfrom_fd, fbuf, sizeof fbuf, !reading_remotely, rl_nulls) == 0) break; sanitize_path(fbuf, fbuf, "", 0, NULL); } else { @@ -1964,13 +1971,13 @@ struct file_list *recv_file_list(int f) start_read = stats.total_read; - flist = flist_new(0, "recv_file_list"); - #ifdef SUPPORT_HARD_LINKS - if (preserve_hard_links && protocol_version < 30) + if (preserve_hard_links && !first_flist) init_hard_links(); #endif + flist = flist_new(0, "recv_file_list"); + if (inc_recurse) { if (flist->ndx_start == 0) dir_flist = flist_new(FLIST_TEMP, "recv_file_list");