Skip to content

Commit 1ef61a6

Browse files
author
Pingfan Liu
committed
kdumpctl: Move _is_osbuild() to kdump-lib.sh
_is_osbuild() will be used in kdump-lib.sh, so moving it from kdumpctl to kdump-lib.sh Signed-off-by: Pingfan Liu <[email protected]>
1 parent 015e0f9 commit 1ef61a6

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

kdump-lib.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,25 @@ is_sme_or_sev_active()
3838
journalctl -q --dmesg --grep "^Memory Encryption Features active: AMD (SME|SEV)$" > /dev/null 2>&1
3939
}
4040

41+
# read the value of an environ variable from given environ file path
42+
#
43+
# The environment variable entries in /proc/[pid]/environ are separated
44+
# by null bytes instead of by spaces.
45+
#
46+
# $1: environment variable
47+
# $2: environ file path
48+
read_proc_environ_var()
49+
{
50+
local _var=$1 _environ_path=$2
51+
sed -n -E "s/.*(^|\x00)${_var}=([^\x00]*).*/\2/p" < "$_environ_path"
52+
}
53+
54+
_OSBUILD_ENVIRON_PATH='/proc/1/environ'
55+
_is_osbuild()
56+
{
57+
[[ $(read_proc_environ_var container "$_OSBUILD_ENVIRON_PATH") == bwrap-osbuild ]]
58+
}
59+
4160
has_command()
4261
{
4362
[[ -x $(command -v "$1") ]]

kdumpctl

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,25 +1970,6 @@ reset_crashkernel_after_update()
19701970
done
19711971
}
19721972

1973-
# read the value of an environ variable from given environ file path
1974-
#
1975-
# The environment variable entries in /proc/[pid]/environ are separated
1976-
# by null bytes instead of by spaces.
1977-
#
1978-
# $1: environment variable
1979-
# $2: environ file path
1980-
read_proc_environ_var()
1981-
{
1982-
local _var=$1 _environ_path=$2
1983-
sed -n -E "s/.*(^|\x00)${_var}=([^\x00]*).*/\2/p" < "$_environ_path"
1984-
}
1985-
1986-
_OSBUILD_ENVIRON_PATH='/proc/1/environ'
1987-
_is_osbuild()
1988-
{
1989-
[[ $(read_proc_environ_var container "$_OSBUILD_ENVIRON_PATH") == bwrap-osbuild ]]
1990-
}
1991-
19921973
reset_crashkernel_for_installed_kernel()
19931974
{
19941975
local _installed_kernel _grub_entry_index _kernel _old_ck _old_fadump

0 commit comments

Comments
 (0)