X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fbuffer.c;h=8edc257fe63ba27510eae8a4153ee2b02c48bf0b;hb=f14558de94eb5486f88ac3719b5e34f9640cb1de;hp=c544ee00d85b5b9a862035dadbce8636f57f52c5;hpb=1d79c6734cfbd302e53358760b4c3fe3e7b9be61;p=chaz%2Ftar diff --git a/src/buffer.c b/src/buffer.c index c544ee0..8edc257 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1,7 +1,7 @@ /* Buffer management for tar. Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, - 2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. + 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc. Written by John Gilmore, on 1985-08-25. @@ -204,7 +204,8 @@ enum compress_type { ct_gzip, ct_bzip2, ct_lzma, - ct_lzop + ct_lzop, + ct_xz }; struct zip_magic @@ -222,8 +223,9 @@ static struct zip_magic const magic[] = { { ct_compress, 2, "\037\235", "compress", "-Z" }, { ct_gzip, 2, "\037\213", "gzip", "-z" }, { ct_bzip2, 3, "BZh", "bzip2", "-j" }, - { ct_lzma, 6, "\xFFLZMA", "lzma", "-J" }, /* FIXME: ???? */ + { ct_lzma, 6, "\xFFLZMA", "lzma", "--lzma" }, /* FIXME: ???? */ { ct_lzop, 4, "\211LZO", "lzop", "--lzop" }, + { ct_xz, 6, "\0xFD7zXZ", "-J" }, }; #define NMAGIC (sizeof(magic)/sizeof(magic[0])) @@ -686,6 +688,18 @@ short_read (size_t status) more = record_start->buffer + status; left = record_size - status; + if (left && left % BLOCKSIZE == 0 + && verbose_option + && record_start_block == 0 && status != 0) + { + unsigned long rsize = status / BLOCKSIZE; + WARN ((0, 0, + ngettext ("Record size = %lu block", + "Record size = %lu blocks", + rsize), + rsize)); + } + while (left % BLOCKSIZE != 0 || (left && status && read_full_records)) { @@ -707,26 +721,10 @@ short_read (size_t status) rest)); } - /* User warned us about this. Fix up. */ - left -= status; more += status; } - /* FIXME: for size=0, multi-volume support. On the first record, warn - about the problem. */ - - if (!read_full_records && verbose_option > 1 - && record_start_block == 0 && status != 0) - { - unsigned long rsize = (record_size - left) / BLOCKSIZE; - WARN ((0, 0, - ngettext ("Record size = %lu block", - "Record size = %lu blocks", - rsize), - rsize)); - } - record_end = record_start + (record_size - left) / BLOCKSIZE; records_read++; } @@ -852,8 +850,6 @@ close_archive (void) flush_archive (); } - sys_drain_input_pipe (); - compute_duration (); if (verify_option) verify_volume (); @@ -861,7 +857,7 @@ close_archive (void) if (rmtclose (archive) != 0) close_error (*archive_name_cursor); - sys_wait_for_child (child_pid); + sys_wait_for_child (child_pid, hit_eof); tar_stat_destroy (¤t_stat_info); if (save_name) @@ -1324,7 +1320,7 @@ _write_volume_label (const char *str) memset (label, 0, BLOCKSIZE); - strcpy (label->header.name, volume_label_option); + strcpy (label->header.name, str); assign_string (¤t_stat_info.file_name, label->header.name); current_stat_info.had_trailing_slash = @@ -1571,6 +1567,9 @@ _gnu_flush_read (void) { while (!try_new_volume ()) ; + if (current_block == record_end) + /* Necessary for blocking_factor == 1 */ + flush_archive(); return; } else if (status == SAFE_READ_ERROR)