Steve Kondik | 2dc24f6 | 2010-07-06 00:19:10 -0400 | [diff] [blame] | 1 | #!/system/bin/sh |
2 | # | ||||
3 | # Compcache manager | ||||
4 | # shade@chemlab.org (cyanogen) | ||||
5 | # | ||||
6 | |||||
Abaakouk Mehdi | 3cf39ad | 2011-02-16 09:50:57 +0100 | [diff] [blame^] | 7 | DEV=/dev/block/zram0 |
8 | SYSFS_PATH=/sys/block/zram0 | ||||
9 | MODULE=zram | ||||
Steve Kondik | 2dc24f6 | 2010-07-06 00:19:10 -0400 | [diff] [blame] | 10 | |
11 | case "$1" in | ||||
12 | start) | ||||
13 | echo 3 > /proc/sys/vm/drop_caches | ||||
Steve Kondik | 0cd3570 | 2010-10-18 12:22:23 -0400 | [diff] [blame] | 14 | echo 30 > /proc/sys/vm/swappiness |
Steve Kondik | 2dc24f6 | 2010-07-06 00:19:10 -0400 | [diff] [blame] | 15 | modprobe $MODULE |
Abaakouk Mehdi | 3cf39ad | 2011-02-16 09:50:57 +0100 | [diff] [blame^] | 16 | echo "$2" > $SYSFS_PATH/disksize |
17 | mkswap $DEV >/dev/null | ||||
Steve Kondik | 2dc24f6 | 2010-07-06 00:19:10 -0400 | [diff] [blame] | 18 | swapon $DEV |
19 | ;; | ||||
20 | |||||
21 | stop) | ||||
22 | swapoff $DEV >/dev/null 2>&1 | ||||
23 | rmmod $MODULE >/dev/null 2>&1 | ||||
24 | ;; | ||||
25 | stats) | ||||
Abaakouk Mehdi | 3cf39ad | 2011-02-16 09:50:57 +0100 | [diff] [blame^] | 26 | cd $SYSFS_PATH && for i in * ; do |
27 | echo -n "$i:" | ||||
28 | cat $i | ||||
29 | done | ||||
Steve Kondik | 2dc24f6 | 2010-07-06 00:19:10 -0400 | [diff] [blame] | 30 | ;; |
31 | *) | ||||
Wes Garner | 2f1711d | 2010-08-31 18:04:01 -0500 | [diff] [blame] | 32 | echo "Usage: $0 {start <size>|stop|stats}" |
Steve Kondik | 2dc24f6 | 2010-07-06 00:19:10 -0400 | [diff] [blame] | 33 | exit 1 |
34 | esac | ||||
35 | |||||
36 | exit 0 | ||||
37 |