blob: 99be7738029e79c5050860b4caaf7d9a360eb1df [file] [log] [blame]
Steve Kondik2dc24f62010-07-06 00:19:10 -04001#!/system/bin/sh
2#
3# Compcache manager
4# shade@chemlab.org (cyanogen)
5#
6
wjb1818fc32011-04-05 12:23:45 -04007isramzswap="$(find /system/lib/modules/ -name ramzswap.ko 2>/dev/null)"
Abaakouk Mehdif92561b2011-04-04 15:36:58 +02008
9if [ -n "$isramzswap" ] ; then
10 MODULE=ramzswap
11 DEV=/dev/block/ramzswap0
12else
13 DEV=/dev/block/zram0
14 MODULE=zram
15 SYSFS_PATH=/sys/block/zram0
16fi
Steve Kondik2dc24f62010-07-06 00:19:10 -040017
18case "$1" in
19 start)
20 echo 3 > /proc/sys/vm/drop_caches
Steve Kondik0cd35702010-10-18 12:22:23 -040021 echo 30 > /proc/sys/vm/swappiness
Steve Kondik2dc24f62010-07-06 00:19:10 -040022 modprobe $MODULE
Abaakouk Mehdif92561b2011-04-04 15:36:58 +020023 if [ $MODULE = ramzswap ]; then
24 rzscontrol $DEV --disksize_kb=$2 --init
25 else
26 echo "$((2 * 1024))" > $SYSFS_PATH/disksize
27 mkswap $DEV >/dev/null
28 fi
Steve Kondik2dc24f62010-07-06 00:19:10 -040029 swapon $DEV
30 ;;
31
32 stop)
33 swapoff $DEV >/dev/null 2>&1
34 rmmod $MODULE >/dev/null 2>&1
35 ;;
36 stats)
Abaakouk Mehdif92561b2011-04-04 15:36:58 +020037 if [ $MODULE = ramzswap ]; then
38 rzscontrol $DEV --stats
39 else
40 cd $SYSFS_PATH && for i in * ; do
41 echo -n "$i:"
42 cat $i
43 done
44 fi
Steve Kondik2dc24f62010-07-06 00:19:10 -040045 ;;
46 *)
Wes Garner2f1711d2010-08-31 18:04:01 -050047 echo "Usage: $0 {start <size>|stop|stats}"
Steve Kondik2dc24f62010-07-06 00:19:10 -040048 exit 1
49esac
50
51exit 0
52