From 816c41b6fcabfefea36f98568477cd06e74be386 Mon Sep 17 00:00:00 2001 From: Daniel Golle Date: Mon, 26 Apr 2021 19:19:10 +0100 Subject: [PATCH] uvol: fix emmitting ubus event when removing UBI volume In case a volume which is down is removed, no ubus event needs to be fired. Don't try. Signed-off-by: Daniel Golle --- utils/uvol/files/ubi.sh | 6 +++--- utils/uvol/files/uvol | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/utils/uvol/files/ubi.sh b/utils/uvol/files/ubi.sh index 0a1b73093c..2da7e309b8 100644 --- a/utils/uvol/files/ubi.sh +++ b/utils/uvol/files/ubi.sh @@ -119,14 +119,14 @@ removevol() { local voldev=$(getdev "$@") local evdata [ "$voldev" ] || return 2 - local volnum=${voldev#${ubidev}_} if vol_is_mode $voldev rw ; then evdata="{\"name\": \"$1\", \"action\": \"down\", \"device\": \"/dev/$voldev\"}" - elif vol_is_mode $voldev ro ; then + elif vol_is_mode $voldev ro && [ -e "/dev/ubiblock${voldev:3}" ]; then evdata="{\"name\": \"$1\", \"action\": \"down\", \"device\": \"/dev/ubiblock${voldev:3}\"}" fi + local volnum=${voldev#${ubidev}_} ubirmvol /dev/$ubidev -n $volnum || return $? - ubus send block.volume "$evdata" + [ "$evdata" ] && ubus send block.volume "$evdata" } activatevol() { diff --git a/utils/uvol/files/uvol b/utils/uvol/files/uvol index a095b3efff..4958d31ff4 100644 --- a/utils/uvol/files/uvol +++ b/utils/uvol/files/uvol @@ -3,6 +3,7 @@ # uvol prototype # future development roadmap (aka. to-do): # * re-implement in C (use libubox, execve lvm/ubi*) +# * hash to validate volume while writing # * add atomic batch processing for use by container/package manager if [ -z "$1" ]; then cat <