diff --git a/kdump-lib.sh b/kdump-lib.sh index ae39c23..9c1d9e1 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -862,7 +862,7 @@ has_aarch64_smmu() ls /sys/devices/platform/arm-smmu-* 1> /dev/null 2>&1 } -is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[KkMmGg]?$ ]]; } +is_memsize() { [[ "$1" =~ ^[+-]?[0-9]+[KkMmGgTtPbEe]?$ ]]; } # range defined for crashkernel parameter # i.e. -[] @@ -893,6 +893,18 @@ to_bytes() _s=${_s::-1} _s="$((_s * 1024 * 1024 * 1024))" ;; + T|t) + _s=${_s::-1} + _s="$((_s * 1024 * 1024 * 1024 * 1024))" + ;; + P|p) + _s=${_s::-1} + _s="$((_s * 1024 * 1024 * 1024 * 1024 * 1024))" + ;; + E|e) + _s=${_s::-1} + _s="$((_s * 1024 * 1024 * 1024 * 1024 * 1024 * 1024))" + ;; *) ;; esac @@ -901,7 +913,7 @@ to_bytes() memsize_add() { - local -a units=("" "K" "M" "G") + local -a units=("" "K" "M" "G" "T" "P" "E") local i a b a=$(to_bytes "$1") || return 1 diff --git a/spec/kdump-lib_spec.sh b/spec/kdump-lib_spec.sh index 814f961..f13372c 100644 --- a/spec/kdump-lib_spec.sh +++ b/spec/kdump-lib_spec.sh @@ -52,14 +52,20 @@ Describe 'kdump-lib' Context "For valid input values" Parameters "1G-4G:256M,4G-64G:320M,64G-:576M" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M" + "1G-4G:256M" "100" "1G-4G:268435556" # avoids any rounding when size % 1024 != 0 "1G-4G:256M,4G-64G:320M,64G-:576M@4G" "100M" "1G-4G:356M,4G-64G:420M,64G-:676M@4G" "1G-4G:1G,4G-64G:2G,64G-:3G@4G" "100M" "1G-4G:1124M,4G-64G:2148M,64G-:3172M@4G" "1G-4G:10000K,4G-64G:20000K,64G-:40000K@4G" "100M" "1G-4G:112400K,4G-64G:122400K,64G-:142400K@4G" "1,high" "1" "2,high" "1K,low" "1" "1025,low" + "128G-1T:4G" "0" "128G-1T:4G" + "10T-100T:1T" "0" "10T-100T:1T" + "128G-1T:4G" "0M" "128G-1T:4G" + "128G-1P:4G" "0M" "128G-1P:4G" + "128G-1E:4G" "0M" "128G-1E:4G" "1M@1G" "1k" "1025K@1G" "500M@1G" "-100m" "400M@1G" - "1099511627776" "0" "1024G" + "1099511627776" "0" "1T" End It "should add delta to every value after ':'" When call _crashkernel_add "$1" "$2"