Kernel hacking scripts

Here's a collection of scripts that you may find useful as you start creating your own kernel patches. Some of them may even be useful in projects outside of the Linux kernel. Enjoy.

Diff handling

Diffsplit - Take a patchfile containing patches to multiple files, and split them into seperate diffs, 1 patch per file.

Diffport - another patch utility that is useful when you want to update a diff against something to a new version (e.g. update a diff against 2.4.16 to be against 2.4.17 easily).

Patchutils - a collection of useful patch-related utilities such as interdiff.

If you need to send a patchset (several patches in a row with a common theme, it's important that you make the emails thread properly to avoid annoying people. William Lee Irwin has written a Haskell script for this. Greg-Kroah Hartman has written an alternative Perl script for doing a similar thing. Use of both scripts must be done carefully; it is suggested you test them by emailing yourself first before using them on the unsuspecting public.

Semi-automated bug checking - A tool by Keith Owens to find symbols in need of __devexit_p (that cause "reference to discarded section ..." errors) - A tool by Keith Owens to find functions that are marked __init which are called from functions which are not marked __init. - Paul Gortmaker's shell script to verify the Documentation directory's 00-INDEX files.

Semi-automated source cleanup - Dan Carpenter's perl script to check mis-use of #ifdef MODULE around module_init() macros and the like. - script by Keith Owens to find large stack allocations in kernel functions, which run the risk of stack overflow, since the kernel stack space is so small. x86-specific. - Perl script by Art Haas that converts common gcc-style structure initialisers (release: foo_release) into C99 style (.release = foo_release). - Andrew Tridgell's script that can identify possible candidates that can be made file-scope (static) from a binary. - script by Dave Jones that looks for typical "kernel janitor" things.

Debugging tools - script by David A. Hinds to dump the BIOS PCI IRQ routing table.

parsemce.c - parse MCE (Machine Check Exception) dumps, by Dave Jones.

dump_insn - illustrative usage of objdump to show how to disassemble parts of code. By Keith Owens.


kernelver - Call it periodically from a cronjob, and get mail whenever finger changes. Or pipe it to a program like gdialog,kdialog etc, and have a window pop up on your X session :) *nb*, in the interests of bandwidth preservation, use common sense when deciding how often to poll. Hammering mirrors isn't polite.

If you've got a script, or an idea for something that could be added here, contact the kernelnewbies team!

(Last modified 2003/04/29)