# Fastest way to start kernel exploration/ development for Linux fellows



## Pegasus711 (Mar 26, 2010)

Hello people,

Lately I have been interested in FreeBSD and would like to explore the kernel. Hence on some tips, got myself a copy of The design and implementation of the FreeBSD kernel by McKusick and Neil.

Although I like the overall feel and I guess it is fairly detailed atleast for a FreeBSD noob like myself, I am a little suprised that they do not refer to the file in the source tree whenever they refer to a structure/entity. May be this is because of my linux background. I do not know honestly. 

For instance, the struct mbuf, which is the FreeBSD equivalent of sk_buff or vice versa (I guess the BSDes are older so it must be the latter ) has been mentioned in chapter 11. But on searching it in fxr.watson.org I could not figure out which one to explore as I could not find a primary definition of it in the huge listing it produced. I guess you got my point, especially if any one of you have had come from the world of Linux, you know that sk_buff is defined in /include/linux/skbuff.h and almost all books mention it when they talk about sk_buff. I mean is this something that has been standardized or something.

I am keen on getting to understand the freebsd kernel and any help would be appreciated. Plus if any one has come from a Linux background, it would be great to understand from his/her experience on how to go about it.

Keen to hear frm you people.

Regards,
Aijaz


----------



## DutchDaemon (Mar 26, 2010)

You mean http://fxr.watson.org/fxr/source/kern/kern_mbuf.c?v=FREEBSD8 ?


----------



## tarkus (Mar 26, 2010)

I'm in the same boat - linux driver guy curious about FreeBSD.  Any shortcuts to the gist of FreeBSD would be appreciated.  Till then I'll start by reading every single post on this site


----------



## Pegasus711 (Mar 27, 2010)

Well, thanks for the link. I came across sys/mbuf.h in the page that came up after following your link. What I actually was talking about is this: http://fxr.watson.org/fxr/source/sys/mbuf.h?v=FREEBSD8;im=bigexcerpts#L152 . 

I believe mccusick and neil could have mentioned that I can find the principal 'top level' mbuf structure @ sys/sys/mbuf.h . Or is it that the /sys/sys/ directory is equivalent to the /include/linux/ in linux? i.e. the header files for most of the kernel structures.

How is the kernel source arranged. I mean according to this document, the /sys/ directory contains the kernel source files. And to my suprise, the directories under /usr/src/ are according to the user space representation of the directory structure.

So these and other things are proving to be a suprise. Keen to hear your inputs people.

Regards,

Aijaz Baig.


----------



## graudeejs (Mar 27, 2010)

Layout of /src

Developers Handboook


----------



## trasz@ (Mar 28, 2010)

@aijazbaig1: Basically, /sys/, which is a symlink to /usr/src/sys/, contains kernel sources.  And yes, /sys/sys/ (i.e. /usr/src/sys/sys/) contains most important kernel headers.

Regarding mbufs - one thing you might not expect is that there are manual pages for kernel interfaces.  See 'man mbuf' or 'man locking' for example.


----------



## jalla (Mar 28, 2010)

trasz@ said:
			
		

> @aijazbaig1: Basically, /sys/, which is a symlink to /usr/src/sys/, contains kernel sources.  And yes, /sys/sys/ (i.e. /usr/src/sys/sys/) contains most important kernel headers.
> 
> Regarding mbufs - one thing you might not expect is that there are manual pages for kernel interfaces.  See 'man mbuf' or 'man locking' for example.



One of the best things in freebsd vs linux IMO is the quality of the documentation.

Where freebsd has comprehensive, concise doc of everything in base, linux-distros seem to rely more on random HOWTO's of variable quality spread around the net.
I'm exaggerating slightly I know, but the quality of manpages (or missing manpages) always irritate me whenever I happen to work with linux.


----------



## Pegasus711 (Mar 29, 2010)

Thanks for your input guys. Yes FreeBSD and linux both are different in this regards. Although the quality of documentation available with FreeBSD is better, it is not so very much but with Linux it is exhaustive, both the one which is freely available and the one which is available in the form of books.

Like presently I am getting to know the networking subsystem of Linux, specially the netfilter architecture and how it fits in the overall scheme of networking in Linux and I have found various diagrams, flowcharts and a couple of books dedicated to the topic. 

It would be great if more people would write on FreeBSD as it is available with Linux so that it becomes easier for kernel noobs like myself to take a dive in. I am not seasoned enough to comment on the architectural advantages of one over the other but as of now I have found freeBSD to be more organized. After one gets enough experience in kernel code, one could try to figure out the whole thing with source code only.

And yeah the best thing that I got to know is that there are man pages for kernel interfaces. And does it mean one can expect to find man pages for important data structures within the kernel?

Regards,
Aijaz Baig.


----------

