Branch Coverage

bpc_attrib.c
Criterion Covered Total %
branch 0 412 0.0


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 ) {
135 0 0 if ( BPC_LogLevel >= 6 ) {
142 0 0 if ( !xattr->value ) {
146 0 0 if ( !(xattr->key.key = malloc(keyLen)) ) {
156 0 0 if ( valueLen > xattr->valueLen ) {
159 0 0 } else if ( valueLen == xattr->valueLen && !memcmp(xattr->value, value, valueLen) ) {
0 0 } else if ( valueLen == xattr->valueLen && !memcmp(xattr->value, value, valueLen) ) {
166 0 0 if ( !xattr->value && !(xattr->value = malloc(valueLen)) ) {
0 0 if ( !xattr->value && !(xattr->value = malloc(valueLen)) ) {
178 0 0 uchar *key = (uchar*)malloc(xattrSrc->key.keyLen > 0 ? xattrSrc->key.keyLen : 1);
179 0 0 uchar *value = (uchar*)malloc(xattrSrc->valueLen > 0 ? xattrSrc->valueLen : 1);
181 0 0 if ( !key || !value ) {
0 0 if ( !key || !value ) {
191 0 0 if ( xattr->value ) {
217 0 0 if ( info->idx < 0 ) return;
219 0 0 if ( info->ignoreRsyncACLs ) {
229 0 0 for ( i = 0 ; i < sizeof(ignoreKeys) / sizeof(ignoreKeys[0]) ; i++ ) {
230 0 0 if ( xattr->key.keyLen == ignoreKeys[i].len
231 0 0 && !memcmp(xattr->key.key, ignoreKeys[i].str, xattr->key.keyLen) ) {
236 0 0 if ( info->list ) {
237 0 0 if ( info->idx + (signed)xattr->key.keyLen > info->listLen ) {
245 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 ) {
249 0 0 if ( BPC_LogLevel >= 6 ) bpc_logMsgf("bpc_attrib_xattrListKey: adding %s\n", info->list + info->idx);
277 0 0 if ( file->name) free(file->name);
300 0 0 if ( file->name ) bpc_attrib_fileDestroy(file);
302 0 0 if ( !file->name ) {
321 0 0 if ( fileDest == fileSrc ) return;
334 0 0 if ( fileSrc->digest.len > 0 || overwriteEmptyDigest ) {
0 0 if ( fileSrc->digest.len > 0 || overwriteEmptyDigest ) {
349 0 0 if ( fileDest == fileSrc ) return;
361 0 0 if ( file0->type != file1->type
362 0 0 || file0->compress != file1->compress
363 0 0 || file0->mode != file1->mode
364 0 0 || file0->uid != file1->uid
365 0 0 || file0->gid != file1->gid
366 0 0 || file0->nlinks != file1->nlinks
367 0 0 || file0->mtime != file1->mtime
368 0 0 || file0->size != file1->size
369 0 0 || file0->inode != file1->inode
370 0 0 || file0->digest.len != file1->digest.len
371 0 0 || memcmp(file0->digest.digest, file1->digest.digest, file0->digest.len)
372 0 0 || bpc_attrib_xattrCount(file0) != bpc_attrib_xattrCount(file1) ) {
373 0 0 if ( BPC_LogLevel >= 9 ) bpc_logMsgf("bpc_attrib_fileCompare: %s %s differ\n", file0->name, file1->name);
378 0 0 if ( !xattr0 ) return 0;
379 0 0 if ( !(xattr1 = bpc_attrib_xattrGet(file1, xattr0->key.key, xattr0->key.keyLen, 0)) ) return 1;
380 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;
388 0 0 if ( !file ) return;
396 0 0 if ( !*file ) return -1;
407 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 "?";
438 0 0 if ( file->digest.len > 0 ) {
441 0 0 if ( BPC_LogLevel >= 7 ) bpc_logMsgf("bpc_attrib_fileRefCount: file %s digest %s delta %d\n", file->name, hexStr, info->incr);
444 0 0 if ( info->inodeMax && file->inode > *info->inodeMax ) {
0 0 if ( info->inodeMax && file->inode > *info->inodeMax ) {
461 0 0 if ( dir->digest.len > 0 ) {
464 0 0 if ( BPC_LogLevel >= 7 ) bpc_logMsgf("bpc_attrib_dirRefCount: attrib digest %s delta = %d\n", hexStr, incr);
467 0 0 if ( BPC_LogLevel >= 7 ) bpc_logMsgf("bpc_attrib_dirRefCount: no attrib digest -> no delta\n");
490 0 0 if ( info->entryIdx < 0 ) return;
491 0 0 if ( info->entries ) {
492 0 0 if ( info->entryIdx + len > info->entrySize ) {
515 0 0 if ( !dir ) {
518 0 0 snprintf(path, BPC_MAXPATHLEN, "%s/%s", dir, attribFileName ? attribFileName : "attrib");
537 0 0 if ( thisRead < 0 ) {
554 0 0 while ( bufP < bufEnd ) {
557 0 0 if ( !(c & 0x80) ) {
580 0 0 while ( bufP < bufEnd ) {
583 0 0 if ( !(c & 0x80) ) {
609 0 0 if ( value && maxBytes > 0 ) c |= 0x80;
0 0 if ( value && maxBytes > 0 ) c |= 0x80;
610 0 0 if ( bufP < bufEnd ) {
615 0 0 } while ( value && maxBytes > 0 );
0 0 } while ( value && maxBytes > 0 );
643 0 0 if ( file->digest.len > 0 && bufP + file->digest.len <= bufEnd ) {
0 0 if ( file->digest.len > 0 && bufP + file->digest.len <= bufEnd ) {
648 0 0 for ( i = 0 ; i < xattrNumEntries ; i++ ) {
652 0 0 if ( bufP + keyLen + valueLen <= bufEnd ) {
653 0 0 if ( xattrFixup && bufP[keyLen - 1] != 0x0 ) {
0 0 if ( xattrFixup && bufP[keyLen - 1] != 0x0 ) {
677 0 0 if ( fileNameLen > BPC_MAXPATHLEN - 1 ) {
684 0 0 if ( BPC_LogLevel >= 6 ) bpc_logMsgf("bpc_attrib_buf2fileFull: xattrNumEntries = %d\n", xattrNumEntries);
709 0 0 if ( (attribFileName = strrchr(attribFilePath, '/')) ) {
715 0 0 if ( BPC_LogLevel >= 6 ) bpc_logMsgf("bpc_attrib_dirRead(%s); dirPath = %s, attribFilePath = %s, attribFileName = %s\n",
718 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) ) {
722 0 0 if ( !strcmp(p + 1, "0") ) return 0;
724 0 0 if ( BPC_LogLevel >= 6 ) {
735 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, '_') ) {
746 0 0 if ( (p = strrchr(attribDirPath, '/')) ) {
751 0 0 if ( !(dirOs = opendir(attribDirPath)) ) {
755 0 0 if ( BPC_LogLevel >= 8 ) bpc_logMsgf("bpc_attrib_dirRead: can't opendir %s (note: this is ok)\n", attribDirPath);
758 0 0 while ( (dp = readdir(dirOs)) ) {
759 0 0 if ( strncmp(dp->d_name, attribFileName, attribFileNameLen) ) continue;
761 0 0 if ( p[0] != '_' ) continue;
763 0 0 if ( !strcmp(p, "0") ) {
767 0 0 if ( BPC_LogLevel >= 6 ) {
774 0 0 if ( BPC_LogLevel >= 6 ) {
787 0 0 if ( dir->digest.len == 0 ) return 0;
790 0 0 if ( bpc_fileZIO_open(&fd, attribPath, 0, dir->compress) ) {
795 0 0 if ( nRead == 0 ) {
801 0 0 if ( !strcmp(attribFileName, "attrib") ) {
806 0 0 if ( rename(attribPath, attribPathTemp) ) {
809 0 0 } else if ( BPC_LogLevel >= 6 ) {
815 0 0 if ( nRead < 4 ) {
823 0 0 if ( magic == BPC_ATTRIB_TYPE_DIGEST ) {
828 0 0 if ( nRead < 20 ) {
833 0 0 if ( digestLen > sizeof(dir->digest.digest) ) digestLen = sizeof(dir->digest.digest);
837 0 0 if ( !KeepOldAttribFiles ) {
842 0 0 if ( attribPathLen + dir->digest.len * 2 + 2 >= sizeof(attribPathNew) ) {
850 0 0 if ( (fdNum = open(attribPathNew, O_WRONLY | O_CREAT | O_TRUNC, 0660)) < 0 ) {
856 0 0 if ( BPC_LogLevel >= 4 ) bpc_logMsgf("bpc_attrib_dirRead: replaced %s with %s\n",
861 0 0 if ( dir->digest.len > 0 ) {
868 0 0 if ( bpc_fileZIO_open(&fd, attribPath, 0, dir->compress) ) {
873 0 0 if ( nRead < 4 ) {
882 0 0 if ( magic == BPC_ATTRIB_TYPE_XATTR ) {
884 0 0 while ( bufP < buf + nRead ) {
891 0 0 if ( nRead == sizeof(buf) && bufP > buf + nRead - 2 * BPC_MAXPATHLEN
0 0 if ( nRead == sizeof(buf) && bufP > buf + nRead - 2 * BPC_MAXPATHLEN
892 0 0 && read_more_data(&fd, buf, sizeof(buf), &nRead, &bufP, attribPath) ) {
898 0 0 if ( fileNameLen > BPC_MAXPATHLEN - 1 ) {
920 0 0 if ( bufP > buf + nRead ) {
926 0 0 if ( retry ) {
932 0 0 if ( BPC_LogLevel >= 7 ) bpc_logMsgf("bpc_attrib_dirRead: retrying file conversion\n");
934 0 0 if ( read_more_data(&fd, buf, sizeof(buf), &nRead, &bufP, attribPath) ) {
942 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",
945 0 0 } else if ( magic == BPC_ATTRIB_TYPE_UNIX ) {
946 0 0 while ( bufP < buf + nRead ) {
953 0 0 if ( nRead == sizeof(buf) && bufP > buf + nRead - 2 * BPC_MAXPATHLEN
0 0 if ( nRead == sizeof(buf) && bufP > buf + nRead - 2 * BPC_MAXPATHLEN
954 0 0 && read_more_data(&fd, buf, sizeof(buf), &nRead, &bufP, attribPath) ) {
960 0 0 if ( fileNameLen > 2 * BPC_MAXPATHLEN - 16 ) {
988 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",
1014 0 0 if ( info->bufP > info->buf ) {
1015 0 0 if ( BPC_LogLevel >= 7 ) bpc_logMsgf("write_file_flush: writing %lu bytes to pool\n", (unsigned long)(info->bufP - info->buf));
1026 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 ) {
1028 0 0 if ( info->bufP[xattr->key.keyLen - 1] != 0x0 ) {
1035 0 0 if ( info->bufP + xattr->valueLen <= info->bufEnd ) {
1057 0 0 if ( bufP + fileNameLen < bufEnd ) {
1074 0 0 if ( bufP + file->digest.len <= bufEnd ) {
1083 0 0 if ( info.numEntries != xattrEntryCnt ) {
1093 0 0 if ( file->isTemp ) {
1094 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",
1103 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",
1110 0 0 if ( bufP <= info->buf + sizeof(info->buf) ) {
1122 0 0 if ( bufP <= info->buf + sizeof(info->buf) ) {
1145 0 0 if ( BPC_LogLevel >= 6 ) bpc_logMsgf("bpc_attrib_dirWriteOld(%s)\n", attribPath);
1147 0 0 if ( (p = strrchr(attribPathTemp, '/')) ) {
1149 0 0 if ( bpc_path_create(attribPathTemp) ) return -1;
1153 0 0 if ( bpc_hashtable_entryCount(&dir->filesHT) == 0 ) {
1158 0 0 if ( (fdNum = open(attribPathTemp, O_WRONLY | O_CREAT | O_TRUNC, 0660)) < 0 ) {
1163 0 0 if ( rename(attribPathTemp, attribPath) ) {
1167 0 0 if ( oldDigest ) bpc_poolRefDeltaUpdate(deltaInfo, dir->compress, oldDigest, -1);
1180 0 0 if ( errorCnt ) return -1;
1185 0 0 if ( bpc_fileZIO_open(&fd, attribPathTemp, 1, dir->compress) ) {
1191 0 0 if ( digest.len > 0 ) {
1195 0 0 if ( bpc_fileZIO_write(&fd, info.buf, info.bufP - info.buf) < 0 ) {
1201 0 0 if ( rename(attribPathTemp, attribPath) ) {
1205 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",
1209 0 0 if ( oldDigest ) bpc_poolRefDeltaUpdate(deltaInfo, dir->compress, oldDigest, -1);
1233 0 0 if ( WriteOldStyleAttribFile ) return bpc_attrib_dirWriteOld(deltaInfo, dir, dirPath, attribFileName, oldDigest);
1239 0 0 if ( (baseAttribFileName = strrchr(attribFileName, '/')) ) {
1247 0 0 if ( BPC_LogLevel >= 6 ) bpc_logMsgf("bpc_attrib_dirWrite(%s): dirPath = %s, attribFileName = %s, baseAttribFileName = %s\n",
1250 0 0 if ( (p = strrchr(attribPathTemp, '/')) ) {
1252 0 0 if ( bpc_path_create(attribPathTemp) ) return -1;
1257 0 0 if ( bpc_hashtable_entryCount(&dir->filesHT) > 0 ) {
1269 0 0 if ( errorCnt ) return -1;
1278 0 0 if ( attribPathLen + digest.len * 2 + 2 >= sizeof(attribPath) ) {
1287 0 0 if ( (fdNum = open(attribPathTemp, O_WRONLY | O_CREAT | O_TRUNC, 0660)) < 0 ) {
1292 0 0 if ( rename(attribPathTemp, attribPath) ) {
1296 0 0 if ( BPC_LogLevel >= 5 ) bpc_logMsgf("bpc_attrib_dirWrite: created new attrib file %s\n", attribPath);
1301 0 0 if ( BPC_LogLevel >= 5 ) bpc_logMsgf("bpc_attrib_dirWrite: skipping creating new empty attrib file %s\n", attribPath);
1305 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",
1309 0 0 digestChanged = !oldDigest || bpc_digest_compare(&digest, oldDigest);
0 0 digestChanged = !oldDigest || bpc_digest_compare(&digest, oldDigest);
1310 0 0 if ( digestChanged && digest.len > 0 ) {
0 0 if ( digestChanged && digest.len > 0 ) {
1314 0 0 if ( oldDigest ) {
1315 0 0 if ( !digestChanged ) {
1316 0 0 if ( BPC_LogLevel >= 4 ) bpc_logMsgf("bpc_attrib_dirWrite: old attrib has same digest; no changes to ref counts\n");
1319 0 0 if ( attribPathLen + oldDigest->len * 2 + 2 >= sizeof(attribPath) ) {
1324 0 0 if ( oldDigest->len > 0 ) {
1330 0 0 if ( !unlink(attribPathTemp) ) {
1331 0 0 if ( BPC_LogLevel >= 5 ) bpc_logMsgf("bpc_attrib_dirWrite: removed old attrib file %s\n", attribPathTemp);
1341 0 0 if ( !(p = strrchr(attribPath, '/')) ) {
1346 0 0 if ( !(dirOs = opendir(attribPath)) ) {
1350 0 0 while ( (dp = readdir(dirOs)) ) {
1351 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;
1354 0 0 if ( BPC_LogLevel >= 5 ) bpc_logMsgf("bpc_attrib_dirWrite: removed other old attrib file %s\n", deletePath);