faubackup2/src/rsync rsync.cpp,1.1.1.1,1.2 rsync.hpp,1.1.1.1,1.2 rsync_wrapper.c,1.1.1.1,1.2 rsync_wrapper.h,1.1.1.1,1.2
Erik Merkel <[email protected]> Mon, 06 Jun 2005 19:45:10 +0000
| Newsgroups | gmane.comp.sysutils.backup.faubackup.cvs |
|---|---|
| Message-ID | <[email protected]> |
Update of /cvsroot/faubackup/faubackup2/src/rsync
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2530/src/rsync
Modified Files:
rsync.cpp rsync.hpp rsync_wrapper.c rsync_wrapper.h
Log Message:
implemented variable blocksize based on filesize for rsync mode
Index: rsync.hpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/rsync/rsync.hpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** rsync.hpp 2 Jun 2005 09:31:13 -0000 1.1.1.1
--- rsync.hpp 6 Jun 2005 19:45:08 -0000 1.2
***************
*** 12,16 ****
{
! void checkSum(string fileName, NetCommunication &out);
void delta(string fileName, NetCommunication &in, NetCommunication &out);
void patch(string newFile, string oldFile, NetCommunication &in);
--- 12,16 ----
{
! void checkSum(string fileName, uint64_t fileSize, NetCommunication &out);
void delta(string fileName, NetCommunication &in, NetCommunication &out);
void patch(string newFile, string oldFile, NetCommunication &in);
Index: rsync_wrapper.c
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/rsync/rsync_wrapper.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** rsync_wrapper.c 2 Jun 2005 09:31:13 -0000 1.1.1.1
--- rsync_wrapper.c 6 Jun 2005 19:45:08 -0000 1.2
***************
*** 9,15 ****
#include <rsync/rsync++_calls.hpp>
- /* librsync default = 2048; must be smaller than 65535 */
- static size_t new_block_len = 8196;
- /*RS_DEFAULT_BLOCK_LEN;*/
/* = 8 librsync default */
--- 9,12 ----
***************
*** 25,29 ****
! rs_result rdiff_sig(FILE *source_file, void *network,rs_stats_t *stats)
{
rs_result result;
--- 22,26 ----
! rs_result rdiff_sig(FILE *source_file, size_t blockSize, void *network,rs_stats_t *stats)
{
rs_result result;
***************
*** 37,41 ****
return RS_IO_ERROR;
! job = rs_sig_begin(new_block_len, strong_len);
if (source_file)
in_fb = rs_filebuf_new2(source_file, NULL, rs_inbuflen);
--- 34,38 ----
return RS_IO_ERROR;
! job = rs_sig_begin(blockSize, strong_len);
if (source_file)
in_fb = rs_filebuf_new2(source_file, NULL, rs_inbuflen);
***************
*** 164,168 ****
assert(buf->next_in >= fb->buf);
assert(buf->next_in <= fb->buf + fb->buf_len);
! } else {
assert(buf->avail_in == 0);
}
--- 161,166 ----
assert(buf->next_in >= fb->buf);
assert(buf->next_in <= fb->buf + fb->buf_len);
! }
! else {
assert(buf->avail_in == 0);
}
***************
*** 260,264 ****
assert(buf->next_in >= fb->buf);
assert(buf->next_in <= fb->buf + fb->buf_len);
! } else {
assert(buf->avail_in == 0);
}
--- 258,263 ----
assert(buf->next_in >= fb->buf);
assert(buf->next_in <= fb->buf + fb->buf_len);
! }
! else {
assert(buf->avail_in == 0);
}
***************
*** 288,292 ****
strerror(errno));*/
return RS_IO_ERROR;
! } else {
/*rs_error("no error bit, but got %d return when trying to read",
len);*/
--- 287,292 ----
strerror(errno));*/
return RS_IO_ERROR;
! }
! else {
/*rs_error("no error bit, but got %d return when trying to read",
len);*/
Index: rsync_wrapper.h
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/rsync/rsync_wrapper.h,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** rsync_wrapper.h 2 Jun 2005 09:31:13 -0000 1.1.1.1
--- rsync_wrapper.h 6 Jun 2005 19:45:08 -0000 1.2
***************
*** 12,16 ****
#ifdef __cplusplus
! extern "C"{
#endif
--- 12,17 ----
#ifdef __cplusplus
! extern "C"
! {
#endif
***************
*** 27,52 ****
! typedef struct rs_filebuf rs_filebuf_t;
! rs_result rdiff_sig(FILE *source_file, void *network, rs_stats_t *stats);
! rs_result rdiff_delta(FILE *source_file, void *network_in, void *network_out, rs_stats_t *stats);
! rs_result rdiff_patch(FILE *source_file, void *network_in, FILE *destination_file, rs_stats_t *stats);
! rs_filebuf_t *rs_filebuf_new2(FILE *f, void * network, size_t buf_len);
! rs_result innetwork_fill(rs_job_t *job, rs_buffers_t *buf,
! void *opaque);
! rs_result outnetwork_drain(rs_job_t *job, rs_buffers_t *buf, void *opaque);
! /* already in librsync.so */
! void * rs_alloc_struct0(size_t size, char const *name);
! void * rs_alloc(size_t size, char const *name);
! rs_result rs_infilebuf_fill2(rs_job_t *job, rs_buffers_t *buf, void *opaque);
! rs_result rs_outfilebuf_drain2(rs_job_t *job, rs_buffers_t *buf, void *opaque);
! void rs_filebuf_free2(rs_filebuf_t *fb);
! void rs_bzero(void *buf, size_t size);
#ifdef __cplusplus
--- 28,53 ----
! typedef struct rs_filebuf rs_filebuf_t;
! rs_result rdiff_sig(FILE *source_file, size_t blockSize, void *network,rs_stats_t *stats);
! rs_result rdiff_delta(FILE *source_file, void *network_in, void *network_out, rs_stats_t *stats);
! rs_result rdiff_patch(FILE *source_file, void *network_in, FILE *destination_file, rs_stats_t *stats);
! rs_filebuf_t *rs_filebuf_new2(FILE *f, void * network, size_t buf_len);
! rs_result innetwork_fill(rs_job_t *job, rs_buffers_t *buf,
! void *opaque);
! rs_result outnetwork_drain(rs_job_t *job, rs_buffers_t *buf, void *opaque);
! /* already in librsync.so */
! void * rs_alloc_struct0(size_t size, char const *name);
! void * rs_alloc(size_t size, char const *name);
! rs_result rs_infilebuf_fill2(rs_job_t *job, rs_buffers_t *buf, void *opaque);
! rs_result rs_outfilebuf_drain2(rs_job_t *job, rs_buffers_t *buf, void *opaque);
! void rs_filebuf_free2(rs_filebuf_t *fb);
! void rs_bzero(void *buf, size_t size);
#ifdef __cplusplus
Index: rsync.cpp
===================================================================
RCS file: /cvsroot/faubackup/faubackup2/src/rsync/rsync.cpp,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** rsync.cpp 2 Jun 2005 09:31:13 -0000 1.1.1.1
--- rsync.cpp 6 Jun 2005 19:45:08 -0000 1.2
***************
*** 2,5 ****
--- 2,6 ----
#include <common/common.hpp>
#include <rsync/rsync_wrapper.h>
+ #include <cmath>
#define STAT_CHAR_ARRAY_SIZE 200
extern "C"
***************
*** 10,14 ****
{
! void checkSum(string fileName, NetCommunication &out)
{
//char buffer[STAT_CHAR_ARRAY_SIZE];
--- 11,15 ----
{
! void checkSum(string fileName, uint64_t fileSize, NetCommunication &out)
{
//char buffer[STAT_CHAR_ARRAY_SIZE];
***************
*** 17,34 ****
FILE *file;
file = fopen(fileName.c_str(), "rb");
! if(!file)
! {
output.non_critical("error opening file for rsync: " + fileName, errno);
return;
}
! result = rdiff_sig(file, &out, &stats);
! if(result != RS_DONE)
! {
const char *error_msg = rs_strerror(result);
output.non_critical("error creating rsync checksum for " + fileName + " " + string(error_msg),0);
}
! else
! {
// rs_format_stats(&stats, buffer, STAT_CHAR_ARRAY_SIZE);
// output.information(fileName + " : " + string(buffer), DEBUG_OUTPUT);
--- 18,46 ----
FILE *file;
file = fopen(fileName.c_str(), "rb");
!
! if(!file) {
output.non_critical("error opening file for rsync: " + fileName, errno);
return;
}
! size_t blocksize;
!
! blocksize = (size_t) sqrtl(fileSize);
!
! /* making 2^x blocksize */
! size_t temp;
! temp = (size_t) fabs(log(blocksize) / log(2));
! blocksize = (size_t)pow(2, temp + 1);
!
! if(blocksize < 512)
! blocksize = 512;
!
! output.information("rsync " + fileName + " with blocksize: " + int2string(blocksize), DEBUG_OUTPUT);
! result = rdiff_sig(file, blocksize, &out, &stats);
! if(result != RS_DONE) {
const char *error_msg = rs_strerror(result);
output.non_critical("error creating rsync checksum for " + fileName + " " + string(error_msg),0);
}
! else {
// rs_format_stats(&stats, buffer, STAT_CHAR_ARRAY_SIZE);
// output.information(fileName + " : " + string(buffer), DEBUG_OUTPUT);
***************
*** 44,61 ****
FILE *file;
file = fopen(fileName.c_str(), "rb");
! if(!file)
! {
output.non_critical("error opening file for rsync: " + fileName, errno);
return;
}
result = rdiff_delta(file, &in, &out, &stats);
! if(result != RS_DONE)
! {
std::cerr << "error" << std::endl;
const char *error_msg = rs_strerror(result);
output.non_critical("error creating rsync delta for " + fileName + " " + string(error_msg),0);
}
! else
! {
// rs_format_stats(&stats, buffer, STAT_CHAR_ARRAY_SIZE);
// output.information(fileName + " : " + string(buffer), DEBUG_OUTPUT);
--- 56,70 ----
FILE *file;
file = fopen(fileName.c_str(), "rb");
! if(!file) {
output.non_critical("error opening file for rsync: " + fileName, errno);
return;
}
result = rdiff_delta(file, &in, &out, &stats);
! if(result != RS_DONE) {
std::cerr << "error" << std::endl;
const char *error_msg = rs_strerror(result);
output.non_critical("error creating rsync delta for " + fileName + " " + string(error_msg),0);
}
! else {
// rs_format_stats(&stats, buffer, STAT_CHAR_ARRAY_SIZE);
// output.information(fileName + " : " + string(buffer), DEBUG_OUTPUT);
***************
*** 71,93 ****
FILE *file_new, *file_old;
file_old = fopen(oldFile.c_str(), "rb");
! if(!file_old)
! {
output.non_critical("error opening file for rsync: " + oldFile, errno);
return;
}
file_new = fopen(newFile.c_str(), "wb");
! if(!file_new)
! {
output.non_critical("error opening file for rsync: " + newFile, errno);
return;
}
result = rdiff_patch(file_old, &in, file_new, &stats);
! if(result != RS_DONE)
! {
const char *error_msg = rs_strerror(result);
output.non_critical("error creating rsync patch for " + newFile + " with " + oldFile+ " " + string(error_msg),0);
}
! else
! {
// rs_format_stats(&stats, buffer, STAT_CHAR_ARRAY_SIZE);
// output.information(newFile + " : " + string(buffer), DEBUG_OUTPUT);
--- 80,98 ----
FILE *file_new, *file_old;
file_old = fopen(oldFile.c_str(), "rb");
! if(!file_old) {
output.non_critical("error opening file for rsync: " + oldFile, errno);
return;
}
file_new = fopen(newFile.c_str(), "wb");
! if(!file_new) {
output.non_critical("error opening file for rsync: " + newFile, errno);
return;
}
result = rdiff_patch(file_old, &in, file_new, &stats);
! if(result != RS_DONE) {
const char *error_msg = rs_strerror(result);
output.non_critical("error creating rsync patch for " + newFile + " with " + oldFile+ " " + string(error_msg),0);
}
! else {
// rs_format_stats(&stats, buffer, STAT_CHAR_ARRAY_SIZE);
// output.information(newFile + " : " + string(buffer), DEBUG_OUTPUT);
-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games. How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20