I've found this issue across all ROMs.
What I've discovered is the init script that does the SD mounting is in a race condition against system_server.
If system_server beats them to the /data directories then it has already grabbed ahold of that FD and won't let go. Since the link points no where, or in the case of bind mounts, the empty directory underneath the mount, there are no apps to enumerate.
I wrote my own App2Ext4 init script for CM ROMs that sort of remedies the situation by checking for system_server in the empty un-bound directories and kills it if it finds it. It basically causes a single "boot loop" (you see the boot animation twice), but you'll stop losing the apps on the Launcher, and most importantly widgets won't have to be set back up.
The remaining bug is if you lose the race and system_process wins, and you have to kill it to keep the Launcher and Apps sane; you'll lose some login information, and I can't figure out where it's stored.
Twitter logs out
Facebook stops syncing
More than a few mobile banking apps "forget" things
Not sure what version this is, I play with it alot, but this gives the basic gist.
Code:#!/system/bin/sh # App2Ext4 A2E4ERROR=0 A2E4LOGFILE="/data/local/tmp/a2e4.log" A2E4SYSLOG="true" # Cut log to last 50 lines [ "${A2E4LOGFILE}" != "" ] && [ -f ${A2E4LOGFILE} ] && sed -e ':a' -e '$q;N;51,$D;ba' -i ${A2E4LOGFILE} # Dump logs to file, syslog, and console logdump() { [ "${A2E4LOGFILE}" != "" ] && echo "App2Ext4: ${1}" >> ${A2E4LOGFILE} [ "${A2E4SYSLOG:=false}" == "true" ] && log -p i -t App2Ext4 -- "${1}" echo "App2Ext4: ${1}" } # Mount the sd-ext, should only be called if missing. mountsdext() { # load ext4 if [ -f /system/lib/modules/ext4.ko ]; then modprobe ext4 else logdump "FAILURE: can not find ext4 kernel module" A2E4ERROR=$((A2E4ERROR+1)) exit $A2E4ERROR 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 # 2nd partition of sdcard should be the sd-ext if exist SD_EXT_PART=/dev/block/mmcblk${MMC_NUM}p2 break fi done if [ -b "$SD_EXT_PART" ]; then logdump "INFO: Checking filesystems" # fsck the sdcard filesystem first if [ -x `which e2fsck` ]; then e2fsck -y $SD_EXT_PART e2fsk_exitcode=$? else logdump "INFO: 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, don't -t ext3 so ext4 will do the work for 2,3&4 mount -o noatime,nodiratime,barrier=1 $SD_EXT_PART $SD_EXT_DIRECTORY if [ "$?" = 0 ]; then chown 1000:1000 $SD_EXT_DIRECTORY chmod 771 $SD_EXT_DIRECTORY logdump "SUCCESS: $SD_EXT_DIRECTORY successfully mounted" else logdump "FAILURE: Unable to mount filesystem for $SD_EXT_DIRECTORY!" A2E4ERROR=$((A2E4ERROR+1)) exit $A2E4ERROR fi else logdump "FAILURE: Unable to repair filesystem, disabling apps2sd" A2E4ERROR=$((A2E4ERROR+1)) exit $A2E4ERROR fi fi } # Check mount proc # + Checks to see if system_server beat us to this mount point, kills it if so chkpsmount() { if [ "${1}" != "" ]; then TGT=$1 else TGT=/data/app fi for i in $(fuser -m ${TGT}); do PNAME=$(ps -p ${i} |tail -n +2|awk '{print $13}') if [ "${PNAME}" == "system_server" ]; then logdump "WARNING: ${PNAME}:${i} beat us to the mount, killing ${i}" kill ${i} fi done } logdump "+ $(date)" # Start FS registration if [ ${A2E4ERROR:=0} -eq 0 ]; then sync setprop cm.filesystem.ready 0 fi if [ "$SD_EXT_DIRECTORY" = "" ]; then SD_EXT_DIRECTORY=/sd-ext fi if [ "$(egrep -q $SD_EXT_DIRECTORY /proc/mounts;echo $?)" != "0" ]; then logdump "INFO: $SD_EXT_DIRECTORY is not mounted, attemping to mount" mountsdext if [ "$(egrep -q $SD_EXT_DIRECTORY /proc/mounts;echo $?)" != "0" ]; then logdump "FAILURE: $SD_EXT_DIRECTORY is not mounted, exiting" A2E4ERROR=$((A2E4ERROR+1)) exit $A2E4ERROR fi fi # Apps if [ "$(egrep -q "/data/app" /proc/mounts;echo $?)" != "0" ]; then [ ! -d $SD_EXT_DIRECTORY/app ] && mkdir $SD_EXT_DIRECTORY/app chown system:system $SD_EXT_DIRECTORY/app chmod 0771 $SD_EXT_DIRECTORY/app chkpsmount /data/app mount -o bind $SD_EXT_DIRECTORY/app/ /data/app if [ "$(egrep -q "/data/app" /proc/mounts;echo $?)" = "0" ]; then logdump "SUCCESS: $SD_EXT_DIRECTORY/app mounted on /data/app" else logdump "FAILURE: $SD_EXT_DIRECTORY/app failed to mount" A2E4ERROR=$((A2E4ERROR+1)) exit $A2E4ERROR fi else logdump "WARNING: $SD_EXT_DIRECTORY/app was already mounted" fi # Apps-private if [ "$(egrep -q "/data/app-private" /proc/mounts;echo $?)" != "0" ]; then [ ! -d $SD_EXT_DIRECTORY/app-private ] && mkdir $SD_EXT_DIRECTORY/app-private chown system:system $SD_EXT_DIRECTORY/app-private chmod 0771 $SD_EXT_DIRECTORY/app-private chkpsmount /data/app-private mount -o bind $SD_EXT_DIRECTORY/app-private /data/app-private if [ "$(egrep -q "/data/app-private" /proc/mounts;echo $?)" = "0" ]; then logdump "SUCCESS: $SD_EXT_DIRECTORY/app-private mounted on /data/app-private" else logdump "FAILURE: $SD_EXT_DIRECTORY/app-private failed to mount" A2E4ERROR=$((A2E4ERROR+1)) exit $A2E4ERROR fi else logdump "WARNING: $SD_EXT_DIRECTORY/app-private was already mounted" fi # Complete FS registration if [ ${A2E4ERROR:=0} -eq 0 ]; then sync setprop cm.filesystem.ready 1 fi logdump "- $(date)"


LinkBack URL
About LinkBacks
Reply With Quote