line |
true |
false |
branch |
64
|
0 |
0 |
if ( writeOldStyleAttribFile >= 0 ) WriteOldStyleAttribFile = writeOldStyleAttribFile; |
65
|
0 |
0 |
if ( keepOldAttribFiles >= 0 ) KeepOldAttribFiles = keepOldAttribFiles; |
66
|
0 |
0 |
if ( BPC_LogLevel >= 5 ) { |
91
|
0 |
0 |
if ( xattr->key.key ) free(xattr->key.key); |
92
|
0 |
0 |
if ( xattr->value ) free(xattr->value); |
99
|
0 |
0 |
if ( !xattr ) return -1; |
127
|
0 |
0 |
if ( ((char*)key)[keyLen - 1] != 0x0 ) { |
128
|
0 |
0 |
if ( keyLen >= BPC_MAXPATHLEN - 8 ) { |
140
|
0 |
0 |
if ( !xattr->value ) { |
144
|
0 |
0 |
if ( !(xattr->key.key = malloc(keyLen)) ) { |
154
|
0 |
0 |
if ( valueLen > xattr->valueLen ) { |
157
|
0 |
0 |
} else if ( valueLen == xattr->valueLen && !memcmp(xattr->value, value, valueLen) ) { |
|
0 |
0 |
} else if ( valueLen == xattr->valueLen && !memcmp(xattr->value, value, valueLen) ) { |
164
|
0 |
0 |
if ( !xattr->value && !(xattr->value = malloc(valueLen)) ) { |
|
0 |
0 |
if ( !xattr->value && !(xattr->value = malloc(valueLen)) ) { |
176
|
0 |
0 |
uchar *key = (uchar*)malloc(xattrSrc->key.keyLen > 0 ? xattrSrc->key.keyLen : 1); |
177
|
0 |
0 |
uchar *value = (uchar*)malloc(xattrSrc->valueLen > 0 ? xattrSrc->valueLen : 1); |
179
|
0 |
0 |
if ( !key || !value ) { |
|
0 |
0 |
if ( !key || !value ) { |
189
|
0 |
0 |
if ( xattr->value ) { |
215
|
0 |
0 |
if ( info->idx < 0 ) return; |
217
|
0 |
0 |
if ( info->ignoreRsyncACLs ) { |
227
|
0 |
0 |
for ( i = 0 ; i < sizeof(ignoreKeys) / sizeof(ignoreKeys[0]) ; i++ ) { |
228
|
0 |
0 |
if ( xattr->key.keyLen == ignoreKeys[i].len |
229
|
0 |
0 |
&& !memcmp(xattr->key.key, ignoreKeys[i].str, xattr->key.keyLen) ) { |
234
|
0 |
0 |
if ( info->list ) { |
235
|
0 |
0 |
if ( info->idx + (signed)xattr->key.keyLen > info->listLen ) { |
243
|
0 |
0 |
if ( xattr->key.keyLen >= 1 && info->list[info->idx + xattr->key.keyLen - 1] != 0x0 ) { |
|
0 |
0 |
if ( xattr->key.keyLen >= 1 && info->list[info->idx + xattr->key.keyLen - 1] != 0x0 ) { |
247
|
0 |
0 |
if ( BPC_LogLevel >= 6 ) bpc_logMsgf("bpc_attrib_xattrListKey: adding %s\n", info->list + info->idx); |
275
|
0 |
0 |
if ( file->name) free(file->name); |
298
|
0 |
0 |
if ( file->name ) bpc_attrib_fileDestroy(file); |
300
|
0 |
0 |
if ( !file->name ) { |
319
|
0 |
0 |
if ( fileDest == fileSrc ) return; |
332
|
0 |
0 |
if ( fileSrc->digest.len > 0 || overwriteEmptyDigest ) { |
|
0 |
0 |
if ( fileSrc->digest.len > 0 || overwriteEmptyDigest ) { |
347
|
0 |
0 |
if ( fileDest == fileSrc ) return; |
359
|
0 |
0 |
if ( file0->type != file1->type |
360
|
0 |
0 |
|| file0->compress != file1->compress |
361
|
0 |
0 |
|| file0->mode != file1->mode |
362
|
0 |
0 |
|| file0->uid != file1->uid |
363
|
0 |
0 |
|| file0->gid != file1->gid |
364
|
0 |
0 |
|| file0->nlinks != file1->nlinks |
365
|
0 |
0 |
|| file0->mtime != file1->mtime |
366
|
0 |
0 |
|| file0->size != file1->size |
367
|
0 |
0 |
|| file0->inode != file1->inode |
368
|
0 |
0 |
|| file0->digest.len != file1->digest.len |
369
|
0 |
0 |
|| memcmp(file0->digest.digest, file1->digest.digest, file0->digest.len) |
370
|
0 |
0 |
|| bpc_attrib_xattrCount(file0) != bpc_attrib_xattrCount(file1) ) { |
371
|
0 |
0 |
if ( BPC_LogLevel >= 9 ) bpc_logMsgf("bpc_attrib_fileCompare: %s %s differ\n", file0->name, file1->name); |
376
|
0 |
0 |
if ( !xattr0 ) return 0; |
377
|
0 |
0 |
if ( !(xattr1 = bpc_attrib_xattrGet(file1, xattr0->key.key, xattr0->key.keyLen, 0)) ) return 1; |
378
|
0 |
0 |
if ( xattr0->valueLen != xattr1->valueLen || memcmp(xattr0->value, xattr1->value, xattr0->valueLen) ) return 1; |
|
0 |
0 |
if ( xattr0->valueLen != xattr1->valueLen || memcmp(xattr0->value, xattr1->value, xattr0->valueLen) ) return 1; |
386
|
0 |
0 |
if ( !file ) return; |
394
|
0 |
0 |
if ( !*file ) return -1; |
405
|
0 |
0 |
if ( type < 0 || type >= (int)(sizeof(FileType2Text) / sizeof(FileType2Text[0])) ) return "?"; |
|
0 |
0 |
if ( type < 0 || type >= (int)(sizeof(FileType2Text) / sizeof(FileType2Text[0])) ) return "?"; |
430
|
0 |
0 |
if ( file->digest.len > 0 ) { |
433
|
0 |
0 |
if ( BPC_LogLevel >= 7 ) bpc_logMsgf("bpc_attrib_fileRefCount: file %s digest %s delta %d\n", file->name, hexStr, info->incr); |
436
|
0 |
0 |
if ( info->inodeMax && file->inode > *info->inodeMax ) { |
|
0 |
0 |
if ( info->inodeMax && file->inode > *info->inodeMax ) { |
453
|
0 |
0 |
if ( dir->digest.len > 0 ) { |
456
|
0 |
0 |
if ( BPC_LogLevel >= 7 ) bpc_logMsgf("bpc_attrib_dirRefCount: attrib digest %s delta = %d\n", hexStr, incr); |
459
|
0 |
0 |
if ( BPC_LogLevel >= 7 ) bpc_logMsgf("bpc_attrib_dirRefCount: no attrib digest -> no delta\n"); |
482
|
0 |
0 |
if ( info->entryIdx < 0 ) return; |
483
|
0 |
0 |
if ( info->entries ) { |
484
|
0 |
0 |
if ( info->entryIdx + len > info->entrySize ) { |
507
|
0 |
0 |
if ( !dir ) { |
510
|
0 |
0 |
snprintf(path, BPC_MAXPATHLEN, "%s/%s", dir, attribFileName ? attribFileName : "attrib"); |
529
|
0 |
0 |
if ( thisRead < 0 ) { |
546
|
0 |
0 |
while ( bufP < bufEnd ) { |
549
|
0 |
0 |
if ( !(c & 0x80) ) { |
572
|
0 |
0 |
while ( bufP < bufEnd ) { |
575
|
0 |
0 |
if ( !(c & 0x80) ) { |
601
|
0 |
0 |
if ( value && maxBytes > 0 ) c |= 0x80; |
|
0 |
0 |
if ( value && maxBytes > 0 ) c |= 0x80; |
602
|
0 |
0 |
if ( bufP < bufEnd ) { |
607
|
0 |
0 |
} while ( value && maxBytes > 0 ); |
|
0 |
0 |
} while ( value && maxBytes > 0 ); |
635
|
0 |
0 |
if ( file->digest.len > 0 && bufP + file->digest.len <= bufEnd ) { |
|
0 |
0 |
if ( file->digest.len > 0 && bufP + file->digest.len <= bufEnd ) { |
640
|
0 |
0 |
for ( i = 0 ; i < xattrNumEntries ; i++ ) { |
644
|
0 |
0 |
if ( bufP + keyLen + valueLen <= bufEnd ) { |
666
|
0 |
0 |
if ( fileNameLen > BPC_MAXPATHLEN - 1 ) { |
673
|
0 |
0 |
if ( BPC_LogLevel >= 6 ) bpc_logMsgf("bpc_attrib_buf2fileFull: xattrNumEntries = %d\n", xattrNumEntries); |
698
|
0 |
0 |
if ( (attribFileName = strrchr(attribFilePath, '/')) ) { |
704
|
0 |
0 |
if ( BPC_LogLevel >= 6 ) bpc_logMsgf("bpc_attrib_dirRead(%s); dirPath = %s, attribFilePath = %s, attribFileName = %s\n", |
707
|
0 |
0 |
if ( (p = strchr(attribFileName, '_')) && !stat(attribPath, &st) && S_ISREG(st.st_mode) ) { |
|
0 |
0 |
if ( (p = strchr(attribFileName, '_')) && !stat(attribPath, &st) && S_ISREG(st.st_mode) ) { |
|
0 |
0 |
if ( (p = strchr(attribFileName, '_')) && !stat(attribPath, &st) && S_ISREG(st.st_mode) ) { |
711
|
0 |
0 |
if ( !strcmp(p + 1, "0") ) return 0; |
713
|
0 |
0 |
if ( BPC_LogLevel >= 6 ) { |
724
|
0 |
0 |
} else if ( stat(attribPath, &st) || !S_ISREG(st.st_mode) || strchr(attribFileName, '_') ) { |
|
0 |
0 |
} else if ( stat(attribPath, &st) || !S_ISREG(st.st_mode) || strchr(attribFileName, '_') ) { |
|
0 |
0 |
} else if ( stat(attribPath, &st) || !S_ISREG(st.st_mode) || strchr(attribFileName, '_') ) { |
735
|
0 |
0 |
if ( (p = strrchr(attribDirPath, '/')) ) { |
740
|
0 |
0 |
if ( !(dirOs = opendir(attribDirPath)) ) { |
744
|
0 |
0 |
if ( BPC_LogLevel >= 8 ) bpc_logMsgf("bpc_attrib_dirRead: can't opendir %s (note: this is ok)\n", attribDirPath); |
747
|
0 |
0 |
while ( (dp = readdir(dirOs)) ) { |
748
|
0 |
0 |
if ( strncmp(dp->d_name, attribFileName, attribFileNameLen) ) continue; |
750
|
0 |
0 |
if ( p[0] != '_' ) continue; |
752
|
0 |
0 |
if ( !strcmp(p, "0") ) { |
756
|
0 |
0 |
if ( BPC_LogLevel >= 6 ) { |
763
|
0 |
0 |
if ( BPC_LogLevel >= 6 ) { |
776
|
0 |
0 |
if ( dir->digest.len == 0 ) return 0; |
779
|
0 |
0 |
if ( bpc_fileZIO_open(&fd, attribPath, 0, dir->compress) ) { |
784
|
0 |
0 |
if ( nRead == 0 ) { |
790
|
0 |
0 |
if ( !strcmp(attribFileName, "attrib") ) { |
795
|
0 |
0 |
if ( rename(attribPath, attribPathTemp) ) { |
798
|
0 |
0 |
} else if ( BPC_LogLevel >= 6 ) { |
804
|
0 |
0 |
if ( nRead < 4 ) { |
812
|
0 |
0 |
if ( magic == BPC_ATTRIB_TYPE_DIGEST ) { |
817
|
0 |
0 |
if ( nRead < 20 ) { |
822
|
0 |
0 |
if ( digestLen > sizeof(dir->digest.digest) ) digestLen = sizeof(dir->digest.digest); |
826
|
0 |
0 |
if ( !KeepOldAttribFiles ) { |
831
|
0 |
0 |
if ( attribPathLen + dir->digest.len * 2 + 2 >= sizeof(attribPathNew) ) { |
839
|
0 |
0 |
if ( (fdNum = open(attribPathNew, O_WRONLY | O_CREAT | O_TRUNC, 0660)) < 0 ) { |
845
|
0 |
0 |
if ( BPC_LogLevel >= 4 ) bpc_logMsgf("bpc_attrib_dirRead: replaced %s with %s\n", |
850
|
0 |
0 |
if ( dir->digest.len > 0 ) { |
857
|
0 |
0 |
if ( bpc_fileZIO_open(&fd, attribPath, 0, dir->compress) ) { |
862
|
0 |
0 |
if ( nRead < 4 ) { |
871
|
0 |
0 |
if ( magic == BPC_ATTRIB_TYPE_XATTR ) { |
873
|
0 |
0 |
while ( bufP < buf + nRead ) { |
879
|
0 |
0 |
if ( nRead == sizeof(buf) && bufP > buf + nRead - 2 * BPC_MAXPATHLEN |
|
0 |
0 |
if ( nRead == sizeof(buf) && bufP > buf + nRead - 2 * BPC_MAXPATHLEN |
880
|
0 |
0 |
&& read_more_data(&fd, buf, sizeof(buf), &nRead, &bufP, attribPath) ) { |
886
|
0 |
0 |
if ( fileNameLen > BPC_MAXPATHLEN - 1 ) { |
907
|
0 |
0 |
if ( bufP > buf + nRead ) { |
913
|
0 |
0 |
if ( retry ) { |
919
|
0 |
0 |
if ( BPC_LogLevel >= 7 ) bpc_logMsgf("bpc_attrib_dirRead: retrying file conversion\n"); |
921
|
0 |
0 |
if ( read_more_data(&fd, buf, sizeof(buf), &nRead, &bufP, attribPath) ) { |
929
|
0 |
0 |
if ( !retry && BPC_LogLevel >= 8 ) bpc_logMsgf("bpc_attrib_dirRead(%s): Got file %s: type = %d, mode = 0%o, uid/gid = %d/%d, size = %d\n", |
|
0 |
0 |
if ( !retry && BPC_LogLevel >= 8 ) bpc_logMsgf("bpc_attrib_dirRead(%s): Got file %s: type = %d, mode = 0%o, uid/gid = %d/%d, size = %d\n", |
932
|
0 |
0 |
} else if ( magic == BPC_ATTRIB_TYPE_UNIX ) { |
933
|
0 |
0 |
while ( bufP < buf + nRead ) { |
940
|
0 |
0 |
if ( nRead == sizeof(buf) && bufP > buf + nRead - 2 * BPC_MAXPATHLEN |
|
0 |
0 |
if ( nRead == sizeof(buf) && bufP > buf + nRead - 2 * BPC_MAXPATHLEN |
941
|
0 |
0 |
&& read_more_data(&fd, buf, sizeof(buf), &nRead, &bufP, attribPath) ) { |
947
|
0 |
0 |
if ( fileNameLen > 2 * BPC_MAXPATHLEN - 16 ) { |
975
|
0 |
0 |
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", |
1001
|
0 |
0 |
if ( info->bufP > info->buf ) { |
1002
|
0 |
0 |
if ( BPC_LogLevel >= 7 ) bpc_logMsgf("write_file_flush: writing %lu bytes to pool\n", (unsigned long)(info->bufP - info->buf)); |
1013
|
0 |
0 |
if ( xattr->key.keyLen >= 1 && info->bufP + xattr->key.keyLen <= info->bufEnd ) { |
|
0 |
0 |
if ( xattr->key.keyLen >= 1 && info->bufP + xattr->key.keyLen <= info->bufEnd ) { |
1015
|
0 |
0 |
if ( info->bufP[xattr->key.keyLen - 1] != 0x0 ) { |
1022
|
0 |
0 |
if ( info->bufP + xattr->valueLen <= info->bufEnd ) { |
1044
|
0 |
0 |
if ( bufP + fileNameLen < bufEnd ) { |
1061
|
0 |
0 |
if ( bufP + file->digest.len <= bufEnd ) { |
1070
|
0 |
0 |
if ( info.numEntries != xattrEntryCnt ) { |
1080
|
0 |
0 |
if ( file->isTemp ) { |
1081
|
0 |
0 |
if ( BPC_LogLevel >= 6 ) bpc_logMsgf("Skipping temp file %s: type = %d, mode = 0%o, uid/gid = %lu/%lu, size = %lu, inode = %lu, nlinks = %d, digest = 0x%02x%02x%02x..., bufUsed = %lu\n", |
1090
|
0 |
0 |
if ( BPC_LogLevel >= 6 ) bpc_logMsgf("Wrote file %s: type = %d, mode = 0%o, uid/gid = %lu/%lu, size = %lu, inode = %lu, nlinks = %d, digest = 0x%02x%02x%02x..., bufUsed = %lu\n", |
1097
|
0 |
0 |
if ( bufP <= info->buf + sizeof(info->buf) ) { |
1109
|
0 |
0 |
if ( bufP <= info->buf + sizeof(info->buf) ) { |
1132
|
0 |
0 |
if ( BPC_LogLevel >= 6 ) bpc_logMsgf("bpc_attrib_dirWriteOld(%s)\n", attribPath); |
1134
|
0 |
0 |
if ( (p = strrchr(attribPathTemp, '/')) ) { |
1136
|
0 |
0 |
if ( bpc_path_create(attribPathTemp) ) return -1; |
1140
|
0 |
0 |
if ( bpc_hashtable_entryCount(&dir->filesHT) == 0 ) { |
1145
|
0 |
0 |
if ( (fdNum = open(attribPathTemp, O_WRONLY | O_CREAT | O_TRUNC, 0660)) < 0 ) { |
1150
|
0 |
0 |
if ( rename(attribPathTemp, attribPath) ) { |
1154
|
0 |
0 |
if ( oldDigest ) bpc_poolRefDeltaUpdate(deltaInfo, dir->compress, oldDigest, -1); |
1167
|
0 |
0 |
if ( errorCnt ) return -1; |
1172
|
0 |
0 |
if ( bpc_fileZIO_open(&fd, attribPathTemp, 1, dir->compress) ) { |
1178
|
0 |
0 |
if ( digest.len > 0 ) { |
1182
|
0 |
0 |
if ( bpc_fileZIO_write(&fd, info.buf, info.bufP - info.buf) < 0 ) { |
1188
|
0 |
0 |
if ( rename(attribPathTemp, attribPath) ) { |
1192
|
0 |
0 |
if ( BPC_LogLevel >= 8 ) bpc_logMsgf("bpc_attrib_dirWrite: new attrib digest = 0x%02x%02x%02x..., oldDigest = 0x%02x%02x...\n", |
|
0 |
0 |
if ( BPC_LogLevel >= 8 ) bpc_logMsgf("bpc_attrib_dirWrite: new attrib digest = 0x%02x%02x%02x..., oldDigest = 0x%02x%02x...\n", |
|
0 |
0 |
if ( BPC_LogLevel >= 8 ) bpc_logMsgf("bpc_attrib_dirWrite: new attrib digest = 0x%02x%02x%02x..., oldDigest = 0x%02x%02x...\n", |
1196
|
0 |
0 |
if ( oldDigest ) bpc_poolRefDeltaUpdate(deltaInfo, dir->compress, oldDigest, -1); |
1219
|
0 |
0 |
if ( WriteOldStyleAttribFile ) return bpc_attrib_dirWriteOld(deltaInfo, dir, dirPath, attribFileName, oldDigest); |
1225
|
0 |
0 |
if ( (baseAttribFileName = strrchr(attribFileName, '/')) ) { |
1233
|
0 |
0 |
if ( BPC_LogLevel >= 6 ) bpc_logMsgf("bpc_attrib_dirWrite(%s): dirPath = %s, attribFileName = %s, baseAttribFileName = %s\n", |
1236
|
0 |
0 |
if ( (p = strrchr(attribPathTemp, '/')) ) { |
1238
|
0 |
0 |
if ( bpc_path_create(attribPathTemp) ) return -1; |
1243
|
0 |
0 |
if ( bpc_hashtable_entryCount(&dir->filesHT) > 0 ) { |
1255
|
0 |
0 |
if ( errorCnt ) return -1; |
1264
|
0 |
0 |
if ( attribPathLen + digest.len * 2 + 2 >= sizeof(attribPath) ) { |
1279
|
0 |
0 |
if ( (fdNum = open(attribPathTemp, O_WRONLY | O_CREAT | O_TRUNC, 0660)) < 0 ) { |
1284
|
0 |
0 |
if ( rename(attribPathTemp, attribPath) ) { |
1288
|
0 |
0 |
if ( BPC_LogLevel >= 5 ) bpc_logMsgf("bpc_attrib_dirWrite: created new attrib file %s\n", attribPath); |
1290
|
0 |
0 |
if ( BPC_LogLevel >= 8 ) bpc_logMsgf("bpc_attrib_dirWrite: new attrib digest = 0x%02x%02x%02x..., oldDigest = 0x%02x%02x...\n", |
|
0 |
0 |
if ( BPC_LogLevel >= 8 ) bpc_logMsgf("bpc_attrib_dirWrite: new attrib digest = 0x%02x%02x%02x..., oldDigest = 0x%02x%02x...\n", |
|
0 |
0 |
if ( BPC_LogLevel >= 8 ) bpc_logMsgf("bpc_attrib_dirWrite: new attrib digest = 0x%02x%02x%02x..., oldDigest = 0x%02x%02x...\n", |
1295
|
0 |
0 |
if ( oldDigest ) { |
1296
|
0 |
0 |
if ( !bpc_digest_compare(&digest, oldDigest) ) { |
1297
|
0 |
0 |
if ( BPC_LogLevel >= 2 ) bpc_logMsgf("bpc_attrib_dirWrite: old attrib has same digest; no changes to ref counts\n"); |
1300
|
0 |
0 |
if ( attribPathLen + oldDigest->len * 2 + 2 >= sizeof(attribPath) ) { |
1305
|
0 |
0 |
if ( oldDigest->len > 0 ) { |
1311
|
0 |
0 |
if ( !unlink(attribPathTemp) ) { |
1312
|
0 |
0 |
if ( BPC_LogLevel >= 5 ) bpc_logMsgf("bpc_attrib_dirWrite: removed old attrib file %s\n", attribPathTemp); |
1322
|
0 |
0 |
if ( !(p = strrchr(attribPath, '/')) ) { |
1327
|
0 |
0 |
if ( !(dirOs = opendir(attribPath)) ) { |
1331
|
0 |
0 |
while ( (dp = readdir(dirOs)) ) { |
1332
|
0 |
0 |
if ( strncmp(dp->d_name, baseAttribFileName, baseAttribFileNameLen) || !strcmp(dp->d_name, p) ) continue; |
|
0 |
0 |
if ( strncmp(dp->d_name, baseAttribFileName, baseAttribFileNameLen) || !strcmp(dp->d_name, p) ) continue; |
1335
|
0 |
0 |
if ( BPC_LogLevel >= 5 ) bpc_logMsgf("bpc_attrib_dirWrite: removed other old attrib file %s\n", deletePath); |