-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsample.c
More file actions
26 lines (21 loc) · 690 Bytes
/
sample.c
File metadata and controls
26 lines (21 loc) · 690 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include <linux/kernel.h> // Kernel logging (pr_info, printk)
#include <linux/init.h> // __init, __exit macros
#include <linux/module.h> // Core header for modules
// Init function - runs when module is loaded
static int __init my_module_init(void)
{
pr_info("Hi from Harsh! Kernel module loaded.\n");
return 0;
}
// Exit function - runs when module is removed
static void __exit my_module_exit(void)
{
pr_info("Goodbye from kernel, Harsh!\n");
}
// Register init and exit functions
module_init(my_module_init);
module_exit(my_module_exit);
// Module metadata
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Harsh Raj Singh");
MODULE_DESCRIPTION("Simple module example");