Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

I wanted multiple times to study the OpenBSD source code and I've downloaded it but I never managed to navigate through it, to find the "head and the tail" or to find a reasonable "map" of the source code. I would like for example to follow the execution path in the source code, from the boot up to the login prompt. Does any documentation like this exist or could anyone give me some hints ? Thanks


There are three parts in this sequence:

1. Boot up - this is very machine-dependent ("MD") so you'll find it in each architecture's source code. Look for files named "locore.s" or "locore.S" in places like src/sys/i386/i386.

2. Kernel - the machine-independent ("MI") part, or where the fun begins... this is in src/sys/kern/init_main.c, look for the function main(). You'll see the different subsystems initialized, from the lowest level (auto configuration of hardware devices and console initialization) through fundamental subsystems (virtual memory, disk, network, processes, etc.), all the way to the scheduler. The scheduler will only have one process to work with (PID 1) which is init (src/sbin/init), so that's what gets executed.

3. Userland - /sbin/init is the first process that runs, and it takes care of running everything else, like daemons and eventually your login prompt. Your points of interest in init.c are runetcrc(), read_ttys(), and multi_user().


What a relief! Thanks for scratching that itch. Also turns out to be good code organization, but I needed that post to boot me up.


Someone should make a site for sharing little "guided tours" of open source code bases...


While not a walk through the code base, there are these wonderful volumes: http://www.aosabook.org/en/index.html that have creators/maintainers/contributors walk through at a higher level how these amazing programs work.


Not a map per se, but I find bxr.su is a great resource to browse *BSD source code. OpenBSD is quite close to its' 4.4BSD roots, so "The Design and Implementation of the 4.4 BSD Operating System" book should still be pretty accurate.

There is also a presentation on openbsd.org/papers that seems relevant "OpenBSD Kernel Internals: The Hitchhiker's Guide". Direct link to PDF : http://atmnis.com/~proger/openkyiv/openkyiv2009_proger_sys.p...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: