我正在尝试基于此示例开发驱动程序:http://www.linux-mag.com/id/2739/?r=s
Linux 3.13 x86_64
如果printk显示信息,则不会发生复制。
鉴于阅读电话的快照:
/* private data */
struct _mydrv_data{
struct list_head list; /*link list*/
char info[10]; /* info */
};
LIST_HEAD( mydrv_list); /*list head*/
int read_proc(struct file *filp, char __user *buf,
size_t count, loff_t *offp)
{
off_t thischunk_len = 0;
struct _mydrv_data *p;
int ret = 0;
//traverse the list and copy info into buf
list_for_each_entry(p, &mydrv_list, list){
ret = copy_to_user(buf, p->info, strlen(p->info));
printk(KERN_DEBUG "ret:%d read proc %s",ret,p->info);
thischunk_len += strlen(p->info);
buf += thischunk_len;
if (count == 0 )
return thischunk_len;
count-= thischunk_len;
}
return thischunk_len;
}
由于