yashsingh1/xdaforums huggingface dataset:
[G1 Android Development] NLJ:
Troubles in logic of 05mountsd part

Hi!

I think I found some bad logic in 05mountsd.

First of all latest CM6 builds seem to not have e2fsck binaries, so line:

logwrapper e2fsck -y $PARTITION;

does not check anything ;o))

Moreover logwrapper hides return code and $? is 0 instead of 127 (logwrapper succeeded even tho e2fsck "failed"). Because of this cm.e2fsck.errors will always be 0 unless logwrapper fails for odd reason (please note LOGWRAPPER not E2FSCK).

Now there is this construct:

setprop cm.e2fsck.errors $?;

if [ "$?" = 0 ];

I think you wanted to check return code from e2fsck but you seem to forgot that $? always gives return code from LAST command so that "if" is checking return code from setprop.

My proposed soultion is in the attached patch (basically it removes e2fsck and goes stright to mounting).

And i really do hope anything above makes any sense to you =o)
[G1 Android Development] staunty:
If you tell me a line to add to the script, I can add it myself so that fixp works for me. As it stands now, if I run fix_permissions, all hell breaks loose. I can't describe exactly what happens but it basically results in me having to nand restore.
[G1 Android Development] NLJ:
@staunty

It's line 739:

sed s~/system/sd~\$SD_EXT_DIRECTORY~ $i -i

(repleace $SD_EXT_DIRECTORY with mount point of your ext partition)
[G1 Android Development] staunty:
Do you mean mount point as in: /dev/block/mmcblk0p2? That's the partition of my sd-ext...

EDIT: Aha! Got it. I also needed to edit line 733. You need to place the mount point between "" in the line: if [ "$SD_EXT_DIRECTORY" != "" ];
[G1 Android Development] staunty:
So much for that. **** started force closing left and right after running patched fix permissions...
[G1 Android Development] Firerat:
yes, I know

but e2fsck will be back at somepoint, so no harm in leaving it as is

but thanks

ps, its a straight pull from cm5 ( with Iconrand's work around for no block device )

if you really want to 'fix' it

http://github.com/CyanogenMod/andro...ob/froyo/prebuilt/common/etc/init.d/05mountsd

edit

but better solution

if [ -b "$PARTITION" ];
then
log -p i -t mountsd "Checking filesystems..";

# fsck the sdcard filesystem first
logwrapper e2fsck -y $PARTITION;
[B]e2fsckExitCode=$?[/B]
# set property with exit code in case an error occurs
setprop cm.e2fsck.errors [B]$e2fsckExitCode[/B];
if [ "[B]$e2fsckExitCode[/B]" = 0 ];
then

# mount and set perms
$BB mount -o noatime,nodiratime -t auto $PARTITION $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
[G1 Android Development] Firerat:
no you are confusing the block device with the mount point

the mount point is the directory on the filesystem, ( /sd-ext or /system/sd )

then block device is the partition ( /dev/block/mmcblk0p2 )

replace fixp function with

fixp ()
{
# new patch, universal i.e. cm5 cm6 or any ( will find mountpoint )
remountrw
for i in `find /system -iname "fix_permiss*"`;do
if [ "`grep -q fix $i;echo $?`" = "0" ];
then
if [ "`grep -q SD_EXT_DIRECTORY $i;echo $?`" != "0" ];
then
sed -e '/VERSION\=\"/ a # sdext mount point\nSD_EXT_DIRECTORY=\`egrep \"sd-ext\|\/system\/sd\" \/proc\/mounts\|awk \"{ print $2 }\"\`\nif \[ \"\$SD_EXT_DIRECTORY\" \= \"\" \]\;\nthen\n\tSD_EXT_DIRECTORY=\/sd-ext\nfi' -e s~/system/sd~\$SD_EXT_DIRECTORY~g $i -i
echo "--------------------------"
echo "$i Patched.."
echo "--------------------------"
else
echo "------------------------------------"
echo "$i is already Patched.."
echo "------------------------------------"
fi
fi
done
return
}

that will suit both mount points
[G1 Android Development] ichibanpnoy:
silly question, perhaps it is something i overlooked but...

why cant i get this script to run in recovery?

amon_ra recovery console

press enter

#

mount -a

sh /sdcard/fr-patch138b.txt all

"root is required to run this script type su and then run again"

any ideas? thx in advance
[G1 Android Development] Firerat:
intresting

the script checks if you have root

rootcheck ()
{
if [ "`busybox id -u`" != "0" ];
then
echo -e "root is required to run this script\ntype\nsu\nand then run again"
exit 1
fi
return
}

sed s/^rootcheck$/#rootcheck/ /sdcard/fr-patch138b.txt -i

will comment out that check, until I can have a proper look at it
[G1 Android Development] jacsonmoore3:
this is what i get when i try to install this..did it work or did it not work or what esle i need to do

export PATH=/data/local/bin:$PATH
$ export PATH=/data/local/bin:$PATH
$ su
# sh /sdcard/fr-patch138b.txt
Firerat script installer Version 1.3.8
Options:
a2sd apps2sdext ( for FroYo ) #NEW#
sdext sdext mount for cm6
lwp LWP fix *
lsd create legacy sd mount point
swap Auto setup swap *
shabang Patch Android scripts to work with ash
remount install remount scripts
fb Patch for Facebook 1.2.x sync on G1
fixp Patch fix_permissions with new sd mount point
dc2x DangerSPL : dalvik-cache will be bound with sd-ext *
NoneDangerSPL : dalvik-cache will be bound with cache *
MT3G : does nothing
all All of the above
* run-parts required ( autodetected )
--------------------------------------
rev <option> reverse the option (swap dc2x lwp )
--------------------------------------
example
sh /sdcard/fr-patch138b.txt swap lwp fixp
will setup swap, patch fix_permissions to see apps on sd
and setup the gpu permissions to enable lwp + 3d apps
# sh /sdcard/fr-patch138b.txt swap lwp fixp
--------------------------------
Danger detected
--------------------------------
--------------------------------------
/data/local/userinit.d/15GPU_perms installed
changes will take effect on next boot
--------------------------------------
--------------------------------------
hw3d.xml is already installed
--------------------------------------
find: /sd-ext/userinit.d: No such file or directory
-------------------------
/data/local/userinit.d/25Swap installed
-------------------------
-----------------------------------------------------
swappy utility installed
just run swappy if you want to change your swappiness
-----------------------------------------------------
find: /userinit.d: No such file or directory
current swappiness=60
what swappiness would you like?
enter a number between 1 and 100
[G1 Android Development] Firerat:
just made a little script, to figure out what has ( or hasn't ) been installed lwp wise

#!/system/bin/sh
alog="/sdcard/diaglwplog.txt"
ls -l /dev/msm_hw3d* |tee -a $alog
for i in 15GPU_perms hw3d.xml 20userinit;do
find /data/local/ /sd-ext/ /system/etc -name $i -exec ls -l {} \; |tee -a $alog
find /data/local/ /sd-ext/ /system/etc -name $i -exec cat {} \; |tee -a $alog
done
unix2dos $alog

it will find the files, tell me the permissions and what is in them

dumping all results to /sdcard/diaglwplog.txt

if you could post that file, I would be greatful

not sure when I can look at it, we finally know who our PM is here in the UK, so I'm going to pop out to the pub, lol, any excuse :)

if its something simple I might be able to fix it while I'm out

su
sh /sdcard/diaglwp.txt

tbh I don't like the need for su with this, but its needed to write the logfile
[G1 Android Development] nyctrini3:
Please don't flame me but how do you instal this? I tried. Before it said can't open file. Thanks
[G1 Android Development] bm6788:
What is the facebook script suppose to fix? I have a MT3G, and my contacts are able to sync but their photo's from facebook dont show up when i call them
[G1 Android Development] Firerat:
fb	Patch for Facebook 1.2.x [B]sync on G1[/B]

it patches

build.trout.prop(G1),

to be a little more like

build.sapphire.prop (mt3g)

does nothing for mt3g
[G1 Android Development] Firerat:
put it on your sdcard

su
sh /sdcard/fr-patch12.txt

it will list the options ( same is the code box in OP )

for example

su
sh /sdcard/fr-patch12.txt fixp

would just run the fix_permissions script

Oh, if you mounted your sdcard to get the file onto it, don't forget to 'unmount' it
[G1 Android Development] nyctrini3:
Thanks firerat I just got the idea I appreciate the quick response
[G1 Android Development] Neejay:
I'll wait for the "swap reverse" updated script before trying swap. I don't have experience with swap and wouldn't want to mess something up. Plus, I'm not sure if it would even help just yet (I see a lot of back and forth on swap opinions).

On a MT3G, is the "lsd" supposed to do anything? It just said "MT3G detected" and didn't show any feedback then went back to the prompt. I thought it created the /system/sd directory, but it wasn't there (manually made it after the fact).
[G1 Android Development] Firerat:
@shawn

I'm wondering if I have messed up the test for

userinit running

moving the files in /data/local/userinit.d/

to

/system/etc/init.d/

should fix it untill I have a proper look

su
busybox mount -o rw,remount /system
cp /data/local/userinit.d/* /etc/init.d/

and reboot

( rwsystem will do instead of the busybox thing, if you have the remount script ;) )

I wanted to do the least I needed to system files

might have backfired on me :o
[G1 Android Development] Klyentel:
Works!

Installed this earlier (all of the tweaks)...just dropping back in to leave some feed:

I must say Fire Rat has out done himself by making this such an easy patch to apply and it really, I mean really, brings the life out of a CM Rom.

Truly beautiful work, ;) Have you spoken to Cyan about implementing this into his future release? It looks to me like it fixes everything that is wrong with CM5 (which isn't much, mostly small bugs) so if he uses this along with his own new enhancements and/or tweaks...we can come out of this Test staging and have ourselves a "stable" Cyan eclair.:cool:
[G1 Android Development] Reyland:
does this script helps or fix anything on mytouch3g users(32b,the original)running cyan?

I'm using SuperBad rom and use this script,run just the fix permisions option and it's working better now,smoth,fast and no problems!Thanks!!
[G1 Android Development] shawn1224:
Thanks Firerat, working like a champ now :D
[G1 Android Development] trock62:
Firerat you are the Man, I went from 63mb use to 28mb internal memory and the laucher is more responsive. Loving this test Rom because of all your good work.:D:D:D:D:D:D

Phone [Black T-Mobile G1]

SPL [Danger]

ROM [HTCClays SuperBad CM5 V1.2.1GJ]

Radio [2.22.23.02]

Recovery [Amon RA Dream Recovery v1.6.2]

Storage [4 Gig Class 6]
[G1 Android Development] ZilverZurfarn:
Not to sound ungrateful, but...

...my G1 (with CM5 T3) has started to misbehave dramatically after running the script with

lsd swap remount fixp dc2x

- sluggish as molasses, then fast for a little while, then spontaneous reboots - Yikes!

Any way to undo what your script did? I foolishly didn't do a Nandroid before I ran the script...
[G1 Android Development] Firerat:
#!/system/bin/sh
for i in 25Swap 15GPU_perms 10bind-dc;do
find /sd-ext /data/local $i -exec rm {} \;
done

Edit: the above is *wrong* it will delete everything on sd-ext

I have corrected the attachment

#!/system/bin/sh
for i in 25Swap 15GPU_perms 10bind-dc;do
find /sd-ext /data/local -name $i -exec rm {} \;
done

Edit end :

that will undo most of it

lsd fixp and remount, should have no effect on the system, but I'll have options to revert them anyway at some point

attached

su
sh /sdcard/fr-depatch.txt

no need for options, it will undo swap lwp and dc2x

(takes effect after boot )

this script is now redundant, as of version 1.3 a reverse option is available for swap lwp and dc2x
[G1 Android Development] ZilverZurfarn:
I have only myself to blame, but after running the depatch script, all apps on sd-ext are gone...
[G1 Android Development] zim2dive:
Might I suggest a dummy-proof step-by-step how-to on using dc2x to flash CM5 (or other ROMs) for NoneDanger for the 1st or 2nd post?
[G1 Android Development] axlastro:
Will a simple reflash undo the patch too?
[G1 Android Development] Firerat:
NO ... I'm so sorry that was my fault

#!/system/bin/sh
for i in 25Swap 15GPU_perms 10bind-dc;do
find /sd-ext /data/local [B]-name[/B] $i -exec rm {} \;
done

I missed the -name bit
[G1 Android Development] Firerat:
no, the init scripts go to the sd ext partition , or data/local/

in a folder called userinit.d
[G1 Android Development] NLJ:
So best solution would be to check if it exists instead of blindly trying to use it =o)

I basically made a shortcut just to make it work properly here and now =o). If filesystem is in bad shape mount will refuse to mount it.

I beg to differ =o( e2fsckExitCode will get exit code of logwrapper and not e2fsck.

Have a look:

# uname -a
Linux localhost 2.6.34.2-cyanogenmod #14 PREEMPT Fri Aug 13 03:52:11 UTC 2010 armv6l GNU/Linux
# which e2fsck
# e2fsck -y /dev/block/mmcblk0p2
e2fsck: not found
# echo $?
127
# logwrapper e2fsck -y /dev/block/mmcblk0p2
# echo $?
0

see what i mean?

I just came up with something like this (please excuse some roughness i just made it):

if [ -b "$MMC" ];
then
FDISK="busybox fdisk"
PARTITION=`$FDISK -l $MMC | awk '/^\// && $5 == 83 {print $1;exit;}'`

if [ -b "$PARTITION" ];
then
E2FSCK=`which e2fsck`
e2fsckExitCode=0
if [ x$E2FSCK = x ];
then
log -p i -t mountsd "Checking filesystems..";
e2fsck -y $PARTITION;
e2fsckExitCode=$?
fi

# set property with exit code in case an error occurs
setprop cm.e2fsck.errors $e2fsckExitCode
if [ $e2fsckExitCode = 0 ];
then

# mount and set perms
$BB mount -o noatime,nodiratime -t auto $PARTITION $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

HTH =o)
[G1 Android Development] Firerat:
yes , I know it will, but it doesn't really matter does it

you are going to blindly mount the ext anyway?

but I'm going to agree with exporting the exit code,

like this

logwrapper $(e2fsck -y $PARTITION;e2fsckExitCode=`echo $?`)

maybe

if [ -e "`which e2fsck`" ];
then
logwrapper $(e2fsck -y $PARTITION;e2fsckExitCode=`echo $?`)
else
logwrapper echo "e2fsck not found, assuming $PARTITION error free"
e2fsckExitCode=0
fi
[G1 Android Development] NLJ:
Well than we are not that different, right? (when there is no e2fsck your script mounts it blindly too =o)

You can shorten it to:

logwrapper $(e2fsck -y $PARTITION; e2fsckExitCode=$?)

but i'm afraid it will not behave as expected. Since logwrapper forks and executes it's arguments than value of e2fsckExitCode will get lost as soon as forked process ends. =o(

why checking existance of existing file? =o)) (at this point /system is read-only so there is not a big chance that `which` has it wrong).

I think simplest way is:

if [ `which e2fsck` ];
...

Please don't take it personal. I do admire what you're doing for Android community. I'm just trying to help make it more bullet proof.
[G1 Android Development] Firerat:
the no such file or directory error should be harmless

I'll fix it so they are not displayed
[G1 Android Development] Firerat:
yeap

I just have a habit with $? of echoing it

if [ "`cmd <opt>;echo $?`" = "<some number>" ];

doh

got to make it easier and github these scripts :)

but yeah, the mount sd script has been broken since cm5, if not earlier

http://github.com/CyanogenMod/andro...ob/froyo/prebuilt/common/etc/init.d/05mountsd

is the place to properly fix it, ( its not put in official CM builds yet, but it will be soon )

I just added the script from cm5, and latter added the mknod work around ( some issue with the way some peoples partitions are setup stops them from being 'seen' until much later on ) , didn't really pay much attention to the rest of it

In all honesty I didn't imagine the a2sd script would be needed for all that long, its initial versions were much dirtier , just symlinking from sd-ext/app*/* to /data/app*/

redone it as symlinking the dirs to /sdext, but now looking to bind mount instead

Along with /data/data

but I'll have to come back to that, as it can get all messy

http://forum.cyanogenmod.com/topic/...ude-apkmanager/page__view__findpost__p__40429
[G1 Android Development] jojo76015:
I'm having the same problem here. how do I grant permission to the terminal emulator because it never asks for it?
[G1 Android Development] wrsg:
if i have a ext2 partition on my sd card and a Froyo rom (CM6 or Chromatic), and i run this script, will apps2ext just work?
[G1 Android Development] noodles2224:
Anyone know if we run the script each time new apps are installed or just reboot after the first time script has been ran? Besides that, works great :)
[G1 Android Development] NLJ:
It should =o)

There is no need to re-run this each time you install app.

If you want you can move app from ext2 back to phone memory using ApkManager.sh (you need to run it from terminal or adb shell)
[G1 Android Development] wrsg:
hehe, you don't sound 100% sure :P
[G1 Android Development] NLJ:
I'm sure. I'm just covering my a* ;o)))
[G1 Android Development] wrsg:
kewl thx

i am about 90% sure personally ;)
[G1 Android Development] brownbomba:
Hello,

I seem to have lost all of my free apps. How do I get them back. I ran the apps to ext patch but I can't seem to figure how to get all my apps back and also how to get them on the ext. The ext is not showing in the settings under sd card and phone storage.

Thanks
[G1 Android Development] Firerat:
gawd...

the a2sd script just symlinks /data/app to /sd-ext/app ( and app-private)

it will not show up in the android gui

and what do you mean you lost free apps, it makes no sense...

apps are moved to /sd-ext, then the app dir is linked , no reason you should lose anything..............................

if you can't tie a shoelace, don't root

edit: just scanned through your past posts, stick with velcro
[G1 Android Development] Noxxolous:
code from terminal

Firerat...if you would please...i really need the code from terminal to reduce the incoming call lag on cyan based eclair ROM...i saw it in a post some where but been searching for a day now :(
[G1 Android Development] Firerat:
errm

pass

I didn't post it
[G1 Android Development] NLJ:
renice -18 `pidof com.android.phone`

should help but this is not permanent (ie when com.android.phone dies for whatever reason it will loose the renice effect)
[G1 Android Development] wrsg:
would this script work on eclair roms?
[G1 Android Development] viande:
Hi, got a problem here with lwp script. In fact now my 3d games are stuttering like ****... wondering what happened.
[G1 Android Development] Firerat:
Well let us know when you find out,

Or decide to share which rom you are using, and which 3d games you are having problems with.
[G1 Android Development] Abhi_UK:
This happened to me on cm6 rc3 when I flashed it the first time. The lwp script doesn't let some apps have 3d permission so they run really slow like when I tried neocore after lwp script It would take more than an hour to complete if I let it run.
[G1 Android Development] Firerat:
if you let me know what apps I can maybe make a work around.

neocore workaround is already in 138b ( well, its always been in the scripts, just never turned on )
[G1 Android Development] cameron.t90:
i think radiant is also one game having performance issues, it keeps working after a new flash including your patch, then after i reboot its very sluggish :/
[G1 Android Development] Firerat:
yeah, just d/l the lite version, it doesn't have the WES permission

I'll have to check lwp's for the vibrate permission
[G1 Android Development] sauudmir:
i was flashing a radio update coz i'm not in US and read that the other one could give more signal strength outside US but it said theres not enough space when writing image file

so i tried ur patch to free up some memory space as i have done it before but then after applying ur patch i'm stuck on CyanogenMod boot animation :confused:
[G1 Android Development] Firerat:
you are very, very confused...

these patches have nothing to do with radio updates

seek "hands on" help if you wan't to update your radio, otherwise you will brick
[G1 Android Development] sauudmir:
no my main question is after i applied this patch i'm bootlooping on cyan boot screen ... before that it was running good
[G1 Android Development] Firerat:
you have not asked a single question, you have just made a series of statements which don't have any context.

just nand restore and move on.
[G1 Android Development] sauudmir:
when i use the apps2sdext to move my apps to external part does it reads it as internal as it did on CM5? i've been using fat32 for a while and decided to move back to ext so i did and after restoring my apps using titanium backup i moved them to ext using frpatch138b.txt but its saying that

moving com.what-ever-app.apk to internal ( tmp )

is it moving to ext or the rom memory on the phone?
[G1 Android Development] lobesy:
I am getting this error when running the latest version of the script in Recovery Console as well as appearing in the recovery log from flashing 1.5.3 of the custom MTD:

id: applet not found

root is required to run this script

type

su

and then run again

Attempting it with 1.34 in recovery console or 1.38b once the ROM has started booting works fine however.

Running latest CM6 nightly on a Dream with Amon Ra 1.7 Recovery and Danger SPL with the custom MTD stuff in addition.
[G1 Android Development] bigboidomo:
I used this universal mod on my htc hero cdma and iy worked nicely except when I go to nandroid out didn't work I use clockwork recovery can that bethe problem?

Did I catch you having fun? *slaps*
[G1 Android Development] cameron.t90:
Firerat I tried downloading the lite version of radiant and that too runs sluggish :/ what could I do to possibly get them to run how they do when I first flash? Do I need to run lwp? Or what? Thanks.
[G1 Android Development] hapa8o8:
Instruction

Are the instructions on the first post current? I just want to make sure
[G1 Android Development] rpmccormick:
(sorry for quick OffTopic... please reply in other thread, not this one)

Firerat (or other linux scripter): I have a request... I was wondering if you could make a script that would allow me to 'sh fr-install.txt update.zip' and have it follow all the instructions inside the zip. I need something like this because my ZT-180 tablet does not have a recovery that can flash zips, and we need to distribute our ROM mods somehow. We have root, adb, etc all setup. Either way, thanks for your work here.

ZT-180 Dev Thread
[G1 Android Development] Firerat:
its doable, in the past I have written a script to do this ( with the old update-script format )

I have no idea how different the zt-180 is, any real reason you can't kang a recovery an run that?

maybe I can have a better look at some point
[G1 Android Development] Firerat:
I use clockwork
[G1 Android Development] Firerat:
instructions are basically

run the script with sh