Make spa_history_zone platform-dependent in kernel

This function should only return "linux" on Linux.

Move the kernel part of the function out of common code.
Fix the tests for FreeBSD.

Reviewed-by: George Melikov <mail@gmelikov.ru>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ryan Moeller <ryan@iXsystems.com>
Closes #10079
This commit is contained in:
Ryan Moeller
2020-03-02 12:43:30 -05:00
committed by GitHub
parent 1289fbb557
commit 9bb907bc3f
4 changed files with 21 additions and 15 deletions
@@ -51,11 +51,11 @@ function run_and_verify
fullcmd="$1"
flags="$2"
if is_linux; then
if is_illumos; then
histcmd=$(echo $fullcmd | sed 's/\/usr\/sbin\///g')
else
histcmd=$(echo $fullcmd | sed 's/^.*\/\(zpool .*\).*$/\1/')
histcmd=$(echo $histcmd | sed 's/^.*\/\(zfs .*\).*$/\1/')
else
histcmd=$(echo $fullcmd | sed 's/\/usr\/sbin\///g')
fi
cmd=$(echo $histcmd | awk '{print $1}')
@@ -112,10 +112,11 @@ function verify_long
typeset suffix=""
if is_linux; then
suffix=":linux"
elif is_freebsd; then
suffix=":freebsd"
fi
grep "$cmd \[user $uid ($user) on $hname$suffix\]" \
$NEW_HISTORY >/dev/null 2>&1
grep -q "$cmd \[user $uid ($user) on $hname$suffix\]" $NEW_HISTORY
if [[ $? != 0 ]]; then
log_note "Couldn't find long information for \"$cmd\""
return 1