Skip to content

Align version check #301

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/devicemodel.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ static int devicemodel_probe(struct platform_device *dev)

return 0;
}
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 11, 0)
static int devicemodel_remove(struct platform_device *dev)
#else
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 11, 0)
static void devicemodel_remove(struct platform_device *dev)
#else
static int devicemodel_remove(struct platform_device *dev)
#endif
{
pr_info("devicemodel example removed\n");
Expand Down
6 changes: 3 additions & 3 deletions examples/static_key.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ static int __init chardev_init(void)

pr_info("I was assigned major number %d\n", major);

#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 4, 0)
cls = class_create(THIS_MODULE, DEVICE_NAME);
#else
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 4, 0)
cls = class_create(DEVICE_NAME);
#else
cls = class_create(THIS_MODULE, DEVICE_NAME);
#endif

device_create(cls, NULL, MKDEV(major, 0), NULL, DEVICE_NAME);
Expand Down
22 changes: 11 additions & 11 deletions examples/syscall-steal.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,7 @@

/* The in-kernel calls to the ksys_close() syscall were removed in Linux v5.11+.
*/
#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 7, 0))

#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 4, 0)
#define HAVE_KSYS_CLOSE 1
#include <linux/syscalls.h> /* For ksys_close() */
#else
#include <linux/kallsyms.h> /* For kallsyms_lookup_name */
#endif

#else
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0))

#if defined(CONFIG_KPROBES)
#define HAVE_KPROBES 1
Expand All @@ -64,7 +55,16 @@ static unsigned long sym = 0;
module_param(sym, ulong, 0644);
#endif /* CONFIG_KPROBES */

#endif /* Version < v5.7 */
#else

#if LINUX_VERSION_CODE <= KERNEL_VERSION(5, 4, 0)
#define HAVE_KSYS_CLOSE 1
#include <linux/syscalls.h> /* For ksys_close() */
#else
#include <linux/kallsyms.h> /* For kallsyms_lookup_name */
#endif

#endif /* Version >= v5.7 */

/* UID we want to spy on - will be filled from the command line. */
static uid_t uid = -1;
Expand Down