summaryrefslogtreecommitdiffstats
path: root/decode_lz.cc
diff options
context:
space:
mode:
Diffstat (limited to 'decode_lz.cc')
-rw-r--r--decode_lz.cc24
1 files changed, 13 insertions, 11 deletions
diff --git a/decode_lz.cc b/decode_lz.cc
index 8780eab..867ffa5 100644
--- a/decode_lz.cc
+++ b/decode_lz.cc
@@ -1,5 +1,5 @@
/* Tarlz - Archiver with multimember lzip compression
- Copyright (C) 2013-2022 Antonio Diaz Diaz.
+ Copyright (C) 2013-2024 Antonio Diaz Diaz.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -20,7 +20,6 @@
#include <algorithm>
#include <cerrno>
#include <cstdio>
-#include <cstdlib>
#include <queue>
#include <pthread.h>
#include <stdint.h> // for lzlib.h
@@ -30,6 +29,8 @@
#if !defined __FreeBSD__ && !defined __OpenBSD__ && !defined __NetBSD__ && \
!defined __DragonFly__ && !defined __APPLE__ && !defined __OS2__
#include <sys/sysmacros.h> // for major, minor, makedev
+#else
+#include <sys/types.h> // for major, minor, makedev
#endif
#include <lzlib.h>
@@ -37,6 +38,7 @@
#include "arg_parser.h"
#include "lzip_index.h"
#include "archive_reader.h"
+#include "common_mutex.h"
#include "decode.h"
/* When a problem is detected by any worker:
@@ -218,7 +220,7 @@ public:
bool reserve_name( const unsigned worker_id, const std::string & filename )
{
- // compare the CRCs of the names, verify collisions comparing the names
+ // compare the CRCs of the names; compare the names if the CRCs collide
const unsigned crc =
crc32c.compute_crc( (const uint8_t *)filename.c_str(), filename.size() );
xlock( &mutex );
@@ -258,10 +260,10 @@ Trival skip_member_lz( Archive_reader_i & ar, Packet_courier & courier,
Trival compare_member_lz( const Cl_options & cl_opts,
- Archive_reader_i & ar, Packet_courier & courier,
- const Extended & extended, const Tar_header header,
- Resizable_buffer & rbuf, const long member_id,
- const int worker_id )
+ Archive_reader_i & ar, Packet_courier & courier,
+ const Extended & extended, const Tar_header header,
+ Resizable_buffer & rbuf, const long member_id,
+ const int worker_id )
{
if( verbosity < 1 ) rbuf()[0] = 0;
else if( !format_member_name( extended, header, rbuf, verbosity > 1 ) )
@@ -357,7 +359,7 @@ Trival extract_member_lz( const Cl_options & cl_opts,
/* Remove file before extraction to prevent following links.
Don't remove an empty dir because other thread may need it. */
if( typeflag != tf_directory ) std::remove( filename );
- if( !make_path( filename ) )
+ if( !make_dirs( filename ) )
{
if( format_file_error( rbuf, filename, intdir_msg, errno ) &&
!courier.collect_packet( member_id, worker_id, rbuf(), Packet::diag ) )
@@ -451,7 +453,7 @@ Trival extract_member_lz( const Cl_options & cl_opts,
chown( filename, extended.get_uid(), extended.get_gid() ) != 0 ) )
{
if( outfd >= 0 ) mode &= ~( S_ISUID | S_ISGID | S_ISVTX );
- // chown will in many cases return with EPERM, which can be safely ignored.
+ // chown in many cases returns with EPERM, which can be safely ignored.
if( errno != EPERM && errno != EINVAL )
{
if( format_file_error( rbuf, filename, chown_msg, errno ) &&
@@ -576,7 +578,7 @@ extern "C" void * dworker( void * arg )
courier.collect_packet( i, worker_id, ar.e_msg(),
( ret == 1 ) ? Packet::error1 : Packet::error2, ar.e_code() );
goto done; }
- if( !verify_ustar_chksum( header ) ) // error or EOA
+ if( !check_ustar_chksum( header ) ) // error or EOA
{
if( !courier.request_mastership( i, worker_id ) ) goto done;
if( block_is_zero( header, header_size ) ) // EOA
@@ -758,6 +760,6 @@ int decode_lz( const Cl_options & cl_opts, const Archive_descriptor & ad,
courier.ocheck_counter,
courier.owait_counter );
- if( !courier.finished() ) internal_error( "courier not finished." );
+ if( !courier.finished() ) internal_error( conofin_msg );
return final_exit_status( retval, cl_opts.program_mode != m_diff );
}