[問題] 有關kernel module寫檔
參考了這個網頁 http://loda.zhupiter.com/LinuxProtectModeArch.htm
在 module 中加入
struct file *filp;
mm_segment_t oldfs;
char buf[] = "123";
filp=filp_open("/file",O_CREAT|O_RDWR,0777);
oldfs=get_fs();
set_fs(KERNEL_DS);
filp->f_op->write(filp,buf,strlen(buf),&filp->f_pos);
set_fs(oldfs);
filp_close(filp,NULL);
目前是可以寫檔了, 但發現以下問題
1.寫檔超過一定大小 就會發生溢位 (從f_pos觀察到的)
2.不能是nfs的檔案 (/mnt/file)
請問是否有解決辦法呢
謝謝
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.115.222.85
推
06/22 16:34, , 1F
06/22 16:34, 1F