[openwrt/openwrt] zram-swap: explicitly use mkswap/swapon/swapoff from /sbin
LEDE Commits
lede-commits at lists.infradead.org
Sun Sep 20 11:52:53 EDT 2020
blocktrron pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/90853439a162d7c5389f6a68028b4390c349c04d
commit 90853439a162d7c5389f6a68028b4390c349c04d
Author: Rui Salvaterra <rsalvaterra at gmail.com>
AuthorDate: Fri Aug 14 13:21:22 2020 +0100
zram-swap: explicitly use mkswap/swapon/swapoff from /sbin
The required BusyBox applets are enabled by default, so we can rely on them
being present in the system. This way, we make sure there are no conflicts
with less featured variants of these same applets which might also be
present in the system.
Fixes: 0bd7dfa3ed60 ("zram-swap: enable swap discard")
Signed-off-by: Rui Salvaterra <rsalvaterra at gmail.com>
[wrap commit description]
Signed-off-by: David Bauer <mail at david-bauer.net>
---
package/system/zram-swap/Makefile | 4 ++--
package/system/zram-swap/files/zram.init | 18 +++++++++---------
2 files changed, 11 insertions(+), 11 deletions(-)
diff --git a/package/system/zram-swap/Makefile b/package/system/zram-swap/Makefile
index 5c132c9062..9a18dd3417 100644
--- a/package/system/zram-swap/Makefile
+++ b/package/system/zram-swap/Makefile
@@ -8,7 +8,7 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=zram-swap
-PKG_RELEASE:=6
+PKG_RELEASE:=7
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)
@@ -17,7 +17,7 @@ include $(INCLUDE_DIR)/package.mk
define Package/zram-swap
SECTION:=utils
CATEGORY:=Base system
- DEPENDS:=+kmod-zram +!(BUSYBOX_CONFIG_MKSWAP&&BUSYBOX_CONFIG_SWAPON&&BUSYBOX_CONFIG_SWAPOFF):swap-utils
+ DEPENDS:=+kmod-zram + at BUSYBOX_CONFIG_MKSWAP + at BUSYBOX_CONFIG_SWAPON + at BUSYBOX_CONFIG_FEATURE_SWAPON_DISCARD + at BUSYBOX_CONFIG_FEATURE_SWAPON_PRI + at BUSYBOX_CONFIG_SWAPOFF
TITLE:=ZRAM swap scripts
PKGARCH:=all
endef
diff --git a/package/system/zram-swap/files/zram.init b/package/system/zram-swap/files/zram.init
index bfb9285600..a42f019d92 100755
--- a/package/system/zram-swap/files/zram.init
+++ b/package/system/zram-swap/files/zram.init
@@ -35,18 +35,18 @@ zram_applicable()
return 1
}
- command -v mkswap >/dev/null || {
- logger -s -t zram_applicable -p daemon.err "[ERROR] 'mkswap' not installed"
+ [ -x /sbin/mkswap ] || {
+ logger -s -t zram_applicable -p daemon.err "[ERROR] 'BusyBox mkswap' not installed"
return 1
}
- command -v swapon >/dev/null || {
- logger -s -t zram_applicable -p daemon.err "[ERROR] 'swapon' not installed"
+ [ -x /sbin/swapon ] || {
+ logger -s -t zram_applicable -p daemon.err "[ERROR] 'BusyBox swapon' not installed"
return 1
}
- command -v swapoff >/dev/null || {
- logger -s -t zram_applicable -p daemon.err "[ERROR] 'swapoff' not installed"
+ [ -x /sbin/swapoff ] || {
+ logger -s -t zram_applicable -p daemon.err "[ERROR] 'BusyBox swapoff' not installed"
return 1
}
}
@@ -182,8 +182,8 @@ start()
zram_comp_algo "$zram_dev"
zram_comp_streams "$zram_dev"
echo $(( $zram_size * 1024 * 1024 )) >"/sys/block/$( basename "$zram_dev" )/disksize"
- mkswap "$zram_dev"
- swapon -d $zram_priority "$zram_dev"
+ /sbin/mkswap "$zram_dev"
+ /sbin/swapon -d $zram_priority "$zram_dev"
}
stop()
@@ -192,7 +192,7 @@ stop()
for zram_dev in $( grep zram /proc/swaps |awk '{print $1}' ); do {
logger -s -t zram_stop -p daemon.debug "deactivate swap $zram_dev"
- swapoff "$zram_dev" && zram_reset "$zram_dev" "claiming memory back"
+ /sbin/swapoff "$zram_dev" && zram_reset "$zram_dev" "claiming memory back"
local dev_index="$( echo $zram_dev | grep -o "[0-9]*$" )"
if [ $dev_index -ne 0 ]; then
logger -s -t zram_stop -p daemon.debug "removing zram $zram_dev"
More information about the lede-commits
mailing list