Skip to content

Instantly share code, notes, and snippets.

@adaskar
Created Jan 30, 2020
Embed
What would you like to do?
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/init.h>
#define DEVICENAME "LKMDevice"
#define bail_assert(s, label, fmt, ...) \
do { \
if (!(s)) { \
printk(KERN_ALERT DEVICENAME " " fmt "\n", ##__VA_ARGS__); \
goto label; \
} \
} while(0) \
#define kinfo(fmt, ...) \
do { \
printk(KERN_INFO DEVICENAME " " fmt "\n", ##__VA_ARGS__); \
} while(0) \
#define kalert(fmt, ...) \
do { \
printk(KERN_ALERT DEVICENAME " " fmt "\n", ##__VA_ARGS__); \
} while(0) \
static int __init lkm_init(void)
{
kinfo("inited");
return 0;
}
static void __exit lkm_exit(void)
{
kinfo("exited");
}
module_init(lkm_init);
module_exit(lkm_exit);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment