Do some format check of the initramfs and append files into it.
CPIO will keep extracting untill there is no valid data, so two
concated CPIO file will still be valid, which is a feature of CPIO.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
kdump-lib.sh | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 7245899..a7b9cba 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -913,3 +913,23 @@ kdump_get_arch_recommend_size()
echo $result
return 0
}
+
+# Append files to an existing initramfs
+# $1: initramfs to be appended to
+# $2: root directory of files to be appended
+append_initramfs()
+{
+ # For security, everything owned by root by default
+ local cpio_owner="0:0"
+ local dracut_params
+
+ dracut_params=$(lsinitrd "$1" '*/lib/dracut/build-parameter.txt')
+ if [[ -z "$dracut_params" ]]; then
+ dwarn "initramfs seems not generated with dracut."
+ elif [[ " $dracut_params " == *" --uefi"* ]]; then
+ derror "initrd packed in UEFI is not supported."
+ return 1
+ fi
+
+ (cd "$2"; find . -print0 | cpio -R $cpio_owner --null -H newc -o --quiet
>> "$1")
+}
--
2.30.2