#!/system/bin/sh
#
# Sets sdcard read cache size

if [ -e /system/bin/log ];
then
    LOGI="log -p i -t mountsd --"
    LOGE="log -p e -t mountsd --"
else
    LOGI=echo
    LOGE=echo
fi

FREQ_LIST_FILE2="/data/local/tmp/available_frequencies"
DEFAULT_KB="2048KB"
DEFAULT=`/system/xbin/echo $DEFAULT_KB | /system/xbin/sed 's/KB//'`
PROP_KB=`getprop persist.sys.sdcardcachereadsize`
PROP=`/system/xbin/echo $PROP_KB | /system/xbin/sed 's/KB//'`

if [ -e /proc/x8oc ]
then
	/system/bin/cat /proc/x8oc | /system/xbin/grep '^     1' | /system/xbin/awk '{print $2}'| /system/xbin/tr '\n' ' ' > $FREQ_LIST_FILE2
fi

if [ -n "$PROP_KB" ];
then
	$LOGI "defined sdcard cache read size is $PROP_KB"
	if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ]
	then
		/system/xbin/echo $PROP > /sys/devices/virtual/bdi/179\:0/read_ahead_kb
	fi
else
	$LOGI "no sdcard cache read size defined, using default of $DEFAULT_KB"
	setprop persist.sys.sdcardcachereadsize $DEFAULT_KB
	/system/xbin/echo $DEFAULT > /sys/devices/virtual/bdi/179:0/read_ahead_kb
fi

