linux - 出现错误 : implicit declaration of function 'proc_create'

标签 linux linux-kernel linux-device-driver

我在编译驱动程序模块时收到“函数‘proc_create’的隐式声明”错误。我想在/proc 中创建一个条目并打印正在使用该模块的程序数量。你能让我知道这里出了什么问题吗?这是我的代码。

#include<linux/module.h>
#include<linux/fs.h>

#define HELLO_MAJOR 234
static int debug_enable = 0;
static int no_of_access;
module_param(debug_enable, int, 0);
MODULE_PARM_DESC(debug_enable, "Enable module debug mode.");
struct file_operations hello_fops;
struct proc_dir_entry *proc_file_entry;

<File operation functions...>
<Incremented global_counter in the file open operation.>

static int hello1_read_proc(char *buf, char **start, off_t offset,
                            int count, int *eof, void *data)
{
    int len=0;
    len += sprintf(buf+len, no_of_access);
    *eof=1;
    return len;

}

static int __init hello_init(void)
{
    int ret;
    proc_file_entry = proc_create("examples/hello1", 0,NULL, hello1_read_proc);
    if(proc_file_entry == NULL)
            return -ENOMEM;
    printk("\nProc file entry for hello1 has been created !!!\n");

}

static void __exit hello_exit(void)
{
    printk("Hello Example Exit\n");
    remove_proc_entry("exmaples/hello1", NULL);
    unregister_chrdev(HELLO_MAJOR,"hello1");
 }

提前致谢。

最佳答案

您还需要包含 <linux/proc_fs.h>

关于linux - 出现错误 : implicit declaration of function 'proc_create' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19610396/

相关文章:

c - 无法写入/dev/mem

c++ - 检测字符串字符集

linux - 我怎样才能在 cat/etc/passwd 上将一行剪成两行?

linux - 为什么 rwxrwxrwx 文件不允许 chmod 777?

linux - 如何实现鼠标驱动 Linux USB鼠标驱动?

linux - 访问硬件寄存器中的内存指针

linux - httpd 没有在进程列表中列出,尽管它运行没有任何问题

c - 如何防止任务从一个 CPU 转移到另一个 CPU?

c - 在核心上运行用户任务并最小化中断/抢占

linux - printk loglevel 在模块编程中的使用