diff --git a/kdump-load.sh.in b/kdump-load.sh.in index b61df85..f343bba 100644 --- a/kdump-load.sh.in +++ b/kdump-load.sh.in @@ -74,6 +74,27 @@ clear_all_initrds() { rm -f "${MOUNT_FOLDER}"/kdump-initrd-* } +# Next routine parses /proc/iomem to obtain the biggest RAM buffer +# available. Saves the results in 2 global variables: MEM_{SIZE,START}. +parse_ram_buffers() { + BUFFERS="$(grep "RAM buffer" /proc/iomem)" + while read -r line + do + RANGE=$(echo "$line" | cut -f1 -d\ ) + + MEM_END=$(echo "$RANGE" | cut -f2 -d-) + MSTART=$(echo "$RANGE" | cut -f1 -d-) + MSIZE=$(( 16#${MEM_END} - 16#${MSTART} )) + + if [ ${MSIZE} -gt "${MEM_SIZE}" ]; then + MEM_SIZE="${MSIZE}" + MEM_START="${MSTART}" + fi + done <<< "${BUFFERS}" + # Trick to preserve global variables modifications inside loops + # using here-strings got from https://stackoverflow.com/a/16854326 . +} + # Function to display basic help about how to use this tool. usage() { cat <