I'm new to programming Linux kernel modules, and many getting started guides on the topic include little information about how to build a kernel module which will run on many versions and CPU platforms of Linux. Most of the guides I've seen simply state things like, "Linux doesn't ensure any ABI/API compatibility between versions." However, other OSes do provide these guarantees for major versions, and the guides are mostly targeting 2.7 (which is a bit old now).
I was wondering if there is any kind of ABI/API compatibility now, or if there are any standard ways to deal with versioning other than isolating the kernel-dependent bits of my code into files with a ton of preprocessor directives. (Also, are there any standard preprocessor symbols I should be using in the second case?)
LINUX_VERSION_CODE
andKERNEL_VERSION(major, minor, micro)
macros are often used in such code to check the kernel version. Like this, for example:#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 7, 0) ...
- Eugenesf_lookup()
in dirops.c. It is probably not an ideal way to handle the changing kernel API but still may give you some hints. - Eugene