Merging upstream version 0.26.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
7185f44b62
commit
180f99b04d
44 changed files with 610 additions and 505 deletions
3
COPYING
3
COPYING
|
@ -1,8 +1,7 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
|
24
ChangeLog
24
ChangeLog
|
@ -1,7 +1,20 @@
|
|||
2024-12-07 Antonio Diaz Diaz <antonio@gnu.org>
|
||||
|
||||
* Version 0.26 released.
|
||||
* decode.cc (decode), delete.cc (delete_members):
|
||||
Return 2 if any empty lzip member is found in a multimember archive.
|
||||
* create_lz.cc, decode_lz.cc:
|
||||
Change 'deliver_packet' to 'deliver_packets'.
|
||||
* create.cc (copy_file): Show file name if read error.
|
||||
* tarlz.texi: New chapter 'Syntax of command-line arguments'.
|
||||
* check.sh: Use 'cp' instead of 'cat'.
|
||||
Skip time stamps out of range or not recognized by system tools.
|
||||
(Reported by J Dean).
|
||||
|
||||
2024-01-03 Antonio Diaz Diaz <antonio@gnu.org>
|
||||
|
||||
* Version 0.25 released.
|
||||
* New option '--ignore-metadata.
|
||||
* New option '--ignore-metadata'.
|
||||
* create.cc, decode.cc, decode_lz.cc:
|
||||
'#include <sys/types.h>' for major, minor, makedev on BSD systems.
|
||||
* compress.cc: Reformat file diagnostics as 'PROGRAM: FILE: MESSAGE'.
|
||||
|
@ -74,7 +87,7 @@
|
|||
2020-11-21 Antonio Diaz Diaz <antonio@gnu.org>
|
||||
|
||||
* Version 0.18 released.
|
||||
* main.cc: New option '--check-lib'.
|
||||
* New option '--check-lib'.
|
||||
* Implement multi-threaded '-x, --extract'.
|
||||
* Don't #include <sys/sysmacros.h> when compiling on OS2.
|
||||
* delete.cc, delete_lz.cc: Use Archive_reader.
|
||||
|
@ -201,7 +214,7 @@
|
|||
|
||||
* Version 0.4 released.
|
||||
* Add some missing #includes.
|
||||
* main.cc: Open files in binary mode on OS2.
|
||||
* main.cc (main): Open files in binary mode on OS2.
|
||||
|
||||
2018-03-19 Antonio Diaz Diaz <antonio@gnu.org>
|
||||
|
||||
|
@ -231,6 +244,5 @@
|
|||
|
||||
Copyright (C) 2013-2024 Antonio Diaz Diaz.
|
||||
|
||||
This file is a collection of facts, and thus it is not copyrightable,
|
||||
but just in case, you have unlimited permission to copy, distribute, and
|
||||
modify it.
|
||||
This file is a collection of facts, and thus it is not copyrightable, but just
|
||||
in case, you have unlimited permission to copy, distribute, and modify it.
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
DISTNAME = $(pkgname)-$(pkgversion)
|
||||
INSTALL = install
|
||||
INSTALL_PROGRAM = $(INSTALL) -m 755
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
INSTALL_DIR = $(INSTALL) -d -m 755
|
||||
INSTALL_DATA = $(INSTALL) -m 644
|
||||
SHELL = /bin/sh
|
||||
CAN_RUN_INSTALLINFO = $(SHELL) -c "install-info --version" > /dev/null 2>&1
|
||||
|
||||
|
@ -31,7 +31,8 @@ main.o : main.cc
|
|||
|
||||
# prevent 'make' from trying to remake source files
|
||||
$(VPATH)/configure $(VPATH)/Makefile.in $(VPATH)/doc/$(pkgname).texi : ;
|
||||
%.h %.cc : ;
|
||||
MAKEFLAGS += -r
|
||||
.SUFFIXES :
|
||||
|
||||
$(objs) : Makefile
|
||||
arg_parser.o : arg_parser.h
|
||||
|
@ -149,12 +150,12 @@ dist : doc
|
|||
$(DISTNAME)/testsuite/t155.tar \
|
||||
$(DISTNAME)/testsuite/t155_fv[1-3].tar \
|
||||
$(DISTNAME)/testsuite/eoa_blocks.tar \
|
||||
$(DISTNAME)/testsuite/em.lz \
|
||||
$(DISTNAME)/testsuite/test.txt.lz \
|
||||
$(DISTNAME)/testsuite/test.txt.tar.lz \
|
||||
$(DISTNAME)/testsuite/test_bad[12].txt.tar.lz \
|
||||
$(DISTNAME)/testsuite/test3.tar.lz \
|
||||
$(DISTNAME)/testsuite/test3_eoa[1-5].tar.lz \
|
||||
$(DISTNAME)/testsuite/test3_em[1-6].tar.lz \
|
||||
$(DISTNAME)/testsuite/test3_gh[1-6].tar.lz \
|
||||
$(DISTNAME)/testsuite/test3_nn.tar.lz \
|
||||
$(DISTNAME)/testsuite/test3_sm[1-4].tar.lz \
|
||||
|
|
17
NEWS
17
NEWS
|
@ -1,14 +1,13 @@
|
|||
Changes in version 0.25:
|
||||
Changes in version 0.26:
|
||||
|
||||
The new option '--ignore-metadata', which makes '-d, --diff' ignore
|
||||
differences in file permissions, owner and group IDs, and modification time,
|
||||
has been added.
|
||||
tarlz now exits with error status 2 if any empty lzip member is found in a
|
||||
multimember compressed archive.
|
||||
|
||||
'#include <sys/types.h>' for major, minor, makedev on BSD systems.
|
||||
Scalability of parallel compressed creation and decoding has been increased.
|
||||
|
||||
File diagnostics of '-z' have been reformatted as 'PROGRAM: FILE: MESSAGE'.
|
||||
A diagnostic message for read error has been improved.
|
||||
|
||||
The option '-o, --output' now creates missing intermediate directories when
|
||||
compressing to a file.
|
||||
The chapter 'Syntax of command-line arguments' has been added to the manual.
|
||||
|
||||
The variable MAKEINFO has been added to configure and Makefile.in.
|
||||
'make check' now skips time stamps out of range or not recognized by system
|
||||
tools. (Reported by J Dean).
|
||||
|
|
10
README
10
README
|
@ -1,3 +1,5 @@
|
|||
See the file INSTALL for compilation and installation instructions.
|
||||
|
||||
Description
|
||||
|
||||
Tarlz is a massively parallel (multi-threaded) combined implementation of
|
||||
|
@ -73,8 +75,8 @@ that the format of the archive is compatible with tarlz.
|
|||
|
||||
The diagram below shows the correspondence between each tar member (formed
|
||||
by one or two headers plus optional data) in the tar archive and each lzip
|
||||
member in the resulting multimember tar.lz archive, when per file
|
||||
compression is used:
|
||||
member in the resulting multimember tar.lz archive, when per file compression
|
||||
is used:
|
||||
|
||||
tar
|
||||
+========+======+=================+===============+========+======+========+
|
||||
|
@ -87,6 +89,10 @@ tar.lz
|
|||
+===============+=================================================+========+
|
||||
|
||||
|
||||
Tarlz uses Arg_parser for command-line argument parsing:
|
||||
http://www.nongnu.org/arg-parser/arg_parser.html
|
||||
|
||||
|
||||
Copyright (C) 2013-2024 Antonio Diaz Diaz.
|
||||
|
||||
This file is free documentation: you have unlimited permission to copy,
|
||||
|
|
|
@ -116,12 +116,12 @@ int Archive_reader::read( uint8_t * const buf, const int size )
|
|||
const int rd = readblock( ad.infd, buf, size );
|
||||
if( rd != size && errno ) return err( -1, rdaerr_msg, errno, rd );
|
||||
const Lzip_header & header = (*(const Lzip_header *)buf);
|
||||
const bool islz = ( rd >= min_member_size && header.check_magic() &&
|
||||
const bool islz = rd >= min_member_size && header.check_magic() &&
|
||||
header.check_version() &&
|
||||
isvalid_ds( header.dictionary_size() ) );
|
||||
const bool istar = ( rd == size && check_ustar_chksum( buf ) );
|
||||
isvalid_ds( header.dictionary_size() );
|
||||
const bool istar = rd == size && check_ustar_chksum( buf );
|
||||
const bool iseoa =
|
||||
( !islz && !istar && rd == size && block_is_zero( buf, size ) );
|
||||
!islz && !istar && rd == size && block_is_zero( buf, size );
|
||||
bool maybe_lz = islz; // maybe corrupt tar.lz
|
||||
if( !islz && !istar && !iseoa ) // corrupt or invalid format
|
||||
{
|
||||
|
|
|
@ -118,3 +118,6 @@ public:
|
|||
int read( uint8_t * const buf, const int size );
|
||||
int skip_member( const Extended & extended );
|
||||
};
|
||||
|
||||
|
||||
const char * const empty_msg = "Empty lzip member not allowed.";
|
||||
|
|
|
@ -75,19 +75,19 @@ bool Arg_parser::parse_long_option( const char * const opt, const char * const a
|
|||
error_ += "' requires an argument";
|
||||
return false;
|
||||
}
|
||||
data.back().argument = &opt[len+3];
|
||||
data.back().argument = &opt[len+3]; // argument may be empty
|
||||
return true;
|
||||
}
|
||||
|
||||
if( options[index].has_arg == yes )
|
||||
if( options[index].has_arg == yes || options[index].has_arg == yme )
|
||||
{
|
||||
if( !arg || !arg[0] )
|
||||
if( !arg || ( options[index].has_arg == yes && !arg[0] ) )
|
||||
{
|
||||
error_ = "option '--"; error_ += options[index].long_name;
|
||||
error_ += "' requires an argument";
|
||||
return false;
|
||||
}
|
||||
++argind; data.back().argument = arg;
|
||||
++argind; data.back().argument = arg; // argument may be empty
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -123,15 +123,16 @@ bool Arg_parser::parse_short_option( const char * const opt, const char * const
|
|||
{
|
||||
data.back().argument = &opt[cind]; ++argind; cind = 0;
|
||||
}
|
||||
else if( options[index].has_arg == yes )
|
||||
else if( options[index].has_arg == yes || options[index].has_arg == yme )
|
||||
{
|
||||
if( !arg || !arg[0] )
|
||||
if( !arg || ( options[index].has_arg == yes && !arg[0] ) )
|
||||
{
|
||||
error_ = "option requires an argument -- '"; error_ += c;
|
||||
error_ += '\'';
|
||||
return false;
|
||||
}
|
||||
data.back().argument = arg; ++argind; cind = 0;
|
||||
++argind; cind = 0;
|
||||
data.back().argument = arg; // argument may be empty
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
10
arg_parser.h
10
arg_parser.h
|
@ -36,14 +36,18 @@
|
|||
The argument '--' terminates all options; any following arguments are
|
||||
treated as non-option arguments, even if they begin with a hyphen.
|
||||
|
||||
The syntax for optional option arguments is '-<short_option><argument>'
|
||||
(without whitespace), or '--<long_option>=<argument>'.
|
||||
The syntax of options with an optional argument is
|
||||
'-<short_option><argument>' (without whitespace), or
|
||||
'--<long_option>=<argument>'.
|
||||
|
||||
The syntax of options with an empty argument is '-<short_option> ""',
|
||||
'--<long_option> ""', or '--<long_option>=""'.
|
||||
*/
|
||||
|
||||
class Arg_parser
|
||||
{
|
||||
public:
|
||||
enum Has_arg { no, yes, maybe };
|
||||
enum Has_arg { no, yes, maybe, yme }; // yme = yes but maybe empty
|
||||
|
||||
struct Option
|
||||
{
|
||||
|
|
|
@ -89,7 +89,7 @@ bool compare_prefix_dir( const char * const dir, const char * const name )
|
|||
{
|
||||
int len = 0;
|
||||
while( dir[len] && dir[len] == name[len] ) ++len;
|
||||
return ( !dir[len] && len > 0 && ( dir[len-1] == '/' || name[len] == '/' ) );
|
||||
return !dir[len] && len > 0 && ( dir[len-1] == '/' || name[len] == '/' );
|
||||
}
|
||||
|
||||
|
||||
|
@ -101,7 +101,7 @@ bool compare_tslash( const char * const name1, const char * const name2 )
|
|||
while( *p && *p == *q ) { ++p; ++q; }
|
||||
while( *p == '/' ) ++p;
|
||||
while( *q == '/' ) ++q;
|
||||
return ( !*p && !*q );
|
||||
return !*p && !*q;
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
|
@ -129,7 +129,7 @@ bool format_member_name( const Extended & extended, const Tar_header header,
|
|||
{ time_t z = 0; if( !gmtime_r( &z, &t ) ) // use UTC, the epoch
|
||||
{ t.tm_year = 70; t.tm_mon = t.tm_hour = t.tm_min = 0; t.tm_mday = 1; } }
|
||||
const Typeflag typeflag = (Typeflag)header[typeflag_o];
|
||||
const bool islink = ( typeflag == tf_link || typeflag == tf_symlink );
|
||||
const bool islink = typeflag == tf_link || typeflag == tf_symlink;
|
||||
const char * const link_string = !islink ? "" :
|
||||
( ( typeflag == tf_link ) ? " link to " : " -> " );
|
||||
// print "user/group size" in a field of width 19 with 8 or more for size
|
||||
|
|
|
@ -134,7 +134,7 @@ bool archive_write( const uint8_t * const buf, const int size,
|
|||
static bool flushed = true; // avoid flushing empty lzip members
|
||||
|
||||
if( size <= 0 && flushed ) return true;
|
||||
flushed = ( size <= 0 );
|
||||
flushed = size <= 0;
|
||||
enum { obuf_size = 65536 };
|
||||
uint8_t obuf[obuf_size];
|
||||
int sz = 0;
|
||||
|
@ -150,7 +150,8 @@ bool archive_write( const uint8_t * const buf, const int size,
|
|||
if( rd < 0 ) internal_error( "library error (LZ_compress_read)." );
|
||||
if( rd == 0 && sz >= size ) break;
|
||||
if( writeblock( outfd, obuf, rd ) != rd )
|
||||
{ show_file_error( ne_output_filename(), werr_msg, errno ); return false; }
|
||||
{ show_file_error( ne_output_filename(), wr_err_msg, errno );
|
||||
return false; }
|
||||
}
|
||||
if( LZ_compress_finished( encoder ) == 1 &&
|
||||
LZ_compress_restart_member( encoder, LLONG_MAX ) < 0 )
|
||||
|
@ -166,7 +167,7 @@ bool tail_compress( const Cl_options & cl_opts,
|
|||
if( cl_opts.solidity != solid && !archive_write( 0, 0, encoder ) )
|
||||
return false; // flush encoder before compressing EOA blocks
|
||||
int size = header_size;
|
||||
bool zero = true; // true until non-zero data found after EOA blocks
|
||||
bool zero = true; // true until nonzero data found after EOA blocks
|
||||
while( true )
|
||||
{
|
||||
if( size > 0 && !archive_write( header, size, encoder ) )
|
||||
|
|
4
configure
vendored
4
configure
vendored
|
@ -6,7 +6,7 @@
|
|||
# to copy, distribute, and modify it.
|
||||
|
||||
pkgname=tarlz
|
||||
pkgversion=0.25
|
||||
pkgversion=0.26
|
||||
progname=tarlz
|
||||
srctrigger=doc/${pkgname}.texi
|
||||
|
||||
|
@ -112,7 +112,7 @@ while [ $# != 0 ] ; do
|
|||
exit 1 ;;
|
||||
esac
|
||||
|
||||
# Check if the option took a separate argument
|
||||
# Check whether the option took a separate argument
|
||||
if [ "${arg2}" = yes ] ; then
|
||||
if [ $# != 0 ] ; then args="${args} \"$1\"" ; shift
|
||||
else echo "configure: Missing argument to '${option}'" 1>&2
|
||||
|
|
19
create.cc
19
create.cc
|
@ -178,7 +178,7 @@ bool archive_write( const uint8_t * const buf, const int size )
|
|||
static bool flushed = true; // avoid flushing empty lzip members
|
||||
|
||||
if( size <= 0 && flushed ) return true;
|
||||
flushed = ( size <= 0 );
|
||||
flushed = size <= 0;
|
||||
if( !encoder ) // uncompressed
|
||||
return writeblock_wrapper( goutfd, buf, size );
|
||||
enum { obuf_size = 65536 };
|
||||
|
@ -307,11 +307,12 @@ bool check_tty_out( const char * const archive_namep, const int outfd,
|
|||
// infd and outfd can refer to the same file if copying to a lower file
|
||||
// position or if source and destination blocks don't overlap.
|
||||
// max_size < 0 means no size limit.
|
||||
bool copy_file( const int infd, const int outfd, const long long max_size )
|
||||
bool copy_file( const int infd, const int outfd, const char * const filename,
|
||||
const long long max_size )
|
||||
{
|
||||
const long long buffer_size = 65536;
|
||||
// remaining number of bytes to copy
|
||||
long long rest = ( ( max_size >= 0 ) ? max_size : buffer_size );
|
||||
long long rest = ( max_size >= 0 ) ? max_size : buffer_size;
|
||||
long long copied_size = 0;
|
||||
uint8_t * const buffer = new uint8_t[buffer_size];
|
||||
bool error = false;
|
||||
|
@ -322,7 +323,7 @@ bool copy_file( const int infd, const int outfd, const long long max_size )
|
|||
if( max_size >= 0 ) rest -= size;
|
||||
const int rd = readblock( infd, buffer, size );
|
||||
if( rd != size && errno )
|
||||
{ show_error( "Error reading input file", errno ); error = true; break; }
|
||||
{ show_file_error( filename, "Read error", errno ); error = true; break; }
|
||||
if( rd > 0 )
|
||||
{
|
||||
if( !writeblock_wrapper( outfd, buffer, rd ) ) { error = true; break; }
|
||||
|
@ -331,7 +332,7 @@ bool copy_file( const int infd, const int outfd, const long long max_size )
|
|||
if( rd < size ) break; // EOF
|
||||
}
|
||||
delete[] buffer;
|
||||
return ( !error && ( max_size < 0 || copied_size == max_size ) );
|
||||
return !error && ( max_size < 0 || copied_size == max_size );
|
||||
}
|
||||
|
||||
|
||||
|
@ -339,7 +340,7 @@ bool writeblock_wrapper( const int outfd, const uint8_t * const buffer,
|
|||
const int size )
|
||||
{
|
||||
if( writeblock( outfd, buffer, size ) != size )
|
||||
{ show_file_error( archive_namep, werr_msg, errno ); return false; }
|
||||
{ show_file_error( archive_namep, wr_err_msg, errno ); return false; }
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -519,8 +520,8 @@ unsigned ustar_chksum( const Tar_header header )
|
|||
|
||||
|
||||
bool check_ustar_chksum( const Tar_header header )
|
||||
{ return ( check_ustar_magic( header ) &&
|
||||
ustar_chksum( header ) == parse_octal( header + chksum_o, chksum_l ) ); }
|
||||
{ return check_ustar_magic( header ) &&
|
||||
ustar_chksum( header ) == parse_octal( header + chksum_o, chksum_l ); }
|
||||
|
||||
|
||||
bool has_lz_ext( const std::string & name )
|
||||
|
@ -605,7 +606,7 @@ int concatenate( const Cl_options & cl_opts )
|
|||
"Not an appendable tar.lz archive." :
|
||||
"Not an appendable tar archive." );
|
||||
close( infd ); retval = 2; break; }
|
||||
if( !copy_file( infd, outfd, size ) || close( infd ) != 0 )
|
||||
if( !copy_file( infd, outfd, filename, size ) || close( infd ) != 0 )
|
||||
{ show_file_error( filename, "Error copying archive", errno );
|
||||
eoa_pending = false; retval = 1; break; }
|
||||
eoa_pending = true;
|
||||
|
|
84
create_lz.cc
84
create_lz.cc
|
@ -60,7 +60,7 @@ public:
|
|||
|
||||
~Slot_tally() { xdestroy_cond( &slot_av ); xdestroy_mutex( &mutex ); }
|
||||
|
||||
bool all_free() { return ( num_free == num_slots ); }
|
||||
bool all_free() { return num_free == num_slots; }
|
||||
|
||||
void get_slot() // wait for a free slot
|
||||
{
|
||||
|
@ -94,8 +94,8 @@ struct Ipacket // filename, file size and headers
|
|||
|
||||
struct Opacket // compressed data to be written to the archive
|
||||
{
|
||||
const uint8_t * const data; // data == 0 means end of lzip member
|
||||
const int size; // number of bytes in data (if any)
|
||||
const uint8_t * data; // data == 0 means end of lzip member
|
||||
int size; // number of bytes in data (if any)
|
||||
|
||||
Opacket() : data( 0 ), size( 0 ) {}
|
||||
Opacket( uint8_t * const d, const int s ) : data( d ), size( s ) {}
|
||||
|
@ -110,11 +110,11 @@ public:
|
|||
unsigned ocheck_counter;
|
||||
unsigned owait_counter;
|
||||
private:
|
||||
int receive_worker_id; // worker queue currently receiving packets
|
||||
int deliver_worker_id; // worker queue currently delivering packets
|
||||
int receive_id; // worker queue currently receiving packets
|
||||
int deliver_id; // worker queue currently delivering packets
|
||||
Slot_tally slot_tally; // limits the number of input packets
|
||||
std::vector< std::queue< const Ipacket * > > ipacket_queues;
|
||||
std::vector< std::queue< const Opacket * > > opacket_queues;
|
||||
std::vector< std::queue< Opacket > > opacket_queues;
|
||||
int num_working; // number of workers still running
|
||||
const int num_workers; // number of workers
|
||||
const unsigned out_slots; // max output packets per queue
|
||||
|
@ -132,11 +132,10 @@ public:
|
|||
Packet_courier( const int workers, const int in_slots, const int oslots )
|
||||
: icheck_counter( 0 ), iwait_counter( 0 ),
|
||||
ocheck_counter( 0 ), owait_counter( 0 ),
|
||||
receive_worker_id( 0 ), deliver_worker_id( 0 ),
|
||||
slot_tally( in_slots ), ipacket_queues( workers ),
|
||||
opacket_queues( workers ), num_working( workers ),
|
||||
num_workers( workers ), out_slots( oslots ), slot_av( workers ),
|
||||
eof( false )
|
||||
receive_id( 0 ), deliver_id( 0 ), slot_tally( in_slots ),
|
||||
ipacket_queues( workers ), opacket_queues( workers ),
|
||||
num_working( workers ), num_workers( workers ),
|
||||
out_slots( oslots ), slot_av( workers ), eof( false )
|
||||
{
|
||||
xinit_mutex( &imutex ); xinit_cond( &iav_or_eof );
|
||||
xinit_mutex( &omutex ); xinit_cond( &oav_or_exit );
|
||||
|
@ -157,9 +156,9 @@ public:
|
|||
if( !ipacket->filename.empty() )
|
||||
slot_tally.get_slot(); // wait for a free slot
|
||||
xlock( &imutex );
|
||||
ipacket_queues[receive_worker_id].push( ipacket );
|
||||
if( ipacket->filename.empty() && ++receive_worker_id >= num_workers )
|
||||
receive_worker_id = 0;
|
||||
ipacket_queues[receive_id].push( ipacket );
|
||||
if( ipacket->filename.empty() && ++receive_id >= num_workers )
|
||||
receive_id = 0;
|
||||
xbroadcast( &iav_or_eof );
|
||||
xunlock( &imutex );
|
||||
}
|
||||
|
@ -194,44 +193,41 @@ public:
|
|||
}
|
||||
|
||||
// collect an opacket from a worker
|
||||
void collect_packet( const Opacket * const opacket, const int worker_id )
|
||||
void collect_packet( const Opacket & opacket, const int worker_id )
|
||||
{
|
||||
xlock( &omutex );
|
||||
if( opacket->data )
|
||||
if( opacket.data )
|
||||
{
|
||||
while( opacket_queues[worker_id].size() >= out_slots )
|
||||
xwait( &slot_av[worker_id], &omutex );
|
||||
}
|
||||
opacket_queues[worker_id].push( opacket );
|
||||
if( worker_id == deliver_worker_id ) xsignal( &oav_or_exit );
|
||||
if( worker_id == deliver_id ) xsignal( &oav_or_exit );
|
||||
xunlock( &omutex );
|
||||
}
|
||||
|
||||
/* Deliver an opacket to muxer.
|
||||
If opacket data == 0, move to next queue and wait again. */
|
||||
const Opacket * deliver_packet()
|
||||
/* Deliver opackets to muxer.
|
||||
If opacket.data == 0, skip opacket and move to next queue. */
|
||||
void deliver_packets( std::vector< Opacket > & opacket_vector )
|
||||
{
|
||||
const Opacket * opacket = 0;
|
||||
opacket_vector.clear();
|
||||
xlock( &omutex );
|
||||
++ocheck_counter;
|
||||
while( true )
|
||||
do {
|
||||
while( opacket_queues[deliver_id].empty() && num_working > 0 )
|
||||
{ ++owait_counter; xwait( &oav_or_exit, &omutex ); }
|
||||
while( !opacket_queues[deliver_id].empty() )
|
||||
{
|
||||
while( opacket_queues[deliver_worker_id].empty() && num_working > 0 )
|
||||
{
|
||||
++owait_counter;
|
||||
xwait( &oav_or_exit, &omutex );
|
||||
Opacket opacket = opacket_queues[deliver_id].front();
|
||||
opacket_queues[deliver_id].pop();
|
||||
if( opacket_queues[deliver_id].size() + 1 == out_slots )
|
||||
xsignal( &slot_av[deliver_id] );
|
||||
if( opacket.data ) opacket_vector.push_back( opacket );
|
||||
else if( ++deliver_id >= num_workers ) deliver_id = 0;
|
||||
}
|
||||
if( opacket_queues[deliver_worker_id].empty() ) break;
|
||||
opacket = opacket_queues[deliver_worker_id].front();
|
||||
opacket_queues[deliver_worker_id].pop();
|
||||
if( opacket_queues[deliver_worker_id].size() + 1 == out_slots )
|
||||
xsignal( &slot_av[deliver_worker_id] );
|
||||
if( opacket->data ) break;
|
||||
if( ++deliver_worker_id >= num_workers ) deliver_worker_id = 0;
|
||||
delete opacket; opacket = 0;
|
||||
}
|
||||
while( opacket_vector.empty() && num_working > 0 );
|
||||
xunlock( &omutex );
|
||||
return opacket;
|
||||
}
|
||||
|
||||
void finish() // grouper has no more packets to send
|
||||
|
@ -371,7 +367,7 @@ void loop_encode( const uint8_t * const ibuf, const int isize,
|
|||
{
|
||||
if( opos > max_packet_size )
|
||||
internal_error( "opacket size exceeded in worker." );
|
||||
courier.collect_packet( new Opacket( obuf, opos ), worker_id );
|
||||
courier.collect_packet( Opacket( obuf, opos ), worker_id );
|
||||
opos = 0; obuf = new( std::nothrow ) uint8_t[max_packet_size];
|
||||
if( !obuf ) { show_error( mem_msg2 ); exit_fail_mt(); }
|
||||
if( LZ_compress_finished( encoder ) == 1 )
|
||||
|
@ -421,7 +417,7 @@ extern "C" void * cworker( void * arg )
|
|||
{
|
||||
if( !flushed ) // this lzip member is not empty
|
||||
loop_encode( 0, 0, data, opos, courier, encoder, worker_id, true );
|
||||
courier.collect_packet( new Opacket, worker_id ); // end of member token
|
||||
courier.collect_packet( Opacket(), worker_id ); // end of member token
|
||||
flushed = true; delete ipacket; continue;
|
||||
}
|
||||
|
||||
|
@ -501,15 +497,19 @@ extern "C" void * cworker( void * arg )
|
|||
*/
|
||||
void muxer( Packet_courier & courier, const int outfd )
|
||||
{
|
||||
std::vector< Opacket > opacket_vector;
|
||||
while( true )
|
||||
{
|
||||
const Opacket * const opacket = courier.deliver_packet();
|
||||
if( !opacket ) break; // queue is empty. all workers exited
|
||||
courier.deliver_packets( opacket_vector );
|
||||
if( opacket_vector.empty() ) break; // queue is empty. all workers exited
|
||||
|
||||
if( !writeblock_wrapper( outfd, opacket->data, opacket->size ) )
|
||||
for( unsigned i = 0; i < opacket_vector.size(); ++i )
|
||||
{
|
||||
Opacket & opacket = opacket_vector[i];
|
||||
if( !writeblock_wrapper( outfd, opacket.data, opacket.size ) )
|
||||
exit_fail_mt();
|
||||
delete[] opacket->data;
|
||||
delete opacket;
|
||||
delete[] opacket.data;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -190,7 +190,7 @@ int extract_member( const Cl_options & cl_opts, Archive_reader & ar,
|
|||
return skip_member( ar, extended, typeflag );
|
||||
}
|
||||
|
||||
const bool islink = ( typeflag == tf_link || typeflag == tf_symlink );
|
||||
const bool islink = typeflag == tf_link || typeflag == tf_symlink;
|
||||
errno = 0;
|
||||
if( !islink &&
|
||||
( !uid_gid_in_range( extended.get_uid(), extended.get_gid() ) ||
|
||||
|
@ -229,7 +229,7 @@ int extract_member( const Cl_options & cl_opts, Archive_reader & ar,
|
|||
}
|
||||
const int wsize = ( rest >= bufsize ) ? bufsize : rest;
|
||||
if( outfd >= 0 && writeblock( outfd, buf, wsize ) != wsize )
|
||||
{ show_file_error( filename, werr_msg, errno ); return 1; }
|
||||
{ show_file_error( filename, wr_err_msg, errno ); return 1; }
|
||||
rest -= wsize;
|
||||
}
|
||||
}
|
||||
|
@ -347,7 +347,7 @@ bool compare_file_type( std::string & estr, std::string & ostr,
|
|||
{
|
||||
char * const buf = new char[st.st_size+1];
|
||||
long len = readlink( filename, buf, st.st_size );
|
||||
bool e = ( len != st.st_size );
|
||||
bool e = len != st.st_size;
|
||||
if( !e )
|
||||
{
|
||||
while( len > 1 && buf[len-1] == '/' ) --len; // trailing '/'
|
||||
|
@ -412,6 +412,8 @@ int decode( const Cl_options & cl_opts )
|
|||
// open archive before changing working directory
|
||||
const Archive_descriptor ad( cl_opts.archive_name );
|
||||
if( ad.infd < 0 ) return 1;
|
||||
if( ad.name.size() && ad.indexed && ad.lzip_index.multi_empty() )
|
||||
{ show_file_error( ad.namep, empty_msg ); close( ad.infd ); return 2; }
|
||||
|
||||
const bool c_present = option_C_present( cl_opts.parser ) &&
|
||||
cl_opts.program_mode != m_list;
|
||||
|
|
79
decode_lz.cc
79
decode_lz.cc
|
@ -73,8 +73,8 @@ public:
|
|||
unsigned owait_counter;
|
||||
private:
|
||||
long error_member_id; // first lzip member with error/misalign/eoa/eof
|
||||
int deliver_worker_id; // worker queue currently delivering packets
|
||||
int master_worker_id; // worker in charge if error/misalign/eoa/eof
|
||||
int deliver_id; // worker queue currently delivering packets
|
||||
int master_id; // worker in charge if error/misalign/eoa/eof
|
||||
std::vector< std::queue< const Packet * > > opacket_queues;
|
||||
int num_working; // number of workers still running
|
||||
const int num_workers; // number of workers
|
||||
|
@ -90,11 +90,10 @@ private:
|
|||
|
||||
public:
|
||||
Packet_courier( const int workers, const int slots )
|
||||
: ocheck_counter( 0 ), owait_counter( 0 ),
|
||||
error_member_id( -1 ), deliver_worker_id( 0 ), master_worker_id( -1 ),
|
||||
opacket_queues( workers ), num_working( workers ),
|
||||
num_workers( workers ), out_slots( slots ), slot_av( workers ),
|
||||
eoa_found_( false )
|
||||
: ocheck_counter( 0 ), owait_counter( 0 ), error_member_id( -1 ),
|
||||
deliver_id( 0 ), master_id( -1 ), opacket_queues( workers ),
|
||||
num_working( workers ), num_workers( workers ),
|
||||
out_slots( slots ), slot_av( workers ), eoa_found_( false )
|
||||
{
|
||||
xinit_mutex( &omutex ); xinit_cond( &oav_or_exit );
|
||||
for( unsigned i = 0; i < slot_av.size(); ++i ) xinit_cond( &slot_av[i] );
|
||||
|
@ -111,22 +110,22 @@ public:
|
|||
bool eoa_found() const { return eoa_found_; }
|
||||
void report_eoa() { eoa_found_ = true; }
|
||||
|
||||
bool mastership_granted() const { return master_worker_id >= 0; }
|
||||
bool mastership_granted() const { return master_id >= 0; }
|
||||
|
||||
bool request_mastership( const long member_id, const int worker_id )
|
||||
{
|
||||
xlock( &omutex );
|
||||
if( mastership_granted() ) // already granted
|
||||
{ xunlock( &omutex ); return ( master_worker_id == worker_id ); }
|
||||
{ xunlock( &omutex ); return master_id == worker_id; }
|
||||
if( error_member_id < 0 || error_member_id > member_id )
|
||||
error_member_id = member_id;
|
||||
while( !mastership_granted() && ( worker_id != deliver_worker_id ||
|
||||
!opacket_queues[deliver_worker_id].empty() ) )
|
||||
while( !mastership_granted() && ( worker_id != deliver_id ||
|
||||
!opacket_queues[deliver_id].empty() ) )
|
||||
xwait( &check_master, &omutex );
|
||||
if( !mastership_granted() && worker_id == deliver_worker_id &&
|
||||
opacket_queues[deliver_worker_id].empty() )
|
||||
if( !mastership_granted() && worker_id == deliver_id &&
|
||||
opacket_queues[deliver_id].empty() )
|
||||
{
|
||||
master_worker_id = worker_id; // grant mastership
|
||||
master_id = worker_id; // grant mastership
|
||||
for( int i = 0; i < num_workers; ++i ) // delete all packets
|
||||
while( !opacket_queues[i].empty() )
|
||||
opacket_queues[i].pop();
|
||||
|
@ -154,46 +153,47 @@ public:
|
|||
{
|
||||
const Packet * const opacket = new Packet( member_id, msg, status, errcode );
|
||||
xlock( &omutex );
|
||||
if( ( mastership_granted() && master_worker_id != worker_id ) ||
|
||||
if( ( mastership_granted() && master_id != worker_id ) ||
|
||||
( error_member_id >= 0 && error_member_id < opacket->member_id ) )
|
||||
{ xunlock( &omutex ); delete opacket; return false; } // reject packet
|
||||
while( opacket_queues[worker_id].size() >= out_slots )
|
||||
xwait( &slot_av[worker_id], &omutex );
|
||||
opacket_queues[worker_id].push( opacket );
|
||||
if( worker_id == deliver_worker_id ) xsignal( &oav_or_exit );
|
||||
if( worker_id == deliver_id ) xsignal( &oav_or_exit );
|
||||
xunlock( &omutex );
|
||||
return true;
|
||||
}
|
||||
|
||||
/* Deliver a packet to muxer.
|
||||
/* Deliver packets to muxer.
|
||||
If packet.status == Packet::member_done, move to next queue.
|
||||
If packet.line.empty(), wait again (empty lzip member). */
|
||||
const Packet * deliver_packet()
|
||||
If packet.line.empty(), wait again (empty lzip member or -q). */
|
||||
void deliver_packets( std::vector< const Packet * > & opacket_vector )
|
||||
{
|
||||
const Packet * opacket = 0;
|
||||
opacket_vector.clear();
|
||||
xlock( &omutex );
|
||||
++ocheck_counter;
|
||||
while( true )
|
||||
{
|
||||
while( opacket_queues[deliver_worker_id].empty() && num_working > 0 )
|
||||
do {
|
||||
while( opacket_queues[deliver_id].empty() && num_working > 0 )
|
||||
{
|
||||
++owait_counter;
|
||||
if( !mastership_granted() && error_member_id >= 0 )
|
||||
xbroadcast( &check_master ); // mastership requested not yet granted
|
||||
xwait( &oav_or_exit, &omutex );
|
||||
}
|
||||
if( opacket_queues[deliver_worker_id].empty() ) break;
|
||||
opacket = opacket_queues[deliver_worker_id].front();
|
||||
opacket_queues[deliver_worker_id].pop();
|
||||
if( opacket_queues[deliver_worker_id].size() + 1 == out_slots )
|
||||
xsignal( &slot_av[deliver_worker_id] );
|
||||
while( !opacket_queues[deliver_id].empty() )
|
||||
{
|
||||
const Packet * opacket = opacket_queues[deliver_id].front();
|
||||
opacket_queues[deliver_id].pop();
|
||||
if( opacket_queues[deliver_id].size() + 1 == out_slots )
|
||||
xsignal( &slot_av[deliver_id] );
|
||||
if( opacket->status == Packet::member_done && !mastership_granted() )
|
||||
{ if( ++deliver_worker_id >= num_workers ) deliver_worker_id = 0; }
|
||||
if( !opacket->line.empty() ) break;
|
||||
delete opacket; opacket = 0;
|
||||
{ if( ++deliver_id >= num_workers ) deliver_id = 0; }
|
||||
if( !opacket->line.empty() ) opacket_vector.push_back( opacket );
|
||||
else delete opacket;
|
||||
}
|
||||
}
|
||||
while( opacket_vector.empty() && num_working > 0 );
|
||||
xunlock( &omutex );
|
||||
return opacket;
|
||||
}
|
||||
|
||||
bool finished() // all packets delivered to muxer
|
||||
|
@ -401,7 +401,7 @@ Trival extract_member_lz( const Cl_options & cl_opts,
|
|||
case tf_directory:
|
||||
{
|
||||
struct stat st;
|
||||
bool exists = ( stat( filename, &st ) == 0 );
|
||||
bool exists = stat( filename, &st ) == 0;
|
||||
if( exists && !S_ISDIR( st.st_mode ) )
|
||||
{ exists = false; std::remove( filename ); }
|
||||
if( !exists && mkdir( filename, mode ) != 0 && errno != EEXIST )
|
||||
|
@ -446,7 +446,7 @@ Trival extract_member_lz( const Cl_options & cl_opts,
|
|||
typeflag );
|
||||
}
|
||||
|
||||
const bool islink = ( typeflag == tf_link || typeflag == tf_symlink );
|
||||
const bool islink = typeflag == tf_link || typeflag == tf_symlink;
|
||||
errno = 0;
|
||||
if( !islink &&
|
||||
( !uid_gid_in_range( extended.get_uid(), extended.get_gid() ) ||
|
||||
|
@ -489,7 +489,7 @@ Trival extract_member_lz( const Cl_options & cl_opts,
|
|||
}
|
||||
const int wsize = ( rest >= bufsize ) ? bufsize : rest;
|
||||
if( outfd >= 0 && writeblock( outfd, buf, wsize ) != wsize )
|
||||
{ format_file_error( rbuf, filename, werr_msg, errno );
|
||||
{ format_file_error( rbuf, filename, wr_err_msg, errno );
|
||||
return Trival( rbuf(), 0, 1 ); }
|
||||
rest -= wsize;
|
||||
}
|
||||
|
@ -672,12 +672,16 @@ done:
|
|||
*/
|
||||
void muxer( const char * const archive_namep, Packet_courier & courier )
|
||||
{
|
||||
std::vector< const Packet * > opacket_vector;
|
||||
int retval = 0;
|
||||
while( retval == 0 )
|
||||
{
|
||||
const Packet * const opacket = courier.deliver_packet();
|
||||
if( !opacket ) break; // queue is empty. all workers exited
|
||||
courier.deliver_packets( opacket_vector );
|
||||
if( opacket_vector.empty() ) break; // queue is empty. all workers exited
|
||||
|
||||
for( unsigned i = 0; i < opacket_vector.size(); ++i )
|
||||
{
|
||||
const Packet * const opacket = opacket_vector[i];
|
||||
switch( opacket->status )
|
||||
{
|
||||
case Packet::error1:
|
||||
|
@ -691,6 +695,7 @@ void muxer( const char * const archive_namep, Packet_courier & courier )
|
|||
}
|
||||
delete opacket;
|
||||
}
|
||||
}
|
||||
if( retval == 0 && !courier.eoa_found() ) // no worker found EOA blocks
|
||||
{ show_file_error( archive_namep, end_msg ); retval = 2; }
|
||||
if( retval ) exit_fail_mt( retval );
|
||||
|
|
|
@ -44,7 +44,7 @@ int tail_copy( const Arg_parser & parser, const Archive_descriptor & ad,
|
|||
const long long rest = ad.lzip_index.file_size() - istream_pos;
|
||||
if( istream_pos > 0 && rest > 0 &&
|
||||
( !safe_seek( ad.infd, istream_pos ) ||
|
||||
!copy_file( ad.infd, outfd, rest ) ) )
|
||||
!copy_file( ad.infd, outfd, ad.namep, rest ) ) )
|
||||
{ show_file_error( ad.namep, "Error during tail copy." );
|
||||
return retval ? retval : 1; }
|
||||
const long long ostream_pos = lseek( outfd, 0, SEEK_CUR );
|
||||
|
@ -85,6 +85,8 @@ int delete_members( const Cl_options & cl_opts )
|
|||
{ show_error( "Deleting from stdin not implemented yet." ); return 1; }
|
||||
const Archive_descriptor ad( cl_opts.archive_name );
|
||||
if( ad.infd < 0 ) return 1;
|
||||
if( ad.name.size() && ad.indexed && ad.lzip_index.multi_empty() )
|
||||
{ show_file_error( ad.namep, empty_msg ); close( ad.infd ); return 2; }
|
||||
const int outfd = open_outstream( cl_opts.archive_name, false );
|
||||
if( outfd < 0 ) { close( ad.infd ); return 1; }
|
||||
|
||||
|
@ -177,7 +179,7 @@ int delete_members( const Cl_options & cl_opts )
|
|||
if( istream_pos == 0 )
|
||||
{ if( !safe_seek( outfd, size ) ) { retval = 1; break; } }
|
||||
else if( !safe_seek( ad.infd, istream_pos ) ||
|
||||
!copy_file( ad.infd, outfd, size ) ||
|
||||
!copy_file( ad.infd, outfd, ad.namep, size ) ||
|
||||
!safe_seek( ad.infd, pos ) ) { retval = 1; break; }
|
||||
}
|
||||
istream_pos = pos;
|
||||
|
|
|
@ -35,8 +35,7 @@
|
|||
*/
|
||||
int delete_members_lz( const Cl_options & cl_opts,
|
||||
const Archive_descriptor & ad,
|
||||
std::vector< char > & name_pending,
|
||||
const int outfd )
|
||||
std::vector< char > & name_pending, const int outfd )
|
||||
{
|
||||
Archive_reader_i ar( ad ); // indexed reader
|
||||
Resizable_buffer rbuf;
|
||||
|
@ -124,7 +123,8 @@ int delete_members_lz( const Cl_options & cl_opts,
|
|||
if( istream_pos == 0 )
|
||||
{ if( !safe_seek( outfd, size ) ) { retval = 1; goto done; } }
|
||||
else if( !safe_seek( ad.infd, istream_pos ) ||
|
||||
!copy_file( ad.infd, outfd, size ) ) { retval = 1; goto done; }
|
||||
!copy_file( ad.infd, outfd, ad.namep, size ) )
|
||||
{ retval = 1; goto done; }
|
||||
}
|
||||
istream_pos = ad.lzip_index.mblock( i ).end(); // member end
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
.\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.49.2.
|
||||
.TH TARLZ "1" "January 2024" "tarlz 0.25" "User Commands"
|
||||
.TH TARLZ "1" "December 2024" "tarlz 0.26" "User Commands"
|
||||
.SH NAME
|
||||
tarlz \- creates tar archives with multimember lzip compression
|
||||
.SH SYNOPSIS
|
||||
|
@ -161,11 +161,12 @@ Report bugs to lzip\-bug@nongnu.org
|
|||
Tarlz home page: http://www.nongnu.org/lzip/tarlz.html
|
||||
.SH COPYRIGHT
|
||||
Copyright \(co 2024 Antonio Diaz Diaz.
|
||||
Using lzlib 1.14\-rc1
|
||||
License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>
|
||||
.br
|
||||
This is free software: you are free to change and redistribute it.
|
||||
There is NO WARRANTY, to the extent permitted by law.
|
||||
Using lzlib 1.15\-rc1
|
||||
Using LZ_API_VERSION = 1015
|
||||
.SH "SEE ALSO"
|
||||
The full documentation for
|
||||
.B tarlz
|
||||
|
|
211
doc/tarlz.info
211
doc/tarlz.info
|
@ -11,12 +11,13 @@ File: tarlz.info, Node: Top, Next: Introduction, Up: (dir)
|
|||
Tarlz Manual
|
||||
************
|
||||
|
||||
This manual is for Tarlz (version 0.25, 3 January 2024).
|
||||
This manual is for Tarlz (version 0.26, 7 December 2024).
|
||||
|
||||
* Menu:
|
||||
|
||||
* Introduction:: Purpose and features of tarlz
|
||||
* Invoking tarlz:: Command-line interface
|
||||
* Argument syntax:: By convention, options start with a hyphen
|
||||
* Portable character set:: POSIX portable filename character set
|
||||
* File format:: Detailed format of the compressed archive
|
||||
* Amendments to pax format:: The reasons for the differences with pax
|
||||
|
@ -92,7 +93,7 @@ in a way compatible with standard tar tools. *Note crc32::.
|
|||
be used to check that the format of the archive is compatible with tarlz.
|
||||
|
||||
|
||||
File: tarlz.info, Node: Invoking tarlz, Next: Portable character set, Prev: Introduction, Up: Top
|
||||
File: tarlz.info, Node: Invoking tarlz, Next: Argument syntax, Prev: Introduction, Up: Top
|
||||
|
||||
2 Invoking tarlz
|
||||
****************
|
||||
|
@ -240,7 +241,7 @@ to '-1 --solid'.
|
|||
used as compressor for GNU tar by using a command like
|
||||
'tar -c -Hustar foo | tarlz -z -o foo.tar.lz'. Tarlz can be used as
|
||||
compressor for zupdate (zutils) by using a command like
|
||||
'zupdate --lz="tarlz -z" foo.tar.gz'. Note that tarlz only works
|
||||
'zupdate --lz='tarlz -z' foo.tar.gz'. Note that tarlz only works
|
||||
reliably on archives without global headers, or with global headers
|
||||
whose content can be ignored.
|
||||
|
||||
|
@ -249,7 +250,7 @@ to '-1 --solid'.
|
|||
end-of-archive block is found, and then compresses the rest of the
|
||||
archive. Unless solid compression is requested, the end-of-archive
|
||||
blocks are compressed in a lzip member separated from the preceding
|
||||
members and from any non-zero garbage following the end-of-archive
|
||||
members and from any nonzero garbage following the end-of-archive
|
||||
blocks. '--compress' implies plzip argument style, not tar style. Each
|
||||
input archive is compressed to a file with the extension '.lz' added
|
||||
unless the option '--output' is used. When '--output' is used, only
|
||||
|
@ -268,8 +269,7 @@ to '-1 --solid'.
|
|||
(lzlib)Library version.
|
||||
|
||||
|
||||
tarlz supports the following options: *Note Argument syntax:
|
||||
(arg_parser)Argument syntax.
|
||||
tarlz supports the following options: *Note Argument syntax::.
|
||||
|
||||
'-B BYTES'
|
||||
'--data-size=BYTES'
|
||||
|
@ -281,17 +281,18 @@ to '-1 --solid'.
|
|||
'-C DIR'
|
||||
'--directory=DIR'
|
||||
Change to directory DIR. When creating, appending, comparing, or
|
||||
extracting, the position of each '-C' option in the command line is
|
||||
extracting, the position of each option '-C' in the command line is
|
||||
significant; it changes the current working directory for the following
|
||||
FILES until a new '-C' option appears in the command line. '--list'
|
||||
and '--delete' ignore any '-C' options specified. DIR is relative to
|
||||
the then current working directory, perhaps changed by a previous '-C'
|
||||
option.
|
||||
FILES until a new option '-C' appears in the command line. '--list'
|
||||
and '--delete' ignore any option '-C' specified. DIR is relative to
|
||||
the then current working directory, perhaps changed by a previous
|
||||
option '-C'.
|
||||
|
||||
Note that a process can only have one current working directory (CWD).
|
||||
Therefore multi-threading can't be used to create or decode an archive
|
||||
if a '-C' option appears after a (relative) file name in the command
|
||||
line. (All file names are made relative when decoding).
|
||||
if an option '-C' appears after a (relative) file name in the command
|
||||
line. (All file names are made relative by removing leading slashes
|
||||
when decoding).
|
||||
|
||||
'-f ARCHIVE'
|
||||
'--file=ARCHIVE'
|
||||
|
@ -307,10 +308,10 @@ to '-1 --solid'.
|
|||
'-n N'
|
||||
'--threads=N'
|
||||
Set the number of (de)compression threads, overriding the system's
|
||||
default. Valid values range from 0 to "as many as your system can
|
||||
support". A value of 0 disables threads entirely. If this option is
|
||||
not used, tarlz tries to detect the number of processors in the system
|
||||
and use it as default value. 'tarlz --help' shows the system's default
|
||||
default. Valid values range from 0 to as many as your system can
|
||||
support. A value of 0 disables threads entirely. If this option is not
|
||||
used, tarlz tries to detect the number of processors in the system and
|
||||
use it as default value. 'tarlz --help' shows the system's default
|
||||
value. See the note about multi-threading in the option '-C' above.
|
||||
|
||||
Note that the number of usable threads is limited during compression to
|
||||
|
@ -347,6 +348,7 @@ to '-1 --solid'.
|
|||
reducing the amount of memory required for decompression.
|
||||
|
||||
Level Dictionary size Match length limit
|
||||
--------------------------------------------
|
||||
-0 64 KiB 16 bytes
|
||||
-1 1 MiB 5 bytes
|
||||
-2 1.5 MiB 6 bytes
|
||||
|
@ -496,9 +498,52 @@ indicate a corrupt or invalid input file, 3 for an internal consistency
|
|||
error (e.g., bug) which caused tarlz to panic.
|
||||
|
||||
|
||||
File: tarlz.info, Node: Portable character set, Next: File format, Prev: Invoking tarlz, Up: Top
|
||||
File: tarlz.info, Node: Argument syntax, Next: Portable character set, Prev: Invoking tarlz, Up: Top
|
||||
|
||||
3 POSIX portable filename character set
|
||||
3 Syntax of command-line arguments
|
||||
**********************************
|
||||
|
||||
POSIX recommends these conventions for command-line arguments.
|
||||
|
||||
* A command-line argument is an option if it begins with a hyphen ('-').
|
||||
|
||||
* Option names are single alphanumeric characters.
|
||||
|
||||
* Certain options require an argument.
|
||||
|
||||
* An option and its argument may or may not appear as separate tokens.
|
||||
(In other words, the whitespace separating them is optional). Thus,
|
||||
'-o foo' and '-ofoo' are equivalent.
|
||||
|
||||
* One or more options without arguments, followed by at most one option
|
||||
that takes an argument, may follow a hyphen in a single token. Thus,
|
||||
'-abc' is equivalent to '-a -b -c'.
|
||||
|
||||
* Options typically precede other non-option arguments.
|
||||
|
||||
* The argument '--' terminates all options; any following arguments are
|
||||
treated as non-option arguments, even if they begin with a hyphen.
|
||||
|
||||
* A token consisting of a single hyphen character is interpreted as an
|
||||
ordinary non-option argument. By convention, it is used to specify
|
||||
standard input, standard output, or a file named '-'.
|
||||
|
||||
GNU adds "long options" to these conventions:
|
||||
|
||||
* A long option consists of two hyphens ('--') followed by a name made
|
||||
of alphanumeric characters and hyphens. Option names are typically one
|
||||
to three words long, with hyphens to separate words. Abbreviations can
|
||||
be used for the long option names as long as the abbreviations are
|
||||
unique.
|
||||
|
||||
* A long option and its argument may or may not appear as separate
|
||||
tokens. In the latter case they must be separated by an equal sign '='.
|
||||
Thus, '--foo bar' and '--foo=bar' are equivalent.
|
||||
|
||||
|
||||
File: tarlz.info, Node: Portable character set, Next: File format, Prev: Argument syntax, Up: Top
|
||||
|
||||
4 POSIX portable filename character set
|
||||
***************************************
|
||||
|
||||
The set of characters from which portable file names are constructed.
|
||||
|
@ -516,7 +561,7 @@ names use only the portable character set without spaces added.
|
|||
|
||||
File: tarlz.info, Node: File format, Next: Amendments to pax format, Prev: Portable character set, Up: Top
|
||||
|
||||
4 File format
|
||||
5 File format
|
||||
*************
|
||||
|
||||
In the diagram below, a box like this:
|
||||
|
@ -534,10 +579,10 @@ In the diagram below, a box like this:
|
|||
represents a variable number of bytes or a fixed but large number of
|
||||
bytes (for example 512).
|
||||
|
||||
|
||||
A tar.lz file consists of one or more lzip members (compressed data
|
||||
sets). The members simply appear one after another in the file, with no
|
||||
additional information before, between, or after them.
|
||||
A tar.lz file consists of one or more lzip members (compressed data sets).
|
||||
The members simply appear one after another in the file, with no additional
|
||||
information before, between, or after them. Empty members (data size = 0)
|
||||
are not allowed in multimember files.
|
||||
|
||||
Each lzip member contains one or more tar members in a simplified POSIX
|
||||
pax interchange format. The only pax typeflag value supported by tarlz (in
|
||||
|
@ -570,7 +615,7 @@ binary zeros, interpreted as an end-of-archive indicator. These EOA blocks
|
|||
are either compressed in a separate lzip member or compressed along with the
|
||||
tar members contained in the last lzip member. For a compressed archive to
|
||||
be recognized by tarlz as appendable, the last lzip member must contain
|
||||
between 512 and 32256 zeros alone (without any non-zero bytes).
|
||||
between 512 and 32256 zeros alone (without any nonzero bytes).
|
||||
|
||||
The diagram below shows the correspondence between each tar member
|
||||
(formed by one or two headers plus optional data) in the tar archive and
|
||||
|
@ -587,15 +632,14 @@ tar.lz
|
|||
| member | member | member |
|
||||
+===============+=================================================+========+
|
||||
|
||||
|
||||
4.1 Pax header block
|
||||
5.1 Pax header block
|
||||
====================
|
||||
|
||||
The pax header block is identical to the ustar header block described below
|
||||
except that the typeflag has the value 'x' (extended). The field 'size' is
|
||||
the size of the extended header data in bytes. Most other fields in the pax
|
||||
header block are zeroed on archive creation to prevent trouble if the
|
||||
archive is read by an ustar tool, and are ignored by tarlz on archive
|
||||
archive is read by a ustar tool, and are ignored by tarlz on archive
|
||||
extraction. *Note flawed-compat::.
|
||||
|
||||
Tarlz limits the size of the pax extended header data so that the whole
|
||||
|
@ -682,14 +726,14 @@ space, equal-sign, and newline.
|
|||
At verbosity level 1 or higher tarlz prints a diagnostic for each unknown
|
||||
extended header keyword found in an archive, once per keyword.
|
||||
|
||||
|
||||
4.2 Ustar header block
|
||||
5.2 Ustar header block
|
||||
======================
|
||||
|
||||
The ustar header block has a length of 512 bytes and is structured as shown
|
||||
in the following table. All lengths and offsets are in decimal.
|
||||
in the following table. All lengths and offsets are in decimal:
|
||||
|
||||
Field Name Offset Length (in bytes)
|
||||
---------------------------------------
|
||||
name 0 100
|
||||
mode 100 8
|
||||
uid 108 8
|
||||
|
@ -810,7 +854,7 @@ longer than standard ustar by not requiring a terminating null character.
|
|||
|
||||
File: tarlz.info, Node: Amendments to pax format, Next: Program design, Prev: File format, Up: Top
|
||||
|
||||
5 The reasons for the differences with pax
|
||||
6 The reasons for the differences with pax
|
||||
******************************************
|
||||
|
||||
Tarlz creates safe archives that allow the reliable detection of invalid or
|
||||
|
@ -821,8 +865,7 @@ achieve this goal and avoid some other flaws in the pax format, tarlz makes
|
|||
some changes to the variant of the pax format that it uses. This chapter
|
||||
describes these changes and the concrete reasons to implement them.
|
||||
|
||||
|
||||
5.1 Add a CRC of the extended records
|
||||
6.1 Add a CRC of the extended records
|
||||
=====================================
|
||||
|
||||
The POSIX pax format has a serious flaw. The metadata stored in pax extended
|
||||
|
@ -849,8 +892,7 @@ place.
|
|||
Redundancy Check (CRC) in a way compatible with standard tar tools. *Note
|
||||
key_crc32::.
|
||||
|
||||
|
||||
5.2 Remove flawed backward compatibility
|
||||
6.2 Remove flawed backward compatibility
|
||||
========================================
|
||||
|
||||
In order to allow the extraction of pax archives by a tar utility conforming
|
||||
|
@ -878,13 +920,12 @@ violations during parallel extraction.
|
|||
|
||||
If an extended header is required for any reason (for example a file
|
||||
size of 8 GiB or larger, or a link name longer than 100 bytes), tarlz also
|
||||
moves the file name to the extended records to prevent an ustar tool from
|
||||
moves the file name to the extended records to prevent a ustar tool from
|
||||
trying to extract the file or link. This also makes easier during parallel
|
||||
decoding the detection of a tar member split between two lzip members at
|
||||
the boundary between the extended header and the ustar header.
|
||||
|
||||
|
||||
5.3 As simple as possible (but not simpler)
|
||||
6.3 As simple as possible (but not simpler)
|
||||
===========================================
|
||||
|
||||
The tarlz format is mainly ustar. Extended pax headers are used only when
|
||||
|
@ -899,8 +940,7 @@ corruption.
|
|||
ignored. Some operations may not behave as expected if the archive contains
|
||||
global headers.
|
||||
|
||||
|
||||
5.4 Improve reproducibility
|
||||
6.4 Improve reproducibility
|
||||
===========================
|
||||
|
||||
Pax includes by default the process ID of the pax process in the ustar name
|
||||
|
@ -912,8 +952,7 @@ extended records, making it easier to produce reproducible archives.
|
|||
ten; '99<97_bytes>' or '100<97_bytes>'. Tarlz minimizes the length of the
|
||||
record and always produces a length of x-1 in these cases.
|
||||
|
||||
|
||||
5.5 No data in hard links
|
||||
6.5 No data in hard links
|
||||
=========================
|
||||
|
||||
Tarlz does not allow data in hard link members. The data (if any) must be in
|
||||
|
@ -922,8 +961,7 @@ the names of a file are stored as hard links, the type of the file is lost.
|
|||
Not allowing data in hard links also prevents invalid actions like
|
||||
extracting file data for a hard link to a symbolic link or to a directory.
|
||||
|
||||
|
||||
5.6 Avoid misconversions to/from UTF-8
|
||||
6.6 Avoid misconversions to/from UTF-8
|
||||
======================================
|
||||
|
||||
There is no portable way to tell what charset a text string is coded into.
|
||||
|
@ -935,7 +973,7 @@ be adjusted with a command-line option in the future.
|
|||
|
||||
File: tarlz.info, Node: Program design, Next: Multi-threaded decoding, Prev: Amendments to pax format, Up: Top
|
||||
|
||||
6 Internal structure of tarlz
|
||||
7 Internal structure of tarlz
|
||||
*****************************
|
||||
|
||||
The parts of tarlz related to sequential processing of the archive are more
|
||||
|
@ -947,7 +985,7 @@ processing.
|
|||
creation is somewhat similar to that of plzip with the added complication
|
||||
of the solidity levels. *Note Program design: (plzip)Program design. A
|
||||
grouper thread and several worker threads are created, acting the main
|
||||
thread as muxer (multiplexer) thread. A "packet courier" takes care of data
|
||||
thread as muxer (multiplexer) thread. A 'packet courier' takes care of data
|
||||
transfers among threads and limits the maximum number of data blocks
|
||||
(packets) being processed simultaneously.
|
||||
|
||||
|
@ -993,8 +1031,8 @@ the archive.
|
|||
|
||||
As misaligned tar.lz archives can't be decoded in parallel, and the
|
||||
misalignment can't be detected until after decoding has started, a
|
||||
"mastership request" mechanism has been designed that allows the decoding to
|
||||
continue instead of signalling an error.
|
||||
'mastership request' mechanism has been designed that allows the decoding to
|
||||
continue instead of exiting with an error.
|
||||
|
||||
During parallel decoding, if a worker finds a misalignment, it requests
|
||||
mastership to decode the rest of the archive. When mastership is requested,
|
||||
|
@ -1015,15 +1053,15 @@ error be avoided.
|
|||
|
||||
File: tarlz.info, Node: Multi-threaded decoding, Next: Minimum archive sizes, Prev: Program design, Up: Top
|
||||
|
||||
7 Limitations of parallel tar decoding
|
||||
8 Limitations of parallel tar decoding
|
||||
**************************************
|
||||
|
||||
Safely decoding an arbitrary tar archive in parallel is only possible if one
|
||||
decodes the headers sequentially first. For example, if a tar archive
|
||||
containing another tar archive is decoded starting from some position other
|
||||
than the beginning, there is no way to know if the first header found there
|
||||
belongs to the outer tar archive or to the inner tar archive. Tar is a
|
||||
format inherently serial; it was designed for tapes.
|
||||
Safely decoding a tar archive in parallel is only possible if one decodes
|
||||
the headers sequentially first. For example, if a tar archive containing
|
||||
another tar archive is decoded starting from some position other than the
|
||||
beginning, there is no way to know if the first header found there belongs
|
||||
to the outer tar archive or to the inner tar archive. Tar is a format
|
||||
inherently serial; it was designed for tapes.
|
||||
|
||||
The pax format is even more serial than the ustar format. Two headers
|
||||
need to be decoded sequentially for each file. The extended header may even
|
||||
|
@ -1071,8 +1109,7 @@ the tar member data because it only decodes the part of each lzip member
|
|||
corresponding to the tar member header. This is another reason why the tar
|
||||
headers must provide their own integrity checking.
|
||||
|
||||
|
||||
7.1 Limitations of multi-threaded extraction
|
||||
8.1 Limitations of multi-threaded extraction
|
||||
============================================
|
||||
|
||||
Multi-threaded extraction may produce different output than single-threaded
|
||||
|
@ -1102,7 +1139,7 @@ links to.
|
|||
|
||||
File: tarlz.info, Node: Minimum archive sizes, Next: Examples, Prev: Multi-threaded decoding, Up: Top
|
||||
|
||||
8 Minimum archive sizes required for multi-threaded block compression
|
||||
9 Minimum archive sizes required for multi-threaded block compression
|
||||
*********************************************************************
|
||||
|
||||
When creating or appending to a compressed archive using multi-threaded
|
||||
|
@ -1140,21 +1177,19 @@ Level
|
|||
|
||||
File: tarlz.info, Node: Examples, Next: Problems, Prev: Minimum archive sizes, Up: Top
|
||||
|
||||
9 A small tutorial with examples
|
||||
********************************
|
||||
10 A small tutorial with examples
|
||||
*********************************
|
||||
|
||||
Example 1: Create a multimember compressed archive 'archive.tar.lz'
|
||||
containing files 'a', 'b' and 'c'.
|
||||
|
||||
tarlz -cf archive.tar.lz a b c
|
||||
|
||||
|
||||
Example 2: Append files 'd' and 'e' to the multimember compressed archive
|
||||
'archive.tar.lz'.
|
||||
|
||||
tarlz -rf archive.tar.lz d e
|
||||
|
||||
|
||||
Example 3: Create a solidly compressed appendable archive 'archive.tar.lz'
|
||||
containing files 'a', 'b' and 'c'. Then append files 'd' and 'e' to the
|
||||
archive.
|
||||
|
@ -1162,7 +1197,6 @@ archive.
|
|||
tarlz --asolid -cf archive.tar.lz a b c
|
||||
tarlz --asolid -rf archive.tar.lz d e
|
||||
|
||||
|
||||
Example 4: Create a compressed appendable archive containing directories
|
||||
'dir1', 'dir2' and 'dir3' with a separate lzip member per directory. Then
|
||||
append files 'a', 'b', 'c', 'd' and 'e' to the archive, all of them
|
||||
|
@ -1172,31 +1206,26 @@ contains 5 lzip members (including the end-of-archive member).
|
|||
tarlz --dsolid -cf archive.tar.lz dir1 dir2 dir3
|
||||
tarlz --asolid -rf archive.tar.lz a b c d e
|
||||
|
||||
|
||||
Example 5: Create a solidly compressed archive 'archive.tar.lz' containing
|
||||
files 'a', 'b' and 'c'. Note that no more files can be later appended to
|
||||
the archive.
|
||||
|
||||
tarlz --solid -cf archive.tar.lz a b c
|
||||
|
||||
|
||||
Example 6: Extract all files from archive 'archive.tar.lz'.
|
||||
|
||||
tarlz -xf archive.tar.lz
|
||||
|
||||
|
||||
Example 7: Extract files 'a' and 'c', and the whole tree under directory
|
||||
'dir1' from archive 'archive.tar.lz'.
|
||||
|
||||
tarlz -xf archive.tar.lz a c dir1
|
||||
|
||||
|
||||
Example 8: Copy the contents of directory 'sourcedir' to the directory
|
||||
'destdir'.
|
||||
|
||||
tarlz -C sourcedir --uncompressed -cf - . | tarlz -C destdir -xf -
|
||||
|
||||
|
||||
Example 9: Compress the existing POSIX archive 'archive.tar' and write the
|
||||
output to 'archive.tar.lz'. Compress each member individually for maximum
|
||||
availability. (If one member in the compressed archive gets damaged, the
|
||||
|
@ -1204,13 +1233,11 @@ other members can still be extracted).
|
|||
|
||||
tarlz -z --no-solid archive.tar
|
||||
|
||||
|
||||
Example 10: Compress the archive 'archive.tar' and write the output to
|
||||
'foo.tar.lz'.
|
||||
|
||||
tarlz -z -o foo.tar.lz archive.tar
|
||||
|
||||
|
||||
Example 11: Concatenate and compress two archives 'archive1.tar' and
|
||||
'archive2.tar', and write the output to 'foo.tar.lz'.
|
||||
|
||||
|
@ -1219,7 +1246,7 @@ Example 11: Concatenate and compress two archives 'archive1.tar' and
|
|||
|
||||
File: tarlz.info, Node: Problems, Next: Concept index, Prev: Examples, Up: Top
|
||||
|
||||
10 Reporting bugs
|
||||
11 Reporting bugs
|
||||
*****************
|
||||
|
||||
There are probably bugs in tarlz. There are certainly errors and omissions
|
||||
|
@ -1241,6 +1268,7 @@ Concept index
|
|||
* Menu:
|
||||
|
||||
* Amendments to pax format: Amendments to pax format. (line 6)
|
||||
* argument syntax: Argument syntax. (line 6)
|
||||
* bugs: Problems. (line 6)
|
||||
* examples: Examples. (line 6)
|
||||
* file format: File format. (line 6)
|
||||
|
@ -1259,25 +1287,26 @@ Concept index
|
|||
|
||||
Tag Table:
|
||||
Node: Top216
|
||||
Node: Introduction1207
|
||||
Node: Invoking tarlz4032
|
||||
Ref: --data-size13076
|
||||
Ref: --bsolid17512
|
||||
Node: Portable character set23425
|
||||
Node: File format24068
|
||||
Ref: key_crc3231050
|
||||
Ref: ustar-uid-gid34315
|
||||
Ref: ustar-mtime35122
|
||||
Node: Amendments to pax format37125
|
||||
Ref: crc3237834
|
||||
Ref: flawed-compat39146
|
||||
Node: Program design43228
|
||||
Node: Multi-threaded decoding47153
|
||||
Ref: mt-extraction50434
|
||||
Node: Minimum archive sizes51740
|
||||
Node: Examples53867
|
||||
Node: Problems56234
|
||||
Node: Concept index56789
|
||||
Node: Introduction1281
|
||||
Node: Invoking tarlz4106
|
||||
Ref: --data-size13109
|
||||
Ref: --bsolid17626
|
||||
Node: Argument syntax23539
|
||||
Node: Portable character set25314
|
||||
Node: File format25958
|
||||
Ref: key_crc3233001
|
||||
Ref: ustar-uid-gid36305
|
||||
Ref: ustar-mtime37112
|
||||
Node: Amendments to pax format39115
|
||||
Ref: crc3239823
|
||||
Ref: flawed-compat41134
|
||||
Node: Program design45211
|
||||
Node: Multi-threaded decoding49138
|
||||
Ref: mt-extraction52407
|
||||
Node: Minimum archive sizes53713
|
||||
Node: Examples55840
|
||||
Node: Problems58199
|
||||
Node: Concept index58754
|
||||
|
||||
End Tag Table
|
||||
|
||||
|
|
220
doc/tarlz.texi
220
doc/tarlz.texi
|
@ -6,8 +6,8 @@
|
|||
@finalout
|
||||
@c %**end of header
|
||||
|
||||
@set UPDATED 3 January 2024
|
||||
@set VERSION 0.25
|
||||
@set UPDATED 7 December 2024
|
||||
@set VERSION 0.26
|
||||
|
||||
@dircategory Archiving
|
||||
@direntry
|
||||
|
@ -38,6 +38,7 @@ This manual is for Tarlz (version @value{VERSION}, @value{UPDATED}).
|
|||
@menu
|
||||
* Introduction:: Purpose and features of tarlz
|
||||
* Invoking tarlz:: Command-line interface
|
||||
* Argument syntax:: By convention, options start with a hyphen
|
||||
* Portable character set:: POSIX portable filename character set
|
||||
* File format:: Detailed format of the compressed archive
|
||||
* Amendments to pax format:: The reasons for the differences with pax
|
||||
|
@ -150,21 +151,22 @@ Tarlz does not use absolute file names nor file names above the current
|
|||
working directory (perhaps changed by option @option{-C}). On archive creation
|
||||
or appending tarlz archives the files specified, but removes from member
|
||||
names any leading and trailing slashes and any file name prefixes containing
|
||||
a @samp{..} component. On extraction, leading and trailing slashes are also
|
||||
removed from member names, and archive members containing a @samp{..}
|
||||
a @file{..} component. On extraction, leading and trailing slashes are also
|
||||
removed from member names, and archive members containing a @file{..}
|
||||
component in the file name are skipped. Tarlz does not follow symbolic links
|
||||
during extraction; not even symbolic links replacing intermediate
|
||||
directories.
|
||||
|
||||
On extraction and listing, tarlz removes leading @samp{./} strings from
|
||||
On extraction and listing, tarlz removes leading @file{./} strings from
|
||||
member names in the archive or given in the command line, so that
|
||||
@w{@samp{tarlz -xf foo ./bar baz}} extracts members @samp{bar} and
|
||||
@samp{./baz} from archive @samp{foo}.
|
||||
@w{@samp{tarlz -xf foo ./bar baz}} extracts members @file{bar} and
|
||||
@file{./baz} from archive @file{foo}.
|
||||
|
||||
If several compression levels or @option{--*solid} options are given, the last
|
||||
setting is used. For example @w{@option{-9 --solid --uncompressed -1}} is
|
||||
equivalent to @w{@option{-1 --solid}}.
|
||||
|
||||
@noindent
|
||||
tarlz supports the following operations:
|
||||
|
||||
@table @code
|
||||
|
@ -277,7 +279,7 @@ standard output (unless the option @option{--output} is used). Tarlz can be
|
|||
used as compressor for GNU tar by using a command like
|
||||
@w{@samp{tar -c -Hustar foo | tarlz -z -o foo.tar.lz}}. Tarlz can be used as
|
||||
compressor for zupdate (zutils) by using a command like
|
||||
@w{@samp{zupdate --lz="tarlz -z" foo.tar.gz}}. Note that tarlz only works
|
||||
@w{@samp{zupdate --lz='tarlz -z' foo.tar.gz}}. Note that tarlz only works
|
||||
reliably on archives without global headers, or with global headers whose
|
||||
content can be ignored.
|
||||
|
||||
|
@ -285,10 +287,10 @@ The compression is reversible, including any garbage present after the
|
|||
end-of-archive blocks. Tarlz stops parsing after the first end-of-archive
|
||||
block is found, and then compresses the rest of the archive. Unless solid
|
||||
compression is requested, the end-of-archive blocks are compressed in a lzip
|
||||
member separated from the preceding members and from any non-zero garbage
|
||||
member separated from the preceding members and from any nonzero garbage
|
||||
following the end-of-archive blocks. @option{--compress} implies plzip
|
||||
argument style, not tar style. Each input archive is compressed to a file
|
||||
with the extension @samp{.lz} added unless the option @option{--output} is
|
||||
with the extension @file{.lz} added unless the option @option{--output} is
|
||||
used. When @option{--output} is used, only one input archive can be specified.
|
||||
@option{-f} can't be used with @option{--compress}.
|
||||
|
||||
|
@ -308,11 +310,8 @@ and the value of LZ_API_VERSION (if defined).
|
|||
|
||||
@end table
|
||||
|
||||
tarlz supports the following
|
||||
@uref{http://www.nongnu.org/arg-parser/manual/arg_parser_manual.html#Argument-syntax,,options}:
|
||||
@ifnothtml
|
||||
@xref{Argument syntax,,,arg_parser}.
|
||||
@end ifnothtml
|
||||
@noindent
|
||||
tarlz supports the following options: @xref{Argument syntax}.
|
||||
|
||||
@table @code
|
||||
@anchor{--data-size}
|
||||
|
@ -326,17 +325,17 @@ defaults to @w{1 MiB}. @xref{Minimum archive sizes}.
|
|||
@item -C @var{dir}
|
||||
@itemx --directory=@var{dir}
|
||||
Change to directory @var{dir}. When creating, appending, comparing, or
|
||||
extracting, the position of each @option{-C} option in the command line is
|
||||
extracting, the position of each option @option{-C} in the command line is
|
||||
significant; it changes the current working directory for the following
|
||||
@var{files} until a new @option{-C} option appears in the command line.
|
||||
@option{--list} and @option{--delete} ignore any @option{-C} options
|
||||
@var{files} until a new option @option{-C} appears in the command line.
|
||||
@option{--list} and @option{--delete} ignore any option @option{-C}
|
||||
specified. @var{dir} is relative to the then current working directory,
|
||||
perhaps changed by a previous @option{-C} option.
|
||||
perhaps changed by a previous option @option{-C}.
|
||||
|
||||
Note that a process can only have one current working directory (CWD).
|
||||
Therefore multi-threading can't be used to create or decode an archive if a
|
||||
@option{-C} option appears after a (relative) file name in the command line.
|
||||
(All file names are made relative when decoding).
|
||||
Therefore multi-threading can't be used to create or decode an archive if an
|
||||
option @option{-C} appears after a (relative) file name in the command line.
|
||||
(All file names are made relative by removing leading slashes when decoding).
|
||||
|
||||
@item -f @var{archive}
|
||||
@itemx --file=@var{archive}
|
||||
|
@ -351,7 +350,7 @@ Archive or compare the files they point to instead of the links themselves.
|
|||
@item -n @var{n}
|
||||
@itemx --threads=@var{n}
|
||||
Set the number of (de)compression threads, overriding the system's default.
|
||||
Valid values range from 0 to "as many as your system can support". A value
|
||||
Valid values range from 0 to as many as your system can support. A value
|
||||
of 0 disables threads entirely. If this option is not used, tarlz tries to
|
||||
detect the number of processors in the system and use it as default value.
|
||||
@w{@samp{tarlz --help}} shows the system's default value. See the note about
|
||||
|
@ -391,7 +390,7 @@ tarlz also minimizes the dictionary size of the lzip members it creates,
|
|||
reducing the amount of memory required for decompression.
|
||||
|
||||
@multitable {Level} {Dictionary size} {Match length limit}
|
||||
@item Level @tab Dictionary size @tab Match length limit
|
||||
@headitem Level @tab Dictionary size @tab Match length limit
|
||||
@item -0 @tab 64 KiB @tab 16 bytes
|
||||
@item -1 @tab 1 MiB @tab 5 bytes
|
||||
@item -2 @tab 1.5 MiB @tab 6 bytes
|
||||
|
@ -410,7 +409,7 @@ uncompressed tar archive instead. With @option{--append}, don't compress the
|
|||
new members appended to the tar archive. Compressed members can't be
|
||||
appended to an uncompressed archive, nor vice versa. @option{--uncompressed}
|
||||
can be omitted if it can be deduced from the archive name. (An uncompressed
|
||||
archive name lacks a @samp{.lz} or @samp{.tlz} extension).
|
||||
archive name lacks a @file{.lz} or @file{.tlz} extension).
|
||||
|
||||
@item --asolid
|
||||
When creating or appending to a compressed archive, use appendable solid
|
||||
|
@ -466,11 +465,11 @@ If @var{group} is not a valid group name, it is decoded as a decimal numeric
|
|||
group ID.
|
||||
|
||||
@item --exclude=@var{pattern}
|
||||
Exclude files matching a shell pattern like @samp{*.o}. A file is considered
|
||||
to match if any component of the file name matches. For example, @samp{*.o}
|
||||
matches @samp{foo.o}, @samp{foo.o/bar} and @samp{foo/bar.o}. If
|
||||
Exclude files matching a shell pattern like @file{*.o}. A file is considered
|
||||
to match if any component of the file name matches. For example, @file{*.o}
|
||||
matches @file{foo.o}, @file{foo.o/bar} and @file{foo/bar.o}. If
|
||||
@var{pattern} contains a @samp{/}, it matches a corresponding @samp{/} in
|
||||
the file name. For example, @samp{foo/*.o} matches @samp{foo/bar.o}.
|
||||
the file name. For example, @file{foo/*.o} matches @file{foo/bar.o}.
|
||||
Multiple @option{--exclude} options can be specified.
|
||||
|
||||
@item --ignore-ids
|
||||
|
@ -545,6 +544,53 @@ etc), 2 to indicate a corrupt or invalid input file, 3 for an internal
|
|||
consistency error (e.g., bug) which caused tarlz to panic.
|
||||
|
||||
|
||||
@node Argument syntax
|
||||
@chapter Syntax of command-line arguments
|
||||
@cindex argument syntax
|
||||
|
||||
POSIX recommends these conventions for command-line arguments.
|
||||
|
||||
@itemize @bullet
|
||||
@item A command-line argument is an option if it begins with a hyphen
|
||||
(@samp{-}).
|
||||
|
||||
@item Option names are single alphanumeric characters.
|
||||
|
||||
@item Certain options require an argument.
|
||||
|
||||
@item An option and its argument may or may not appear as separate tokens.
|
||||
(In other words, the whitespace separating them is optional).
|
||||
Thus, @w{@option{-o foo}} and @option{-ofoo} are equivalent.
|
||||
|
||||
@item One or more options without arguments, followed by at most one option
|
||||
that takes an argument, may follow a hyphen in a single token.
|
||||
Thus, @option{-abc} is equivalent to @w{@option{-a -b -c}}.
|
||||
|
||||
@item Options typically precede other non-option arguments.
|
||||
|
||||
@item The argument @samp{--} terminates all options; any following arguments
|
||||
are treated as non-option arguments, even if they begin with a hyphen.
|
||||
|
||||
@item A token consisting of a single hyphen character is interpreted as an
|
||||
ordinary non-option argument. By convention, it is used to specify standard
|
||||
input, standard output, or a file named @samp{-}.
|
||||
@end itemize
|
||||
|
||||
@noindent
|
||||
GNU adds @dfn{long options} to these conventions:
|
||||
|
||||
@itemize @bullet
|
||||
@item A long option consists of two hyphens (@samp{--}) followed by a name
|
||||
made of alphanumeric characters and hyphens. Option names are typically one
|
||||
to three words long, with hyphens to separate words. Abbreviations can be
|
||||
used for the long option names as long as the abbreviations are unique.
|
||||
|
||||
@item A long option and its argument may or may not appear as separate
|
||||
tokens. In the latter case they must be separated by an equal sign @samp{=}.
|
||||
Thus, @w{@option{--foo bar}} and @option{--foo=bar} are equivalent.
|
||||
@end itemize
|
||||
|
||||
|
||||
@node Portable character set
|
||||
@chapter POSIX portable filename character set
|
||||
@cindex portable character set
|
||||
|
@ -587,10 +633,11 @@ represents one byte; a box like this:
|
|||
represents a variable number of bytes or a fixed but large number of
|
||||
bytes (for example 512).
|
||||
|
||||
@sp 1
|
||||
@noindent
|
||||
A tar.lz file consists of one or more lzip members (compressed data sets).
|
||||
The members simply appear one after another in the file, with no additional
|
||||
information before, between, or after them.
|
||||
information before, between, or after them. Empty members (data size = 0)
|
||||
are not allowed in multimember files.
|
||||
|
||||
Each lzip member contains one or more tar members in a simplified POSIX pax
|
||||
interchange format. The only pax typeflag value supported by tarlz (in
|
||||
|
@ -628,7 +675,7 @@ binary zeros, interpreted as an end-of-archive indicator. These EOA blocks
|
|||
are either compressed in a separate lzip member or compressed along with the
|
||||
tar members contained in the last lzip member. For a compressed archive to
|
||||
be recognized by tarlz as appendable, the last lzip member must contain
|
||||
between 512 and 32256 zeros alone (without any non-zero bytes).
|
||||
between 512 and 32256 zeros alone (without any nonzero bytes).
|
||||
|
||||
The diagram below shows the correspondence between each tar member (formed
|
||||
by one or two headers plus optional data) in the tar archive and each
|
||||
|
@ -652,25 +699,24 @@ tar.lz
|
|||
@end verbatim
|
||||
|
||||
@ignore
|
||||
When @option{--permissive} is used, the following violations of the
|
||||
archive format are allowed:@*
|
||||
If several extended headers precede an ustar header, only the last
|
||||
extended header takes effect. The other extended headers are ignored.
|
||||
Similarly, if several records with the same keyword appear in the same
|
||||
block of extended records, only the last record for the repeated keyword
|
||||
takes effect. The other records for the repeated keyword are ignored.@*
|
||||
A global header inserted between an extended header and an ustar header.@*
|
||||
When @option{--permissive} is used, the following violations of the archive
|
||||
format are allowed:@*
|
||||
If several extended headers precede a ustar header, only the last extended
|
||||
header takes effect. The other extended headers are ignored. Similarly, if
|
||||
several records with the same keyword appear in the same block of extended
|
||||
records, only the last record for the repeated keyword takes effect. The
|
||||
other records for the repeated keyword are ignored.@*
|
||||
A global header inserted between an extended header and a ustar header.@*
|
||||
An extended header just before the end-of-archive blocks.
|
||||
@end ignore
|
||||
|
||||
@sp 1
|
||||
@section Pax header block
|
||||
|
||||
The pax header block is identical to the ustar header block described below
|
||||
except that the typeflag has the value @samp{x} (extended). The field
|
||||
@samp{size} is the size of the extended header data in bytes. Most other
|
||||
fields in the pax header block are zeroed on archive creation to prevent
|
||||
trouble if the archive is read by an ustar tool, and are ignored by tarlz on
|
||||
trouble if the archive is read by a ustar tool, and are ignored by tarlz on
|
||||
archive extraction. @xref{flawed-compat}.
|
||||
|
||||
Tarlz limits the size of the pax extended header data so that the whole
|
||||
|
@ -756,14 +802,13 @@ swapping of two bytes.
|
|||
At verbosity level 1 or higher tarlz prints a diagnostic for each unknown
|
||||
extended header keyword found in an archive, once per keyword.
|
||||
|
||||
@sp 1
|
||||
@section Ustar header block
|
||||
|
||||
The ustar header block has a length of 512 bytes and is structured as
|
||||
shown in the following table. All lengths and offsets are in decimal.
|
||||
shown in the following table. All lengths and offsets are in decimal:
|
||||
|
||||
@multitable {Field Name} {Offset} {Length (in bytes)}
|
||||
@item Field Name @tab Offset @tab Length (in bytes)
|
||||
@headitem Field Name @tab Offset @tab Length (in bytes)
|
||||
@item name @tab 0 @tab 100
|
||||
@item mode @tab 100 @tab 8
|
||||
@item uid @tab 108 @tab 8
|
||||
|
@ -901,7 +946,6 @@ In order to achieve this goal and avoid some other flaws in the pax format,
|
|||
tarlz makes some changes to the variant of the pax format that it uses. This
|
||||
chapter describes these changes and the concrete reasons to implement them.
|
||||
|
||||
@sp 1
|
||||
@anchor{crc32}
|
||||
@section Add a CRC of the extended records
|
||||
|
||||
|
@ -928,7 +972,6 @@ Because of the above, tarlz protects the extended records with a Cyclic
|
|||
Redundancy Check (CRC) in a way compatible with standard tar tools.
|
||||
@xref{key_crc32}.
|
||||
|
||||
@sp 1
|
||||
@anchor{flawed-compat}
|
||||
@section Remove flawed backward compatibility
|
||||
|
||||
|
@ -958,12 +1001,11 @@ extraction.
|
|||
|
||||
If an extended header is required for any reason (for example a file size of
|
||||
@w{8 GiB} or larger, or a link name longer than 100 bytes), tarlz also moves
|
||||
the file name to the extended records to prevent an ustar tool from trying
|
||||
to extract the file or link. This also makes easier during parallel decoding
|
||||
the file name to the extended records to prevent a ustar tool from trying to
|
||||
extract the file or link. This also makes easier during parallel decoding
|
||||
the detection of a tar member split between two lzip members at the boundary
|
||||
between the extended header and the ustar header.
|
||||
|
||||
@sp 1
|
||||
@section As simple as possible (but not simpler)
|
||||
|
||||
The tarlz format is mainly ustar. Extended pax headers are used only when
|
||||
|
@ -978,7 +1020,6 @@ Global pax headers are tolerated, but not supported; they are parsed and
|
|||
ignored. Some operations may not behave as expected if the archive contains
|
||||
global headers.
|
||||
|
||||
@sp 1
|
||||
@section Improve reproducibility
|
||||
|
||||
Pax includes by default the process ID of the pax process in the ustar name
|
||||
|
@ -990,7 +1031,6 @@ Pax allows an extended record to have length x-1 or x if x is a power of
|
|||
ten; @samp{99<97_bytes>} or @samp{100<97_bytes>}. Tarlz minimizes the length
|
||||
of the record and always produces a length of x-1 in these cases.
|
||||
|
||||
@sp 1
|
||||
@section No data in hard links
|
||||
|
||||
Tarlz does not allow data in hard link members. The data (if any) must be in
|
||||
|
@ -999,7 +1039,6 @@ the names of a file are stored as hard links, the type of the file is lost.
|
|||
Not allowing data in hard links also prevents invalid actions like
|
||||
extracting file data for a hard link to a symbolic link or to a directory.
|
||||
|
||||
@sp 1
|
||||
@section Avoid misconversions to/from UTF-8
|
||||
|
||||
There is no portable way to tell what charset a text string is coded into.
|
||||
|
@ -1025,7 +1064,7 @@ added complication of the solidity levels.
|
|||
@xref{Program design,,,plzip}.
|
||||
@end ifnothtml
|
||||
A grouper thread and several worker threads are created, acting the main
|
||||
thread as muxer (multiplexer) thread. A "packet courier" takes care of data
|
||||
thread as muxer (multiplexer) thread. A 'packet courier' takes care of data
|
||||
transfers among threads and limits the maximum number of data blocks
|
||||
(packets) being processed simultaneously.
|
||||
|
||||
|
@ -1074,8 +1113,8 @@ access files in the file system either to read them (diff) or write them
|
|||
|
||||
As misaligned tar.lz archives can't be decoded in parallel, and the
|
||||
misalignment can't be detected until after decoding has started, a
|
||||
"mastership request" mechanism has been designed that allows the decoding to
|
||||
continue instead of signalling an error.
|
||||
'mastership request' mechanism has been designed that allows the decoding to
|
||||
continue instead of exiting with an error.
|
||||
|
||||
During parallel decoding, if a worker finds a misalignment, it requests
|
||||
mastership to decode the rest of the archive. When mastership is requested,
|
||||
|
@ -1098,12 +1137,12 @@ error be avoided.
|
|||
@chapter Limitations of parallel tar decoding
|
||||
@cindex parallel tar decoding
|
||||
|
||||
Safely decoding an arbitrary tar archive in parallel is only possible if one
|
||||
decodes the headers sequentially first. For example, if a tar archive
|
||||
containing another tar archive is decoded starting from some position other
|
||||
than the beginning, there is no way to know if the first header found there
|
||||
belongs to the outer tar archive or to the inner tar archive. Tar is a
|
||||
format inherently serial; it was designed for tapes.
|
||||
Safely decoding a tar archive in parallel is only possible if one decodes
|
||||
the headers sequentially first. For example, if a tar archive containing
|
||||
another tar archive is decoded starting from some position other than the
|
||||
beginning, there is no way to know if the first header found there belongs
|
||||
to the outer tar archive or to the inner tar archive. Tar is a format
|
||||
inherently serial; it was designed for tapes.
|
||||
|
||||
The pax format is even more serial than the ustar format. Two headers need
|
||||
to be decoded sequentially for each file. The extended header may even need
|
||||
|
@ -1153,7 +1192,6 @@ the tar member data because it only decodes the part of each lzip member
|
|||
corresponding to the tar member header. This is another reason why the tar
|
||||
headers must provide their own integrity checking.
|
||||
|
||||
@sp 1
|
||||
@anchor{mt-extraction}
|
||||
@section Limitations of multi-threaded extraction
|
||||
|
||||
|
@ -1225,40 +1263,37 @@ data size for each level:
|
|||
@cindex examples
|
||||
|
||||
@noindent
|
||||
Example 1: Create a multimember compressed archive @samp{archive.tar.lz}
|
||||
containing files @samp{a}, @samp{b} and @samp{c}.
|
||||
Example 1: Create a multimember compressed archive @file{archive.tar.lz}
|
||||
containing files @file{a}, @file{b} and @file{c}.
|
||||
|
||||
@example
|
||||
tarlz -cf archive.tar.lz a b c
|
||||
@end example
|
||||
|
||||
@sp 1
|
||||
@noindent
|
||||
Example 2: Append files @samp{d} and @samp{e} to the multimember compressed
|
||||
archive @samp{archive.tar.lz}.
|
||||
Example 2: Append files @file{d} and @file{e} to the multimember compressed
|
||||
archive @file{archive.tar.lz}.
|
||||
|
||||
@example
|
||||
tarlz -rf archive.tar.lz d e
|
||||
@end example
|
||||
|
||||
@sp 1
|
||||
@noindent
|
||||
Example 3: Create a solidly compressed appendable archive
|
||||
@samp{archive.tar.lz} containing files @samp{a}, @samp{b} and @samp{c}.
|
||||
Then append files @samp{d} and @samp{e} to the archive.
|
||||
@file{archive.tar.lz} containing files @file{a}, @file{b} and @file{c}.
|
||||
Then append files @file{d} and @file{e} to the archive.
|
||||
|
||||
@example
|
||||
tarlz --asolid -cf archive.tar.lz a b c
|
||||
tarlz --asolid -rf archive.tar.lz d e
|
||||
@end example
|
||||
|
||||
@sp 1
|
||||
@noindent
|
||||
Example 4: Create a compressed appendable archive containing directories
|
||||
@samp{dir1}, @samp{dir2} and @samp{dir3} with a separate lzip member per
|
||||
directory. Then append files @samp{a}, @samp{b}, @samp{c}, @samp{d} and
|
||||
@samp{e} to the archive, all of them contained in a single lzip member.
|
||||
The resulting archive @samp{archive.tar.lz} contains 5 lzip members
|
||||
@file{dir1}, @file{dir2} and @file{dir3} with a separate lzip member per
|
||||
directory. Then append files @file{a}, @file{b}, @file{c}, @file{d} and
|
||||
@file{e} to the archive, all of them contained in a single lzip member.
|
||||
The resulting archive @file{archive.tar.lz} contains 5 lzip members
|
||||
(including the end-of-archive member).
|
||||
|
||||
@example
|
||||
|
@ -1266,46 +1301,41 @@ tarlz --dsolid -cf archive.tar.lz dir1 dir2 dir3
|
|||
tarlz --asolid -rf archive.tar.lz a b c d e
|
||||
@end example
|
||||
|
||||
@sp 1
|
||||
@noindent
|
||||
Example 5: Create a solidly compressed archive @samp{archive.tar.lz}
|
||||
containing files @samp{a}, @samp{b} and @samp{c}. Note that no more
|
||||
Example 5: Create a solidly compressed archive @file{archive.tar.lz}
|
||||
containing files @file{a}, @file{b} and @file{c}. Note that no more
|
||||
files can be later appended to the archive.
|
||||
|
||||
@example
|
||||
tarlz --solid -cf archive.tar.lz a b c
|
||||
@end example
|
||||
|
||||
@sp 1
|
||||
@noindent
|
||||
Example 6: Extract all files from archive @samp{archive.tar.lz}.
|
||||
Example 6: Extract all files from archive @file{archive.tar.lz}.
|
||||
|
||||
@example
|
||||
tarlz -xf archive.tar.lz
|
||||
@end example
|
||||
|
||||
@sp 1
|
||||
@noindent
|
||||
Example 7: Extract files @samp{a} and @samp{c}, and the whole tree under
|
||||
directory @samp{dir1} from archive @samp{archive.tar.lz}.
|
||||
Example 7: Extract files @file{a} and @file{c}, and the whole tree under
|
||||
directory @file{dir1} from archive @file{archive.tar.lz}.
|
||||
|
||||
@example
|
||||
tarlz -xf archive.tar.lz a c dir1
|
||||
@end example
|
||||
|
||||
@sp 1
|
||||
@noindent
|
||||
Example 8: Copy the contents of directory @samp{sourcedir} to the directory
|
||||
@samp{destdir}.
|
||||
Example 8: Copy the contents of directory @file{sourcedir} to the directory
|
||||
@file{destdir}.
|
||||
|
||||
@example
|
||||
tarlz -C sourcedir --uncompressed -cf - . | tarlz -C destdir -xf -
|
||||
@end example
|
||||
|
||||
@sp 1
|
||||
@noindent
|
||||
Example 9: Compress the existing POSIX archive @samp{archive.tar} and write
|
||||
the output to @samp{archive.tar.lz}. Compress each member individually for
|
||||
Example 9: Compress the existing POSIX archive @file{archive.tar} and write
|
||||
the output to @file{archive.tar.lz}. Compress each member individually for
|
||||
maximum availability. (If one member in the compressed archive gets damaged,
|
||||
the other members can still be extracted).
|
||||
|
||||
|
@ -1313,19 +1343,17 @@ the other members can still be extracted).
|
|||
tarlz -z --no-solid archive.tar
|
||||
@end example
|
||||
|
||||
@sp 1
|
||||
@noindent
|
||||
Example 10: Compress the archive @samp{archive.tar} and write the output to
|
||||
@samp{foo.tar.lz}.
|
||||
Example 10: Compress the archive @file{archive.tar} and write the output to
|
||||
@file{foo.tar.lz}.
|
||||
|
||||
@example
|
||||
tarlz -z -o foo.tar.lz archive.tar
|
||||
@end example
|
||||
|
||||
@sp 1
|
||||
@noindent
|
||||
Example 11: Concatenate and compress two archives @samp{archive1.tar} and
|
||||
@samp{archive2.tar}, and write the output to @samp{foo.tar.lz}.
|
||||
Example 11: Concatenate and compress two archives @file{archive1.tar} and
|
||||
@file{archive2.tar}, and write the output to @file{foo.tar.lz}.
|
||||
|
||||
@example
|
||||
tarlz -A archive1.tar archive2.tar | tarlz -z -o foo.tar.lz
|
||||
|
|
|
@ -49,9 +49,8 @@ const char * bad_version( const unsigned version )
|
|||
|
||||
bool Lzip_index::check_header( const Lzip_header & header, const bool first )
|
||||
{
|
||||
if( !header.check_magic() )
|
||||
{ error_ = bad_magic_msg; retval_ = 2; if( first ) bad_magic_ = true;
|
||||
return false; }
|
||||
if( header.check_magic() ) { if( first ) good_magic_ = true; }
|
||||
else { error_ = bad_magic_msg; retval_ = 2; return false; }
|
||||
if( !header.check_version() )
|
||||
{ error_ = bad_version( header.version() ); retval_ = 2; return false; }
|
||||
if( !isvalid_ds( header.dictionary_size() ) )
|
||||
|
@ -146,20 +145,20 @@ bool Lzip_index::skip_trailing_data( const int fd, unsigned long long & pos )
|
|||
|
||||
Lzip_index::Lzip_index( const int infd )
|
||||
: insize( lseek( infd, 0, SEEK_END ) ), retval_( 0 ), dictionary_size_( 0 ),
|
||||
bad_magic_( false )
|
||||
good_magic_( false )
|
||||
{
|
||||
if( insize < 0 )
|
||||
{ set_errno_error( "Input file is not seekable: " ); return; }
|
||||
Lzip_header header;
|
||||
if( insize >= header.size &&
|
||||
( !read_header( infd, header, 0 ) ||
|
||||
!check_header( header, true ) ) ) return;
|
||||
if( insize < min_member_size )
|
||||
{ error_ = "Input file is too short."; retval_ = 2; return; }
|
||||
{ error_ = "Input file is truncated."; retval_ = 2; return; }
|
||||
if( insize > INT64_MAX )
|
||||
{ error_ = "Input file is too long (2^63 bytes or more).";
|
||||
retval_ = 2; return; }
|
||||
|
||||
Lzip_header header;
|
||||
if( !read_header( infd, header, 0 ) ||
|
||||
!check_header( header, true ) ) return;
|
||||
|
||||
unsigned long long pos = insize; // always points to a header or to EOF
|
||||
while( pos >= min_member_size )
|
||||
{
|
||||
|
|
12
lzip_index.h
12
lzip_index.h
|
@ -55,7 +55,7 @@ class Lzip_index
|
|||
const long long insize;
|
||||
int retval_;
|
||||
unsigned dictionary_size_; // largest dictionary size in the file
|
||||
bool bad_magic_; // bad magic in first header
|
||||
bool good_magic_; // good magic in first header
|
||||
|
||||
bool check_header( const Lzip_header & header, const bool first );
|
||||
void set_errno_error( const char * const msg );
|
||||
|
@ -70,7 +70,15 @@ public:
|
|||
const std::string & error() const { return error_; }
|
||||
int retval() const { return retval_; }
|
||||
unsigned dictionary_size() const { return dictionary_size_; }
|
||||
bool bad_magic() const { return bad_magic_; }
|
||||
bool good_magic() const { return good_magic_; }
|
||||
|
||||
bool multi_empty() const // multimember file with empty member(s)
|
||||
{
|
||||
if( member_vector.size() > 1 )
|
||||
for( unsigned long i = 0; i < member_vector.size(); ++i )
|
||||
if( member_vector[i].dblock.size() == 0 ) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
long long udata_size() const
|
||||
{ if( member_vector.empty() ) return 0;
|
||||
|
|
34
main.cc
34
main.cc
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <cctype>
|
||||
#include <cerrno>
|
||||
#include <climits> // CHAR_BIT
|
||||
#include <cstdarg>
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
|
@ -140,14 +141,28 @@ void show_help( const long num_online )
|
|||
}
|
||||
|
||||
|
||||
void show_lzlib_version()
|
||||
{
|
||||
std::printf( "Using lzlib %s\n", LZ_version() );
|
||||
#if !defined LZ_API_VERSION
|
||||
std::fputs( "LZ_API_VERSION is not defined.\n", stdout );
|
||||
#elif LZ_API_VERSION >= 1012
|
||||
std::printf( "Using LZ_API_VERSION = %u\n", LZ_api_version() );
|
||||
#else
|
||||
std::printf( "Compiled with LZ_API_VERSION = %u. "
|
||||
"Using an unknown LZ_API_VERSION\n", LZ_API_VERSION );
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void show_version()
|
||||
{
|
||||
std::printf( "%s %s\n", program_name, PROGVERSION );
|
||||
std::printf( "Copyright (C) %s Antonio Diaz Diaz.\n", program_year );
|
||||
std::printf( "Using lzlib %s\n", LZ_version() );
|
||||
std::printf( "License GPLv2+: GNU GPL version 2 or later <http://gnu.org/licenses/gpl.html>\n"
|
||||
"This is free software: you are free to change and redistribute it.\n"
|
||||
"There is NO WARRANTY, to the extent permitted by law.\n" );
|
||||
show_lzlib_version();
|
||||
}
|
||||
|
||||
|
||||
|
@ -193,18 +208,7 @@ int check_lib()
|
|||
std::printf( "warning: LZ_API_VERSION != LZ_api_version() (%u vs %u)\n",
|
||||
LZ_API_VERSION, LZ_api_version() ); }
|
||||
#endif
|
||||
if( verbosity >= 1 )
|
||||
{
|
||||
std::printf( "Using lzlib %s\n", LZ_version() );
|
||||
#if !defined LZ_API_VERSION
|
||||
std::fputs( "LZ_API_VERSION is not defined.\n", stdout );
|
||||
#elif LZ_API_VERSION >= 1012
|
||||
std::printf( "Using LZ_API_VERSION = %u\n", LZ_api_version() );
|
||||
#else
|
||||
std::printf( "Compiled with LZ_API_VERSION = %u. "
|
||||
"Using an unknown LZ_API_VERSION\n", LZ_API_VERSION );
|
||||
#endif
|
||||
}
|
||||
if( verbosity >= 1 ) show_lzlib_version();
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -222,7 +226,7 @@ const char * format_num3( long long num )
|
|||
char * p = buf + bufsize - 1; // fill the buffer backwards
|
||||
*p = 0; // terminator
|
||||
const bool negative = num < 0;
|
||||
if( num > 1024 || num < -1024 )
|
||||
if( num > 9999 || num < -9999 )
|
||||
{
|
||||
char prefix = 0; // try binary first, then si
|
||||
for( int i = 0; i < n && num != 0 && num % 1024 == 0; ++i )
|
||||
|
@ -396,7 +400,7 @@ int hstat( const char * const filename, struct stat * const st,
|
|||
|
||||
|
||||
bool nonempty_arg( const Arg_parser & parser, const int i )
|
||||
{ return ( parser.code( i ) == 0 && !parser.argument( i ).empty() ); }
|
||||
{ return parser.code( i ) == 0 && !parser.argument( i ).empty(); }
|
||||
|
||||
|
||||
int open_instream( const std::string & name )
|
||||
|
|
33
tarlz.h
33
tarlz.h
|
@ -81,9 +81,9 @@ inline int decimal_digits( unsigned long long value )
|
|||
|
||||
inline bool dotdot_at_i( const char * const filename, const int i )
|
||||
{
|
||||
return ( filename[i] == '.' && filename[i+1] == '.' &&
|
||||
return filename[i] == '.' && filename[i+1] == '.' &&
|
||||
( i == 0 || filename[i-1] == '/' ) &&
|
||||
( filename[i+2] == 0 || filename[i+2] == '/' ) );
|
||||
( filename[i+2] == 0 || filename[i+2] == '/' );
|
||||
}
|
||||
|
||||
|
||||
|
@ -244,10 +244,10 @@ class CRC32
|
|||
uint32_t data[256]; // Table of CRCs of all 8-bit messages.
|
||||
|
||||
public:
|
||||
CRC32( const bool castagnoli = false )
|
||||
explicit CRC32( const bool castagnoli = false )
|
||||
{
|
||||
const unsigned cpol = 0x82F63B78U; // CRC32-C Castagnoli polynomial.
|
||||
const unsigned ipol = 0xEDB88320U; // IEEE 802.3 Ethernet polynomial.
|
||||
const unsigned cpol = 0x82F63B78U; // CRC32-C Castagnoli polynomial
|
||||
const unsigned ipol = 0xEDB88320U; // IEEE 802.3 Ethernet polynomial
|
||||
const unsigned poly = castagnoli ? cpol : ipol;
|
||||
|
||||
for( unsigned n = 0; n < 256; ++n )
|
||||
|
@ -275,8 +275,7 @@ public:
|
|||
uint32_t compute_crc( const uint8_t * const buffer, const int size ) const
|
||||
{
|
||||
uint32_t crc = 0xFFFFFFFFU;
|
||||
for( int i = 0; i < size; ++i )
|
||||
crc = data[(crc^buffer[i])&0xFF] ^ ( crc >> 8 );
|
||||
update_buf( crc, buffer, size );
|
||||
return crc ^ 0xFFFFFFFFU;
|
||||
}
|
||||
|
||||
|
@ -322,8 +321,8 @@ enum {
|
|||
|
||||
|
||||
inline bool isvalid_ds( const unsigned dictionary_size )
|
||||
{ return ( dictionary_size >= min_dictionary_size &&
|
||||
dictionary_size <= max_dictionary_size ); }
|
||||
{ return dictionary_size >= min_dictionary_size &&
|
||||
dictionary_size <= max_dictionary_size; }
|
||||
|
||||
|
||||
const uint8_t lzip_magic[4] = { 0x4C, 0x5A, 0x49, 0x50 }; // "LZIP"
|
||||
|
@ -335,14 +334,13 @@ struct Lzip_header
|
|||
// 4 version
|
||||
// 5 coded dictionary size
|
||||
|
||||
bool check_magic() const
|
||||
{ return ( std::memcmp( data, lzip_magic, 4 ) == 0 ); }
|
||||
bool check_magic() const { return std::memcmp( data, lzip_magic, 4 ) == 0; }
|
||||
|
||||
bool check_prefix( const int sz ) const // detect (truncated) header
|
||||
{
|
||||
for( int i = 0; i < sz && i < 4; ++i )
|
||||
if( data[i] != lzip_magic[i] ) return false;
|
||||
return ( sz > 0 );
|
||||
return sz > 0;
|
||||
}
|
||||
|
||||
bool check_corrupt() const // detect corrupt header
|
||||
|
@ -350,15 +348,15 @@ struct Lzip_header
|
|||
int matches = 0;
|
||||
for( int i = 0; i < 4; ++i )
|
||||
if( data[i] == lzip_magic[i] ) ++matches;
|
||||
return ( matches > 1 && matches < 4 );
|
||||
return matches > 1 && matches < 4;
|
||||
}
|
||||
|
||||
uint8_t version() const { return data[4]; }
|
||||
bool check_version() const { return ( data[4] == 1 ); }
|
||||
bool check_version() const { return data[4] == 1; }
|
||||
|
||||
unsigned dictionary_size() const
|
||||
{
|
||||
unsigned sz = ( 1 << ( data[5] & 0x1F ) );
|
||||
unsigned sz = 1 << ( data[5] & 0x1F );
|
||||
if( sz > min_dictionary_size )
|
||||
sz -= ( sz / 16 ) * ( ( data[5] >> 5 ) & 7 );
|
||||
return sz;
|
||||
|
@ -488,7 +486,7 @@ const char * const eclosa_msg = "Error closing archive";
|
|||
const char * const eclosf_msg = "Error closing file";
|
||||
const char * const nfound_msg = "Not found in archive.";
|
||||
const char * const seek_msg = "Seek error";
|
||||
const char * const werr_msg = "Write error";
|
||||
const char * const wr_err_msg = "Write error";
|
||||
const char * const chdir_msg = "Error changing working directory";
|
||||
const char * const intdir_msg = "Failed to create intermediate directory";
|
||||
|
||||
|
@ -521,7 +519,8 @@ void show_atpos_error( const char * const filename, const long long pos,
|
|||
int compress( const Cl_options & cl_opts );
|
||||
|
||||
// defined in create.cc
|
||||
bool copy_file( const int infd, const int outfd, const long long max_size = -1 );
|
||||
bool copy_file( const int infd, const int outfd, const char * const filename,
|
||||
const long long max_size = -1 );
|
||||
bool writeblock_wrapper( const int outfd, const uint8_t * const buffer,
|
||||
const int size );
|
||||
bool write_eoa_records( const int outfd, const bool compressed );
|
||||
|
|
|
@ -34,6 +34,7 @@ in_tar="${testdir}"/test.txt.tar
|
|||
in_tar_lz="${testdir}"/test.txt.tar.lz
|
||||
inbad1="${testdir}"/test_bad1.txt
|
||||
inbad2="${testdir}"/test_bad2.txt
|
||||
em_lz="${testdir}"/em.lz
|
||||
test3="${testdir}"/test3.tar
|
||||
test3_lz="${testdir}"/test3.tar.lz
|
||||
test3dir="${testdir}"/test3_dir.tar
|
||||
|
@ -76,8 +77,8 @@ cyg_symlink() { [ ${lwarnc} = 0 ] &&
|
|||
# tar_in_tlz1.tar.lz: 2 members (test.txt.tar test3.tar) 3 lzip members
|
||||
# tar_in_tlz2.tar.lz: 2 members (test.txt.tar test3.tar) 5 lzip members
|
||||
# ts_in_link.tar.lz: 4 symbolic links (link[1-4]) to / /dir/ dir/ dir(107/)
|
||||
# test_bad1.txt.tar.lz: truncated at offset 6000 (of 7495)
|
||||
# test_bad2.txt.tar.lz: byte at offset 6000 changed from 0x56 to 0x46
|
||||
# test_bad1.txt.tar.lz: truncated at offset 6000 (of 7459)
|
||||
# test_bad2.txt.tar.lz: byte at offset 6000 changed from 0x53 to 0x43
|
||||
# test3.tar[.lz]: 3 members (foo bar baz) + 2 zeroed 512-byte blocks
|
||||
# test3_dir.tar[.lz] like test3.tar but members /dir/foo /dir/bar /dir/baz
|
||||
# test3_dot.tar.lz: 3 times 3 members ./foo ././bar ./././baz
|
||||
|
@ -100,8 +101,6 @@ cyg_symlink() { [ ${lwarnc} = 0 ] &&
|
|||
# test3_eoa3.tar.lz: test3.tar.lz with one zeroed block between foo and bar
|
||||
# test3_eoa4.tar.lz: test3.tar.lz ended by extended header without EOA blocks
|
||||
# test3_eoa5.tar.lz: test3.tar.lz split extended bar member, without EOA blocks
|
||||
# test3_em?.tar.lz: test3.tar.lz with one empty lzip member at each position
|
||||
# test3_em6.tar.lz: test3.tar.lz preceded by four empty lzip members
|
||||
# test3_gh?.tar: test3.tar with global header at each position
|
||||
# test3_gh?.tar.lz: test3.tar.lz with global before bar split in 4 ways
|
||||
# test3_gh5.tar.lz: test3.tar.lz with global in lzip member before foo
|
||||
|
@ -235,9 +234,9 @@ done
|
|||
rm -f out || framework_failure
|
||||
|
||||
# test3 reference files for cmp
|
||||
cat "${testdir}"/rfoo > cfoo || framework_failure
|
||||
cat "${testdir}"/rbar > cbar || framework_failure
|
||||
cat "${testdir}"/rbaz > cbaz || framework_failure
|
||||
cp "${testdir}"/rfoo cfoo || framework_failure
|
||||
cp "${testdir}"/rbar cbar || framework_failure
|
||||
cp "${testdir}"/rbaz cbaz || framework_failure
|
||||
|
||||
# test --list and --extract test3
|
||||
rm -f foo bar baz || framework_failure
|
||||
|
@ -492,9 +491,26 @@ for i in gh1 gh2 gh3 gh4 ; do
|
|||
rm -f foo bar baz out || framework_failure
|
||||
done
|
||||
|
||||
# test --list and --extract with empty lzip members, global headers and
|
||||
# extended tar members split among lzip members
|
||||
for i in em1 em2 em3 em4 em5 em6 gh1 gh2 gh3 gh4 gh5 gh6 sm1 sm2 sm3 sm4 ; do
|
||||
# test --list and --extract with empty lzip member
|
||||
cat "${em_lz}" "${test3_lz}" > test3_em.tar.lz || framework_failure
|
||||
"${TARLZ}" -q -tf test3_em.tar.lz > out
|
||||
[ $? = 2 ] || test_failed $LINENO
|
||||
"${TARLZ}" -tvf - < test3_em.tar.lz > out || test_failed $LINENO
|
||||
diff -u vlist3 out || test_failed $LINENO
|
||||
"${TARLZ}" -q -xf test3_em.tar.lz
|
||||
[ $? = 2 ] || test_failed $LINENO
|
||||
[ ! -e foo ] || test_failed $LINENO
|
||||
[ ! -e bar ] || test_failed $LINENO
|
||||
[ ! -e baz ] || test_failed $LINENO
|
||||
"${TARLZ}" -xf - < test3_em.tar.lz || test_failed $LINENO
|
||||
cmp cfoo foo || test_failed $LINENO
|
||||
cmp cbar bar || test_failed $LINENO
|
||||
cmp cbaz baz || test_failed $LINENO
|
||||
rm -f foo bar baz || framework_failure
|
||||
|
||||
# test --list and --extract with global headers and extended tar members
|
||||
# split among lzip members
|
||||
for i in gh1 gh2 gh3 gh4 gh5 gh6 sm1 sm2 sm3 sm4 ; do
|
||||
for j in 0 2 6 ; do
|
||||
"${TARLZ}" -n$j -tf "${testdir}"/test3_${i}.tar.lz > out ||
|
||||
test_failed $LINENO "$i $j"
|
||||
|
@ -518,14 +534,14 @@ rm -f list3 vlist3 || framework_failure
|
|||
printf "\ntesting --concatenate..."
|
||||
|
||||
# test --concatenate compressed
|
||||
cat "${in}" > out.tar.lz || framework_failure # invalid tar.lz
|
||||
cp "${in}" out.tar.lz || framework_failure # invalid tar.lz
|
||||
"${TARLZ}" -Aqf out.tar.lz "${test3_lz}"
|
||||
[ $? = 2 ] || test_failed $LINENO
|
||||
cat "${in_tar_lz}" > out.tar.lz || framework_failure
|
||||
cp "${in_tar_lz}" out.tar.lz || framework_failure
|
||||
"${TARLZ}" -q --un -Af out.tar.lz "${test3_lz}" # contradictory ext
|
||||
[ $? = 1 ] || test_failed $LINENO
|
||||
cmp "${in_tar_lz}" out.tar.lz || test_failed $LINENO
|
||||
cat "${in_tar_lz}" > out.tar.lz || framework_failure
|
||||
cp "${in_tar_lz}" out.tar.lz || framework_failure
|
||||
"${TARLZ}" -Af out.tar.lz "${test3_lz}" || test_failed $LINENO
|
||||
"${TARLZ}" -xf out.tar.lz || test_failed $LINENO
|
||||
cmp "${in}" test.txt || test_failed $LINENO
|
||||
|
@ -547,12 +563,12 @@ cmp out.tar.lz aout.tar.lz || test_failed $LINENO
|
|||
cmp "${in_tar_lz}" aout.tar.lz || test_failed $LINENO
|
||||
"${TARLZ}" -A "${in_tar_lz}" "${test3_lz}" > aout.tar.lz || test_failed $LINENO
|
||||
cmp out.tar.lz aout.tar.lz || test_failed $LINENO
|
||||
cat "${eoa_lz}" > aout.tar.lz || framework_failure
|
||||
cp "${eoa_lz}" aout.tar.lz || framework_failure
|
||||
"${TARLZ}" -Aqf aout.tar.lz "${in_tar}" # concatenate to empty archive
|
||||
[ $? = 2 ] || test_failed $LINENO
|
||||
"${TARLZ}" -Af aout.tar.lz "${in_tar_lz}" "${test3_lz}" || test_failed $LINENO
|
||||
cmp out.tar.lz aout.tar.lz || test_failed $LINENO
|
||||
cat "${in_tar_lz}" > aout.tar.lz || framework_failure
|
||||
cp "${in_tar_lz}" aout.tar.lz || framework_failure
|
||||
"${TARLZ}" -Aqf aout.tar.lz "${test3_lz}" "${test3}"
|
||||
[ $? = 2 ] || test_failed $LINENO
|
||||
cmp out.tar.lz aout.tar.lz || test_failed $LINENO
|
||||
|
@ -566,14 +582,14 @@ cmp out.tar.lz aout.tar.lz || test_failed $LINENO
|
|||
rm -f out.tar.lz aout.tar.lz || framework_failure
|
||||
|
||||
# test --concatenate uncompressed
|
||||
cat "${in}" > out.tar || framework_failure # invalid tar
|
||||
cp "${in}" out.tar || framework_failure # invalid tar
|
||||
"${TARLZ}" -Aqf out.tar "${test3}"
|
||||
[ $? = 2 ] || test_failed $LINENO
|
||||
cat "${in_tar}" > out.tar || framework_failure
|
||||
cp "${in_tar}" out.tar || framework_failure
|
||||
"${TARLZ}" -q -0 -Af out.tar "${test3}" # contradictory ext
|
||||
[ $? = 1 ] || test_failed $LINENO
|
||||
cmp "${in_tar}" out.tar || test_failed $LINENO
|
||||
cat "${in_tar}" > out.tar || framework_failure
|
||||
cp "${in_tar}" out.tar || framework_failure
|
||||
"${TARLZ}" -Af out.tar "${test3}" || test_failed $LINENO
|
||||
"${TARLZ}" -xf out.tar || test_failed $LINENO
|
||||
cmp "${in}" test.txt || test_failed $LINENO
|
||||
|
@ -595,12 +611,12 @@ cmp out.tar aout.tar || test_failed $LINENO
|
|||
cmp "${in_tar}" aout.tar || test_failed $LINENO
|
||||
"${TARLZ}" -A "${in_tar}" "${test3}" > aout.tar || test_failed $LINENO
|
||||
cmp out.tar aout.tar || test_failed $LINENO
|
||||
cat "${eoa}" > aout.tar || framework_failure # concatenate to empty archive
|
||||
cp "${eoa}" aout.tar || framework_failure # concatenate to empty archive
|
||||
"${TARLZ}" -Aqf aout.tar "${in_tar_lz}"
|
||||
[ $? = 2 ] || test_failed $LINENO
|
||||
"${TARLZ}" -Af aout.tar "${in_tar}" "${test3}" || test_failed $LINENO
|
||||
cmp out.tar aout.tar || test_failed $LINENO
|
||||
cat "${in_tar}" > aout.tar || framework_failure
|
||||
cp "${in_tar}" aout.tar || framework_failure
|
||||
"${TARLZ}" -Aqf aout.tar "${test3}" "${test3_lz}"
|
||||
[ $? = 2 ] || test_failed $LINENO
|
||||
cmp out.tar aout.tar || test_failed $LINENO
|
||||
|
@ -616,13 +632,13 @@ rm -f out.tar aout.tar || framework_failure
|
|||
printf "\ntesting --create..."
|
||||
|
||||
# test --create
|
||||
cat "${in}" > test.txt || framework_failure
|
||||
cp "${in}" test.txt || framework_failure
|
||||
"${TARLZ}" --warn-newer -0 -cf out.tar.lz test.txt || test_failed $LINENO
|
||||
is_compressed out.tar.lz || test_failed $LINENO
|
||||
rm -f test.txt || framework_failure
|
||||
"${TARLZ}" -xf out.tar.lz --missing-crc || test_failed $LINENO
|
||||
cmp "${in}" test.txt || test_failed $LINENO
|
||||
cat "${in}" > test.txt || framework_failure
|
||||
cp "${in}" test.txt || framework_failure
|
||||
"${TARLZ}" --warn-newer --un -cf out.tar test.txt || test_failed $LINENO
|
||||
is_uncompressed out.tar || test_failed $LINENO
|
||||
rm -f test.txt || framework_failure
|
||||
|
@ -630,9 +646,9 @@ rm -f test.txt || framework_failure
|
|||
cmp "${in}" test.txt || test_failed $LINENO
|
||||
rm -f test.txt out.tar out.tar.lz || framework_failure
|
||||
|
||||
cat cfoo > foo || framework_failure
|
||||
cp cfoo foo || framework_failure
|
||||
rm -f bar || framework_failure
|
||||
cat cbaz > baz || framework_failure
|
||||
cp cbaz baz || framework_failure
|
||||
"${TARLZ}" -0 -q -cf out.tar.lz foo bar baz
|
||||
[ $? = 1 ] || test_failed $LINENO
|
||||
rm -f foo bar baz || framework_failure
|
||||
|
@ -648,9 +664,9 @@ rm -f foo bar baz || framework_failure
|
|||
[ ! -e baz ] || test_failed $LINENO
|
||||
rm -f out.tar.lz || framework_failure
|
||||
|
||||
cat cfoo > foo || framework_failure
|
||||
cat cbar > bar || framework_failure
|
||||
cat cbaz > baz || framework_failure
|
||||
cp cfoo foo || framework_failure
|
||||
cp cbar bar || framework_failure
|
||||
cp cbaz baz || framework_failure
|
||||
"${TARLZ}" -0 -cf out.tar.lz foo bar baz --out-slots=1 || test_failed $LINENO
|
||||
"${TARLZ}" -0 -q -cf aout.tar.lz foo bar aout.tar.lz baz || test_failed $LINENO
|
||||
cmp out.tar.lz aout.tar.lz || test_failed $LINENO # test reproducible
|
||||
|
@ -709,9 +725,9 @@ rm -rf dir1 || framework_failure
|
|||
rm -f out.tar.lz aout.tar.lz || framework_failure
|
||||
|
||||
# test --create --exclude
|
||||
cat cfoo > foo || framework_failure
|
||||
cat cbar > bar || framework_failure
|
||||
cat cbaz > baz || framework_failure
|
||||
cp cfoo foo || framework_failure
|
||||
cp cbar bar || framework_failure
|
||||
cp cbaz baz || framework_failure
|
||||
"${TARLZ}" -0 -cf out.tar.lz foo bar baz --exclude 'ba?' || test_failed $LINENO
|
||||
rm -f foo bar baz || framework_failure
|
||||
"${TARLZ}" -xf out.tar.lz || test_failed $LINENO
|
||||
|
@ -719,9 +735,9 @@ cmp cfoo foo || test_failed $LINENO
|
|||
[ ! -e bar ] || test_failed $LINENO
|
||||
[ ! -e baz ] || test_failed $LINENO
|
||||
rm -f out.tar.lz foo bar baz || framework_failure
|
||||
cat cfoo > foo || framework_failure
|
||||
cat cbar > bar || framework_failure
|
||||
cat cbaz > baz || framework_failure
|
||||
cp cfoo foo || framework_failure
|
||||
cp cbar bar || framework_failure
|
||||
cp cbaz baz || framework_failure
|
||||
"${TARLZ}" -cf out.tar foo bar baz --exclude 'ba*' || test_failed $LINENO
|
||||
is_uncompressed out.tar || test_failed $LINENO
|
||||
rm -f foo bar baz || framework_failure
|
||||
|
@ -746,9 +762,14 @@ dates='@-9223372036854775808 @-9223372036854775807
|
|||
2242-03-16T12:56:31 2242-03-16T12:56:32 @8589934591 @8589934592
|
||||
9999-12-31T23:59:58 9999-12-31T23:59:59
|
||||
2147483647-12-31T23:59:59 @9223372036854775807'
|
||||
touch -d 2022-01-05T12:22:13 bar || framework_failure
|
||||
touch -d 2022-01-05T12:22:13 bar >/dev/null 2>&1 ||
|
||||
touch -d '2022-01-05 12:22:13' bar >/dev/null 2>&1 ||
|
||||
touch bar || framework_failure
|
||||
for i in ${dates} @-8Ei '2017-10-01 09:00:00' '2017-10-1 9:0:0' \
|
||||
'2017-10-01 09:00' '2017-10-01 09' 2017-10-01 ./bar ; do
|
||||
# Skip a time stamp $i if it's out of range for this platform,
|
||||
# or if it uses a notation that this platform does not recognize.
|
||||
[ "$i" = "./bar" ] || touch -d "$i" foo >/dev/null 2>&1 || continue
|
||||
touch foo || framework_failure
|
||||
"${TARLZ}" -cf out.tar --mtime="$i" foo || test_failed $LINENO "$i"
|
||||
is_uncompressed out.tar || test_failed $LINENO "$i"
|
||||
|
@ -761,11 +782,7 @@ done
|
|||
rm -f out.tar foo bar || framework_failure
|
||||
|
||||
mkdir dir || framework_failure
|
||||
for i in ${dates} ; do
|
||||
# Skip a time stamp $i if it's out of range for this platform,
|
||||
# of if it uses a notation that this platform does not recognize.
|
||||
touch -d "$i" "dir/f$i" >/dev/null 2>&1 || continue
|
||||
done
|
||||
for i in ${dates} ; do touch -d "$i" "dir/f$i" >/dev/null 2>&1 ; done
|
||||
"${TARLZ}" -cf out.tar dir || test_failed $LINENO
|
||||
is_uncompressed out.tar || test_failed $LINENO
|
||||
"${TARLZ}" -df out.tar || test_failed $LINENO
|
||||
|
@ -814,14 +831,14 @@ rm -f out.tar aout.tar foo bar baz || framework_failure
|
|||
printf "\ntesting --delete..."
|
||||
|
||||
# test --delete
|
||||
cat "${in}" > out.tar || framework_failure # invalid tar
|
||||
cp "${in}" out.tar || framework_failure # invalid tar
|
||||
"${TARLZ}" -q -f out.tar --delete foo
|
||||
[ $? = 2 ] || test_failed $LINENO
|
||||
rm -f out.tar || framework_failure
|
||||
cat "${in}" > out.tar.lz || framework_failure # invalid tar.lz
|
||||
cp "${in}" out.tar.lz || framework_failure # invalid tar.lz
|
||||
"${TARLZ}" -q -f out.tar.lz --delete foo
|
||||
[ $? = 2 ] || test_failed $LINENO
|
||||
cat "${in_lz}" > out.tar.lz || framework_failure # invalid tar.lz
|
||||
cp "${in_lz}" out.tar.lz || framework_failure # invalid tar.lz
|
||||
"${TARLZ}" -q -f out.tar.lz --delete foo
|
||||
[ $? = 2 ] || test_failed $LINENO
|
||||
rm -f out.tar.lz || framework_failure
|
||||
|
@ -881,10 +898,10 @@ for e in "" .lz ; do
|
|||
done
|
||||
|
||||
# test --delete individual member after collective member
|
||||
cat cfoo > foo || framework_failure
|
||||
cat cbar > bar || framework_failure
|
||||
cat cbaz > baz || framework_failure
|
||||
cat "${in}" > test.txt || framework_failure
|
||||
cp cfoo foo || framework_failure
|
||||
cp cbar bar || framework_failure
|
||||
cp cbaz baz || framework_failure
|
||||
cp "${in}" test.txt || framework_failure
|
||||
"${TARLZ}" -0 -cf out.tar.lz foo bar baz --asolid || test_failed $LINENO
|
||||
"${TARLZ}" -0 -rf out.tar.lz test.txt || test_failed $LINENO
|
||||
rm -f foo bar baz test.txt || framework_failure
|
||||
|
@ -901,20 +918,16 @@ cmp cbaz baz || test_failed $LINENO
|
|||
rm -f out.tar.lz foo bar baz test.txt || framework_failure
|
||||
|
||||
# test --delete with empty lzip member, global header
|
||||
for i in 1 2 3 4 5 6 ; do
|
||||
cat "${testdir}"/test3_em${i}.tar.lz > out.tar.lz || framework_failure
|
||||
for j in foo bar baz ; do
|
||||
"${TARLZ}" -f out.tar.lz --delete $j || test_failed $LINENO "$i $j"
|
||||
done
|
||||
rm -f out.tar.lz || framework_failure
|
||||
done
|
||||
cat "${testdir}"/test3_gh5.tar.lz > out.tar.lz || framework_failure
|
||||
"${TARLZ}" -q -f test3_em.tar.lz --delete foo
|
||||
[ $? = 2 ] || test_failed $LINENO
|
||||
rm -f test3_em.tar.lz || framework_failure
|
||||
cp "${testdir}"/test3_gh5.tar.lz out.tar.lz || framework_failure
|
||||
for i in foo bar baz ; do
|
||||
"${TARLZ}" -f out.tar.lz --delete $i || test_failed $LINENO $i
|
||||
done
|
||||
rm -f out.tar.lz || framework_failure
|
||||
for i in 1 2 3 4 ; do
|
||||
cat "${testdir}"/test3_gh${i}.tar > out.tar || framework_failure
|
||||
cp "${testdir}"/test3_gh${i}.tar out.tar || framework_failure
|
||||
for j in foo bar baz ; do
|
||||
"${TARLZ}" -f out.tar --delete $j || test_failed $LINENO "$i $j"
|
||||
done
|
||||
|
@ -935,9 +948,9 @@ rm -f dummy_slink dummy_link dummy_file || framework_failure
|
|||
#
|
||||
if [ "${ln_works}" = yes ] ; then
|
||||
mkdir dir || framework_failure
|
||||
cat cfoo > dir/foo || framework_failure
|
||||
cat cbar > dir/bar || framework_failure
|
||||
cat cbaz > dir/baz || framework_failure
|
||||
cp cfoo dir/foo || framework_failure
|
||||
cp cbar dir/bar || framework_failure
|
||||
cp cbaz dir/baz || framework_failure
|
||||
ln -s dir dir_link || framework_failure
|
||||
"${TARLZ}" -0 -c dir_link > out1 || test_failed $LINENO
|
||||
is_compressed out1 || test_failed $LINENO
|
||||
|
@ -968,9 +981,9 @@ fi
|
|||
printf "\ntesting --append..."
|
||||
|
||||
# test --append compressed
|
||||
cat cfoo > foo || framework_failure
|
||||
cat cbar > bar || framework_failure
|
||||
cat cbaz > baz || framework_failure
|
||||
cp cfoo foo || framework_failure
|
||||
cp cbar bar || framework_failure
|
||||
cp cbaz baz || framework_failure
|
||||
"${TARLZ}" -0 -cf out.tar.lz foo bar baz --out-slots=1024 || test_failed $LINENO
|
||||
"${TARLZ}" -0 -cf nout.tar.lz foo bar baz --no-solid || test_failed $LINENO
|
||||
"${TARLZ}" -0 -cf aout.tar.lz foo || test_failed $LINENO
|
||||
|
@ -994,7 +1007,7 @@ cmp out.tar.lz aout.tar.lz || test_failed $LINENO
|
|||
"${TARLZ}" --un -q -rf aout.tar.lz foo bar baz # contradictory ext
|
||||
[ $? = 1 ] || test_failed $LINENO
|
||||
cmp out.tar.lz aout.tar.lz || test_failed $LINENO
|
||||
cat "${eoa_lz}" > aout.tar.lz || framework_failure # append to empty archive
|
||||
cp "${eoa_lz}" aout.tar.lz || framework_failure # append to empty archive
|
||||
"${TARLZ}" -0 -rf aout.tar.lz foo bar baz || test_failed $LINENO
|
||||
cmp out.tar.lz aout.tar.lz || test_failed $LINENO
|
||||
rm -f out.tar.lz aout.tar.lz || framework_failure
|
||||
|
@ -1028,7 +1041,7 @@ cmp out.tar aout.tar || test_failed $LINENO
|
|||
"${TARLZ}" -0 -q -rf aout.tar foo bar baz # contradictory ext
|
||||
[ $? = 1 ] || test_failed $LINENO
|
||||
cmp out.tar aout.tar || test_failed $LINENO
|
||||
cat "${eoa}" > aout.tar || framework_failure # append to empty archive
|
||||
cp "${eoa}" aout.tar || framework_failure # append to empty archive
|
||||
"${TARLZ}" -rf aout.tar foo bar baz || test_failed $LINENO
|
||||
cmp out.tar aout.tar || test_failed $LINENO
|
||||
rm -f out.tar aout.tar || framework_failure
|
||||
|
@ -1036,7 +1049,7 @@ rm -f out.tar aout.tar || framework_failure
|
|||
# test --append to solid archive
|
||||
"${TARLZ}" --solid -q -0 -cf out.tar.lz "${in}" foo bar || test_failed $LINENO
|
||||
"${TARLZ}" -q -tf out.tar.lz || test_failed $LINENO # compressed seekable
|
||||
cat out.tar.lz > aout.tar.lz || framework_failure
|
||||
cp out.tar.lz aout.tar.lz || framework_failure
|
||||
for i in --asolid --bsolid --dsolid --solid -0 ; do
|
||||
"${TARLZ}" $i -q -rf out.tar.lz baz
|
||||
[ $? = 2 ] || test_failed $LINENO $i
|
||||
|
@ -1083,7 +1096,7 @@ if [ "${ln_works}" = yes ] ; then
|
|||
mkdir dir1 || framework_failure
|
||||
mkdir dir1/dir2 || framework_failure
|
||||
mkdir dir1/dir2/dir3 || framework_failure
|
||||
cat "${in}" > dir1/dir2/dir3/in || framework_failure
|
||||
cp "${in}" dir1/dir2/dir3/in || framework_failure
|
||||
ln dir1/dir2/dir3/in dir1/dir2/dir3/"${name_100}" || framework_failure
|
||||
ln dir1/dir2/dir3/in "${path_100}" || framework_failure
|
||||
ln dir1/dir2/dir3/in "${path_106}" || framework_failure
|
||||
|
@ -1160,20 +1173,20 @@ rm -f foo || framework_failure
|
|||
|
||||
printf "\ntesting --compress..."
|
||||
|
||||
cat cfoo > foo || framework_failure
|
||||
cat cbar > bar || framework_failure
|
||||
cat cbaz > baz || framework_failure
|
||||
cat "${in}" > test.txt || framework_failure
|
||||
cp cfoo foo || framework_failure
|
||||
cp cbar bar || framework_failure
|
||||
cp cbaz baz || framework_failure
|
||||
cp "${in}" test.txt || framework_failure
|
||||
"${TARLZ}" -cf out.tar test.txt foo bar baz test.txt || test_failed $LINENO
|
||||
"${TARLZ}" -cf out3.tar foo bar baz || test_failed $LINENO
|
||||
cat out.tar > outz.tar || framework_failure
|
||||
cat out3.tar > out3z.tar || framework_failure
|
||||
cp out.tar outz.tar || framework_failure
|
||||
cp out3.tar out3z.tar || framework_failure
|
||||
#
|
||||
"${TARLZ}" -0 -z outz.tar out3z.tar || test_failed $LINENO
|
||||
"${TARLZ}" -q -tf outz.tar.lz || test_failed $LINENO
|
||||
"${TARLZ}" -q -tf out3z.tar.lz || test_failed $LINENO
|
||||
cat outz.tar.lz > out || test_failed $LINENO
|
||||
cat out3z.tar.lz > out3 || test_failed $LINENO
|
||||
cp outz.tar.lz out || test_failed $LINENO
|
||||
cp out3z.tar.lz out3 || test_failed $LINENO
|
||||
rm -f out3z.tar.lz || framework_failure
|
||||
"${TARLZ}" -q -0 -z outz.tar out3z.tar # outz.tar.lz exists
|
||||
[ $? = 1 ] || test_failed $LINENO
|
||||
|
@ -1271,7 +1284,7 @@ rm -f truncated.tar || framework_failure
|
|||
|
||||
# test --delete with split 'bar' tar member
|
||||
for i in 1 2 3 4 ; do
|
||||
cat "${testdir}"/test3_sm${i}.tar.lz > out.tar.lz || framework_failure
|
||||
cp "${testdir}"/test3_sm${i}.tar.lz out.tar.lz || framework_failure
|
||||
for j in bar baz ; do
|
||||
"${TARLZ}" -q -f out.tar.lz --delete $j
|
||||
[ $? = 2 ] || test_failed $LINENO "$i $j"
|
||||
|
|
BIN
testsuite/em.lz
Normal file
BIN
testsuite/em.lz
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,8 +1,7 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
@ -339,8 +338,7 @@ Public License instead of this License.
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,8 +1,7 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
@ -304,4 +303,6 @@ the "copyright" line and a pointer to where the full notice is found.
|
|||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and pa
|
Binary file not shown.
Binary file not shown.
|
@ -1,8 +1,7 @@
|
|||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 2, June 1991
|
||||
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
|
||||
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
Copyright (C) 1989, 1991 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
|
@ -304,17 +303,7 @@ the "copyright" line and a pointer to where the full notice is found.
|
|||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. Ifodifnperived from the Progr"work based on therogrdifneneraeuse of software generally.
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT X FR TO NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
|
||||
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT X FR TO NO WARRANTY
|
||||
|
||||
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARQIS NO WARRATHERE IS NO WARRANTY
|
||||
FOR THE
|
||||
|
||||
This ee
|
||||
Also add information on how to contact you by electronic and papeLicost ordinram iThis Ysequence ofttp
|
||||
erwise to cod the ITING THE any e licenntradict thel cense, CH DAM
|
Binary file not shown.
Loading…
Add table
Reference in a new issue