From 5bd288b4be0619f215ffaeec6a07776170b1fdea Mon Sep 17 00:00:00 2001 From: Thomas Schoebel-Theuer Date: Wed, 26 Sep 2018 09:33:19 +0200 Subject: [PATCH] marsadm: detect orphan logfile sizes --- userspace/marsadm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/userspace/marsadm b/userspace/marsadm index 0d13bf7e..60b20b80 100755 --- a/userspace/marsadm +++ b/userspace/marsadm @@ -4070,12 +4070,21 @@ sub eval_fn { my $peer = parse_macro($arg1, $env); $peer = $$env{"host"} unless $peer; my $replay = get_link($$env{"resdir"} . "/replay-$peer", 1); - $replay =~ m/^(log-[^,]+),/; + $replay =~ m/^(log-[^,]+),([0-9]*)/; my $logfile = $$env{"resdir"} . "/" . $1; - if (-r $logfile) { - return 0; + my $logpos = $2; + if (! -r $logfile) { + return 1; } - return 1; + my @stat = stat($logfile); + if (!@stat) { + return 1; + } + my $size= $stat[7]; + if ($size < $logpos) { + return 1; + } + return 0; } if (/^is[-_]?(almost[-_]?)?consistent$/) { my $almost = $1;