X-Git-Url: https://mattmccutchen.net/rsync/rsync.git/blobdiff_plain/554dc122f271fc361b963067fa3d80084fd7ca91..57edc4808f566fbaa58ec96bc7e543b1ccb92ab9:/flist.c diff --git a/flist.c b/flist.c index ad6b5bf0..f90c286c 100644 --- a/flist.c +++ b/flist.c @@ -52,12 +52,9 @@ extern int preserve_devices; extern int preserve_specials; extern int delete_during; extern int missing_args; -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; extern int ignore_perishable; extern int non_perishable_cnt; extern int prune_empty_dirs; @@ -72,6 +69,7 @@ extern int sender_symlink_iconv; extern int output_needs_newline; extern int sender_keeps_checksum; extern int unsort_ndx; +extern uid_t our_uid; extern struct stats stats; extern char *filesfrom_host; extern char *usermap, *groupmap; @@ -130,7 +128,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]; @@ -508,7 +506,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; @@ -641,15 +639,17 @@ 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) { + /* Older protocols expect the dev number to be transmitted + * 1-incremented so that it is never zero. */ if (protocol_version < 26) { /* 32-bit dev_t and ino_t */ - write_int(f, (int32)dev); + write_int(f, (int32)(dev+1)); write_int(f, (int32)tmp_ino); } else { /* 64-bit dev_t and ino_t */ if (!(xflags & XMIT_SAME_DEV_pre30)) - write_longint(f, dev); + write_longint(f, dev+1); write_longint(f, tmp_ino); } } @@ -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 @@ -1372,10 +1372,12 @@ struct file_struct *make_file(const char *fname, struct file_list *flist, } #endif file->mode = st.st_mode; - if (uid_ndx) /* Check uid_ndx instead of preserve_uid for del support */ + if (preserve_uid) F_OWNER(file) = st.st_uid; - if (gid_ndx) /* Check gid_ndx instead of preserve_gid for del support */ + if (preserve_gid) F_GROUP(file) = st.st_gid; + if (am_generator && st.st_uid == our_uid) + file->flags |= FLAG_OWNED_BY_US; if (basename != thisname) file->dirname = lastdir; @@ -3175,13 +3177,14 @@ char *f_name(const struct file_struct *f, char *fbuf) * of the dirname string, and also indicates that "dirname" is a MAXPATHLEN * buffer (the functions we call will append names onto the end, but the old * dir value will be restored on exit). */ -struct file_list *get_dirlist(char *dirname, int dlen, int ignore_filter_rules) +struct file_list *get_dirlist(char *dirname, int dlen, int flags) { struct file_list *dirlist; char dirbuf[MAXPATHLEN]; int save_recurse = recurse; int save_xfer_dirs = xfer_dirs; int save_prune_empty_dirs = prune_empty_dirs; + int senddir_fd = flags & GDL_IGNORE_FILTER_RULES ? -2 : -1; if (dlen < 0) { dlen = strlcpy(dirbuf, dirname, MAXPATHLEN); @@ -3194,7 +3197,7 @@ struct file_list *get_dirlist(char *dirname, int dlen, int ignore_filter_rules) recurse = 0; xfer_dirs = 1; - send_directory(ignore_filter_rules ? -2 : -1, dirlist, dirname, dlen, FLAG_CONTENT_DIR); + send_directory(senddir_fd, dirlist, dirname, dlen, FLAG_CONTENT_DIR); xfer_dirs = save_xfer_dirs; recurse = save_recurse; if (INFO_GTE(PROGRESS, 1))