2010-07-06 04:19:10 +00:00
|
|
|
#!/system/bin/sh
|
|
|
|
#
|
|
|
|
# Compcache manager
|
|
|
|
# shade@chemlab.org (cyanogen)
|
|
|
|
#
|
|
|
|
|
2011-04-05 16:23:45 +00:00
|
|
|
isramzswap="$(find /system/lib/modules/ -name ramzswap.ko 2>/dev/null)"
|
2011-04-07 22:28:27 +00:00
|
|
|
isramzswapbuiltin="$(ls -l /dev/block/ramzswap0 2>/dev/null)"
|
2011-04-04 13:36:58 +00:00
|
|
|
|
2011-04-07 22:28:27 +00:00
|
|
|
if [ -n "$isramzswap$isramzswapbuiltin" ] ; then
|
2011-04-04 13:36:58 +00:00
|
|
|
MODULE=ramzswap
|
|
|
|
DEV=/dev/block/ramzswap0
|
|
|
|
else
|
|
|
|
DEV=/dev/block/zram0
|
|
|
|
MODULE=zram
|
|
|
|
SYSFS_PATH=/sys/block/zram0
|
|
|
|
fi
|
2010-07-06 04:19:10 +00:00
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
echo 3 > /proc/sys/vm/drop_caches
|
2010-10-18 16:22:23 +00:00
|
|
|
echo 30 > /proc/sys/vm/swappiness
|
2010-07-06 04:19:10 +00:00
|
|
|
modprobe $MODULE
|
2011-04-04 13:36:58 +00:00
|
|
|
if [ $MODULE = ramzswap ]; then
|
|
|
|
rzscontrol $DEV --disksize_kb=$2 --init
|
|
|
|
else
|
2011-04-10 21:25:16 +00:00
|
|
|
echo "$(($2 * 1024))" > $SYSFS_PATH/disksize
|
2011-04-04 13:36:58 +00:00
|
|
|
mkswap $DEV >/dev/null
|
|
|
|
fi
|
2010-07-06 04:19:10 +00:00
|
|
|
swapon $DEV
|
|
|
|
;;
|
|
|
|
|
|
|
|
stop)
|
|
|
|
swapoff $DEV >/dev/null 2>&1
|
|
|
|
rmmod $MODULE >/dev/null 2>&1
|
|
|
|
;;
|
|
|
|
stats)
|
2011-04-04 13:36:58 +00:00
|
|
|
if [ $MODULE = ramzswap ]; then
|
|
|
|
rzscontrol $DEV --stats
|
|
|
|
else
|
|
|
|
cd $SYSFS_PATH && for i in * ; do
|
|
|
|
echo -n "$i:"
|
|
|
|
cat $i
|
|
|
|
done
|
|
|
|
fi
|
2010-07-06 04:19:10 +00:00
|
|
|
;;
|
|
|
|
*)
|
2010-08-31 23:04:01 +00:00
|
|
|
echo "Usage: $0 {start <size>|stop|stats}"
|
2010-07-06 04:19:10 +00:00
|
|
|
exit 1
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|
|
|
|
|