I know that in the Android boot up sequence, after the Linux kernel boots up, it looks for init.
I replaced init with my custom C application myapp. In myapp, I wait for a user input for 5 seconds. If nothing is received, I want to run the original init, which I renamed as init_original. If I received user input, I wanna go on to do my stuff.
I placed my custom init and init_original in my unpacked ramdisk and cpio-ed and gzip-ed it according to instructions from http://android-dls.com/wiki/index.php?title=HOWTO:_Unpack%2C_Edit%2C_and_Re-Pack_Boot_Images
init_original is successfully called from my program using execve(). However, I get the following output:
[ 3.851928] cpuidle: initiated for CPU0.
[ 3.857116] cpuidle: initiated for CPU1.
[ 3.862579] Freeing init memory: 320K
===============================================================================
Application started
Press enter in 1 second to enter test tool...
1 second is up, starting normal init
[ 4.883422] init: /init.rc: 865: ignored duplicate definition of service 'ril-daemon'
[ 8.247894] av8100_hdmi av8100_hdmi.3: HDMI display probed
[ 9.694915] init: Timed out waiting for /dev/.coldboot_done
[ 9.839630] init: cannot find '/system/bin/logwrapper', disabling 'cspsa'
[ 9.847137] init: cannot execve('/system/bin/logwrapper'): No such file or directory
[ 9.855102] init: /system/bin/logwrapper terminated with status 127.
[ 9.869934] init: cannot find '/system/xbin/watchdog-kicker', disabling 'watchdog-kicker'
[ 9.887695] init: cannot find '/system/bin/ifconfig', disabling 'shrm-netdev'
[ 9.894836] init: cannot find '/system/bin/sh', disabling 'modem'
[ 9.907714] init: cannot find '/system/bin/modem-supervisor', disabling 'modem-supervisor'
[ 9.916015] init: cannot find '/system/bin/copsdaemon', disabling 'copsd'
[ 9.922851] init: cannot find '/system/bin/cn_server', disabling 'cn_server'
[ 9.929931] init: cannot find '/system/bin/simd', disabling 'simd'
....
Any idea what’s wrong? Something to do with the way I call init_original, or the way I repacked the ramdisk.img, or something else?
Thanks!
Ok I found the answer.
I did it the other way around, the original
init.cis edited to callmyappinstead.In android’s /system/core/init:
init.c, I callmyappafter the lineIf
myappis called beforeumask(0), the same errors shown aboe happen. I’ve no idea why it works this way though. If anyone can explain to me whatumask(0)is doing (setting permissions or something like that I think) I will be grateful.