[openwrt/openwrt] zram-swap: bail out early if the kernel doesn't support swap

LEDE Commits lede-commits at lists.infradead.org
Sat Apr 3 18:17:41 BST 2021


hauke pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/565dfeb1280343fb3f838581169e5d7a1c947862

commit 565dfeb1280343fb3f838581169e5d7a1c947862
Author: Rui Salvaterra <rsalvaterra at gmail.com>
AuthorDate: Thu Apr 1 14:36:33 2021 +0100

    zram-swap: bail out early if the kernel doesn't support swap
    
    Since KERNEL_SWAP is only enabled by default for !SMALL_FLASH targets, we need
    to check if the current kernel supports swap before trying to configure
    zram-swap, as opkg can't check for kernel dependencies.
    
    Signed-off-by: Rui Salvaterra <rsalvaterra at gmail.com>
---
 package/system/zram-swap/files/zram.init | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/package/system/zram-swap/files/zram.init b/package/system/zram-swap/files/zram.init
index 685648aae5..d97e85efa5 100755
--- a/package/system/zram-swap/files/zram.init
+++ b/package/system/zram-swap/files/zram.init
@@ -150,6 +150,11 @@ zram_compact()
 
 start()
 {
+	[ -e /proc/swaps ] || {
+		logger -s -t zram_start -p daemon.crit "kernel doesn't support swap"
+		return 1
+	}
+
 	if [ $( grep -cs zram /proc/swaps ) -ne 0 ]; then
 		logger -s -t zram_start -p daemon.notice "[OK] zram swap is already mounted"
 		return 1



More information about the lede-commits mailing list