static int changed_non_file(struct sbuf *p1b, struct manio *ucmanio, enum cmd cmd, struct conf **cconfs) { // As new_non_file. if(manio_write_sbuf(ucmanio, p1b)) return -1; cntr_add_changed(get_cntr(cconfs), cmd); sbuf_free_content(p1b); return 0; }
static int changed_non_file(struct sbuf *p1b, FILE *ucfp, char cmd, struct conf *cconf) { // As new_non_file. if(sbufl_to_manifest(p1b, ucfp, NULL)) return -1; else cntr_add_changed(cconf->cntr, cmd); sbuf_free_content(p1b); return 0; }
static int changed_non_file(struct sbuf *p1b, struct fzp *ucfp, enum cmd cmd, struct conf **cconfs) { // As new_non_file. if(sbufl_to_manifest(p1b, ucfp)) return -1; else cntr_add_changed(get_cntr(cconfs[OPT_CNTR]), cmd); sbuf_free_content(p1b); return 0; }
static int deal_with_receive_end_file(struct asfd *asfd, struct sdirs *sdirs, struct sbuf *rb, FILE *p2fp, struct conf *cconf, char **last_requested) { static char *cp=NULL; static struct iobuf *rbuf; rbuf=asfd->rbuf; // Finished the file. // Write it to the phase2 file, and free the buffers. if(close_fp(&(rb->burp1->fp))) { logp("error closing delta for %s in receive\n", rb->path); goto error; } if(gzclose_fp(&(rb->burp1->zp))) { logp("error gzclosing delta for %s in receive\n", rb->path); goto error; } iobuf_copy(&rb->burp1->endfile, rbuf); rbuf->buf=NULL; if(rb->flags & SBUFL_RECV_DELTA && finish_delta(sdirs, rb)) goto error; if(sbufl_to_manifest(rb, p2fp, NULL)) goto error; if(rb->flags & SBUFL_RECV_DELTA) cntr_add_changed(cconf->cntr, rb->path.cmd); else cntr_add(cconf->cntr, rb->path.cmd, 0); if(*last_requested && !strcmp(rb->path.buf, *last_requested)) { free(*last_requested); *last_requested=NULL; } cp=strchr(rb->burp1->endfile.buf, ':'); if(rb->burp1->endfile.buf) cntr_add_bytes(cconf->cntr, strtoull(rb->burp1->endfile.buf, NULL, 10)); if(cp) { // checksum stuff goes here } sbuf_free_content(rb); return 0; error: sbuf_free_content(rb); return -1; }
static int deal_with_receive_end_file(struct asfd *asfd, struct sdirs *sdirs, struct sbuf *rb, struct manio *chmanio, struct conf **cconfs, char **last_requested) { int ret=-1; static char *cp=NULL; static struct iobuf *rbuf; struct cntr *cntr=get_cntr(cconfs); rbuf=asfd->rbuf; // Finished the file. // Write it to the phase2 file, and free the buffers. if(fzp_close(&(rb->protocol1->fzp))) { logp("error closing delta for %s in receive\n", rb->path.buf); goto end; } iobuf_move(&rb->endfile, rbuf); if(rb->flags & SBUF_RECV_DELTA && finish_delta(sdirs, rb)) goto end; if(manio_write_sbuf(chmanio, rb)) goto end; if(rb->flags & SBUF_RECV_DELTA) cntr_add_changed(cntr, rb->path.cmd); else cntr_add(cntr, rb->path.cmd, 0); if(*last_requested && !strcmp(rb->path.buf, *last_requested)) free_w(last_requested); cp=strchr(rb->endfile.buf, ':'); if(rb->endfile.buf) cntr_add_bytes(cntr, strtoull(rb->endfile.buf, NULL, 10)); if(cp) { // checksum stuff goes here } ret=0; end: sbuf_free_content(rb); return ret; }
// Return -1 for error, 0 for entry not changed, 1 for entry changed (or new). static int found_in_current_manifest(struct sbuf *csb, struct sbuf *sb, struct manios *manios, struct asfd *chfd, struct cntr *cntr) { // Located the entry in the current manifest. // 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(csb->path.cmd!=sb->path.cmd) { if(manio_forward_through_sigs(csb, manios->current)<0) return -1; return 1; } // mtime is the actual file data. // ctime is the attributes or meta data. if(csb->statp.st_mtime==sb->statp.st_mtime && csb->statp.st_ctime==sb->statp.st_ctime) { // Got an unchanged file. cntr_add_same(cntr, sb->path.cmd); return unchanged(csb, sb, manios, chfd); } if(csb->statp.st_mtime==sb->statp.st_mtime && csb->statp.st_ctime!=sb->statp.st_ctime) { // FIX THIS: // File data stayed the same, but attributes or meta data // changed. We already have the attributes, but may need to // get extra meta data. cntr_add_same(cntr, sb->path.cmd); return unchanged(csb, sb, manios, chfd); } // File data changed. cntr_add_changed(cntr, sb->path.cmd); if(manio_forward_through_sigs(csb, manios->current)<0) return -1; return 1; }
static #endif int get_last_good_entry(struct manio *manio, struct iobuf *result, struct cntr *cntr, struct dpth *dpth, enum protocol protocol, man_off_t **pos) { int ars=0; int got_vss_start=0; struct sbuf *sb=NULL; struct iobuf lastpath; if(!(sb=sbuf_alloc(protocol))) goto error; iobuf_init(&lastpath); man_off_t_free(pos); if(!(*pos=manio_tell(manio))) { logp("Could not manio_tell first pos in %s(): %s\n", __func__, strerror(errno)); goto error; } while(1) { if(sb->path.buf && !got_vss_start) { iobuf_free_content(&lastpath); iobuf_move(&lastpath, &sb->path); if(!sbuf_is_filedata(sb) && !sbuf_is_vssdata(sb)) { iobuf_free_content(result); iobuf_move(result, &lastpath); man_off_t_free(pos); if(!(*pos=manio_tell(manio))) { logp("Could not manio_tell pos in %s(): %s\n", __func__, strerror(errno)); goto error; } } } if(sb->endfile.buf && !got_vss_start) { iobuf_free_content(result); iobuf_move(result, &lastpath); man_off_t_free(pos); if(!(*pos=manio_tell(manio))) { logp("Could not manio_tell pos in %s(): %s\n", __func__, strerror(errno)); goto error; } } sbuf_free_content(sb); ars=manio_read(manio, sb); if(dpth && set_higher_datapth(sb, dpth)) goto error; switch(ars) { case 0: break; case 1: iobuf_free_content(&lastpath); sbuf_free(&sb); return 0; default: if(result->buf) logp("Error after %s in %s()\n", result->buf, __func__); // Treat error in changed manio as // OK - could have been a short write. iobuf_free_content(&lastpath); sbuf_free(&sb); return 0; } // Some hacks for split_vss. switch(sb->path.cmd) { case CMD_VSS: case CMD_ENC_VSS: got_vss_start=1; break; case CMD_VSS_T: case CMD_ENC_VSS_T: got_vss_start=0; break; case CMD_FILE: case CMD_ENC_FILE: if(S_ISDIR(sb->statp.st_mode)) got_vss_start=0; break; default: break; } if(cntr) { // FIX THIS: cannot distinguish between new and // changed files. cntr_add_changed(cntr, sb->path.cmd); if(sb->endfile.buf) { uint64_t e=strtoull(sb->endfile.buf, NULL, 10); cntr_add_bytes(cntr, e); } } } error: iobuf_free_content(&lastpath); sbuf_free(&sb); man_off_t_free(pos); return -1; }