if (tmpdir) {
/* Note: this can't overflow, so the return value is safe */
length = strlcpy(fnametmp, tmpdir, MAXPATHLEN - 2);
fnametmp[length++] = '/';
if (tmpdir) {
/* Note: this can't overflow, so the return value is safe */
length = strlcpy(fnametmp, tmpdir, MAXPATHLEN - 2);
fnametmp[length++] = '/';
- strlcpy(fnametmp + length, f, maxname);
- strcat(fnametmp + length, ".XXXXXX");
+ added = strlcpy(fnametmp + length, f, maxname);
+ if (added >= maxname)
+ added = maxname - 1;
+ memcpy(fnametmp + length + added, ".XXXXXX", 8);
if (do_progress)
show_progress(offset, total_size);
sum_update(map_ptr(mapbuf, offset, len), len);
if (do_progress)
show_progress(offset, total_size);
sum_update(map_ptr(mapbuf, offset, len), len);
- for (i = -1; (i = bitbag_next_bit(delayed_bits, i)) >= 0; ) {
- struct file_struct *file = flist->files[i];
+ for (ndx = -1; (ndx = bitbag_next_bit(delayed_bits, ndx)) >= 0; ) {
+ struct file_struct *file = flist->files[ndx];
fname = local_name ? local_name : f_name(file, NULL);
if ((partialptr = partial_dir_fname(fname)) != NULL) {
if (make_backups && !make_backup(fname))
fname = local_name ? local_name : f_name(file, NULL);
if ((partialptr = partial_dir_fname(fname)) != NULL) {
if (make_backups && !make_backup(fname))
"rename failed for %s (from %s)",
full_fname(fname), partialptr);
} else {
"rename failed for %s (from %s)",
full_fname(fname), partialptr);
} else {
- if (remove_sent_files
- || (preserve_hard_links
- && file->link_u.links)) {
- SIVAL(numbuf, 0, i);
- send_msg(MSG_SUCCESS,numbuf,4);
- }
+ if (remove_source_files
+ || (preserve_hard_links && F_IS_HLINKED(file)))
+ send_msg_int(MSG_SUCCESS, ndx);
rprintf(FINFO,
"(No batched update for%s \"%s\")\n",
phase ? " resend of" : "",
rprintf(FINFO,
"(No batched update for%s \"%s\")\n",
phase ? " resend of" : "",
- next_gen_i = read_int(batch_gen_fd);
- if (next_gen_i == -1)
- next_gen_i = the_file_list->count;
+ next_gen_ndx = read_int(batch_gen_fd);
+ if (next_gen_ndx == -1)
+ next_gen_ndx = the_file_list->count;
* Receiver process runs on the same host as the generator process. */
int recv_files(int f_in, struct file_list *flist, char *local_name)
{
* Receiver process runs on the same host as the generator process. */
int recv_files(int f_in, struct file_list *flist, char *local_name)
{
int fd1,fd2;
STRUCT_STAT st;
int iflags, xlen;
char *fname, fbuf[MAXPATHLEN];
char xname[MAXPATHLEN];
char fnametmp[MAXPATHLEN];
int fd1,fd2;
STRUCT_STAT st;
int iflags, xlen;
char *fname, fbuf[MAXPATHLEN];
char xname[MAXPATHLEN];
char fnametmp[MAXPATHLEN];
char fnamecmpbuf[MAXPATHLEN];
uchar fnamecmp_type;
struct file_struct *file;
struct stats initial_stats;
int save_make_backups = make_backups;
char fnamecmpbuf[MAXPATHLEN];
uchar fnamecmp_type;
struct file_struct *file;
struct stats initial_stats;
int save_make_backups = make_backups;
- iflags = read_item_attrs(f_in, -1, i, &fnamecmp_type,
+ iflags = read_item_attrs(f_in, -1, ndx, &fnamecmp_type,
- if (!am_server && log_format)
- log_item(file, &stats, iflags, NULL);
+ log_item(FCLIENT, file, &stats, iflags, NULL);
- log_item(file, &stats, iflags, NULL);
+ log_item(FINFO, file, &stats, iflags, NULL);
- next_gen_i = get_next_gen_i(batch_gen_fd, next_gen_i, i);
- if (i < next_gen_i) {
+ next_gen_ndx = get_next_gen_ndx(batch_gen_fd, next_gen_ndx, ndx);
+ if (ndx < next_gen_ndx) {
if (fnamecmp_type >= basis_dir_cnt) {
rprintf(FERROR,
"invalid basis_dir index: %d.\n",
if (fnamecmp_type >= basis_dir_cnt) {
rprintf(FERROR,
"invalid basis_dir index: %d.\n",
rsyserr(FERROR, errno, "fstat %s failed",
full_fname(fnamecmp));
rsyserr(FERROR, errno, "fstat %s failed",
full_fname(fnamecmp));
if (inplace) {
fd2 = do_open(fname, O_WRONLY|O_CREAT, 0600);
if (fd2 == -1) {
rsyserr(FERROR, errno, "open %s failed",
full_fname(fname));
if (inplace) {
fd2 = do_open(fname, O_WRONLY|O_CREAT, 0600);
if (fd2 == -1) {
rsyserr(FERROR, errno, "open %s failed",
full_fname(fname));
if (fd2 == -1) {
rsyserr(FERROR, errno, "mkstemp %s failed",
full_fname(fnametmp));
if (fd2 == -1) {
rsyserr(FERROR, errno, "mkstemp %s failed",
full_fname(fnametmp));
- log_item(file, &initial_stats, iflags, NULL);
+ log_item(FCLIENT, file, &initial_stats, iflags, NULL);
else if (!am_server && verbose && do_progress)
rprintf(FINFO, "%s\n", fname);
/* recv file data */
recv_ok = receive_data(f_in, fnamecmp, fd1, st.st_size,
else if (!am_server && verbose && do_progress)
rprintf(FINFO, "%s\n", fname);
/* recv file data */
recv_ok = receive_data(f_in, fnamecmp, fd1, st.st_size,
- if (!log_before_transfer)
- log_item(file, &initial_stats, iflags, NULL);
+ log_item(log_code, file, &initial_stats, iflags, NULL);
finish_transfer(partialptr, fnametmp, NULL,
file, recv_ok, !partial_dir);
if (delay_updates && recv_ok) {
finish_transfer(partialptr, fnametmp, NULL,
file, recv_ok, !partial_dir);
if (delay_updates && recv_ok) {
- if (remove_sent_files
- || (preserve_hard_links && file->link_u.links)) {
- SIVAL(numbuf, 0, i);
- send_msg(MSG_SUCCESS, numbuf, 4);
- }
+ if (remove_source_files
+ || (preserve_hard_links && F_IS_HLINKED(file)))
+ send_msg_int(MSG_SUCCESS, ndx);
if (msgtype == FERROR || verbose) {
char *errstr, *redostr, *keptstr;
if (!(keep_partial && partialptr) && !inplace)
if (msgtype == FERROR || verbose) {
char *errstr, *redostr, *keptstr;
if (!(keep_partial && partialptr) && !inplace)
"%s: %s failed verification -- update %s%s.\n",
errstr, fname, keptstr, redostr);
}
"%s: %s failed verification -- update %s%s.\n",
errstr, fname, keptstr, redostr);
}