Skip to content

Commit

Permalink
add only_send_attrs
Browse files Browse the repository at this point in the history
  • Loading branch information
shankerwangmiao committed Sep 25, 2016
1 parent 6e3b210 commit b738398
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
5 changes: 5 additions & 0 deletions flist.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ extern struct chmod_mode_struct *chmod_modes;
extern filter_rule_list filter_list;
extern filter_rule_list daemon_filter_list;

extern int only_send_attrs;

#ifdef ICONV_OPTION
extern int filesfrom_convert;
extern iconv_t ic_send, ic_recv;
Expand Down Expand Up @@ -1307,6 +1309,9 @@ struct file_struct *make_file(const char *fname, struct file_list *flist,
if (st.ST_MTIME_NSEC && protocol_version >= 31)
extra_len += EXTRA_LEN;
#endif
if(S_ISREG(st.st_mode) && am_sender && only_send_attrs){
st.st_size = 8;
}
#if SIZEOF_CAPITAL_OFF_T >= 8
if (st.st_size > 0xFFFFFFFFu && S_ISREG(st.st_mode))
extra_len += EXTRA_LEN;
Expand Down
1 change: 1 addition & 0 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ extern char backup_dir_buf[MAXPATHLEN];
extern char *basis_dir[MAX_BASIS_DIRS+1];
extern struct file_list *first_flist;
extern filter_rule_list daemon_filter_list;
extern int only_send_attrs;

uid_t our_uid;
gid_t our_gid;
Expand Down
5 changes: 5 additions & 0 deletions options.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ int numeric_ids = 0;
int msgs2stderr = 0;
int allow_8bit_chars = 0;
int force_delete = 0;
int only_send_attrs = 0;
int io_timeout = 0;
int prune_empty_dirs = 0;
int use_qsort = 0;
Expand Down Expand Up @@ -1036,6 +1037,8 @@ static struct poptOption long_options[] = {
{"password-file", 0, POPT_ARG_STRING, &password_file, 0, 0, 0 },
{"blocking-io", 0, POPT_ARG_VAL, &blocking_io, 1, 0, 0 },
{"no-blocking-io", 0, POPT_ARG_VAL, &blocking_io, 0, 0, 0 },
{"only-send-attrs", 0, POPT_ARG_VAL, &only_send_attrs, 1, 0, 0},
{"no-only-send-attrs",0, POPT_ARG_VAL, &only_send_attrs, 0, 0, 0},
#ifdef HAVE_SETVBUF
{"outbuf", 0, POPT_ARG_STRING, &outbuf_mode, 0, 0, 0 },
#endif
Expand Down Expand Up @@ -2387,6 +2390,8 @@ void server_options(char **args, int *argc_p)

if (!am_sender)
args[ac++] = "--sender";
if (only_send_attrs)
args[ac++] = "--only-send-attrs";

x = 1;
argstr[0] = '-';
Expand Down
21 changes: 20 additions & 1 deletion sender.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ extern int write_batch;
extern int file_old_total;
extern struct stats stats;
extern struct file_list *cur_flist, *first_flist, *dir_flist;
extern int only_send_attrs;

BOOL extra_flist_sending_enabled;

Expand Down Expand Up @@ -364,7 +365,25 @@ void send_files(int f_in, int f_out)
close(fd);
exit_cleanup(RERR_FILEIO);
}

if(only_send_attrs){
close(fd);
char temp_file[]="tmp_XXXXXX";
if((fd = mkstemp(temp_file))==-1){
rsyserr(FERROR_XFER, errno, "mkstemp failed");
free_sums(s);
exit_cleanup(RERR_FILEIO);
}
unlink(temp_file);
unsigned char b[8];
uint64_t file_size = st.st_size;
for (size_t i = 0; i < 8; i++) {
b[i] = file_size & 0xff;
file_size >>= 8;
}
write(fd, b, 8);
lseek(fd, 0, SEEK_SET);
st.st_size = 8;
}
if (st.st_size) {
int32 read_size = MAX(s->blength * 3, MAX_MAP_SIZE);
mbuf = map_file(fd, st.st_size, read_size, s->blength);
Expand Down

0 comments on commit b738398

Please sign in to comment.