marsadm: add primitive macro errno-text

This commit is contained in:
Thomas Schoebel-Theuer 2016-01-15 07:56:57 +01:00 committed by Thomas Schoebel-Theuer
parent 6c41326f7a
commit cc1074fc53
2 changed files with 26 additions and 1 deletions

View File

@ -7339,6 +7339,23 @@ marsadm
\begin_layout Labeling
\labelwidthstring 00.00.0000
\family typewriter
errno-text
\family default
This macro takes 1 argument, which must represent a Linux
\family typewriter
errno
\family default
number, and converts it to human readable form (similar to the C
\family typewriter
strerror()
\family default
function).
\end_layout
\begin_layout Labeling
\labelwidthstring 00.00.0000
\family typewriter
todo-{attach,sync,fetch,replay,primary}
\family default

View File

@ -1159,7 +1159,7 @@ sub __conv_errno {
my ($txt, $error) = @_;
return "$txt$error" if !defined($error) || ($error <= 0);
$! = $error;
my $res = "${txt}${error} [$!]";
my $res = "${txt}${error}[$!]";
$! = 0;
return $res;
}
@ -2783,6 +2783,12 @@ sub eval_fn {
my $max = make_numeric(parse_macro($arg4, $env));
return progress_bar($length, $min, $mid, $max);
}
if (/^errno[-_]?text$/) {
my $code = parse_macro($arg1, $env);
return "" unless defined($code) && $code != 0;
$code = -$code if $code < 0;
return __conv_errno("", $code);
}
if (/^get[-_]?log[-_]?status/) {
return get_error_text($$env{"cmd"}, $$env{"res"});
}
@ -3994,6 +4000,8 @@ my %trivial_globs =
=> "",
"replay-code"
=> "When negative, this indidates that a replay/recovery error has occurred.",
"errno-text"
=> "Convert errno numbers (positive or negative) into human readable text.",
"{sync,fetch,replay,work,syncpos}-{size,pos}"
=> "",
"{sync,fetch,replay,work}-{rest,{almost-,threshold-,}reached,percent,permille,vector}"