summaryrefslogtreecommitdiffstats
path: root/create_lz.cc
diff options
context:
space:
mode:
Diffstat (limited to 'create_lz.cc')
-rw-r--r--create_lz.cc31
1 files changed, 15 insertions, 16 deletions
diff --git a/create_lz.cc b/create_lz.cc
index e2aaf3d..e72839e 100644
--- a/create_lz.cc
+++ b/create_lz.cc
@@ -41,7 +41,7 @@ namespace {
enum { max_packet_size = 1 << 20 };
class Packet_courier;
-Packet_courier * courierp = 0; // local vars needed by add_member
+Packet_courier * courierp = 0; // local vars needed by add_member_lz
unsigned long long partial_data_size = 0; // size of current block
@@ -257,9 +257,10 @@ public:
// send one ipacket with tar member metadata to courier
-int add_member( const char * const filename, const struct stat *,
- const int flag, struct FTW * )
+int add_member_lz( const char * const filename, const struct stat *,
+ const int flag, struct FTW * )
{
+ if( Exclude::excluded( filename ) ) return 0; // skip excluded
unsigned long long file_size = 0;
// metadata for extended records
Extended * const extended = new( std::nothrow ) Extended;
@@ -286,6 +287,7 @@ struct Grouper_arg
{
Packet_courier * courier;
const Arg_parser * parser;
+ bool dereference;
};
@@ -296,6 +298,7 @@ extern "C" void * grouper( void * arg )
const Grouper_arg & tmp = *(const Grouper_arg *)arg;
Packet_courier & courier = *tmp.courier;
const Arg_parser & parser = *tmp.parser;
+ const bool dereference = tmp.dereference;
for( int i = 0; i < parser.arguments(); ++i ) // parse command line
{
@@ -312,11 +315,13 @@ extern "C" void * grouper( void * arg )
while( len > 1 && arg[len-1] == '/' ) --len;
if( len < arg.size() )
{ deslashed.assign( arg, 0, len ); filename = deslashed.c_str(); }
+ if( Exclude::excluded( filename ) ) continue; // skip excluded
struct stat st;
if( lstat( filename, &st ) != 0 ) // filename from command line
{ show_file_error( filename, "Can't stat input file", errno );
set_error_status( 1 ); }
- else if( nftw( filename, add_member, 16, FTW_PHYS ) != 0 )
+ else if( nftw( filename, add_member_lz, 16,
+ dereference ? 0 : FTW_PHYS ) != 0 )
cleanup_and_fail(); // write error or oom
else if( solidity == dsolid ) // end of group
courier.receive_packet( new Ipacket );
@@ -401,7 +406,7 @@ extern "C" void * cworker( void * arg )
LZ_Encoder * encoder = 0;
uint8_t * data = 0;
- Resizable_buffer rbuf( 2 * header_size ); // extended header + data
+ Resizable_buffer rbuf; // extended header + data
if( !rbuf.size() ) { show_error( mem_msg2 ); cleanup_and_fail(); }
int opos = 0;
@@ -518,21 +523,22 @@ void muxer( Packet_courier & courier, const int outfd )
// init the courier, then start the grouper and the workers and call the muxer
int encode_lz( const Arg_parser & parser, const int dictionary_size,
const int match_len_limit, const int num_workers,
- const int outfd, const int debug_level )
+ const int outfd, const int out_slots, const int debug_level,
+ const bool dereference )
{
const int in_slots = 65536; // max small files (<=512B) in 64 MiB
const int total_in_slots = ( INT_MAX / num_workers >= in_slots ) ?
num_workers * in_slots : INT_MAX;
- const int out_slots = 64;
/* If an error happens after any threads have been started, exit must be
called before courier goes out of scope. */
Packet_courier courier( num_workers, total_in_slots, out_slots );
- courierp = &courier; // needed by add_member
+ courierp = &courier; // needed by add_member_lz
Grouper_arg grouper_arg;
grouper_arg.courier = &courier;
grouper_arg.parser = &parser;
+ grouper_arg.dereference = dereference;
pthread_t grouper_thread;
int errcode = pthread_create( &grouper_thread, 0, grouper, &grouper_arg );
@@ -570,14 +576,7 @@ int encode_lz( const Arg_parser & parser, const int dictionary_size,
{ show_error( "Can't join grouper thread", errcode ); cleanup_and_fail(); }
// write End-Of-Archive records
- int retval = 0;
- enum { eof_member_size = 44 };
- const uint8_t eof_member[eof_member_size] = {
- 0x4C, 0x5A, 0x49, 0x50, 0x01, 0x0C, 0x00, 0x00, 0x6F, 0xFD, 0xFF, 0xFF,
- 0xA3, 0xB7, 0x80, 0x0C, 0x82, 0xDB, 0xFF, 0xFF, 0x9F, 0xF0, 0x00, 0x00,
- 0x2E, 0xAF, 0xB5, 0xEF, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x2C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
- if( !writeblock_wrapper( outfd, eof_member, eof_member_size ) ) retval = 1;
+ int retval = !write_eof_records( outfd, true );
if( close( outfd ) != 0 && !retval )
{ show_error( "Error closing archive", errno ); retval = 1; }