#!/system/bin/sh
#=====================================================
#=====================================================
#=== Fly-On Mod SDCard speed Fix by Slaid480@XDA ====
#=====================================================
#=====================================================

#============ Copyright (C) 2013 Salah Abouabdallah(Slaid480)===========#
 
#  This program is free software: you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
 
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#  GNU General Public License for more details.
 
#  You should have received a copy of the GNU General Public License along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
#=======================================================================#

FLY=/data/Fly-On/03sdcardspeedfix.log

busybox rm -f $FLY
busybox touch $FLY

echo "# Fly-On Mod LOGGING ENGINE" | tee -a $FLY
echo "" | tee -a $FLY
echo "$( date +"%m-%d-%Y %H:%M:%S" ) Tweaking SDCard read_ahead cache..." | tee -a $FLY;


READ_AHEAD_KB="2048"

if [ -e /sys/devices/virtual/bdi/0:18/read_ahead_kb ]; then
    echo $READ_AHEAD_KB > /sys/devices/virtual/bdi/0:18/read_ahead_kb
    echo "SD card read ahead kb SET to $READ_AHEAD_KB"
fi

if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ]; then
    echo $READ_AHEAD_KB > /sys/devices/virtual/bdi/179:0/read_ahead_kb
    echo "SD card read ahead kb SET to $READ_AHEAD_KB"
fi

if [ -e /sys/devices/virtual/bdi/7:0/read_ahead_kb ]; then
    echo $READ_AHEAD_KB > /sys/devices/virtual/bdi/7:0/read_ahead_kb
    echo "SD card read ahead kb SET to $READ_AHEAD_KB"
fi

if [ -e /sys/devices/virtual/bdi/7:1/read_ahead_kb ]; then
    echo $READ_AHEAD_KB > /sys/devices/virtual/bdi/7:1/read_ahead_kb
    echo "SD card read ahead kb SET to $READ_AHEAD_KB"
fi

if [ -e /sys/devices/virtual/bdi/7:2/read_ahead_kb ]; then
    echo $READ_AHEAD_KB > /sys/devices/virtual/bdi/7:2/read_ahead_kb
    echo "SD card read ahead kb SET to $READ_AHEAD_KB"
fi

if [ -e /sys/devices/virtual/bdi/7:3/read_ahead_kb ]; then
    echo $READ_AHEAD_KB > /sys/devices/virtual/bdi/7:3/read_ahead_kb
    echo "SD card read ahead kb SET to $READ_AHEAD_KB"
fi

if [ -e /sys/devices/virtual/bdi/7:4/read_ahead_kb ]; then
    echo $READ_AHEAD_KB > /sys/devices/virtual/bdi/7:4/read_ahead_kb
    echo "SD card read ahead kb SET to $READ_AHEAD_KB"
fi

if [ -e /sys/devices/virtual/bdi/7:5/read_ahead_kb ]; then
    echo $READ_AHEAD_KB > /sys/devices/virtual/bdi/7:5/read_ahead_kb
    echo "SD card read ahead kb SET to $READ_AHEAD_KB"
fi

if [ -e /sys/devices/virtual/bdi/7:6/read_ahead_kb ]; then
    echo $READ_AHEAD_KB > /sys/devices/virtual/bdi/7:6/read_ahead_kb
    echo "SD card read ahead kb SET to $READ_AHEAD_KB"
fi

if [ -e /sys/devices/virtual/bdi/7:7/read_ahead_kb ]; then
    echo $READ_AHEAD_KB > /sys/devices/virtual/bdi/7:7/read_ahead_kb
    echo "SD card read ahead kb SET to $READ_AHEAD_KB"
fi

if [ -e /sys/devices/virtual/bdi/default/read_ahead_kb ]; then
    echo $READ_AHEAD_KB > /sys/devices/virtual/bdi/default/read_ahead_kb
    echo "SD card read ahead kb SET to $READ_AHEAD_KB"
fi



echo "" | tee -a $FLY
echo "$( date +"%m-%d-%Y %H:%M:%S" ) SDCard tweaking done!" | tee -a $FLY;
