zram-swap: CONFIG_PROCD_ZRAM_TMPFS compatibility
[openwrt/staging/mkresin.git] / package / system / zram-swap / files / zram.init
index 23de915c8f13da31ad406d3c5895e956fc104c43..431e47c8f944192f142b09da99b3b89acefb6fb8 100644 (file)
@@ -71,8 +71,17 @@ zram_reset()
 
 list_cpu_idx()
 {
-       local line i=0
-
+       # Offset by 1 if /dev/zram0 is in use by /tmp
+       if [ "$(mount | grep /dev/zram0)" ]; then
+               local line i=1
+               # Hot-add new ZRAM device (if necessary)
+               if [ ! -b /dev/zram1 ]; then 
+                       cat /sys/class/zram-control/hot_add
+               fi
+       else
+               local line i=0
+       fi
+       
        while read line; do {
                case "$line" in
                        [Pp]rocessor*)