From 8a4814081bd504e814699339e5ff62b3a87e0534 Mon Sep 17 00:00:00 2001 From: Con Kolivas Date: Wed, 2 Mar 2011 14:29:56 +1100 Subject: [PATCH] Must read magic before testing free space. Resolve conflict. --- main.c | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/main.c b/main.c index 227c9ac..295509c 100644 --- a/main.c +++ b/main.c @@ -437,23 +437,31 @@ static void decompress_file(void) fd_out = open_tmpoutfile(); control.fd_out = fd_out; - /* Check if there's enough free space on the device chosen to fit the - * decompressed file. */ - if (unlikely(fstatvfs(fd_out, &fbuf))) - fatal("Failed to fstatvfs in decompress_file\n"); - free_space = fbuf.f_bsize * fbuf.f_bavail; - if (free_space < expected_size) { - if (FORCE_REPLACE) - print_err("Warning, inadequate free space detected, but attempting to decompress due to -f option being used.\n"); - else - failure("Inadequate free space to decompress file, use -f to override.\n"); - } - - fd_hist = open(control.outfile, O_RDONLY); + if (control.tmp_outfile) + fd_hist = shm_open(control.tmp_outfile, O_RDONLY, 0777); + else + fd_hist = open(control.outfile, O_RDONLY); if (unlikely(fd_hist == -1)) fatal("Failed to open history file %s\n", control.outfile); + control.fd_hist = fd_hist; read_magic(fd_in, &expected_size); + + /* Check if there's enough free space on the device chosen to fit the + * decompressed file. */ + if (!STDOUT) { + if (unlikely(fstatvfs(fd_out, &fbuf))) + fatal("Failed to fstatvfs in decompress_file\n"); + free_space = fbuf.f_bsize * fbuf.f_bavail; + if (free_space < expected_size) { + if (FORCE_REPLACE) + print_err("Warning, inadequate free space detected, but attempting to decompress due to -f option being used.\n"); + else + failure("Inadequate free space to decompress file, use -f to override." + " Free space %lld, expected size %lld\n", free_space, expected_size); + } + } + if (NO_MD5) print_verbose("Not performing MD5 hash check\n"); if (HAS_MD5)