Created
January 30, 2020 21:29
-
-
Save adaskar/338a5bcc101454dcb748028e0bc12117 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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