Slashdot Mirror


Become a Linux Kernel Hacker and Write Your Own Module

M-Saunders (706738) writes "It might sound daunting, but kernel hacking isn't a mysterious black art reserved for the geekiest of programmers. With a bit of background knowledge, anyone with a grounding in C can implement a new kernel module and understand how the kernel works internally. Linux Voice explains how to write a module that creates a new device node, /dev/reverse, that reverses a string when it's written to it. Sure, it's not the most practical example in the world, but it's a good starting point for your own projects, and gives you an insight into how it all fits together."

10 of 143 comments (clear)

  1. Oh no! by fizzer06 · · Score: 5, Funny

    Just to have Linus publicly cuss me out? No thanks!

  2. Very true... by MindPrison · · Score: 4, Interesting

    ...I remember my first meeting with Slackware, it was a Linux distro that provoked any user to learn stuff from scratch, and you HAD to use the command line (bash/shell) to install it if you wanted to use it. This forced me to learn Linux. (At least some of the basics)

    It also came with a Kernel compilation system + all the needed libraries and packages, so compiling to your own computer was a few commands and worked right out of the box. And then my curiosity got piqued and this drove me to go into the configuration and find out how I could optimize my kernel to fit my needs. In the beginning it was a lot of trial and error, and it looked real daunting, but after a few tries - it wasn't nearly as scary. Before you knew it, I was coding my first stuff in C++. A lot of fun, actually.

    So yeah, by all means - if you guys have the time, the curiosity, do go ahead and code something, but do yourself a favor - start off easy.

    --
    What this world is coming to - is for you and me to decide.
  3. Umm by ADRA · · Score: 4, Insightful

    Well yes, any C developer (already a minority in the umbrella of 'programmers' these days) can write code for the kernel, but just because one can write software for the kernel doesn't mean they can write anything meaningful to be done in kernel space vs. anywhere else. If you're expecting a slew of new driver hackers reverse engineering chipsets, and implementing better drivers, testing all corner cases (because dev's LOVE testing) I think you're barking up a very small tree, but all the luck to you, becase what's good for Linux is good for me, you, us all.

    --
    Bye!
  4. just remember ... by nblender · · Score: 5, Funny

    In kernel space, no one can hear you scream.

    1. Re:just remember ... by mlts · · Score: 3, Insightful

      There is always the ability to panic.

  5. just because by Anonymous Coward · · Score: 5, Funny

    you are 100% required to send all your code to linus, even your test builds

    1. Re:just because by Anonymous Coward · · Score: 3, Funny

      No it was simply a joke Admiral Aspergers.

  6. Writing modules near impossible by Eravnrekaree · · Score: 3, Interesting

    While the article shows a cute little example on how to write a useless module, it does not show anyone how to actually write a serious kernel module. The Linux kernel has never been known for documenting kernel internals, such documentation is scant at best and simply not sufficient to write a module. It is safe to say tha due to the poor practices of Kernel developers who constitently ignore good practice by not Documenting Their Crap, the kernel is an elite club of developers with knowledge that is secret. The practices of the Linux kernel development is just sheer sloppiness, horribly bad practice. They could have easily set up a Wiki and documented the interfaces and their architecture. What we see with the kernel developers is that they do not care about anyone else, not users, and not even outside techies, so why would they care about whether or not an outsider can understand the kernel, just as why would they care if a user can upgrade kernel versions without having all of their device drivers blow up. As anyone well versed in computer science knows, computer code is rarely self documenting, especially the kernel, and trying to reverse document a large software project is an outrageous waste of time and can be enough of a problem that it keeps even seasoned programmers away from the project. A huge piece of undocumented code is just not worth the effort to learn.

  7. Re:First Tutorial I've seen with Goto... by frank_adrian314159 · · Score: 3, Informative

    Just like any other construct - when it makes the code more clean, clear, correct, and/or optimized. These are tradeoffs.

    For instance, let's say you have a function having a deeply nested conditional:

    if (!a) {
        if (!b) {
            if (!c) {
    ...

    } } }

    This code might be more simply understood as:

    if (a) goto done;
    if (b) goto done;
    if (c) goto done;
    ...
    done:
    ...

    --
    That is all.
  8. screw it i'm gonna put my hosts file in the kernel by Anonymous Coward · · Score: 4, Insightful

    Take that APK! I'm going to put my motherfucking hosts file in the kernel..that's right.. I'm going to have a /dev/hosts

    You heard me right! /dev/motherfucking/hosts

    True ring 0 baby!