Skip to content

pmirror: Add option --noatime #124

Merged
merged 1 commit into from
May 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 9 additions & 3 deletions pmirror/pmirror
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ use Getopt::Long;
use Sys::Hostname;
use IO::File;
use IO::Socket::INET;
use Fcntl ':mode';
use Fcntl qw(:mode O_NOATIME);
import My::Escaper;

use Time::HiRes;
Expand All @@ -172,7 +172,8 @@ our ($debug,$quiet,$fileop_noop,$fileop_debug,$delete);
our ($slave_mode,$local_slave,$slave_unprivileged,
$lockident,$safety,$identity_file,$mkdir_slave,
$reduce,$force_status,$bandwidth,$allowremotefs,
$ssh_opt , $cksum , $nice , $unix_socket, $unix_socket_name);
$ssh_opt , $cksum , $nice , $unix_socket, $unix_socket_name,
$noatime);

# globals

Expand Down Expand Up @@ -466,7 +467,7 @@ sub send_file
my $data_buf;
my $len;

my $fh=IO::File->new($filename,O_RDONLY);
my $fh=IO::File->new($filename, O_RDONLY + ($noatime ? O_NOATIME : 0) );
unless (defined $fh) {
# one reason to get here is that the file was deleted after it has been offered to
# and requested by the client.
Expand Down Expand Up @@ -1047,6 +1048,7 @@ usage: $0 [options] path [node:]path
--nice EXPERIMENTAL nice
--unix-socket EXPERIMENTAL establish data channel over ssh via AF unix sockets
--socket-name PATH EXPERIMENTAL use PATH as name for AF unix sockets
--noatime don't touch atime on sender

__EOF__

Expand Down Expand Up @@ -1075,13 +1077,17 @@ use constant OPTIONS => (
'nice' => \$nice,
'unix-socket' => \$unix_socket,
'socket-name=s' => \$unix_socket_name,
'noatime' => \$noatime,
);

if ($ENV{SSH_ORIGINAL_COMMAND}) {
($_,@ARGV)=split ' ',$ENV{SSH_ORIGINAL_COMMAND};
}

GetOptions(OPTIONS) or die USAGE;
if ($noatime && $cksum) {
die "$0: --cksum together with --noatime not implemented\n";
}

if ($nice) {
system "ionice -c idle -p $$ 2>/dev/null"
Expand Down