| 1 | #============================================================= -*-perl-*- | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | # File::RsyncP::FileIO package | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | # Provide file system IO for File::RsyncP. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # AUTHOR | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # Craig Barratt <cbarratt@users.sourceforge.net> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # COPYRIGHT | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | # File::RsyncP is Copyright (C) 2002 Craig Barratt. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | # Rsync is Copyright (C) 1996-2001 by Andrew Tridgell, 1996 by Paul | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | # Mackerras, and 2001, 2002 by Martin Pool. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | # This program is free software: you can redistribute it and/or modify | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | # it under the terms of the GNU General Public License as published by | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | # the Free Software Foundation, either version 3 of the License, or | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | # (at your option) any later version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | # This program is distributed in the hope that it will be useful, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | # GNU General Public License for more details. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | # You should have received a copy of the GNU General Public License | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | # along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | #======================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | # Version 0.76, released 14 Sep 2020. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 34 | # See http://perlrsync.sourceforge.net. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 35 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | #======================================================================== | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | package File::RsyncP::FileIO; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | ▶ | use File::RsyncP::Digest; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 3 | ▶ | use File::Path; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | ▶ | use File::Find; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 3 | ▶ | use vars qw($VERSION); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 3 | $VERSION = '0.76'; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 3 | ▶ | use constant S_IFMT => 0170000; # type of file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 3 | ▶ | use constant S_IFDIR => 0040000; # directory | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 3 | ▶ | use constant S_IFCHR => 0020000; # character special | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 3 | ▶ | use constant S_IFBLK => 0060000; # block special | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 3 | ▶ | use constant S_IFREG => 0100000; # regular | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 3 | ▶ | use constant S_IFLNK => 0120000; # symbolic link | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 3 | ▶ | use constant S_IFSOCK => 0140000; # socket | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 3 | ▶ | use constant S_IFIFO => 0010000; # fifo | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | sub new | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 0 | my($class, $options) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 0 | ▶ | $options ||= {}; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$options ||= {}
MC/DC0%0/1
$options ||= {}
$options
Truth table0%0/2
A
A= $options
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | my $self = bless { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | blockSize => 700, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | logLevel => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | digest => File::RsyncP::Digest->new($options->{protocol_version}), | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | checksumSeed => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | logHandler => \&logHandler, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | %$options, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | sub blockSize | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
blockSize: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | my($fio, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 0 | ▶ | $fio->{blockSize} = $value if ( defined($value) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | return $fio->{blockSize}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | # We publish our version to File::RsyncP. This is so File::RsyncP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | # can provide backward compatibility to older FileIO code. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 85 | # Versions: | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 86 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | # undef or 1: protocol version 26, no hardlinks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 88 | # 2: protocol version 28, supports hardlinks | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | sub version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
version: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | return 2; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | sub preserve_hard_links | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
preserve_hard_links: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 97 | 0 | my($fio, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 99 | 0 | ▶ | $fio->{preserve_hard_links} = $value if ( defined($value) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | return $fio->{preserve_hard_links}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 101 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | sub protocol_version | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
protocol_version: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my($fio, $value) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | if ( defined($value) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | $fio->{protocol_version} = $value; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $fio->{digest}->protocol($fio->{protocol_version}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | return $fio->{protocol_version}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 114 | sub logHandlerSet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logHandlerSet: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | my($fio, $sub) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | $fio->{logHandler} = $sub; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | # Given a remote name, return the local name | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 122 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | sub localName | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
localName: not called CC=4 SCAR=30.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my($fio, $name) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 127 | return $name if ( !defined($fio->{localDir}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | && !defined($fio->{remoteDir}) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fio->{"localDir"} or defined $fio->{"remoteDir"}
MC/DC0%0/2
defined $fio->{"localDir"} or defined $fio->{"remoteDir"}
defined $fio->{"localDir"}
defined $fio->{"remoteDir"}
Truth table0%0/3
A or B
A= defined $fio->{"localDir"}B= defined $fio->{"remoteDir"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | ▶ | if ( substr($name, 0, length($fio->{remoteDir})) eq $fio->{remoteDir} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | substr($name, 0, length($fio->{remoteDir})) = $fio->{localDir}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | return $name; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 135 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 136 | # Setup rsync checksum computation for the given file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 137 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | sub csumStart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
csumStart: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | my($fio, $f, $needMD4) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | local(*F); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | 0 | my $localName = $fio->localName($f->{name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $fio->{file} = $f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | ▶ | $fio->csumEnd if ( defined($fio->{fh}) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | return if ( !-f $localName || -l $localName ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not -f $localName or -l $localName
MC/DC0%0/2
not -f $localName or -l $localName
not -f $localName
-l $localName
Truth table0%0/3
not(A) or B
A= not -f $localNameB= -l $localName
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | ▶ | if ( !open(F, $localName) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $fio->log("Can't open $localName"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | ▶ | if ( $needMD4) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 152 | $fio->{csumDigest} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | = File::RsyncP::Digest->new($fio->{protocol_version}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $fio->{csumDigest}->add(pack("V", $fio->{checksumSeed})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | delete($fio->{csumDigest}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | $fio->{fh} = *F; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 161 | sub csumGet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
csumGet: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | my($fio, $num, $csumLen, $blockSize) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my($fileData); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | ▶ | $num ||= 100; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$num ||= 100
MC/DC0%0/1
$num ||= 100
$num
Truth table0%0/2
A
A= $num
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | $csumLen ||= 16; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$csumLen ||= 16
MC/DC0%0/1
$csumLen ||= 16
$csumLen
Truth table0%0/2
A
A= $csumLen
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | return if ( !defined($fio->{fh}) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | if ( sysread($fio->{fh}, $fileData, $blockSize * $num) <= 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | $fio->{csumDigest}->add($fileData) if ( defined($fio->{csumDigest}) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 174 | $fio->log(sprintf("%s: getting csum ($num,$csumLen,%d,0x%x)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 175 | $fio->{file}{name}, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | length($fileData), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 177 | $fio->{checksumSeed})) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | ▶ | if ( $fio->{logLevel} >= 10 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 179 | return $fio->{digest}->blockDigest($fileData, $blockSize, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | $csumLen, $fio->{checksumSeed}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | sub csumEnd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
csumEnd: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | 0 | my($fio) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | return if ( !defined($fio->{fh}) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | # make sure we read the entire file for the file MD4 digest | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 190 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | if ( defined($fio->{csumDigest}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | while ( sysread($fio->{fh}, my $fileData, 65536) > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | $fio->{csumDigest}->add($fileData); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | close($fio->{fh}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | delete($fio->{fh}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | return $fio->{csumDigest}->digest if ( defined($fio->{csumDigest}) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | sub readStart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readStart: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | 0 | my($fio, $f) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | local(*F); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | my $localName = $fio->localName($f->{name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $fio->{file} = $f; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | ▶ | $fio->readEnd if ( defined($fio->{fh}) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | ▶ | return if ( !-f $localName || -l $localName ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not -f $localName or -l $localName
MC/DC0%0/2
not -f $localName or -l $localName
not -f $localName
-l $localName
Truth table0%0/3
not(A) or B
A= not -f $localNameB= -l $localName
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 210 | 0 | ▶ | if ( !open(F, $localName) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | 0 | $fio->log("Can't open $localName"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 213 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $fio->{fh} = *F; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 215 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 217 | sub read | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
read: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my($fio, $num) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | my($fileData); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | ▶ | $num ||= 32768; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$num ||= 32768
MC/DC0%0/1
$num ||= 32768
$num
Truth table0%0/2
A
A= $num
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | ▶ | return if ( !defined($fio->{fh}) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | ▶ | if ( sysread($fio->{fh}, $fileData, $num) <= 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | return $fio->readEnd; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | return \$fileData; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | sub readEnd | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
readEnd: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my($fio) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | ▶ | return if ( !defined($fio->{fh}) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 235 | 0 | close($fio->{fh}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | delete($fio->{fh}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | sub checksumSeed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checksumSeed: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | my($fio, $checksumSeed) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 242 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | 0 | $fio->{checksumSeed} = $checksumSeed; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | sub dirs | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
dirs: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my($fio, $localDir, $remoteDir) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 249 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | $fio->{localDir} = $localDir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | $fio->{remoteDir} = $remoteDir; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | sub attribGet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attribGet: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | my($fio, $f) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $localName = $fio->localName($f->{name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my @s = stat($localName); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | return if ( !@s ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 261 | return { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | mode => $s[2], | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 263 | uid => $s[4], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 264 | gid => $s[5], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 265 | size => $s[7], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | mtime => $s[9], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 268 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 269 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | # Set the attributes for a file. Returns non-zero on error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | sub attribSet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
attribSet: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my($fio, $f, $placeHolder) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | my $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 278 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | # Ignore placeholder attribute sets: only do real ones. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | ▶ | return if ( $placeHolder ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my $lName = $fio->localName($f->{name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my @s = stat($lName); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my $a = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | mode => $s[2], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | uid => $s[4], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | gid => $s[5], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | size => $s[7], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | atime => $s[8], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | mtime => $s[9], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | $f->{atime} = $f->{mtime} if ( !defined($f->{atime}) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | ▶ | if ( ($f->{mode} & ~S_IFMT) != ($a->{mode} & ~S_IFMT) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
($f->{"mode"} & '18446744073709490175') != ($a->{"mode"} & '18446744073709490175') and not chmod($f->{"mode"} & '18446744073709490175', $lName)
MC/DC0%0/2
($f->{"mode"} & '18446744073709490175') != ($a->{"mode"} & '18446744073709490175') and not chmod($f->{"mode"} & '18446744073709490175', $lName)
($f->{"mode"} & '18446744073709490175') != ($a->{"mode"} & '18446744073709490175')
not chmod($f->{"mode"} & '18446744073709490175', $lName)
Truth table0%0/3
A and not(B)
A= ($f->{"mode"} & '18446744073709490175') != ($a->{"mode"} & '18446744073709490175')B= not chmod($f->{"mode"} & '18446744073709490175', $lName)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 295 | && !chmod($f->{mode} & ~S_IFMT, $lName) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | $fio->log(sprintf("Can't chmod(%s, 0%o)", $lName, $f->{mode})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | $ret = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | if ( ($f->{uid} != $a->{uid} || $f->{gid} != $a->{gid}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$f->{"uid"} != $a->{"uid"} || $f->{"gid"} != $a->{"gid"} and not chown($f->{"uid"}, $f->{"gid"}, $lName)
$f->{"uid"} != $a->{"uid"} or $f->{"gid"} != $a->{"gid"}
MC/DC0%0/3
$f->{"uid"} != $a->{"uid"} || $f->{"gid"} != $a->{"gid"} and not chown($f->{"uid"}, $f->{"gid"}, $lName)
$f->{"uid"} != $a->{"uid"}
$f->{"gid"} != $a->{"gid"}
not chown($f->{"uid"}, $f->{"gid"}, $lName)
Truth table0%0/5
A or B and not(C)
A= $f->{"uid"} != $a->{"uid"}B= $f->{"gid"} != $a->{"gid"}C= not chown($f->{"uid"}, $f->{"gid"}, $lName)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 300 | && !chown($f->{uid}, $f->{gid}, $lName) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | $fio->log("Can't chown($f->{uid}, $f->{gid}, $lName)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $ret = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | if ( ($f->{mtime} != $a->{mtime} || $f->{atime} != $a->{atime}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$f->{"mtime"} != $a->{"mtime"} || $f->{"atime"} != $a->{"atime"} and not utime($f->{"atime"}, $f->{"mtime"}, $lName)
$f->{"mtime"} != $a->{"mtime"} or $f->{"atime"} != $a->{"atime"}
MC/DC0%0/3
$f->{"mtime"} != $a->{"mtime"} || $f->{"atime"} != $a->{"atime"} and not utime($f->{"atime"}, $f->{"mtime"}, $lName)
$f->{"mtime"} != $a->{"mtime"}
$f->{"atime"} != $a->{"atime"}
not utime($f->{"atime"}, $f->{"mtime"}, $lName)
Truth table0%0/5
A or B and not(C)
A= $f->{"mtime"} != $a->{"mtime"}B= $f->{"atime"} != $a->{"atime"}C= not utime($f->{"atime"}, $f->{"mtime"}, $lName)
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | && !utime($f->{atime}, $f->{mtime}, $lName) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | 0 | $fio->log("Can't mtime($f->{atime}, $f->{mtime}, $lName)"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $ret = -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | return $ret; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 311 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 312 | sub statsGet | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
statsGet: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | 0 | my($fio) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | return {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | # Make a given directory. Returns non-zero on error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | sub makePath | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makePath: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my($fio, $f) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my $localDir = $fio->localName($f->{name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | return $fio->attribSet($f) if ( -d $localDir ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | 0 | File::Path::mkpath($localDir, 0, $f->{mode}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | return $fio->attribSet($f) if ( -d $localDir ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $fio->log("Can't create directory $localDir"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 335 | # Make a special file. Returns non-zero on error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 336 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | sub makeSpecial | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeSpecial: not called CC=7 SCAR=40.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | my($fio, $f) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | my $localPath = $fio->localName($f->{name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | # TODO: check if the special file is the same, then do nothing. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | # Should also create as a new unique name, then rename/unlink. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | 0 | $fio->unlink($f->{name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | if ( ($f->{mode} & S_IFMT) == S_IFCHR ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | my($major, $minor); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $major = $f->{rdev} >> 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $minor = $f->{rdev} & 0xff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | return system("mknod $localPath c $major $minor"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } elsif ( ($f->{mode} & S_IFMT) == S_IFBLK ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | my($major, $minor); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | 0 | $major = $f->{rdev} >> 8; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | 0 | $minor = $f->{rdev} & 0xff; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | return system("mknod $localPath b $major $minor"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | } elsif ( ($f->{mode} & S_IFMT) == S_IFLNK ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | 0 | ▶ | if ( !symlink($f->{link}, $localPath) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | } elsif ( ($f->{mode} & S_IFMT) == S_IFIFO ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | if ( system("mknod $localPath p") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | return $fio->attribSet($f); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 371 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | # Make a hardlink. Returns non-zero on error. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | # This actually gets called twice for each hardlink. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | # Once as the file list is processed, and again at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | # the end. This subroutine should decide whether it | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | # should do the hardlinks during the transer or at | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | # the end. Normally they would be done at the end | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | # since the target might not exist until them. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | # BackupPC does them as it goes (since it is just saving the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | # hardlink info and not actually making hardlinks). | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | sub makeHardLink | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
makeHardLink: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | my($fio, $f, $end) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 386 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | # In this case, only do hardlinks at the end. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | ▶ | return if ( !$end ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | my $localPath = $fio->localName($f->{name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | my $destLink = $fio->localName($f->{hlink}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | ▶ | $fio->unlink($localPath) if ( -e $localPath ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | return !link($destLink, $localPath); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 396 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 397 | sub unlink | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
unlink: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | my($fio, $path) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 400 | 0 | my $localPath = $fio->localName($path); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | return if ( !-e $localPath && !-l $localPath ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
-e $localPath or -l $localPath
MC/DC0%0/2
-e $localPath or -l $localPath
-e $localPath
-l $localPath
Truth table0%0/3
A or B
A= -e $localPathB= -l $localPath
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | ▶ | if ( -d _ ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | rmtree($localPath); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 405 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | CORE::unlink($localPath); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 407 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 408 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 410 | sub ignoreAttrOnFile | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ignoreAttrOnFile: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 412 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 416 | # Start receive of file deltas for a particular file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 417 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | sub fileDeltaRxStart | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fileDeltaRxStart: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | my($fio, $f, $cnt, $size, $remainder) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | $fio->{rxFile} = $f; # file attributes | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 423 | 0 | $fio->{rxBlkCnt} = $cnt; # how many blocks we will receive | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | $fio->{rxBlkSize} = $size; # block size | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | $fio->{rxRemainder} = $remainder; # size of the last block | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | $fio->{rxMatchBlk} = 0; # current start of match | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | $fio->{rxMatchNext} = 0; # current next block of match | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | $fio->{rxSize} = 0; # size of received file | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | ▶ | if ( $fio->{rxFile}{size} != ($cnt > 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | ? ($cnt - 1) * $size + $remainder | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | : 0) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | $fio->{rxMatchBlk} = undef; # size different, so no file match | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 433 | $fio->log("$fio->{rxFile}{name}: size doesn't match" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 434 | . " ($fio->{rxFile}{size})") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | ▶ | if ( $fio->{logLevel} >= 5 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 436 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | delete($fio->{rxInFd}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | delete($fio->{rxOutFd}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 439 | 0 | delete($fio->{rxDigest}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | $fio->{rxFile}{localName} = $fio->localName($fio->{rxFile}{name}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 443 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 444 | # Process the next file delta for the current file. Returns 0 if ok, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 445 | # -1 if not. Must be called with either a block number, $blk, or new data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | # $newData, (not both) defined. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 447 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | sub fileDeltaRxNext | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fileDeltaRxNext: not called CC=27 SCAR=66.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | my($fio, $blk, $newData) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | if ( defined($blk) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | if ( defined($fio->{rxMatchBlk}) && $fio->{rxMatchNext} == $blk ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fio->{"rxMatchBlk"} and $fio->{"rxMatchNext"} == $blk
MC/DC0%0/2
defined $fio->{"rxMatchBlk"} and $fio->{"rxMatchNext"} == $blk
defined $fio->{"rxMatchBlk"}
$fio->{"rxMatchNext"} == $blk
Truth table0%0/3
A and B
A= defined $fio->{"rxMatchBlk"}B= $fio->{"rxMatchNext"} == $blk
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 454 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 455 | # got the next block in order; just keep track. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 456 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | 0 | $fio->{rxMatchNext}++; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 460 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | my $newDataLen = length($newData); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 462 | $fio->log("$fio->{rxFile}{name}: blk=$blk, newData=$newDataLen," | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | . " rxMatchBlk=$fio->{rxMatchBlk}, rxMatchNext=$fio->{rxMatchNext}") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | 0 | ▶ | if ( $fio->{logLevel} >= 8 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | if ( !defined($fio->{rxOutFd}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 467 | # maybe the file has no changes | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 468 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | ▶ | if ( $fio->{rxMatchNext} == $fio->{rxBlkCnt} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$fio->{"rxMatchNext"} == $fio->{"rxBlkCnt"} and not defined $blk and not defined $newData
$fio->{"rxMatchNext"} == $fio->{"rxBlkCnt"} and not defined $blk
MC/DC0%0/3
$fio->{"rxMatchNext"} == $fio->{"rxBlkCnt"} and not defined $blk and not defined $newData
$fio->{"rxMatchNext"} == $fio->{"rxBlkCnt"}
not defined $blk
not defined $newData
Truth table0%0/4
A and not(B) and not(C)
A= $fio->{"rxMatchNext"} == $fio->{"rxBlkCnt"}B= not defined $blkC= not defined $newData
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 470 | && !defined($blk) && !defined($newData) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | #$fio->log("$fio->{rxFile}{name}: file is unchanged"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 472 | # if ( $fio->{logLevel} >= 8 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 474 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 477 | # need to open a temporary output file where we will build the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 478 | # new version. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | local(*F); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | my $rxTmpFile; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | for ( my $i = 0 ; ; $i++ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | $rxTmpFile = "$fio->{rxFile}{localName}__tmp__$$.$i"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | last if ( !-e $rxTmpFile ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 485 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | if ( !open(F, ">$rxTmpFile") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | $fio->log("Can't open/create $rxTmpFile"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | $fio->log("$fio->{rxFile}{name}: opening tmp output file $rxTmpFile") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | ▶ | if ( $fio->{logLevel} >= 10 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | $fio->{rxOutFd} = *F; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | $fio->{rxTmpFile} = $rxTmpFile; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $fio->{rxDigest} = File::RsyncP::Digest->new($fio->{protocol_version}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | $fio->{rxDigest}->add(pack("V", $fio->{checksumSeed})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | ▶ | if ( defined($fio->{rxMatchBlk}) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $fio->{"rxMatchBlk"} and $fio->{"rxMatchBlk"} != $fio->{"rxMatchNext"}
MC/DC0%0/2
defined $fio->{"rxMatchBlk"} and $fio->{"rxMatchBlk"} != $fio->{"rxMatchNext"}
defined $fio->{"rxMatchBlk"}
$fio->{"rxMatchBlk"} != $fio->{"rxMatchNext"}
Truth table0%0/3
A and B
A= defined $fio->{"rxMatchBlk"}B= $fio->{"rxMatchBlk"} != $fio->{"rxMatchNext"}
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 499 | && $fio->{rxMatchBlk} != $fio->{rxMatchNext} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 501 | # need to copy the sequence of blocks that matched | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 502 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | if ( !defined($fio->{rxInFd}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | ▶ | if ( open(F, "$fio->{rxFile}{localName}") ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | $fio->{rxInFd} = *F; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 506 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | $fio->log("Unable to open $fio->{rxFile}{localName}"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | my $lastBlk = $fio->{rxMatchNext} - 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | $fio->log("$fio->{rxFile}{name}: writing blocks $fio->{rxMatchBlk}.." | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 513 | . "$lastBlk") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | ▶ | if ( $fio->{logLevel} >= 10 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | my $seekPosn = $fio->{rxMatchBlk} * $fio->{rxBlkSize}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | if ( !sysseek($fio->{rxInFd}, $seekPosn, 0) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | $fio->log("Unable to seek $fio->{rxFile}{localName} to $seekPosn"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 518 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | my $cnt = $fio->{rxMatchNext} - $fio->{rxMatchBlk}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | my($thisCnt, $len, $data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | ▶ | for ( my $i = 0 ; $i < $cnt ; $i += $thisCnt ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | $thisCnt = $cnt - $i; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | ▶ | $thisCnt = 512 if ( $thisCnt > 512 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | ▶ | if ( $fio->{rxMatchBlk} + $i + $thisCnt == $fio->{rxBlkCnt} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 526 | 0 | $len = ($thisCnt - 1) * $fio->{rxBlkSize} + $fio->{rxRemainder}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | $len = $thisCnt * $fio->{rxBlkSize}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 529 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | if ( sysread($fio->{rxInFd}, $data, $len) != $len ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | $fio->log("Unable to read $len bytes from" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | . " $fio->{rxFile}{localName} ($i,$thisCnt,$fio->{rxBlkCnt})"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 533 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | ▶ | if ( syswrite($fio->{rxOutFd}, $data) != $len ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | 0 | $fio->log("Unable to write $len bytes to" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | . " $fio->{rxTmpFile}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | 0 | $fio->{rxDigest}->add($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | 0 | $fio->{rxSize} += length($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | $fio->{rxMatchBlk} = undef; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | 0 | ▶ | if ( defined($blk) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | # Remember the new block number | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | $fio->{rxMatchBlk} = $blk; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | $fio->{rxMatchNext} = $blk + 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | if ( defined($newData) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 553 | # Write the new chunk | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | my $len = length($newData); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | $fio->log("$fio->{rxFile}{name}: writing $len bytes new data") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | 0 | ▶ | if ( $fio->{logLevel} >= 10 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | ▶ | if ( syswrite($fio->{rxOutFd}, $newData) != $len ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | 0 | $fio->log("Unable to write $len bytes to $fio->{rxTmpFile}"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | $fio->{rxDigest}->add($newData); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | $fio->{rxSize} += length($newData); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 568 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 569 | # Finish up the current receive file. Returns undef if ok, -1 if not. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | # Returns 1 if the md4 digest doesn't match. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 571 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | sub fileDeltaRxDone | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fileDeltaRxDone: not called CC=21 SCAR=61.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | my($fio, $md4) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | if ( !defined($fio->{rxDigest}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | local(*F); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 578 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 579 | # File was exact match, but we still need to verify the | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 580 | # MD4 checksum. Therefore open and read the file. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | $fio->{rxDigest} = File::RsyncP::Digest->new($fio->{protocol_version}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | $fio->{rxDigest}->add(pack("V", $fio->{checksumSeed})); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | ▶ | if ( open(F, $fio->{rxFile}{localName}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | $fio->{rxInFd} = *F; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | ▶ | while ( sysread($fio->{rxInFd}, my $data, 4 * 65536) > 0 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | $fio->{rxDigest}->add($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | $fio->{rxSize} += length($data); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | # error | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 593 | $fio->log("$fio->{rxFile}{name}: got exact match") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | ▶ | if ( $fio->{logLevel} >= 5 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 595 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | ▶ | close($fio->{rxInFd}) if ( defined($fio->{rxInFd}) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | ▶ | close($fio->{rxOutFd}) if ( defined($fio->{rxOutFd}) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 598 | 0 | my $newDigest = $fio->{rxDigest}->digest; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | ▶ | if ( $fio->{logLevel} >= 3 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | my $md4Str = unpack("H*", $md4); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | 0 | my $newStr = unpack("H*", $newDigest); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | $fio->log("$fio->{rxFile}{name}: got digests $md4Str vs $newStr") | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | 0 | ▶ | if ( $md4 eq $newDigest ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 606 | # Nothing to do if there is no output file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 607 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | 0 | ▶ | if ( !defined($fio->{rxOutFd}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | $fio->log("$fio->{rxFile}{name}: nothing to do") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | ▶ | if ( $fio->{logLevel} >= 5 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | return $fio->attribSet($fio->{rxFile}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | # First rename the original file (in case the rename below fails) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 616 | # to a unique temporary name. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | my $oldFile; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | ▶ | if ( -e $fio->{rxFile}{localName} ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | for ( my $i = 0 ; ; $i++ ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | $oldFile = "$fio->{rxFile}{localName}__old__$$.$i"; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | last if ( !-e $oldFile ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 624 | $fio->log("$fio->{rxFile}{name}: unlinking/renaming") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | if ( $fio->{logLevel} >= 5 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | ▶ | if ( !rename($fio->{rxFile}{localName}, $oldFile) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | $fio->log("Can't rename $fio->{rxFile}{localName}" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 628 | . " to $oldFile"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | 0 | CORE::unlink($fio->{rxTmpFile}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | 0 | ▶ | if ( !rename($fio->{rxTmpFile}, $fio->{rxFile}{localName}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | # Restore old file | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 637 | 0 | ▶ | if ( !rename($oldFile, $fio->{rxFile}{localName}) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | $fio->log("Can't retore original file $oldFile after rename" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 639 | . " of $fio->{rxTmpFile} failed"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 640 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | $fio->log("Can't rename $fio->{rxTmpFile} to" | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 642 | . " $fio->{rxFile}{localName}"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | ▶ | if ( defined($oldFile) && CORE::unlink($oldFile) != 1 ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $oldFile and CORE::unlink($oldFile) != 1
MC/DC0%0/2
defined $oldFile and CORE::unlink($oldFile) != 1
defined $oldFile
CORE::unlink($oldFile) != 1
Truth table0%0/3
A and B
A= defined $oldFileB= CORE::unlink($oldFile) != 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | $fio->log("Can't unlink old file $oldFile"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | return -1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | $fio->log("$fio->{rxFile}{name}: md4 doesn't match") | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | 0 | ▶ | if ( $fio->{logLevel} >= 1 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | 0 | ▶ | CORE::unlink($fio->{rxTmpFile}) if ( defined($fio->{rxTmpFile}) ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | 0 | delete($fio->{rxDigest}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | $fio->{rxFile}{size} = $fio->{rxSize}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | return $fio->attribSet($fio->{rxFile}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | sub fileListEltSend | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fileListEltSend: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | my($fio, $name, $fList, $outputFunc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 664 | 0 | my @s; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | 0 | my $extra = {}; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | 0 | (my $n = $name) =~ s/^\Q$fio->{localDir}/$fio->{remoteDir}/; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | 0 | ▶ | if ( -l $name ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | 0 | @s = lstat($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | 0 | $extra = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | %$extra, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | link => readlink($name), | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | 0 | @s = stat($name); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | 0 | ▶ | if ( $fio->{preserve_hard_links} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/9
$fio->{"preserve_hard_links"} and ($s[2] & 61440) == 32768 and $fio->{"protocol_version"} < 27 || $s[3] > 1
$fio->{"preserve_hard_links"} and ($s[2] & 61440) == 32768
$fio->{"protocol_version"} < 27 or $s[3] > 1
MC/DC0%0/4
$fio->{"preserve_hard_links"} and ($s[2] & 61440) == 32768 and $fio->{"protocol_version"} < 27 || $s[3] > 1
$fio->{"preserve_hard_links"}
($s[2] & 61440) == 32768
$fio->{"protocol_version"} < 27
$s[3] > 1
Truth table0%0/5
A and B and C or D
A= $fio->{"preserve_hard_links"}B= ($s[2] & 61440) == 32768C= $fio->{"protocol_version"} < 27D= $s[3] > 1
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | && ($s[2] & S_IFMT) == S_IFREG | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | && ($fio->{protocol_version} < 27 || $s[3] > 1) ) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | $extra = { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 681 | %$extra, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | dev => $s[0], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | inode => $s[1], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 684 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | ▶ | $fio->log("fileList send $name (remote=$n)") if ( $fio->{logLevel} >= 3 ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | $fList->encode({ | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 688 | name => $n, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | mode => $s[2], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 690 | uid => $s[4], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 691 | gid => $s[5], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | rdev => $s[6], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 693 | size => $s[7], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | mtime => $s[9], | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | %$extra, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 696 | }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | &$outputFunc($fList->encodeData); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | sub fileListSend | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
fileListSend: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | my($fio, $flist, $outputFunc) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | 0 | ▶ | find({wanted => sub { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | 0 | $fio->fileListEltSend($File::Find::name, $flist, $outputFunc); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | no_chdir => 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | }, $fio->{localDir}); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | sub finish | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
finish: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | 0 | my($fio, $isChild) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | # Default log handler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | sub logHandler | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
logHandler: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | 0 | my($str) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | 0 | print(STDERR $str, "\n"); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | # Handle one or more log messages | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | # | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | sub log | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | 0 | ▶ | { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
log: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | my($fio, @logStr) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 734 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | foreach my $str ( @logStr ) { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | ▶ | next if ( $str eq "" ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 737 | 0 | $fio->{logHandler}->($str); | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||