zram-swap: bail out early if the kernel doesn't support swap
authorRui Salvaterra <rsalvaterra@gmail.com>
Thu, 1 Apr 2021 13:36:33 +0000 (14:36 +0100)
committerHauke Mehrtens <hauke@hauke-m.de>
Sat, 3 Apr 2021 16:57:13 +0000 (18:57 +0200)
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@gmail.com>
package/system/zram-swap/files/zram.init

index 685648aae56001e13377a91d03a7f7ca482f473f..d97e85efa58d8f92b5392c6f9ba37508b639951a 100755 (executable)
@@ -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