From 427df4cd4affd87eb3059543d6891e46fbba41b1 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Sun, 12 Dec 2010 17:40:58 +1100 Subject: [PATCH] Fix stdin failing due to getting sizes all wrong. Fix stdin compression values not being shown at end. Fix inappropriate failure when lzma doesn't compress block. --- rzip.c | 6 +++++- stream.c | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/rzip.c b/rzip.c index ceb0939..bc4129e 100644 --- a/rzip.c +++ b/rzip.c @@ -663,7 +663,7 @@ static void mmap_stdin(uchar *buf, struct rzip_state *st) buf = mremap(buf, st->chunk_size, total, 0); if (unlikely(buf == MAP_FAILED)) fatal("Failed to remap to smaller buf in mmap_stdin\n"); - st->chunk_size = total; + st->mmap_size = st->chunk_size = total; st->stdin_eof = 1; break; } @@ -782,6 +782,7 @@ void rzip_fd(int fd_in, int fd_out) if (control.window) control.max_chunk = MIN(control.max_chunk, control.window * CHUNK_MULTIPLE); round_to_page(&control.max_chunk); + control.max_mmap = MIN(control.max_mmap, control.max_chunk); if (!STDIN) st->chunk_size = MIN(control.max_chunk, len); @@ -829,6 +830,7 @@ retry: fatal("Unable to mmap any ram\n"); goto retry; } + st->chunk_size = st->mmap_size; mmap_stdin(sb.buf_low, st); } else { /* NOTE The buf is saved here for !STDIN mode */ @@ -906,6 +908,8 @@ retry: close_streamout_threads(); gettimeofday(¤t, NULL); + if (STDIN) + s.st_size = control.st_size; chunkmbs = (s.st_size / 1024 / 1024) / ((double)(current.tv_sec-start.tv_sec)? : 1); fstat(fd_out, &s2); diff --git a/stream.c b/stream.c index 4ed7e72..f8a9c86 100644 --- a/stream.c +++ b/stream.c @@ -336,7 +336,8 @@ retry: * remain uncompressed */ print_verbose("Unable to allocate enough RAM for any sized compression window, falling back to bzip2 compression.\n"); return bzip2_compress_buf(cthread); - } + } else if (lzma_ret == SZ_ERROR_OUTPUT_EOF) + return 0; return -1; }