Skip to content

Commit

Permalink
Imported rsync-bpc-3.0.9.3.tar
Browse files Browse the repository at this point in the history
  • Loading branch information
Craig Barratt authored and larstobi committed May 16, 2016
1 parent b180d31 commit bd70967
Show file tree
Hide file tree
Showing 9 changed files with 83 additions and 47 deletions.
21 changes: 21 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
NEWS for rsync-bpc-3.0.9.

3.0.9.3 released 1 Dec 2013:

- Fixed bug in merging of V3 incrementals during restore. Reported by
Denis Jedig and Steve Palm.

3.0.9.2 released 16 Sep 2013:

- increased BPC_POOL_WRITE_CONCURRENT_MATCH from 4 to 16.

- increased log threshold in bpc_lib_conf_init from 3 to 8.

3.0.9.1 released 1 Jul 2013:

- no changes.

3.0.9.0 released 24 June 2013:

- Initial version based on rsync 3.0.9, plus rsync-patches-3.0.9.tar.gz (23-Sep-2011 10:46).

NEWS for rsync 3.0.9 (23 Sep 2011)
Protocol: 30 (unchanged)
Changes since 3.0.8:
Expand Down
5 changes: 3 additions & 2 deletions backuppc/backuppc.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,7 @@ typedef struct {
time_t mtime;
OFF_T size;
ino_t inode;
int32 backupNum;
bpc_digest digest;
/*
* hash table of bpc_attrib_xattr entries, indexed by xattr key
Expand Down Expand Up @@ -317,7 +318,7 @@ uchar *bpc_attrib_buf2file(bpc_attrib_file *file, uchar *buf, uchar *bufEnd, int
uchar *bpc_attrib_buf2fileFull(bpc_attrib_file *file, uchar *buf, uchar *bufEnd);
uchar *bpc_attrib_file2buf(bpc_attrib_file *file, uchar *buf, uchar *bufEnd);
int bpc_attrib_digestRead(bpc_attrib_dir *dir, bpc_digest *digest, char *attribPath);
int bpc_attrib_dirRead(bpc_attrib_dir *dir, char *dirPath, char *attribFileName);
int bpc_attrib_dirRead(bpc_attrib_dir *dir, char *dirPath, char *attribFileName, int backupNum);
int bpc_attrib_dirWrite(bpc_attrib_dir *dir, char *dirPath, char *attribFileName, bpc_digest *oldDigest);

/*
Expand Down Expand Up @@ -407,6 +408,6 @@ int bpc_attribCache_deleteInode(bpc_attribCache_info *ac, ino_t inode);
int bpc_attribCache_getDirEntryCnt(bpc_attribCache_info *ac, char *path);
ssize_t bpc_attribCache_getDirEntries(bpc_attribCache_info *ac, char *path, char *entries, ssize_t entrySize);
void bpc_attribCache_flush(bpc_attribCache_info *ac, int all, char *path);
void bpc_attribCache_getFullMangledPath(bpc_attribCache_info *ac, char *path, char *dirName);
void bpc_attribCache_getFullMangledPath(bpc_attribCache_info *ac, char *path, char *dirName, int backupNum);

#endif
47 changes: 25 additions & 22 deletions backuppc/bpc_attrib.c
Original file line number Diff line number Diff line change
Expand Up @@ -281,16 +281,17 @@ void bpc_attrib_fileCopyOpt(bpc_attrib_file *fileDest, bpc_attrib_file *fileSrc,
{
if ( fileDest == fileSrc ) return;

fileDest->type = fileSrc->type;
fileDest->compress = fileSrc->compress;
fileDest->mode = fileSrc->mode;
fileDest->isTemp = fileSrc->isTemp;
fileDest->uid = fileSrc->uid;
fileDest->gid = fileSrc->gid;
fileDest->nlinks = fileSrc->nlinks;
fileDest->mtime = fileSrc->mtime;
fileDest->size = fileSrc->size;
fileDest->inode = fileSrc->inode;
fileDest->type = fileSrc->type;
fileDest->compress = fileSrc->compress;
fileDest->mode = fileSrc->mode;
fileDest->isTemp = fileSrc->isTemp;
fileDest->uid = fileSrc->uid;
fileDest->gid = fileSrc->gid;
fileDest->nlinks = fileSrc->nlinks;
fileDest->mtime = fileSrc->mtime;
fileDest->size = fileSrc->size;
fileDest->inode = fileSrc->inode;
fileDest->backupNum = fileSrc->backupNum;
if ( fileSrc->digest.len > 0 || overwriteEmptyDigest ) {
fileDest->digest = fileSrc->digest;
}
Expand Down Expand Up @@ -518,8 +519,8 @@ static int64 getVarInt(uchar **bufPP, uchar *bufEnd)
i += 7;
}
/*
* we ran out of data... make sure bufP is greater more than bufEnd, since
* returning * it to be equal (ie: bufP) will be incorrectly interpreted as
* we ran out of data... make sure bufP is greater than bufEnd, since
* returning it to be equal (ie: bufP) will be incorrectly interpreted as
* meaning the integer correctly ended right at the end of the buffer.
*/
*bufPP = bufEnd + 1;
Expand All @@ -543,7 +544,7 @@ static int64 getVarInt_v3(uchar **bufPP, uchar *bufEnd)
}
}
/*
* we ran out of data... make sure bufP is greater more than bufEnd, since
* we ran out of data... make sure bufP is greater than bufEnd, since
* returning it to be equal (ie: bufP) will be incorrectly interpreted as
* meaning the integer correctly ended right at the end of the buffer.
*/
Expand Down Expand Up @@ -640,7 +641,7 @@ uchar *bpc_attrib_buf2fileFull(bpc_attrib_file *file, uchar *bufP, uchar *bufEnd
return bufP;
}

int bpc_attrib_dirRead(bpc_attrib_dir *dir, char *dirPath, char *attribFileName)
int bpc_attrib_dirRead(bpc_attrib_dir *dir, char *dirPath, char *attribFileName, int backupNum)
{
char attribPath[BPC_MAXPATHLEN];
bpc_fileZIO_fd fd;
Expand Down Expand Up @@ -734,6 +735,7 @@ int bpc_attrib_dirRead(bpc_attrib_dir *dir, char *dirPath, char *attribFileName)

file = bpc_attrib_fileGet(dir, fileName, 1);
bpc_attrib_fileInit(file, fileName, xattrNumEntries);
file->backupNum = backupNum;

bufP = bpc_attrib_buf2file(file, bufP, buf + nRead, xattrNumEntries);
if ( bufP > buf + nRead ) {
Expand Down Expand Up @@ -794,14 +796,15 @@ int bpc_attrib_dirRead(bpc_attrib_dir *dir, char *dirPath, char *attribFileName)
file = bpc_attrib_fileGet(dir, fileName, 1);
bpc_attrib_fileInit(file, fileName, 0);

file->type = type;
file->mode = getVarInt_v3(&bufP, buf + nRead);
file->uid = getVarInt_v3(&bufP, buf + nRead);
file->gid = getVarInt_v3(&bufP, buf + nRead);
sizeDiv4GB = getVarInt_v3(&bufP, buf + nRead);
file->size = (sizeDiv4GB << 32) + getVarInt_v3(&bufP, buf + nRead);
file->mtime = CONV_BUF_TO_UINT32(bufP); bufP += 4;
file->compress = dir->compress;
file->type = type;
file->mode = getVarInt_v3(&bufP, buf + nRead);
file->uid = getVarInt_v3(&bufP, buf + nRead);
file->gid = getVarInt_v3(&bufP, buf + nRead);
sizeDiv4GB = getVarInt_v3(&bufP, buf + nRead);
file->size = (sizeDiv4GB << 32) + getVarInt_v3(&bufP, buf + nRead);
file->mtime = CONV_BUF_TO_UINT32(bufP); bufP += 4;
file->compress = dir->compress;
file->backupNum = backupNum;

if ( BPC_LogLevel >= 8 ) bpc_logMsgf("bpc_attrib_dirRead(%s): Got v3 file %s: type = %d, mode = 0%o, uid/gid = %d/%d, size = %d\n",
attribPath, file->name, file->type, file->mode, file->uid, file->gid, file->size);
Expand Down
33 changes: 22 additions & 11 deletions backuppc/bpc_attribCache.c
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static bpc_attribCache_dir *bpc_attribCache_loadPath(bpc_attribCache_info *ac, c
continue;
}
bpc_attrib_dirInit(&dir, ac->bkupMergeList[i].compress);
if ( (status = bpc_attrib_dirRead(&dir, topDir, attribPath)) ) {
if ( (status = bpc_attrib_dirRead(&dir, topDir, attribPath, ac->bkupMergeList[i].num)) ) {
bpc_logErrf("bpc_attribCache_loadPath: bpc_attrib_dirRead(%s/%s) returned %d\n", topDir, attribPath, status);
}
entrySize = bpc_attrib_getEntries(&dir, NULL, 0);
Expand All @@ -238,6 +238,7 @@ static bpc_attribCache_dir *bpc_attribCache_loadPath(bpc_attribCache_info *ac, c
bpc_attrib_fileInit(fileDest, fileName, 0);
}
bpc_attrib_fileCopy(fileDest, file);
fileDest->backupNum = ac->bkupMergeList[i].num;
}
}
} else {
Expand All @@ -254,7 +255,7 @@ static bpc_attribCache_dir *bpc_attribCache_loadPath(bpc_attribCache_info *ac, c
/*
* non-merge case - read the single attrib file
*/
if ( (status = bpc_attrib_dirRead(&attr->dir, ac->backupTopDir, attribPath)) ) {
if ( (status = bpc_attrib_dirRead(&attr->dir, ac->backupTopDir, attribPath, ac->backupNum)) ) {
bpc_logErrf("bpc_attribCache_loadPath: bpc_attrib_dirRead(%s, %s) returned %d\n", ac->backupTopDir, attribPath, status);
}
}
Expand Down Expand Up @@ -321,7 +322,7 @@ static bpc_attribCache_dir *bpc_attribCache_loadInode(bpc_attribCache_info *ac,
continue;
}
bpc_attrib_dirInit(&dir, ac->bkupMergeList[i].compress);
if ( (status = bpc_attrib_dirRead(&dir, topDir, attribPath)) ) {
if ( (status = bpc_attrib_dirRead(&dir, topDir, attribPath, ac->bkupMergeList[i].num)) ) {
bpc_logErrf("bpc_attribCache_loadInode: bpc_attrib_dirRead(%s/%s) returned %d\n", topDir, attribPath, status);
}
entrySize = bpc_attrib_getEntries(&dir, NULL, 0);
Expand Down Expand Up @@ -358,7 +359,7 @@ static bpc_attribCache_dir *bpc_attribCache_loadInode(bpc_attribCache_info *ac,
/*
* non-merge case - read the single attrib file
*/
if ( (status = bpc_attrib_dirRead(&attr->dir, ac->backupTopDir, attribPath)) ) {
if ( (status = bpc_attrib_dirRead(&attr->dir, ac->backupTopDir, attribPath, ac->backupNum)) ) {
bpc_logErrf("bpc_attrib_dirRead: bpc_attrib_dirRead(%s/%s) returned %d\n", ac->backupTopDir, attribPath, status);
}
}
Expand Down Expand Up @@ -509,7 +510,7 @@ int bpc_attribCache_getDirEntryCnt(bpc_attribCache_info *ac, char *path)
size_t pathLen = strlen(path);

/*
* Append a fake file name so we actually open the directory's contents, not the directory entry on level up
* Append a fake file name so we actually open the directory's contents, not the directory entry one level up
*/
if ( pathLen >= BPC_MAXPATHLEN - 3 ) return -1;
strcpy(path + pathLen, "/x");
Expand Down Expand Up @@ -553,12 +554,18 @@ ssize_t bpc_attribCache_getDirEntries(bpc_attribCache_info *ac, char *path, char
ino_t inode = 0;

/*
* Append a fake file name so we actually open the directory's contents, not the directory entry on level up
* Append a fake file name so we actually open the directory's contents, not the directory entry one level up
*/
if ( pathLen >= BPC_MAXPATHLEN - 3 ) return -1;
strcpy(path + pathLen, "/x");
attr = bpc_attribCache_loadPath(ac, fileName, path);
path[pathLen] = '\0';
if ( pathLen == 1 && path[0] == '.' ) {
strcpy(path, "/x");
attr = bpc_attribCache_loadPath(ac, fileName, path);
strcpy(path, ".");
} else {
strcpy(path + pathLen, "/x");
attr = bpc_attribCache_loadPath(ac, fileName, path);
path[pathLen] = '\0';
}
if ( !attr ) return -1;
attr->lruCnt = ac->cacheLruCnt++;

Expand Down Expand Up @@ -729,7 +736,7 @@ void bpc_attribCache_flush(bpc_attribCache_info *ac, int all, char *path)
/*
* Returns the full mangled path, given a file path.
*/
void bpc_attribCache_getFullMangledPath(bpc_attribCache_info *ac, char *path, char *dirName)
void bpc_attribCache_getFullMangledPath(bpc_attribCache_info *ac, char *path, char *dirName, int backupNum)
{
char *p;
int len;
Expand All @@ -740,7 +747,11 @@ void bpc_attribCache_getFullMangledPath(bpc_attribCache_info *ac, char *path, ch
while ( dirName[0] == '/' ) dirName++;
} while ( p != dirName );

len = snprintf(path, BPC_MAXPATHLEN, "%s/%s", ac->backupTopDir, ac->shareName);
if ( backupNum < 0 || ac->bkupMergeCnt <= 0 ) {
backupNum = ac->backupNum;
}

len = snprintf(path, BPC_MAXPATHLEN, "%s/pc/%s/%d/%s", BPC_TopDir, ac->hostName, backupNum, ac->shareName);
if ( (dirName[0] == '/' && dirName[1] == '\0') || dirName[0] == '\0' || len >= BPC_MAXPATHLEN - 1 ) {
return;
}
Expand Down
4 changes: 2 additions & 2 deletions backuppc/bpc_dirOps.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ int bpc_path_remove(char *path, int compress)
bpc_attrib_dir dir;

bpc_attrib_dirInit(&dir, compress);
if ( bpc_attrib_dirRead(&dir, NULL, filePath) ) {
if ( bpc_attrib_dirRead(&dir, NULL, filePath, 0) ) {
bpc_logErrf("bpc_path_remove: can't read attrib file %s\n", filePath);
errorCnt++;
}
Expand Down Expand Up @@ -212,7 +212,7 @@ int bpc_path_refCountAll(char *path, int compress)
bpc_attrib_dir dir;

bpc_attrib_dirInit(&dir, compress);
if ( bpc_attrib_dirRead(&dir, NULL, filePath) ) {
if ( bpc_attrib_dirRead(&dir, NULL, filePath, 0) ) {
bpc_logErrf("bpc_path_refCountAll: can't read attrib file %s\n", filePath);
errorCnt++;
} else {
Expand Down
14 changes: 6 additions & 8 deletions bpc_sysCalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ static FdInfo *bpc_fileOpen(bpc_attribCache_info *ac, char *fileName, int flags)
/*
* must be a V3 file - look in the backup directory
*/
bpc_attribCache_getFullMangledPath(&acNew, fullPath, (char*)fileName);
bpc_attribCache_getFullMangledPath(&acNew, fullPath, (char*)fileName, file->backupNum);
if ( bpc_fileZIO_open(&fdz, fullPath, 0, file->compress) ) {
bpc_logErrf("bpc_fileOpen: can't open V3 file %s (from %s, %d, %d)\n", fullPath, fd->fileName, file->compress, file->digest.len);
Stats.ErrorCnt++;
Expand Down Expand Up @@ -573,7 +573,7 @@ static off_t bpc_fileReadAll(bpc_attribCache_info *ac, char *fileName, char *buf
/*
* V3 look in the backup directory
*/
bpc_attribCache_getFullMangledPath(&acNew, fullPath, (char*)fileName);
bpc_attribCache_getFullMangledPath(&acNew, fullPath, (char*)fileName, file->backupNum);
}
if ( bpc_fileZIO_open(&fd, fullPath, 0, file->compress) ) {
bpc_logErrf("bpc_fileReadAll: can't open %s (from %s)\n", fullPath, fileName);
Expand Down Expand Up @@ -854,13 +854,11 @@ int bpc_fchmod(int filedes, mode_t mode)

int bpc_unlink(const char *fileName)
{
char path[BPC_MAXPATHLEN];
bpc_attrib_file *file;
int deleteInode = 0;

if ( LogLevel >= 4 ) bpc_logMsgf("bpc_unlink(%s)\n", fileName);

bpc_attribCache_getFullMangledPath(&acNew, path, (char*)fileName);
if ( !(file = bpc_attribCache_getFile(&acNew, (char*)fileName, 0, 0)) ) {
errno = ENOENT;
return -1;
Expand Down Expand Up @@ -1379,8 +1377,8 @@ int bpc_rename(const char *oldName, const char *newName)
if ( file->type == BPC_FTYPE_DIR ) {
char path[BPC_MAXPATHLEN], pathOld[BPC_MAXPATHLEN];

bpc_attribCache_getFullMangledPath(&acNew, path, (char*)newName);
bpc_attribCache_getFullMangledPath(&acNew, pathOld, (char*)oldName);
bpc_attribCache_getFullMangledPath(&acNew, path, (char*)newName, file->backupNum);
bpc_attribCache_getFullMangledPath(&acNew, pathOld, (char*)oldName, file->backupNum);

if ( rename(pathOld, path) ) {
bpc_logErrf("bpc_rename: directory rename %s -> %s failed\n", pathOld, path);
Expand Down Expand Up @@ -1664,7 +1662,7 @@ int bpc_mkdir(const char *dirName, mode_t mode)

if ( LogLevel >= 4 ) bpc_logMsgf("bpc_mkdir(%s, 0%o)\n", dirName, mode);

bpc_attribCache_getFullMangledPath(&acNew, path, (char*)dirName);
bpc_attribCache_getFullMangledPath(&acNew, path, (char*)dirName, -1);
if ( bpc_attribCache_getFile(&acNew, (char*)dirName, 0, 0) ) {
errno = EEXIST;
return -1;
Expand Down Expand Up @@ -1699,8 +1697,8 @@ int bpc_rmdir(const char *dirName)

if ( LogLevel >= 4 ) bpc_logMsgf("bpc_rmdir(%s)\n", dirName);

bpc_attribCache_getFullMangledPath(&acNew, path, (char*)dirName);
file = bpc_attribCache_getFile(&acNew, (char*)dirName, 0, 0);
bpc_attribCache_getFullMangledPath(&acNew, path, (char*)dirName, file->backupNum);

statOk = !stat(path, &st);
if ( file && (!statOk || !S_ISDIR(st.st_mode)) ) {
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ AC_CONFIG_SRCDIR([byteorder.h])
AC_CONFIG_HEADER(config.h)
AC_PREREQ(2.59)

RSYNC_VERSION=3.0.9.2
RSYNC_VERSION=3.0.9.3
AC_SUBST(RSYNC_VERSION)
AC_MSG_NOTICE([Configuring rsync $RSYNC_VERSION])

Expand Down
2 changes: 1 addition & 1 deletion configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2419,7 +2419,7 @@ ac_config_headers="$ac_config_headers config.h"
RSYNC_VERSION=3.0.9.2
RSYNC_VERSION=3.0.9.3
{ $as_echo "$as_me:${as_lineno-$LINENO}: Configuring rsync_bpc $RSYNC_VERSION" >&5
$as_echo "$as_me: Configuring rsync_bpc $RSYNC_VERSION" >&6;}
Expand Down
2 changes: 2 additions & 0 deletions generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -762,13 +762,15 @@ int unchanged_file(char *fn, struct file_struct *file, STRUCT_STAT *st)
if (always_checksum > 0 && S_ISREG(st->st_mode)) {
char sum[MAX_DIGEST_LEN];
file_checksum(fn, sum, st->st_size);
/*
{
uchar *p = (uchar*)F_SUM(file);
fprintf(stderr, "checksum(%s): %s %02x%02x%02x%02x... vs %02x%02x%02x%02x...\n",
fn, memcmp(sum, F_SUM(file), checksum_len) ? "neq" : "equal",
p[0], p[1], p[2], p[3],
sum[0] & 0xff, sum[1] & 0xff, sum[2] & 0xff, sum[3] & 0xff);
}
*/
if ( memcmp(sum, F_SUM(file), checksum_len) ) return 0;
}

Expand Down

0 comments on commit bd70967

Please sign in to comment.