BB 0.6.2.1 and link2sd 1.5.5 on OG Droid

This is a discussion on BB 0.6.2.1 and link2sd 1.5.5 on OG Droid within the Bugless forums, part of the Custom Roms category; 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 ...

+ Reply to Thread
Page 2 of 2 FirstFirst 1 2
Results 11 to 12 of 12

Thread: BB 0.6.2.1 and link2sd 1.5.5 on OG Droid

  1. Junior Droid
    neoaeon's Avatar
    Member #
    183384
    Join Date
    Mar 2011
    Posts
    17
    Phone
    Motorola DROID
    #11
    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)"
  2. Master Droid
    buellboy9's Avatar
    Member #
    53378
    Join Date
    Mar 2010
    Posts
    370
    Liked
    1 times
    Phone
    Motorola Droid
    #12
    Interesting, but your script was written for CM and not BB, right?

Sponsors

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Similar Threads

  1. Problem with link2sd
    By rishisinghreen in forum Tech Issues, Bug Reports & Suggestions
    Replies: 12
    Last Post: 08-11-2011, 03:47 PM
  2. Link2sd Issues
    By dpaine88 in forum Project Elite
    Replies: 5
    Last Post: 06-16-2011, 10:07 PM
  3. Updating CM7 - deprimed, link2sd, etc
    By chmcclellan in forum Cyanogenmod
    Replies: 7
    Last Post: 04-30-2011, 10:15 AM

Search tags for this page

1.5.5 do link2sd
,
avata 1.5.5
,

avatar 1.5.5

,
bugless beast link2sd
,
create link failure not allowed to su
,

link2sd

,

link2sd apps disappear

,

link2sd create link failure

,
link2sd create link failure not allowed to su
,
link2sd droid 1
,
link2sd ext4
,
link2sd failure
,

link2sd not allowed to su

,

link2sd quick reboot

,

og droid

Click on a term to search our site for related topics.

Tags for this Thread