Hello.

Not so long ago, I became interested in a low-level issue of the OS, but I could not immediately resolve it. I was advised (in principle and logical) to read the kernel sources in order to clarify to myself how things really are. Downloading the source code of the ubuntu kernel was not a problem, but for me it turned out to be quite problematic for me, which is not surprising. There are so many files there, and it’s completely incomprehensible where to dig = (

In short, I need advice or even a technique on how to approach the source code of the kernel, and of someone else’s source code in general (although I doubt that there can be any method at all), not specifically related to my problem (I deliberately I don’t tell what I want to know), but in general, in principle. I would like to begin with at least to decide on the folder structure, to understand which files are responsible for what, to find out about some possibly basic source code files.

I would be very happy links to useful resources or any books on this topic!

    2 answers 2

    Downloading the source code of the ubuntu kernel was not a problem, but for me it turned out to be quite problematic for me, which is not surprising. There are so many files there, and it’s completely incomprehensible where to dig = (

    For me, as is possible for most people,
    There was the easiest way in the knowledge of the nucleus,
    Delving into all the features and settings,
    I had to collect it from scratch. Compile.

    Ie collect, collect, collect, collect
    Once again, collect, then load it
    Not troubled, again, trouble, again go and compile.
    Look in the dmesg, search, delve,
    Quit everything and sit for 30-50 minutes again and compile.

    In winter, you can warm your palms
    When the draft and cold break through the curtains of the curtains,
    Having already gone through double-glazed windows, through walls ...
    On the laptop you type make CONFIG .

    Why take ubuntushnoe,
    Take the default, right on www.kernel.org,
    There is documentation, about here: www.kernel.org/doc


    At the very beginning, at dawn,
    the core was of itself
    only basic functionality
    And it was constantly written down by the wise Torvalds.

    Everyone dealt with the kernel in the course of performing some small tasks.
    For example, to run some beautiful demonic
    It was necessary to патчить ядро .
    Source codes were taken, the patch was made and the custom kernel was going to.

    Now, most of the things needed
    Such as the layered file system aufs,
    And the network interface listening modules,
    All this is already in the default kernel,
    Turns on and off with just one line
    In the kernel build configuration file.

    But you can repeat all this way.
    Find an interesting project such as grsecurity.net

    With the help of this patch, you can create a bullet-not-punched sideboard
    With a million tracking, logging elements.
    Prohibit everything that can be prohibited.
    By the way, quite nontrivial
    Is the task of starting the X server
    With the maximum possible "included" grsecurity-patch.

    In the process of building a custom bullet-non-punched core
    And trying to boot from it,
    You will have some idea of ​​the hierarchy of all flags.
    You can understand that 90% of the kernel is nothing more than modules.
    Specifically taken piece of iron, network and sound cards
    And any such good.

    And those remaining 10% - this is the core itself,
    Core of Kernel, if I may say so.
    Network, disk subsystems,
    Scheduler - Task Scheduler
    All sorts of features, hooks, khaki, bugs ...

    Although, no matter how much I delved into it all.
    Until now, most agree,
    What better documentation than the source code itself - NO.
    Probably the creation of a kind of " wikipedia " "core-pedii"
    Over kernel code and maintaining up-to-date documentation
    This is the task of many billion man-hours.
    This task is simply not helpful to the community.
    Therefore, the entrance to the kernel-hacking is still
    High enough and requires at least a good knowledge of C / C ++.

    In short, I need advice or even a technique on how to approach the source code of a kernel,

    Look for an interesting patch,
    Bring in ...
    And compile, hundreds of times ...
    After 2 thousand procedures
    Illumination will come to you.
    So it was with everyone.
    And always will be.

    Faber est suae quisque fortunae

    • what is it - etki
    • @Etki No words, some emotions - igumnov
    • @Etki blank verse? - PashaPash
    • the core itself is not s͉̹̣͇k͉̹̣͇o͏͉m̮̳̙̫p̮̳̙̫i͞li̙r̡̼̞͇̞̻͖̭uet̴̮̠ - etki
    • Have you collected the core and still consider yourself different? Then we go to you! - igumnov
    1. The Linux kernel is a large and complex system, so it’s extremely hard to learn.
    2. You should always start with the basics to understand how the system works as a whole. For example, read the book Linux kernel: a system programmer’s guide .
    3. View notes for beginners at kernelnewbies.org .
    4. Find the module of interest to the kernel (based on the task that stands).
    5. Next - search by code grep'om and view it line by line. Sometimes IDEs that build function call diagrams and the connections between them help.