error: implicit declaration of function 'create_proc_read_entry' [-Werror=implicit-function-declaration]

前端 未结 3 2038
余生分开走
余生分开走 2020-12-19 03:25

I\'m trying to compile a kernel module on kernel 3.13 and I get this error:

error: implicit declaration of function \'create_proc_read_entry\' [-Werror=impli         


        
相关标签:
3条回答
  • 2020-12-19 03:51

    In your linux version 3.13 create_proc_read_entry this method has been deleted,instead using proc_create or proc_create_data.You can use this API

    struct proc_dir_entry *proc_create_data(const char *, umode_t,
                           struct proc_dir_entry *,
                           const struct file_operations *,
                           void *);
    
    static inline struct proc_dir_entry *proc_create(
             const char *name, umode_t mode, struct proc_dir_entry *parent,
             const struct file_operations *proc_fops);
    
    0 讨论(0)
  • 2020-12-19 03:59

    in Linux 3.9

    static inline struct proc_dir_entry *create_proc_read_entry(const char *name,
                                                                umode_t mode, 
                                                                struct proc_dir_entry *base, 
                                                                read_proc_t *read_proc, 
                                                                void * data
                                                               ) { return NULL; }
    

    http://lxr.free-electrons.com/source/include/linux/proc_fs.h?v=3.9

    in Linux 3.10

    static inline struct proc_dir_entry *proc_create(const char *name, 
                                                     umode_t mode, 
                                                     struct proc_dir_entry *parent,
                                                     const struct file_operations *proc_fops
                                                    )
    

    http://lxr.free-electrons.com/source/include/linux/proc_fs.h?v=3.10

    So change create_proc_read_entry() to proc_create(), and change the 5 parameters to 4 parameters. It then works.

    0 讨论(0)
  • 2020-12-19 04:02

    The error is because you are not including explicitly the header that declares the function and the compiler is 'including' implicitily for you and this throws a warning. The flag '-Werror' is making the compiler treats the warning as an error. Try adding: #include <linux/proc_fs.h>

    Also: create_proc_read_entry is a deprecated function.

    Take a look at: https://lkml.org/lkml/2013/4/11/215

    0 讨论(0)
提交回复
热议问题