This file contains hidden or 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/init.h> | |
#include<linux/kernel.h> | |
#include<linux/fs.h> | |
MODULE_LICENSE("GPL"); | |
MODULE_AUTHOR("CVAM"); | |
MODULE_VERSION("0.1"); | |
dev_t dev=0; |
This file contains hidden or 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/init.h> | |
#include<linux/kernel.h> | |
#include<linux/fs.h> | |
MODULE_LICENSE("GPL"); | |
MODULE_AUTHOR("CVAM"); | |
MODULE_VERSION("0.1"); | |
dev_t dev=MKDEV(235,0); // dev is the dev_t structure variable for major and minor no. |
This file contains hidden or 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
" VIM Configuration File | |
" Description: Optimized for C/C++ development, but useful also for other things. | |
" Author: Gerhard Gappmeier | |
" | |
" set UTF-8 encoding | |
set enc=utf-8 | |
set fenc=utf-8 | |
set termencoding=utf-8 | |
" disable vi compatibility (emulation of old bugs) |
This file contains hidden or 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
/* An example of Memory Allocation */ | |
#include<linux/slab.h> | |
#include<linux/init.h> | |
#include<linux/module.h> | |
#include<linux/kernel.h> | |
#define size 10 | |
MODULE_DESCRIPTION("example of memory allocation "); |
This file contains hidden or 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
pr_emerg(fmt, ...); /* similar to printk(KERN_EMERG pr_fmt(fmt), ...); */ | |
pr_alert(fmt, ...); /* similar to printk(KERN_ALERT pr_fmt(fmt), ...); */ | |
pr_crit(fmt, ...); /* similar to printk(KERN_CRIT pr_fmt(fmt), ...); */ | |
pr_err(fmt, ...); /* similar to printk(KERN_ERR pr_fmt(fmt), ...); */ | |
pr_warning(fmt, ...); /* similar to printk(KERN_WARNING pr_fmt(fmt), ...); */ | |
pr_warn(fmt, ...); /* similar to cu printk(KERN_WARNING pr_fmt(fmt), ...); */ | |
pr_notice(fmt, ...); /* similar to printk(KERN_NOTICE pr_fmt(fmt), ...); */ | |
pr_info(fmt, ...); /* similar to printk(KERN_INFO pr_fmt(fmt), ...); */ |
This file contains hidden or 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
/* Some more example of the macros for the Alert msg are */ | |
#define KERN_EMERG "<0>" /* system is unusable */ | |
#define KERN_ALERT "<1>" /* action must be taken immediately */ | |
#define KERN_CRIT "<2>" /* critical conditions */ | |
#define KERN_ERR "<3>" /* error conditions */ | |
#define KERN_WARNING "<4>" /* warning conditions */ | |
#define KERN_NOTICE "<5>" /* normal but significant condition */ | |
#define KERN_INFO "<6>" /* informational */ | |
#define KERN_DEBUG "<7>" /* debug-level messages */ |
This file contains hidden or 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
if(alloc_memory() != 0 ) | |
return -ENOMEM; | |
if (user_parameter_valid()!=0) | |
return -EINVAL; | |
/* | |
Some of the examples of the macros are | |
#define ENOTEMPTY 39 /* Directory not empty */ |
This file contains hidden or 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
EXTRA_CFLAGS = -Wall -g | |
obj-m = example_lkm.o |
This file contains hidden or 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
KDIR = /lib/modules/`uname -r`/build | |
kbuild: | |
make -C $(KDIR) M=`pwd` | |
clean: | |
make -C $(KDIR) M=`pwd` clean | |
This file contains hidden or 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
/* An Example of Loadable Kernel Module */ | |
#include<linux/kernel.h> | |
#include<linux/init.h> | |
#include<linux/module.h> | |
MODULE_DESCRIPTION("cvam example kernel module "); | |
MODULE_AUTHOR("cvam"); | |
MODULE_LICENSE("GPL"); |
NewerOlder