2010-07-06 03:09:35 +00:00
|
|
|
#!/system/bin/sh
|
|
|
|
#
|
2011-01-20 15:09:46 +00:00
|
|
|
# mount ext partition from sd card
|
2010-07-06 03:09:35 +00:00
|
|
|
|
|
|
|
BB="logwrapper busybox";
|
|
|
|
|
|
|
|
if [ "$SD_EXT_DIRECTORY" = "" ];
|
|
|
|
then
|
|
|
|
SD_EXT_DIRECTORY=/sd-ext;
|
|
|
|
fi;
|
|
|
|
|
2010-12-30 18:11:27 +00:00
|
|
|
# find SD Card
|
|
|
|
for MMC_NUM in `seq 0 9`;
|
2010-07-06 03:09:35 +00:00
|
|
|
do
|
2010-12-30 18:11:27 +00:00
|
|
|
MMC_TYPE=`cat /sys/block/mmcblk$MMC_NUM/device/type`
|
|
|
|
if [ "$MMC_TYPE" = "SD" ];
|
|
|
|
then
|
2011-01-20 15:09:46 +00:00
|
|
|
# 2nd partition of sdcard should be the sd-ext if exist
|
|
|
|
SD_EXT_PART=/dev/block/mmcblk${MMC_NUM}p2
|
2010-12-30 18:11:27 +00:00
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
2010-07-06 03:09:35 +00:00
|
|
|
|
2011-01-20 15:09:46 +00:00
|
|
|
if [ -b "$SD_EXT_PART" ];
|
2010-07-06 03:09:35 +00:00
|
|
|
then
|
2011-01-20 15:09:46 +00:00
|
|
|
log -p i -t mountsd "Checking filesystems..";
|
2010-07-06 03:09:35 +00:00
|
|
|
|
2011-01-20 15:09:46 +00:00
|
|
|
# fsck the sdcard filesystem first
|
|
|
|
if [ -x `which e2fsck` ];
|
2010-07-06 03:09:35 +00:00
|
|
|
then
|
2011-01-20 15:09:46 +00:00
|
|
|
e2fsck -y $SD_EXT_PART
|
|
|
|
e2fsk_exitcode=$?
|
|
|
|
else
|
|
|
|
echo "executable e2fsck not found, assuming no filesystem errors"
|
|
|
|
e2fsk_exitcode=0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# set property with exit code in case an error occurs
|
|
|
|
setprop cm.e2fsck.errors $e2fsk_exitcode;
|
|
|
|
if [ "$e2fsk_exitcode" -lt 2 ];
|
|
|
|
then
|
|
|
|
# mount and set perms
|
|
|
|
$BB mount -o noatime,nodiratime,barrier=1 -t ext3 $SD_EXT_PART $SD_EXT_DIRECTORY;
|
|
|
|
if [ "$?" = 0 ];
|
2010-07-06 03:09:35 +00:00
|
|
|
then
|
2011-01-20 15:09:46 +00:00
|
|
|
$BB chown 1000:1000 $SD_EXT_DIRECTORY;
|
|
|
|
$BB chmod 771 $SD_EXT_DIRECTORY;
|
|
|
|
log -p i -t mountsd "$SD_EXT_DIRECTORY successfully mounted";
|
2010-07-06 03:09:35 +00:00
|
|
|
else
|
2011-01-20 15:09:46 +00:00
|
|
|
log -p e -t mountsd "Unable to mount filesystem for $SD_EXT_DIRECTORY!";
|
2010-07-06 03:09:35 +00:00
|
|
|
fi
|
2011-01-20 15:09:46 +00:00
|
|
|
else
|
|
|
|
log -p e -t mountsd "Unable to repair filesystem, disabling apps2sd";
|
2010-07-06 03:09:35 +00:00
|
|
|
fi
|
|
|
|
fi
|