Chinaunix

标题: 关于文件系统来访问内核的数据? [打印本页]

作者: zlinux123456    时间: 2007-09-04 22:00
标题: 关于文件系统来访问内核的数据?
主要程序如下:
static struct proc_dir_entry *pAdv7180ProcDir =NULL;

/*然后在初始化模块的例程(init)中加入以下的代码*/
{
      pAdv7180ProcDir =proc_mkdir("adv7180",0);

      struct proc_dir_entry *pstatusprocent =NULL;

      pstatusprocent  = create_proc_entry( "videostatus", 0, pAdv7180ProcDir);
      pstatusprocent  ->read_proc = fortune_read;
      pstatusprocent  ->data =NULL;
      pstatusprocent  ->owner = THIS_MODULE;

    }

/*我每次在串口命令cat /proc/adv7180/videostatus  ,下面的fortune_read函数都会调用3次,
有没有办法只执行一次的呢?*/


static int fortune_read( char *page, char **start, off_t off,
                   int count, int *eof, void *data )
{
    printk(<0>111111\n");
}
作者: apony    时间: 2007-09-05 17:27
请处理read回调返回值和offset指针
read返回0表示结束,没结束cat还会读的
作者: zlinux123456    时间: 2007-09-05 21:03
我用cat命令怎么来判断read的返回值,能详细一点吗?谢谢




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2