|
|
9f65cc |
From 6ed9cff05fb1015fe50951c93430052004d22b01 Mon Sep 17 00:00:00 2001
|
|
|
9f65cc |
From: Harald Hoyer <harald@redhat.com>
|
|
|
9f65cc |
Date: Fri, 21 May 2021 12:19:32 +0200
|
|
|
9f65cc |
Subject: [PATCH] fix(dracut-functions): get_maj_min without
|
|
|
9f65cc |
get_maj_min_cache_file set
|
|
|
9f65cc |
|
|
|
9f65cc |
If `get_maj_min_cache_file` is unset `get_maj_min()` would error out.
|
|
|
9f65cc |
|
|
|
9f65cc |
Fix it to work without a cache file set.
|
|
|
9f65cc |
|
|
|
9f65cc |
(cherry picked from commit a277a5fc7acc0a9e8d853f09671495f9d27645c1)
|
|
|
9f65cc |
|
|
|
9f65cc |
Cherry-picked from: a277a5fc7acc0a9e8d853f09671495f9d27645c1
|
|
|
9f65cc |
Resolves: #1957622
|
|
|
9f65cc |
---
|
|
|
9f65cc |
dracut-functions.sh | 15 +++++++++++----
|
|
|
9f65cc |
1 file changed, 11 insertions(+), 4 deletions(-)
|
|
|
9f65cc |
|
|
|
9f65cc |
diff --git a/dracut-functions.sh b/dracut-functions.sh
|
|
|
9f65cc |
index a221967c..eb2ce748 100755
|
|
|
9f65cc |
--- a/dracut-functions.sh
|
|
|
9f65cc |
+++ b/dracut-functions.sh
|
|
|
9f65cc |
@@ -200,13 +200,20 @@ get_fs_env() {
|
|
|
9f65cc |
# 8:2
|
|
|
9f65cc |
get_maj_min() {
|
|
|
9f65cc |
local _majmin
|
|
|
9f65cc |
- out="$(grep -m1 -oP "^$1 \K\S+$" "${get_maj_min_cache_file:?}")"
|
|
|
9f65cc |
- if [ -z "$out" ]; then
|
|
|
9f65cc |
+ local _out
|
|
|
9f65cc |
+
|
|
|
9f65cc |
+ if [[ $get_maj_min_cache_file ]]; then
|
|
|
9f65cc |
+ _out="$(grep -m1 -oP "^$1 \K\S+$" "$get_maj_min_cache_file")"
|
|
|
9f65cc |
+ fi
|
|
|
9f65cc |
+
|
|
|
9f65cc |
+ if ! [[ "$_out" ]]; then
|
|
|
9f65cc |
_majmin="$(stat -L -c '%t:%T' "$1" 2>/dev/null)"
|
|
|
9f65cc |
out="$(printf "%s" "$((0x${_majmin%:*})):$((0x${_majmin#*:}))")"
|
|
|
9f65cc |
- echo "$1 $out" >> "${get_maj_min_cache_file:?}"
|
|
|
9f65cc |
+ if [[ $get_maj_min_cache_file ]]; then
|
|
|
9f65cc |
+ echo "$1 $_out" >> "$get_maj_min_cache_file"
|
|
|
9f65cc |
+ fi
|
|
|
9f65cc |
fi
|
|
|
9f65cc |
- echo -n "$out"
|
|
|
9f65cc |
+ echo -n "$_out"
|
|
|
9f65cc |
}
|
|
|
9f65cc |
|
|
|
9f65cc |
# get_devpath_block <device>
|
|
|
9f65cc |
|