+ /* The file was copied, so tweak the perms of the copied file. If it
+ * was copied to partialptr, move it into its final destination. */
+ fnametmp = partialptr ? partialptr : fname;
+
+ do_set_file_attrs:
+ set_file_attrs(fnametmp, file, NULL, fnamecmp,
+ ok_to_set_time ? 0 : ATTRS_SKIP_MTIME);
+
+ if (partialptr) {
+ if (do_rename(fnametmp, fname) < 0) {
+ rsyserr(FERROR, errno, "rename %s -> \"%s\"",
+ full_fname(fnametmp), fname);
+ } else
+ handle_partial_dir(partialptr, PDIR_DELETE);
+ }
+}
+
+struct file_list *flist_for_ndx(int ndx)
+{
+ struct file_list *flist = cur_flist;
+
+ if (!flist && !(flist = first_flist))
+ return NULL;
+
+ while (ndx < flist->ndx_start) {
+ if (flist == first_flist)
+ return NULL;
+ flist = flist->prev;
+ }
+ while (ndx >= flist->ndx_start + flist->count) {
+ if (!(flist = flist->next))
+ return NULL;
+ }
+ return flist;
+}
+
+const char *who_am_i(void)
+{
+ if (am_starting_up)
+ return am_server ? "server" : "client";
+ return am_sender ? "sender" : am_generator ? "generator" : "receiver";