1
0
Fork 0

Merging upstream version 0.26.

Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
Daniel Baumann 2025-02-17 21:27:57 +01:00
parent 7185f44b62
commit 180f99b04d
Signed by: daniel
GPG key ID: FBB4F0E80A80222F
44 changed files with 610 additions and 505 deletions

View file

@ -20,14 +20,14 @@
#include <algorithm>
#include <cerrno>
#include <cstdio>
#include <stdint.h> // for lzlib.h
#include <stdint.h> // for lzlib.h
#include <unistd.h>
#include <sys/stat.h>
#if !defined __FreeBSD__ && !defined __OpenBSD__ && !defined __NetBSD__ && \
!defined __DragonFly__ && !defined __APPLE__ && !defined __OS2__
#include <sys/sysmacros.h> // for major, minor
#include <sys/sysmacros.h> // for major, minor
#else
#include <sys/types.h> // for major, minor
#include <sys/types.h> // for major, minor
#endif
#include <ftw.h>
#include <grp.h>
@ -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;