8ba581ead2
check for mmc device type = SD mount sd-ext partition by label = sd-ext we are smart, so only ext4 support removed wait for device Change-Id: Ie1ee2de3365d5515030d46801099418607e1265e
68 lines
1.9 KiB
Bash
68 lines
1.9 KiB
Bash
#!/system/bin/sh
|
|
#
|
|
# mount ext4 partition from sd card
|
|
|
|
BB="logwrapper busybox";
|
|
|
|
if [ "$SD_EXT_DIRECTORY" = "" ];
|
|
then
|
|
SD_EXT_DIRECTORY=/sd-ext;
|
|
fi;
|
|
|
|
# find SD Card
|
|
for MMC_NUM in `seq 0 9`;
|
|
do
|
|
MMC_TYPE=`cat /sys/block/mmcblk$MMC_NUM/device/type`
|
|
if [ "$MMC_TYPE" = "SD" ];
|
|
then
|
|
SDCARD=/dev/block/mmcblk$MMC_NUM
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [ -b "$SDCARD" ];
|
|
then
|
|
# find sd-ext partition by label
|
|
PARTITIONS=`cat /proc/partitions|grep mmcblk$MMC_NUM|grep -v "mmcblk$MMC_NUM$"|awk '{print $4}'`
|
|
for PARTITION in $PARTITIONS
|
|
do
|
|
LABEL=`e2label /dev/block/$PARTITION`
|
|
if [ "$LABEL" = "sd-ext" ];
|
|
then
|
|
SD_EXT_PART=/dev/block/$PARTITION
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [ -b "$SD_EXT_PART" ];
|
|
then
|
|
log -p i -t mountsd "Checking filesystems..";
|
|
|
|
# fsck the sdcard filesystem first
|
|
if [ -x `which e2fsck` ];
|
|
then
|
|
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,barrier=1,data=ordered,noauto_da_alloc -t ext4 $SD_EXT_PART $SD_EXT_DIRECTORY;
|
|
if [ "$?" = 0 ];
|
|
then
|
|
$BB chown 1000:1000 $SD_EXT_DIRECTORY;
|
|
$BB chmod 771 $SD_EXT_DIRECTORY;
|
|
log -p i -t mountsd "$SD_EXT_DIRECTORY successfully mounted";
|
|
else
|
|
log -p e -t mountsd "Unable to mount filesystem for $SD_EXT_DIRECTORY!";
|
|
fi
|
|
else
|
|
log -p e -t mountsd "Unable to repair filesystem, disabling apps2sd";
|
|
fi
|
|
fi
|
|
fi
|