static int process_new(struct sdirs *sdirs, struct conf **cconfs, struct sbuf *p1b, struct fzp *ucfp) { if(!p1b->path.buf) return 0; if(cmd_is_filedata(p1b->path.cmd)) { //logp("need to process new file: %s\n", p1b->path); // Flag the things that need to be sent (to the client) p1b->flags |= SBUFL_SEND_STAT; p1b->flags |= SBUFL_SEND_PATH; } else { new_non_file(p1b, ucfp, cconfs); } return 0; }
int iobuf_is_filedata(struct iobuf *iobuf) { return cmd_is_filedata(iobuf->cmd); }
// returns 1 for finished ok. static int do_stuff_to_receive(struct asfd *asfd, struct sdirs *sdirs, struct conf **cconfs, struct sbuf *rb, struct fzp *chfp, struct dpth *dpth, char **last_requested) { struct iobuf *rbuf=asfd->rbuf; iobuf_free_content(rbuf); // This also attempts to write anything in the write buffer. if(asfd->as->read_write(asfd->as)) { logp("error in %s\n", __func__); return -1; } if(!rbuf->buf) return 0; if(rbuf->cmd==CMD_MESSAGE || rbuf->cmd==CMD_WARNING) { log_recvd(rbuf, cconfs, 0); return 0; } if(rb->protocol1->fzp) { // Currently writing a file (or meta data) switch(rbuf->cmd) { case CMD_APPEND: if(deal_with_receive_append(asfd, rb, cconfs)) goto error; return 0; case CMD_END_FILE: if(deal_with_receive_end_file(asfd, sdirs, rb, chfp, cconfs, last_requested)) goto error; return 0; default: iobuf_log_unexpected(rbuf, __func__); goto error; } } // Otherwise, expecting to be told of a file to save. switch(rbuf->cmd) { case CMD_DATAPTH: iobuf_move(&rb->protocol1->datapth, rbuf); return 0; case CMD_ATTRIBS: iobuf_move(&rb->attr, rbuf); return 0; case CMD_GEN: if(!strcmp(rbuf->buf, "okbackupphase2end")) goto end_phase2; iobuf_log_unexpected(rbuf, __func__); goto error; case CMD_INTERRUPT: // Interrupt - forget about the last requested // file if it matches. Otherwise, we can get // stuck on the select in the async stuff, // waiting for something that will never arrive. if(*last_requested && !strcmp(rbuf->buf, *last_requested)) free_w(last_requested); return 0; default: break; } if(cmd_is_filedata(rbuf->cmd)) { if(deal_with_filedata(asfd, sdirs, rb, rbuf, dpth, cconfs)) goto error; return 0; } iobuf_log_unexpected(rbuf, __func__); error: return -1; end_phase2: return 1; }
static int maybe_do_delta_stuff(struct asfd *asfd, struct sdirs *sdirs, struct sbuf *cb, struct sbuf *p1b, struct fzp *ucfp, struct conf **cconfs) { int oldcompressed=0; int compression=get_int(cconfs[OPT_COMPRESSION]); // If the file type changed, I think it is time to back it up again // (for example, EFS changing to normal file, or back again). if(cb->path.cmd!=p1b->path.cmd) return process_new_file(sdirs, cconfs, cb, p1b, ucfp); // mtime is the actual file data. // ctime is the attributes or meta data. if(cb->statp.st_mtime==p1b->statp.st_mtime && cb->statp.st_ctime==p1b->statp.st_ctime) { // got an unchanged file //logp("got unchanged file: %s %c %c\n", // cb->path.buf, cb->path.cmd, p1b->path.cmd); return process_unchanged_file(p1b, cb, ucfp, cconfs); } if(cb->statp.st_mtime==p1b->statp.st_mtime && cb->statp.st_ctime!=p1b->statp.st_ctime) { // File data stayed the same, but attributes or meta data // changed. We already have the attributes, but may need to get // extra meta data. // FIX THIS horrible mess. if(cb->path.cmd==CMD_ENC_METADATA || p1b->path.cmd==CMD_ENC_METADATA // FIX THIS: make unencrypted metadata use the librsync || cb->path.cmd==CMD_METADATA || p1b->path.cmd==CMD_METADATA || cb->path.cmd==CMD_VSS || p1b->path.cmd==CMD_VSS || cb->path.cmd==CMD_ENC_VSS || p1b->path.cmd==CMD_ENC_VSS || cb->path.cmd==CMD_VSS_T || p1b->path.cmd==CMD_VSS_T || cb->path.cmd==CMD_ENC_VSS_T || p1b->path.cmd==CMD_ENC_VSS_T || cb->path.cmd==CMD_EFS_FILE || p1b->path.cmd==CMD_EFS_FILE) return process_new_file(sdirs, cconfs, cb, p1b, ucfp); // On Windows, we have to back up the whole file if ctime // changed, otherwise things like permission changes do not get // noticed. So, in that case, fall through to the changed stuff // below. // Non-Windows clients finish here. else if(!get_int(cconfs[OPT_CLIENT_IS_WINDOWS])) return process_unchanged_file(p1b, cb, ucfp, cconfs); } // Got a changed file. //logp("got changed file: %s\n", p1b->path); // If either old or new is encrypted, or librsync is off, we need to // get a new file. // FIX THIS horrible mess. if(get_int(cconfs[OPT_LIBRSYNC]) || cb->path.cmd==CMD_ENC_FILE || p1b->path.cmd==CMD_ENC_FILE || cb->path.cmd==CMD_ENC_METADATA || p1b->path.cmd==CMD_ENC_METADATA || cb->path.cmd==CMD_EFS_FILE || p1b->path.cmd==CMD_EFS_FILE // FIX THIS: make unencrypted metadata use the librsync || cb->path.cmd==CMD_METADATA || p1b->path.cmd==CMD_METADATA || cb->path.cmd==CMD_VSS || p1b->path.cmd==CMD_VSS || cb->path.cmd==CMD_ENC_VSS || p1b->path.cmd==CMD_ENC_VSS || cb->path.cmd==CMD_VSS_T || p1b->path.cmd==CMD_VSS_T || cb->path.cmd==CMD_ENC_VSS_T || p1b->path.cmd==CMD_ENC_VSS_T) return process_new_file(sdirs, cconfs, cb, p1b, ucfp); // Get new files if they have switched between compression on or off. if(cb->protocol1->datapth.buf && dpth_protocol1_is_compressed(cb->compression, cb->protocol1->datapth.buf)) oldcompressed=1; if( ( oldcompressed && !compression) || (!oldcompressed && compression)) return process_new_file(sdirs, cconfs, cb, p1b, ucfp); // Otherwise, do the delta stuff (if possible). if(cmd_is_filedata(p1b->path.cmd)) { if(process_changed_file(asfd, sdirs, cconfs, cb, p1b, sdirs->currentdata)) return -1; } else { if(changed_non_file(p1b, ucfp, p1b->path.cmd, cconfs)) return -1; } sbuf_free_content(cb); return 1; }