- if (do_rmdir(fname) == 0 || errno == ENOENT)
- return 0;
- if (!force_delete || !recurse
- || (errno != ENOTEMPTY && errno != EEXIST)) {
- rsyserr(FERROR, errno, "delete_file: rmdir %s failed",
- full_fname(fname));
- return -1;
+/* This is used by sender.c with a valid f_out, and by receive.c with
+ * f_out = -1. */
+int read_ndx_and_attrs(int f_in, int f_out, int *iflag_ptr,
+ uchar *type_ptr, char *buf, int *len_ptr)
+{
+ int len, iflags = 0;
+ struct file_list *flist;
+ uchar fnamecmp_type = FNAMECMP_FNAME;
+ int verbose_save, ndx;
+
+ read_loop:
+ while (1) {
+ ndx = read_ndx(f_in);
+
+ if (ndx >= 0)
+ break;
+ if (ndx == NDX_DONE)
+ return ndx;
+ if (!incremental || am_sender)
+ goto invalid_ndx;
+ if (ndx == NDX_FLIST_EOF) {
+ flist_eof = 1;
+ send_msg(MSG_FLIST_EOF, "", 0);
+ continue;
+ }
+ ndx = NDX_FLIST_OFFSET - ndx;
+ if (ndx < 0 || ndx >= dir_flist->count) {
+ ndx = NDX_FLIST_OFFSET - ndx;
+ rprintf(FERROR,
+ "Invalid dir index: %d (%d - %d)\n",
+ ndx, NDX_FLIST_OFFSET,
+ NDX_FLIST_OFFSET - dir_flist->count);
+ exit_cleanup(RERR_PROTOCOL);
+ }
+ verbose_save = verbose;
+ verbose = 0; /* TODO allow verbose messages? */
+
+ /* Send everything read from f_in to msg_fd_out. */
+ send_msg_int(MSG_FLIST, ndx);
+ start_flist_forward(f_in);
+ flist = recv_file_list(f_in);
+ flist->parent_ndx = ndx;
+ stop_flist_forward();
+
+ verbose = verbose_save;