Fix handling of compression flags in adaptive mode

Fix error handling when chunk size is too small for dedupe
Bump version to 0.6
This commit is contained in:
Moinak Ghosh 2012-08-10 10:47:11 +05:30
parent 6b6e564886
commit bde917c8e9
4 changed files with 26 additions and 13 deletions

View file

@ -197,17 +197,17 @@ adapt_decompress(void *src, size_t srclen, void *dst,
size_t *dstlen, int level, uchar_t chdr, void *data)
{
struct adapt_data *adat = (struct adapt_data *)(data);
uchar_t HDR;
uchar_t cmp_flags;
HDR = chdr;
cmp_flags = (chdr>>4) & CHDR_ALGO_MASK;
if (HDR & (COMPRESS_LZMA << 4)) {
if (cmp_flags == COMPRESS_LZMA) {
return (lzma_decompress(src, srclen, dst, dstlen, level, chdr, adat->lzma_data));
} else if (HDR & (COMPRESS_BZIP2 << 4)) {
} else if (cmp_flags == COMPRESS_BZIP2) {
return (bzip2_decompress(src, srclen, dst, dstlen, level, chdr, NULL));
} else if (HDR & (COMPRESS_PPMD << 4)) {
} else if (cmp_flags == COMPRESS_PPMD) {
return (ppmd_decompress(src, srclen, dst, dstlen, level, chdr, adat->ppmd_data));
} else {

16
main.c
View file

@ -467,11 +467,15 @@ start_decompress(const char *filename, const char *to_filename)
UNCOMP_BAIL;
}
}
if (enable_rabin_scan)
if (enable_rabin_scan) {
tdat->rctx = create_rabin_context(chunksize, compressed_chunksize,
algo, enable_delta_encode);
else
if (tdat->rctx == NULL) {
UNCOMP_BAIL;
}
} else {
tdat->rctx = NULL;
}
if (pthread_create(&(tdat->thr), NULL, perform_decompress,
(void *)tdat) != 0) {
perror("Error in thread creation: ");
@ -981,11 +985,15 @@ start_compress(const char *filename, uint64_t chunksize, int level)
COMP_BAIL;
}
}
if (enable_rabin_scan)
if (enable_rabin_scan) {
tdat->rctx = create_rabin_context(chunksize, compressed_chunksize,
algo, enable_delta_encode);
else
if (tdat->rctx == NULL) {
COMP_BAIL;
}
} else {
tdat->rctx = NULL;
}
if (pthread_create(&(tdat->thr), NULL, perform_compress,
(void *)tdat) != 0) {

View file

@ -39,18 +39,23 @@ extern "C" {
#define MIN_CHUNK 2048
#define VERSION 2
#define FLAG_DEDUP 1
#define UTILITY_VERSION 0.5
#define UTILITY_VERSION 0.6
#define COMPRESSED 1
#define UNCOMPRESSED 0
#define CHSIZE_MASK 0x80
#define BZIP2_A_NUM 16
#define LZMA_A_NUM 32
#define CHUNK_FLAG_DEDUP 2
#define COMP_EXTN ".pz"
/*
* lower 3 bits in higher nibble indicate compression algorithm.
*/
#define COMPRESS_LZMA 1
#define COMPRESS_BZIP2 2
#define COMPRESS_PPMD 3
#define CHUNK_FLAG_DEDUP 2
#define COMP_EXTN ".pz"
#define CHDR_ALGO_MASK 7
extern uint64_t lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc);
extern uint64_t lzma_crc64_8bchk(const uint8_t *buf, size_t size,

View file

@ -105,7 +105,7 @@ create_rabin_context(uint64_t chunksize, uint64_t real_chunksize, const char *al
}
if (chunksize < RAB_MIN_CHUNK_SIZE) {
fprintf(stderr, "Minimum chunk size for Dedup must be %l bytes\n",
fprintf(stderr, "Minimum chunk size for Dedup must be %llu bytes\n",
RAB_MIN_CHUNK_SIZE);
return (NULL);
}