static int make_rev_sig(const char *dst, const char *sig, const char *endfile, int compression, struct conf *conf) { int ret=-1; FILE *dstfp=NULL; gzFile dstzp=NULL; FILE *sigp=NULL; //logp("make rev sig: %s %s\n", dst, sig); if(dpthl_is_compressed(compression, dst)) dstzp=gzopen_file(dst, "rb"); else dstfp=open_file(dst, "rb"); if((!dstzp && !dstfp) || !(sigp=open_file(sig, "wb")) || rs_sig_gzfile(NULL, dstfp, dstzp, sigp, get_librsync_block_len(endfile), RS_DEFAULT_STRONG_LEN, NULL, conf->cntr)!=RS_DONE) goto end; ret=0; end: //logp("end of make rev sig\n"); gzclose_fp(&dstzp); close_fp(&dstfp); if(close_fp(&sigp)) { logp("error closing %s in %s\n", sig, __func__); return -1; } return ret; }
static int make_rev_sig(const char *dst, const char *sig, const char *endfile, int compression, struct conf **confs) { int ret=-1; struct fzp *dstfzp=NULL; struct fzp *sigp=NULL; //logp("make rev sig: %s %s\n", dst, sig); if(dpth_protocol1_is_compressed(compression, dst)) dstfzp=fzp_gzopen(dst, "rb"); else dstfzp=fzp_open(dst, "rb"); if(!dstfzp || !(sigp=fzp_open(sig, "wb")) || rs_sig_gzfile(dstfzp, sigp, get_librsync_block_len(endfile), RS_DEFAULT_STRONG_LEN, confs)!=RS_DONE) goto end; ret=0; end: //logp("end of make rev sig\n"); fzp_close(&dstfzp); if(fzp_close(&sigp)) { logp("error closing %s in %s\n", sig, __func__); return -1; } return ret; }
static int make_rev_sig(const char *dst, const char *sig, const char *endfile, int compression, struct cntr *cntr) { FILE *dstfp=NULL; gzFile dstzp=NULL; FILE *sigp=NULL; rs_result result; //logp("make rev sig: %s %s\n", dst, sig); if(dpth_is_compressed(compression, dst)) dstzp=gzopen_file(dst, "rb"); else dstfp=open_file(dst, "rb"); if((!dstzp && !dstfp) || !(sigp=open_file(sig, "wb"))) { gzclose_fp(&dstzp); close_fp(&dstfp); return -1; } result=rs_sig_gzfile(dstfp, dstzp, sigp, get_librsync_block_len(endfile), RS_DEFAULT_STRONG_LEN, NULL, cntr); gzclose_fp(&dstzp); close_fp(&dstfp); close_fp(&sigp); //logp("end of make rev sig\n"); return result; }
static int process_changed_file(struct asfd *asfd, struct sdirs *sdirs, struct conf **cconfs, struct sbuf *cb, struct sbuf *p1b, const char *adir) { size_t blocklen=0; char *curpath=NULL; //logp("need to process changed file: %s (%s)\n", // cb->path, cb->datapth); // Move datapth onto p1b. iobuf_move(&p1b->protocol1->datapth, &cb->protocol1->datapth); if(!(curpath=prepend_s(adir, p1b->protocol1->datapth.buf))) { log_out_of_memory(__func__); return -1; } if(dpth_protocol1_is_compressed(cb->compression, curpath)) p1b->protocol1->sigfzp=fzp_gzopen(curpath, "rb"); else p1b->protocol1->sigfzp=fzp_open(curpath, "rb"); if(!p1b->protocol1->sigfzp) { logp("could not open %s: %s\n", curpath, strerror(errno)); free(curpath); return -1; } free(curpath); blocklen=get_librsync_block_len(cb->protocol1->endfile.buf); if(!(p1b->protocol1->sigjob= #ifdef RS_DEFAULT_STRONG_LEN rs_sig_begin(blocklen, RS_DEFAULT_STRONG_LEN) #else // This is for librsync-1.0.0. RS_DEFAULT_STRONG_LEN was 8 in // librsync-0.9.7. rs_sig_begin(blocklen, 8, rshash_to_magic_number(get_e_rshash(cconfs[OPT_RSHASH]))) #endif )) { logp("could not start signature job.\n"); return -1; } //logp("sig begin: %s\n", p1b->protocol1->datapth.buf); if(!(p1b->protocol1->infb=rs_filebuf_new(asfd, NULL, p1b->protocol1->sigfzp, -1, blocklen, -1, get_cntr(cconfs[OPT_CNTR])))) { logp("could not rs_filebuf_new for infb.\n"); return -1; } if(!(p1b->protocol1->outfb=rs_filebuf_new(asfd, NULL, NULL, asfd->fd, ASYNC_BUF_LEN, -1, get_cntr(cconfs[OPT_CNTR])))) { logp("could not rs_filebuf_new for in_outfb.\n"); return -1; } // Flag the things that need to be sent (to the client) p1b->flags |= SBUFL_SEND_DATAPTH; p1b->flags |= SBUFL_SEND_STAT; p1b->flags |= SBUFL_SEND_PATH; //logp("sending sig for %s\n", p1b->path); //logp("(%s)\n", p1b->datapth); return 0; }
static int process_changed_file(struct sbuf *cb, struct sbuf *p1b, const char *currentdata, const char *datadirtmp, const char *deltmppath, int *resume_partial, struct cntr *cntr, struct config *cconf) { size_t blocklen=0; char *curpath=NULL; //logp("need to process changed file: %s (%s)\n", cb->path, cb->datapth); // Move datapth onto p1b. if(p1b->datapth) free(p1b->datapth); p1b->datapth=cb->datapth; cb->datapth=NULL; if(!(curpath=prepend_s(currentdata, p1b->datapth, strlen(p1b->datapth)))) { log_out_of_memory(__FUNCTION__); return -1; } if(dpth_is_compressed(cb->compression, curpath)) p1b->sigzp=gzopen_file(curpath, "rb"); else p1b->sigfp=open_file(curpath, "rb"); if(!p1b->sigzp && !p1b->sigfp) { logp("could not open %s: %s\n", curpath, strerror(errno)); free(curpath); return -1; } if(*resume_partial && p1b->cmd==CMD_FILE && cconf->librsync) // compression? { if(resume_partial_changed_file(cb, p1b, currentdata, curpath, datadirtmp, deltmppath, cconf, cntr)) return -1; // Burp only transfers one file at a time, so // if there was an interruption, there is only // a possibility of one partial file to resume. *resume_partial=0; } free(curpath); blocklen=get_librsync_block_len(cb->endfile); if(!(p1b->sigjob=rs_sig_begin(blocklen, RS_DEFAULT_STRONG_LEN))) { logp("could not start signature job.\n"); return -1; } //logp("sig begin: %s\n", p1b->datapth); if(!(p1b->infb=rs_filebuf_new(NULL, p1b->sigfp, p1b->sigzp, -1, blocklen, -1, cntr))) { logp("could not rs_filebuf_new for infb.\n"); return -1; } if(!(p1b->outfb=rs_filebuf_new(NULL, NULL, NULL, async_get_fd(), ASYNC_BUF_LEN, -1, cntr))) { logp("could not rs_filebuf_new for in_outfb.\n"); return -1; } // Flag the things that need to be sent (to the client) p1b->senddatapth++; p1b->sendstat++; p1b->sendpath++; //logp("sending sig for %s\n", p1b->path); //logp("(%s)\n", p1b->datapth); return 0; }
static int process_changed_file(struct asfd *asfd, struct sdirs *sdirs, struct conf *cconf, struct sbuf *cb, struct sbuf *p1b, const char *adir) { size_t blocklen=0; char *curpath=NULL; //logp("need to process changed file: %s (%s)\n", cb->path, cb->datapth); // Move datapth onto p1b. iobuf_copy(&p1b->burp1->datapth, &cb->burp1->datapth); cb->burp1->datapth.buf=NULL; if(!(curpath=prepend_s(adir, p1b->burp1->datapth.buf))) { log_out_of_memory(__func__); return -1; } if(dpthl_is_compressed(cb->compression, curpath)) p1b->burp1->sigzp=gzopen_file(curpath, "rb"); else p1b->burp1->sigfp=open_file(curpath, "rb"); if(!p1b->burp1->sigzp && !p1b->burp1->sigfp) { logp("could not open %s: %s\n", curpath, strerror(errno)); free(curpath); return -1; } free(curpath); blocklen=get_librsync_block_len(cb->burp1->endfile.buf); if(!(p1b->burp1->sigjob=rs_sig_begin(blocklen, RS_DEFAULT_STRONG_LEN))) { logp("could not start signature job.\n"); return -1; } //logp("sig begin: %s\n", p1b->burp1->datapth.buf); if(!(p1b->burp1->infb=rs_filebuf_new(asfd, NULL, p1b->burp1->sigfp, p1b->burp1->sigzp, -1, blocklen, -1, cconf->cntr))) { logp("could not rs_filebuf_new for infb.\n"); return -1; } if(!(p1b->burp1->outfb=rs_filebuf_new(asfd, NULL, NULL, NULL, asfd->fd, ASYNC_BUF_LEN, -1, cconf->cntr))) { logp("could not rs_filebuf_new for in_outfb.\n"); return -1; } // Flag the things that need to be sent (to the client) p1b->flags |= SBUFL_SEND_DATAPTH; p1b->flags |= SBUFL_SEND_STAT; p1b->flags |= SBUFL_SEND_PATH; //logp("sending sig for %s\n", p1b->path); //logp("(%s)\n", p1b->datapth); return 0; }