LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-26-2010, 03:07 PM   #1
hua
Member
 
Registered: Oct 2006
Location: Slovak Republic
Distribution: Slackware 14.2, current
Posts: 461

Rep: Reputation: 78
deep into the linux code


Hi
I made a decision that it is inevitably for me to go into the deepest corners of the Linux code. I am prepared to read the codes as long as there is a variable which I didn't understand. I know that it is a task which has to be completed only by me but ...
What is the best entry point?
I use Slackware for my desktops and servers. It seems to me that the best point is the linux kernel.

Please, if anybody knows about some good links or documentations post it. I want to find the best sources of information.

Thanks a lot.
 
Old 11-27-2010, 02:30 AM   #2
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
Starting with the kernel itself is probably not the best way. Id start by studying the intrd used by the Slackware installer. Then start studying the 'real' system by begiining at /etc/rc.d/rc.S, while peeking at some kernel code related to what happens just before and as the root '/' partition gets mounted by the kernel. That'll keep you busy for a while....
 
Old 11-27-2010, 02:52 AM   #3
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Depending on how much knowledge you have already it might be best to start by studying a simple external command such as /bin/tail (the link s to the BSD version because GNU versions are generally harder to understand). That might sound trivial but even something as trivial as tail has over 2000 lines of source code. You will definitely want a good understanding of the process model, good pages: here (userland), here (userland programming) and here (kernel space overview).
 
Old 11-27-2010, 08:35 AM   #4
hua
Member
 
Registered: Oct 2006
Location: Slovak Republic
Distribution: Slackware 14.2, current
Posts: 461

Original Poster
Rep: Reputation: 78
Quote:
Depending on how much knowledge you have already
I use linux approximately 10 years. I know all basic user operations (shell commands, kernel compilation ...) and run several servers. I also wrote already some C++ applications. My point here is to dig deeper and follow the hierarchy in the source code. I mean if there is a process which starts first at the beginning (boot) I want to understand that process before I continue to the second.

Quote:
Id start by studying the intrd used by the Slackware installer
Yes, I am already doing it. I study right now the main.c in the source code of the init. I want to follow the exact order of the processes as the system is booting up, the setup process.
Thorough the years of my technical experience I found out that the most important thing is to find the best source of information. Something like this:
http://www.ibm.com/developerworks/li...y/l-linuxboot/

Thanks for your replies.

Last edited by hua; 11-27-2010 at 08:38 AM.
 
Old 11-27-2010, 10:54 AM   #5
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,928

Rep: Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612Reputation: 612
The init process can be best understood by studying the init scripts. 'init' itself is pretty simple in what it does. It sometimes is called the 'mother of all processes'. It's main purpose is to run the startup scripts and keep daemons running -restarting them if they die, etc. What is harder to understand is how init gets started -there I'd suggest working backwards a little into the kernel code to see how init gets started. Studying a very simple initrd helps you to understand what is most basic to a running system. grep in the kernel source code for '/sbin/init' and you'll soon find the critical things which are needed to make the transition from a fully loaded kernel to a running system -via 'init'.
Once the kernel is loaded into RAM, it looks for a very few things in the root partition. The bootloader has told the kernel where the root partition is located, so the kernel tries to mount that partition and tries to figure out if it really is a bootable system by looking for three things: /dev/console, /bin/sh and init which must be located at either /sbin/init, /bin/init or /etc/init. The kernel also looks to see if there is a /linuxrc file. If there is, it will try to run that before turning over execution to 'init'. /linuxrc was/is typically used in an initrd to perform some extra jobs before the normal init runs. Modern kernels use pivot_root to make the transition from the initrd to the 'real' system. An initrd is typically used to do some fancy things like creating a ramdisk which can then have a filesystem image mounted in it -this is how LiveCD's work by fooling the kernel into thinking it has a 'real' writable system to work with. initrd's are also used to load any kernel modules needed to access the real filesystem, when those modules are not hard-linked into the kernel. Once you've understood what happens when the kernel transitions to init, you'll find it much easier to understand what happens before and after that point.
 
1 members found this post helpful.
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Ofris - Deep Freeze Like Application For Linux LXer Syndicated Linux News 0 08-28-2010 03:11 PM
Windows/DOS girl thrown in deep end with Linux chibibarako LinuxQuestions.org Member Intro 18 05-24-2010 06:25 PM
LXer: Deep Thoughts: What Does This Humor Have To Do With Linux Or Unix? LXer Syndicated Linux News 0 12-21-2008 12:11 AM
Any Deep Packet Inspection in Linux? netlogic Linux - Security 2 11-15-2007 04:39 PM
Need an exit strategy...(in deep with Linux) southsibling Linux - Software 17 06-01-2005 06:05 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration