diff --git a/source/lib/internal/kernel_module/common/proc.c b/source/lib/internal/kernel_module/common/proc.c index c9afc8342e17a94631456ae24dc97c047ad374d6..0184954ab12b3159ceb34558944bd60c884fb20c 100644 --- a/source/lib/internal/kernel_module/common/proc.c +++ b/source/lib/internal/kernel_module/common/proc.c @@ -21,8 +21,13 @@ struct proc_dir_entry *sysak_proc_mkdir(const char *name) return NULL; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) +struct proc_dir_entry *sysak_proc_create(const char *name, + const struct proc_ops *proc_fops) +#else struct proc_dir_entry *sysak_proc_create(const char *name, const struct file_operations *proc_fops) +#endif { if (check_sysak_root()) return proc_create(name, 0644, sysak_root_dir, proc_fops); diff --git a/source/lib/internal/kernel_module/common/proc.h b/source/lib/internal/kernel_module/common/proc.h index 05bc624172f2f99b2bedfc870b7a969db2d28c49..fdc0e52376e7478295adc863c7830ac2cc433e61 100644 --- a/source/lib/internal/kernel_module/common/proc.h +++ b/source/lib/internal/kernel_module/common/proc.h @@ -50,7 +50,7 @@ int __weak kstrtobool_from_user(const char __user *s, size_t count, bool *res) #define DEFINE_PROC_ATTRIBUTE_RO(name) \ DEFINE_PROC_ATTRIBUTE(name, NULL) -#else +#elif LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) #define DEFINE_PROC_ATTRIBUTE(name, __write) \ static int name##_open(struct inode *inode, struct file *file) \ { \ @@ -78,15 +78,49 @@ int __weak kstrtobool_from_user(const char __user *s, size_t count, bool *res) #define DEFINE_PROC_ATTRIBUTE_RO(name) \ DEFINE_PROC_ATTRIBUTE(name, NULL) +#else +#define DEFINE_PROC_ATTRIBUTE(name, __write) \ + static int name##_open(struct inode *inode, struct file *file) \ + { \ + return single_open(file, name##_show, PDE_DATA(inode)); \ + } \ + \ + static const struct proc_ops name##_fops = { \ + .proc_open = name##_open, \ + .proc_read = seq_read, \ + .proc_write = __write, \ + .proc_lseek = seq_lseek, \ + .proc_release = single_release, \ + } + +#define DEFINE_PROC_ATTRIBUTE_RW(name) \ + static ssize_t name##_write(struct file *file, \ + const char __user *buf, \ + size_t count, loff_t *ppos) \ + { \ + return name##_store(PDE_DATA(file_inode(file)), buf, \ + count); \ + } \ + DEFINE_PROC_ATTRIBUTE(name, name##_write) + +#define DEFINE_PROC_ATTRIBUTE_RO(name) \ + DEFINE_PROC_ATTRIBUTE(name, NULL) +#endif #endif extern struct proc_dir_entry *sysak_proc_mkdir(const char *name); + +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 10, 0) +extern struct proc_dir_entry *sysak_proc_create(const char *name, + const struct proc_ops *proc_fops); +#else extern struct proc_dir_entry *sysak_proc_create(const char *name, const struct file_operations *proc_fops); +#endif extern void sysak_remove_proc_entry(const char *name); extern int sysak_remove_proc_subtree(const char *name); extern int sysak_proc_init(void); extern void sysak_proc_exit(void); -#endif +#endif \ No newline at end of file