diff --git a/dracut-functions.sh b/dracut-functions.sh index 5af4e458..1991c62e 100755 --- a/dracut-functions.sh +++ b/dracut-functions.sh @@ -234,8 +234,13 @@ get_fs_env() { # 8:2 get_maj_min() { local _majmin - _majmin="$(stat -L -c '%t:%T' "$1" 2> /dev/null)" - printf "%s" "$((0x${_majmin%:*})):$((0x${_majmin#*:}))" + out="$(grep -m1 -oP "^$1 \K\S+$" "${get_maj_min_cache_file:?}")" + if [ -z "$out" ]; then + _majmin="$(stat -L -c '%t:%T' "$1" 2> /dev/null)" + out="$(printf "%s" "$((0x${_majmin%:*})):$((0x${_majmin#*:}))")" + echo "$1 $out" >> "${get_maj_min_cache_file:?}" + fi + echo -n "$out" } # get_devpath_block diff --git a/dracut.sh b/dracut.sh index ec00097e..c19606ae 100755 --- a/dracut.sh +++ b/dracut.sh @@ -1131,6 +1131,10 @@ readonly DRACUT_TMPDIR="$(mktemp -p "$TMPDIR/" -d -t dracut.XXXXXX)" exit 1 } +# Cache file used to optimize get_maj_min() +declare -x -r get_maj_min_cache_file="${DRACUT_TMPDIR}/majmin_cache" +: > "$get_maj_min_cache_file" + # clean up after ourselves no matter how we die. trap ' ret=$?;