有關kernel module寫檔 - Linux

Table of Contents

參考了這個網頁 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)

請問是否有解決辦法呢
謝謝

--

All Comments

Faithe avatarFaithe2009-06-20
我也想知道耶!! 有高手知道嗎?