diff options
-rw-r--r-- | slx-tools | 12 |
1 files changed, 6 insertions, 6 deletions
@@ -28,9 +28,9 @@ get_backing_dev_mp() { is_volatile() { [ -z "$1" ] && return 2 local _dev="$(get_backing_dev "$1")" - [ -z "$_dev" ] && return 0 - # NOTE: ash does not search/replace when the expression is surrounded by quotes - [ "x$_dev" = "x"${_dev//\/dev\/mapper/} ] && return 1 + [ -z "$_dev" ] && return 0 # No result, assume tmpfs + [ "$_dev" = "${_dev#/dev/zram}" ] && return 0 # zram is in RAM, like tmpfs + [ "$_dev" = "${_dev#/dev/mapper/}" ] && return 1 # Doesn't start with /dev/mapper, assume some kind of storage local _mp="$(get_backing_dev_mp "$1")" [ -z "$_mp" ] && return 2 # it is a device mapper device, check if it was setup in dracut's initramfs. @@ -44,8 +44,7 @@ is_volatile() { get_dm_backing_size() { [ -z "$1" ] && return 1 local _dev="$(get_backing_dev $1)" - # NOTE: ash does not search/replace when the expression is surrounded by quotes - [ "x$_dev" = "x"${_dev//\/dev\/mapper/} ] && return 1 + [ "$_dev" = "${_dev#/dev/mapper/}" ] && return 1 local _dm_line="$(grep -m1 -E "^${_dev}\s+/\s+type=[^0]" "$dmstate")" [ -z "$_dm_line" ] && return 1 local _dm_dev_size="$(echo "$_dm_line" | grep -Po '(?<=physical_size=|virtual_size=)\w*' )" @@ -53,7 +52,7 @@ get_dm_backing_size() { } regex_match() { - echo "$1" | grep -qE "$2" + echo "$1" | grep -qP "$2" } get_partitions_by_id () { @@ -96,3 +95,4 @@ get_partitions_by_id () { && echo "$(blockdev --getsize64 "$dev") $dev" done | sort -n -k1 -r | cut -d' ' -f2 } + |