3f47346c30
Change-Id: Ib36051d48c232dc7b0bd6fdbb782847ca5ae6398
54 lines
1.1 KiB
Bash
Executable File
54 lines
1.1 KiB
Bash
Executable File
#!/system/bin/sh
|
|
#
|
|
# Compcache manager
|
|
# shade@chemlab.org (cyanogen)
|
|
#
|
|
|
|
isramzswap="$(find /system/lib/modules/ -name ramzswap.ko 2>/dev/null)"
|
|
isramzswapbuiltin="$(ls -l /dev/block/ramzswap0 2>/dev/null)"
|
|
|
|
if [ -n "$isramzswap$isramzswapbuiltin" ] ; then
|
|
MODULE=ramzswap
|
|
DEV=/dev/block/ramzswap0
|
|
else
|
|
DEV=/dev/block/zram0
|
|
MODULE=zram
|
|
SYSFS_PATH=/sys/block/zram0
|
|
fi
|
|
|
|
case "$1" in
|
|
start)
|
|
echo 3 > /proc/sys/vm/drop_caches
|
|
echo 30 > /proc/sys/vm/swappiness
|
|
modprobe $MODULE
|
|
if [ $MODULE = ramzswap ]; then
|
|
rzscontrol $DEV --disksize_kb=$2 --init
|
|
else
|
|
echo "$(($2 * 1024))" > $SYSFS_PATH/disksize
|
|
mkswap $DEV >/dev/null
|
|
fi
|
|
swapon $DEV
|
|
;;
|
|
|
|
stop)
|
|
swapoff $DEV >/dev/null 2>&1
|
|
rmmod $MODULE >/dev/null 2>&1
|
|
;;
|
|
stats)
|
|
if [ $MODULE = ramzswap ]; then
|
|
rzscontrol $DEV --stats
|
|
else
|
|
cd $SYSFS_PATH && for i in * ; do
|
|
echo -n "$i:"
|
|
cat $i
|
|
done
|
|
fi
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start <size>|stop|stats}"
|
|
exit 1
|
|
esac
|
|
|
|
exit 0
|
|
|