LDD-Tricks

/proc

/proc filesystem is a special, software-created filesystem that is used by the kernel to export information to the world.
If you want to work with /proc, include <linux/proc_fs.h>.
We don't suggest you create a file in /proc, but if do want to do this, do the following steps:
Implement your read_proc function
int (*read_proc)(char *page, char **start, off_t offset, int count, int *eof, void *data);
Connect the read_proc to an entry in /proc hierarchy with create_proc_read_entry
struct proc_dir_entry *create_proc_read_entry(const char *name, mode_t mode,
                   struct proc_dir_entry *base,read_proc_t *read_proc, void *data);
while remove_proc_entry does the contrary.
 
Debug

Add macros in header files:
 1 #undef PDEBUG /* undef it, just in case */
 2 #ifdef SCULL_DEBUG
 3 #ifdef __KERNEL__
 4 /* This one if debugging is on, and kernel space */ 
 5 #define PDEBUG(fmt, args...) printk( KERN_DEBUG "scull: " fmt, ## args)
 6 #else  /* This one for user space */ 
 7 #define PDEBUG(fmt, args...) fprintf(stderr, fmt, ## args)
 8 #endif
 9 #else
10 #define PDEBUG(fmt, args...) /* not debugging: nothing */
11 #endif
12 #undef PDEBUGG
13 #define PDEBUGG(fmt, args...) /* nothing: it's a placeholder */
Add following lines to makefile:
1 # Comment/uncomment the following line to disable/enable debugging
2 DEBUG = y
3 # Add your debugging flag (or not) to CFLAGS
4 ifeq ($(DEBUG),y)
5     DEBFLAGS = -O -g -DSCULL_DEBUG # "-O" is needed to expand inlines
6 else   
7     DEBFLAGS = -O2
8 endif
9 CFLAGS += $(DEBFLAGS)

 

 

转载于:https://www.cnblogs.com/adera/p/9921219.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值