有關kernel module寫檔 - Linux

By Selena
at 2009-06-20T01:27
at 2009-06-20T01:27
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)
請問是否有解決辦法呢
謝謝
--
在 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)
請問是否有解決辦法呢
謝謝
--
Tags:
Linux
All Comments

By Faithe
at 2009-06-20T06:00
at 2009-06-20T06:00
Related Posts
連網頁目錄問題

By Joe
at 2009-06-19T23:54
at 2009-06-19T23:54
centos5.3 解析度問題 只有800X600 640X480

By Aaliyah
at 2009-06-19T23:36
at 2009-06-19T23:36
又是vmware workstation

By Valerie
at 2009-06-19T23:05
at 2009-06-19T23:05
ubuntu 9.04 安裝筆記

By Selena
at 2009-06-19T22:59
at 2009-06-19T22:59
Makefile in ubuntu 9.04

By Wallis
at 2009-06-19T22:22
at 2009-06-19T22:22