+ All Categories
Home > Documents > Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in...

Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in...

Date post: 21-Jul-2020
Category:
Upload: others
View: 4 times
Download: 0 times
Share this document with a friend
17
LINUX KERNEL Source overview
Transcript
Page 1: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

LINUX KERNEL

Source overview

Page 2: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

Makefile

This is the top-level Makefile of the Linux source tree

Most of the important variables and rules (like the gcc compilation flags) are defined here

Page 3: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

Documentation/

The good news: This contains useful information about configuring your kernel

The bad news: It’s often out of date

More information helping with configuration can be found in Kconfig files in each directory

Also, several shell commands exist to help us obtain configuration information regarding our machine

Page 4: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

arch/

Contains all architecture specific code

Each architecture has its own directory here (for instance i386 or x86)

• You shall also find low level memory management, interrupt handling and others here•When you compile your kernel, your bootable image (bzImage file) shall show up under arch/yourArchitecture/boot

Page 5: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

crypto/

This is where the cryptographic API’s used by the kernel are kept

Page 6: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

drivers/

Code for peripheral devices is generally stored under a subdirectory of drivers/

Subdirectories here include drivers/bluetooth, drivers/net (network card drivers) and others

Page 7: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

fs/

The generic file system code (VFS contract) and the code for each different file system is stored here

Examples:

proc

sysfs

Page 8: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

include/

Herein lie most of the header files any .c file within the kernel may use

Architecture specific header files are in the include/asm directory

Page 9: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

init/

Here is where the main.c lies as well as code for creating the early user space*.

version.c can also be located here. This file defines the Linux version string

*early user space is a set of libraries and programs that provide services that are important enough to be availablewhen the kernel is coming up but perhaps not important enough to be in the kernel itself

Page 10: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

ipc/

The acronym IPC stands for “Inter Process Communication”.

This directory contains code pertinent to shared memory, semaphores, mutex, etc

Page 11: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

kernel/

Code that didn’t seem to belong to anywhere else in particular shall usually be stored here

The scheduler, signal handling code and printk() are just a few

The good news: Once you’re here, the file names are pretty descriptive

The bad news: This is the last place you are likely to look for anything

Page 12: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

lib/

Code of general usefulness to the all kernel code is stored here

Useful string operations and command line parsing code may be found in this directory

Page 13: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

mm/

High level memory management code can be found here.

Memory mapping of files takes all its code from files in this directory as do management of page caches, malloc and page swapping

Page 14: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

net/

Here the high-level networking code is stored

The ancillary code used by most network protocols is found in net/core

The actual code for the protocols themselves is stored in subdirectories. Examples

net/ethernet

net/ipv6

Page 15: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

scripts/

No actual kernel incorporated code is stored here. The scripts do, however help in building the kernel

For instance, the kconfig subdirectory there contains the code for running menuconfig

Page 16: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

security/

Socket and network security

hooks as well as the different

Linux security models code

can be found in this directory

Page 17: Linux Kernel - cs.huji.ac.il · kernel/ Code that didn’t seem to belong to anywhere else in particular shall usually be stored here The scheduler, signal handling code and printk()

How to search for stuff

If we know the title of a given file or even a part of its name we can use the following command:

$ find –name \*string\*Where “string” is the substring we are looking for.This command shall return all the files that contain the substring “string”

If we want to find the code around some string that was printed (say “cannot mount hsd1 on 0xcfff”) we could do

$ grep –r “cannot mount hsd1 on” If all else fails, google is your friend


Recommended