刚好回答过,所以拷贝给你看!
内核读写,仅供参考。
如果可以,你可以仔细研究filp一套函数,其实还有很多种读写方式的,你可以根据filp去搜索。
struct file *fd;
lock_kernel();
fd=filp_open(IPFILE,O_CREAT|O_WRONLY,0666);
if(IS_ERR(fd))return(-1);
len=sizeof(buf)-1;
unlock_kernel();
oldfs=get_fs();
set_fs(get_ds()); /* buffer is in kernel space */
rc = fd->f_op->read(fd, buf,len,&fd->f_pos);
set_fs(oldfs);
lock_kernel();
filp_close(fd,NULL);
unlock_kernel();