Where are the C files available in linux(I use Ubuntu) that generate init executable?
It depends which package provides the init
executable. In a default Ubuntu Utopic install, /sbin/init
is a symlink to /sbin/upstart
, so you would want to find the source to upstart
. A simple search with your favorite search engine will probably point you to the Upstart page, which includes links to source downloads and the VCS repository.
You can also use the apt-get source
command to download the sources for a particular package. You also need the dpkg-dev
package installed (apt-get install dpkg-dev
), after which you can run:
apt-get source upstart
After which you will have:
root@ubuntu:~# ls upstart-1.13.2/
ABOUT-NLS config.guess contrib extra ltmain.sh po TODO
aclocal.m4 config.h.in COPYING HACKING m4 README util
AUTHORS config.rpath dbus init Makefile.am README.tests
ChangeLog config.sub debian INSTALL Makefile.in scripts
compile configure depcomp install-sh missing test
conf configure.ac doc lib NEWS test-driver
On Ubuntu Vivid, /sbin/init
is a symlink to /lib/systemd/systemd
, so you will want to get the systemd sources.
Note that both upstart and systemd operate very different from the legacy /sbin/init
system. The documentation at the above links describes how each system operates.
How is the init called from the kernel module; how does the bootloader call init module after reaching out to the kernel /boot/vmlinuz file?
The bootloader doesn't call init
. The bootloader loads and executes the kernel.
Is there a way to trace which function calls init function? What I tried so far: Tried to go through readelf and nm but couldn't trace back to the callee using them.
I'm not clear what you're trying to do here. The kernel calls /sbin/init
. Maybe this question is relevant.
Boot procedure after systemd replacing init. I came to an understanding that the listening sockets are invoked first related to udev and d-bus; and then every process kick starts and get connections to these sockets. But I needed clarity in understanding how the system works.
As I said earlier, systemd didn't replace init, it replaced upstart, and upstart replaced init. Hopefully the documentation available at the systemd web site is able to help you understand how things work. If not, you will probably get better answers if you ask questions about specific things that are unclear or not behaving as you think they should.