line |
true |
false |
branch |
56
|
0 |
0 |
for ( i = 0 ; i < BPC_POOL_WRITE_CONCURRENT_MATCH ; i++ ) { |
59
|
0 |
0 |
if ( DataBufferFreeList ) { |
65
|
0 |
0 |
if ( !info->buffer ) { |
69
|
0 |
0 |
if ( digest ) { |
77
|
0 |
0 |
if ( snprintf(info->tmpFileName, sizeof(info->tmpFileName), "%s/%d.%d.%d", |
|
0 |
0 |
if ( snprintf(info->tmpFileName, sizeof(info->tmpFileName), "%s/%d.%d.%d", |
94
|
0 |
0 |
for ( i = 0 ; i < BPC_POOL_WRITE_CONCURRENT_MATCH ; i++ ) { |
95
|
0 |
0 |
if ( info->match[i].used ) { |
99
|
0 |
0 |
while ( info->candidateList ) { |
105
|
0 |
0 |
if ( bpc_fileZIO_open(&info->match[i].fd, candidateFile->fileName, 0, info->compress) ) { |
116
|
0 |
0 |
if ( info->matchPosn > 0 ) { |
117
|
0 |
0 |
if ( info->fdOpen ) { |
126
|
0 |
0 |
while ( idx < info->matchPosn ) { |
130
|
0 |
0 |
if ( thisRead > COMPARE_BUF_SZ ) thisRead = COMPARE_BUF_SZ; |
133
|
0 |
0 |
if ( nread0 != nread1 || memcmp(buf0, buf1, nread0) ) { |
|
0 |
0 |
if ( nread0 != nread1 || memcmp(buf0, buf1, nread0) ) { |
148
|
0 |
0 |
while ( idx < info->matchPosn ) { |
152
|
0 |
0 |
if ( thisRead > COMPARE_BUF_SZ ) thisRead = COMPARE_BUF_SZ; |
153
|
0 |
0 |
if ( thisRead > info->bufferIdx - idx ) thisRead = info->bufferIdx - idx; |
155
|
0 |
0 |
if ( thisRead != nread1 || memcmp(info->buffer + idx, buf1, thisRead) ) { |
|
0 |
0 |
if ( thisRead != nread1 || memcmp(info->buffer + idx, buf1, thisRead) ) { |
163
|
0 |
0 |
if ( !match ) { |
164
|
0 |
0 |
if ( BPC_LogLevel >= 8 ) bpc_logMsgf("Discarding %s since it doesn't match starting portion\n", candidateFile->fileName); |
175
|
0 |
0 |
if ( BPC_LogLevel >= 9 ) bpc_logMsgf("match[%d] now set to %s\n", i, info->match[i].fileName); |
190
|
0 |
0 |
if ( info->errorCnt ) return -1; |
194
|
0 |
0 |
if ( info->state == 0 ) { |
198
|
0 |
0 |
if ( data ) { |
202
|
0 |
0 |
if ( info->bufferIdx + dataLen <= BPC_POOL_WRITE_BUF_SZ ) { |
212
|
0 |
0 |
if ( data && info->bufferIdx < (1 << 20) && BPC_POOL_WRITE_BUF_SZ >= (1 << 20) ) { |
|
0 |
0 |
if ( data && info->bufferIdx < (1 << 20) && BPC_POOL_WRITE_BUF_SZ >= (1 << 20) ) { |
220
|
0 |
0 |
if ( !info->digest.len ) { |
227
|
0 |
0 |
if ( bpc_fileZIO_open(&info->fd, info->tmpFileName, 1, info->compress) ) { |
234
|
0 |
0 |
if ( info->bufferIdx > 0 ) { |
235
|
0 |
0 |
if ( (writeRet = bpc_fileZIO_write(&info->fd, info->buffer, info->bufferIdx)) != (signed)info->bufferIdx ) { |
258
|
0 |
0 |
if ( BPC_PoolV3Enabled ) { |
260
|
0 |
0 |
if ( BPC_LogLevel >= 8 ) { |
266
|
0 |
0 |
} else if ( BPC_LogLevel >= 8 ) { |
274
|
0 |
0 |
if ( info->state == 1 ) { |
280
|
0 |
0 |
if ( dataLen > 0 ) { |
281
|
0 |
0 |
if ( (writeRet = bpc_fileZIO_write(&info->fd, data, dataLen)) != (ssize_t)dataLen ) { |
289
|
0 |
0 |
if ( !data ) { |
295
|
0 |
0 |
if ( bpc_fileZIO_open(&info->fd, info->tmpFileName, 0, info->compress) ) { |
303
|
0 |
0 |
if ( BPC_PoolV3Enabled ) { |
305
|
0 |
0 |
if ( BPC_LogLevel >= 8 ) { |
311
|
0 |
0 |
} else if ( BPC_LogLevel >= 8 ) { |
319
|
0 |
0 |
if ( info->state == 2 ) { |
339
|
0 |
0 |
if ( info->fileSize > 0 && !memcmp(info->digest.digest, zeroLenMD5, sizeof(zeroLenMD5)) ) { |
|
0 |
0 |
if ( info->fileSize > 0 && !memcmp(info->digest.digest, zeroLenMD5, sizeof(zeroLenMD5)) ) { |
357
|
0 |
0 |
if ( stat(poolPath, &st) ) break; |
358
|
0 |
0 |
if ( S_ISREG(st.st_mode) ) { |
359
|
0 |
0 |
if ( st.st_size > 0 ) { |
361
|
0 |
0 |
if ( (st.st_mode & S_IXOTH) && bpc_poolWrite_unmarkPendingDelete(poolPath) ) { |
|
0 |
0 |
if ( (st.st_mode & S_IXOTH) && bpc_poolWrite_unmarkPendingDelete(poolPath) ) { |
367
|
0 |
0 |
if ( !candidateFile ) { |
378
|
0 |
0 |
if ( BPC_LogLevel >= 7 ) bpc_logMsgf("Candidate matching file %s\n", candidateFile->fileName); |
379
|
0 |
0 |
} else if ( info->digestExtZeroLen < 0 ) { |
396
|
0 |
0 |
if ( BPC_PoolV3Enabled && !info->candidateList ) { |
|
0 |
0 |
if ( BPC_PoolV3Enabled && !info->candidateList ) { |
416
|
0 |
0 |
if ( stat(poolPath, &st) ) break; |
417
|
0 |
0 |
if ( S_ISREG(st.st_mode) |
418
|
0 |
0 |
&& 1 < st.st_nlink && st.st_nlink < (unsigned)BPC_HardLinkMax ) { |
|
0 |
0 |
&& 1 < st.st_nlink && st.st_nlink < (unsigned)BPC_HardLinkMax ) { |
420
|
0 |
0 |
if ( !candidateFile ) { |
431
|
0 |
0 |
if ( BPC_LogLevel >= 7 ) bpc_logMsgf("Candidate v3 matching file %s\n", candidateFile->fileName); |
442
|
0 |
0 |
if ( info->state == 3 ) { |
453
|
0 |
0 |
if ( info->fdOpen ) { |
458
|
0 |
0 |
if ( nread0 > info->bufferIdx - info->matchPosn ) nread0 = info->bufferIdx - info->matchPosn; |
461
|
0 |
0 |
for ( i = 0 ; i < BPC_POOL_WRITE_CONCURRENT_MATCH ; i++ ) { |
464
|
0 |
0 |
if ( !info->match[i].used ) continue; |
470
|
0 |
0 |
if ( BPC_LogLevel >= 9 ) bpc_logMsgf("Read %d bytes of %d from match[%d] (%s)\n", (int)nread1, (int)nread0, i, info->match[i].fileName); |
471
|
0 |
0 |
if ( nread0 != nread1 || (nread0 > 0 && memcmp(buf, buf1, nread0)) ) { |
|
0 |
0 |
if ( nread0 != nread1 || (nread0 > 0 && memcmp(buf, buf1, nread0)) ) { |
|
0 |
0 |
if ( nread0 != nread1 || (nread0 > 0 && memcmp(buf, buf1, nread0)) ) { |
473
|
0 |
0 |
if ( BPC_LogLevel >= 8 ) bpc_logMsgf("match[%d] no longer matches\n", i); |
480
|
0 |
0 |
if ( replaceCnt ) { |
483
|
0 |
0 |
if ( nread0 == 0 || nMatch == 0 ) { |
|
0 |
0 |
if ( nread0 == 0 || nMatch == 0 ) { |
492
|
0 |
0 |
if ( info->state == 4 ) { |
498
|
0 |
0 |
for ( i = BPC_POOL_WRITE_CONCURRENT_MATCH -1 ; i >= 0 ; i-- ) { |
499
|
0 |
0 |
if ( !info->match[i].used ) continue; |
503
|
0 |
0 |
if ( nMatch == 0 ) { |
508
|
0 |
0 |
if ( !info->fdOpen && info->fileSize > 0 ) { |
|
0 |
0 |
if ( !info->fdOpen && info->fileSize > 0 ) { |
509
|
0 |
0 |
if ( bpc_fileZIO_open(&info->fd, info->tmpFileName, 1, info->compress) ) { |
514
|
0 |
0 |
if ( info->bufferIdx > 0 ) { |
515
|
0 |
0 |
if ( (writeRet = bpc_fileZIO_write(&info->fd, info->buffer, info->bufferIdx)) != (ssize_t)info->bufferIdx ) { |
524
|
0 |
0 |
if ( info->fileSize > 0 ) { |
528
|
0 |
0 |
if ( BPC_LogLevel >= 5 ) bpc_logMsgf("No match... adding %s to pool (digest = %s)\n", info->tmpFileName, hexStr); |
531
|
0 |
0 |
if ( BPC_LogLevel >= 5 ) bpc_logMsgf("Zero length file - don't match anything\n"); |
540
|
0 |
0 |
if ( nMatch > 1 ) { |
542
|
0 |
0 |
if ( BPC_LogLevel >= 4 ) bpc_logMsgf("Botch - got multiple pool file matches\n"); |
547
|
0 |
0 |
if ( BPC_LogLevel >= 7 ) bpc_logMsgf("Found match with match[%d] (%s)\n", iMatch, info->match[iMatch].fileName); |
548
|
0 |
0 |
if ( info->match[iMatch].v3File ) { |
556
|
0 |
0 |
if ( info->fdOpen ) { |
575
|
0 |
0 |
if ( !(p = strrchr(path, '/')) ) { |
582
|
0 |
0 |
if ( (ret = bpc_path_create(path)) ) { |
593
|
0 |
0 |
if ( info->fdOpen ) bpc_fileZIO_close(&info->fd); |
596
|
0 |
0 |
while ( info->candidateList ) { |
601
|
0 |
0 |
for ( i = 0 ; i < BPC_POOL_WRITE_CONCURRENT_MATCH ; i++ ) { |
602
|
0 |
0 |
if ( !info->match[i].used ) continue; |
606
|
0 |
0 |
if ( info->buffer ) { |
652
|
0 |
0 |
if ( BPC_LogLevel >= 5 ) bpc_logMsgf("bpc_poolWrite_repeatPoolWrite: rewriting %s\n", fileNameTmp); |
653
|
0 |
0 |
if ( info->retryCnt++ > 8 ) { |
660
|
0 |
0 |
if ( bpc_fileZIO_open(&info->fd, fileNameTmp, 0, info->compress) < 0 ) { |
676
|
0 |
0 |
if ( (fdWrite = open(poolPath, O_WRONLY | O_CREAT | O_EXCL, 0666)) < 0 ) { |
681
|
0 |
0 |
if ( (fdRead = open(fileName, O_RDONLY)) < 0 ) { |
687
|
0 |
0 |
while ( (nRead = read(fdRead, info->buffer, sizeof(info->buffer))) > 0 ) { |
692
|
0 |
0 |
while ( nWrite < nRead ) { |
695
|
0 |
0 |
} while ( thisWrite < 0 && errno == EINTR ); |
|
0 |
0 |
} while ( thisWrite < 0 && errno == EINTR ); |
696
|
0 |
0 |
if ( thisWrite < 0 ) { |
719
|
0 |
0 |
if ( bpc_poolWrite_createPoolDir(info, &info->digest) ) return; |
727
|
0 |
0 |
if ( info->digestExtZeroLen >= 0 ) { |
730
|
0 |
0 |
if ( stat(poolPath, &st) || st.st_size != 0 ) { |
|
0 |
0 |
if ( stat(poolPath, &st) || st.st_size != 0 ) { |
734
|
0 |
0 |
if ( !redo ) { |
737
|
0 |
0 |
if ( !stat(poolPath, &st) ) { |
745
|
0 |
0 |
if ( !redo && info->digestExtZeroLen >= 0 ) { |
|
0 |
0 |
if ( !redo && info->digestExtZeroLen >= 0 ) { |
761
|
0 |
0 |
if ( BPC_LogLevel >= 6 ) bpc_logMsgf("bpc_poolWrite_addToPool: replacing empty pool file %s with %s\n", poolPath, fileName); |
768
|
0 |
0 |
if ( lockFd < 0 || stat(poolPath, &st) || st.st_size != 0 || rename(fileName, poolPath) ) { |
|
0 |
0 |
if ( lockFd < 0 || stat(poolPath, &st) || st.st_size != 0 || rename(fileName, poolPath) ) { |
|
0 |
0 |
if ( lockFd < 0 || stat(poolPath, &st) || st.st_size != 0 || rename(fileName, poolPath) ) { |
|
0 |
0 |
if ( lockFd < 0 || stat(poolPath, &st) || st.st_size != 0 || rename(fileName, poolPath) ) { |
769
|
0 |
0 |
if ( BPC_LogLevel >= 5 ) { |
773
|
0 |
0 |
if ( lockFd >= 0 ) { |
781
|
0 |
0 |
info->retValue = v3PoolFile ? 2 : 0; |
792
|
0 |
0 |
if ( !redo ) { |
803
|
0 |
0 |
if ( stat(fileName, &st) ) { |
810
|
0 |
0 |
if ( !(statOk = !stat(poolPath, &st)) ) linkOk = 0; |
812
|
0 |
0 |
if ( BPC_LogLevel >= 6 ) bpc_logMsgf("bpc_poolWrite_addToPool: link %s -> %s (linkOk = %d, statOk = %d, ino = %lu/%lu)\n", |
819
|
0 |
0 |
if ( statOk && fileIno == poolIno ) { |
|
0 |
0 |
if ( statOk && fileIno == poolIno ) { |
825
|
0 |
0 |
info->retValue = v3PoolFile ? 2 : 0; |
834
|
0 |
0 |
if ( !statOk ) { |
871
|
0 |
0 |
if ( !(p = strrchr(lockFile, '/')) ) return -1; |
873
|
0 |
0 |
if ( !(p = strrchr(lockFile, '/')) ) return -1; |
875
|
0 |
0 |
if ( (lockFd = bpc_lockRangeFile(lockFile, 0, 1, 1)) < 0 ) return -1; |
876
|
0 |
0 |
if ( !stat(poolPath, &st) && !chmod(poolPath, st.st_mode & ~S_IXOTH & ~S_IFMT) ) { |
|
0 |
0 |
if ( !stat(poolPath, &st) && !chmod(poolPath, st.st_mode & ~S_IXOTH & ~S_IFMT) ) { |
877
|
0 |
0 |
if ( BPC_LogLevel >= 7 ) bpc_logMsgf("bpc_poolWrite_unmarkPendingDelete(%s) succeeded\n", poolPath); |