kernel: tidy-up code

Signed-off-by: Faris <rissu.ntk@gmail.com>
This commit is contained in:
Faris
2025-11-02 00:43:48 +07:00
committed by ShirkNeko
parent b3fab49730
commit 7f2c838145
3 changed files with 77 additions and 96 deletions

View File

@@ -0,0 +1,48 @@
// This header should not be used outside of pkg_observer.c!
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0)
typedef const struct qstr *ksu_fname_t;
#define ksu_fname_len(f) ((f)->len)
#define ksu_fname_arg(f) ((f)->name)
#else
typedef const unsigned char *ksu_fname_t;
#define ksu_fname_len(f) (strlen(f))
#define ksu_fname_arg(f) (f)
#endif
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 9, 0)
#define KSU_DECL_FSNOTIFY_OPS(name) \
int name(struct fsnotify_mark *mark, u32 mask, \
struct inode *inode, struct inode *dir, \
const struct qstr *file_name, u32 cookie)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 2, 0)
#define KSU_DECL_FSNOTIFY_OPS(name) \
int name(struct fsnotify_group *group, \
struct inode *inode, u32 mask, const void *data, int data_type, \
ksu_fname_t file_name, u32 cookie, \
struct fsnotify_iter_info *iter_info)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 18, 0)
#define KSU_DECL_FSNOTIFY_OPS(name) \
int name(struct fsnotify_group *group, \
struct inode *inode, u32 mask, const void *data, int data_type, \
ksu_fname_t file_name, u32 cookie, \
struct fsnotify_iter_info *iter_info)
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
#define KSU_DECL_FSNOTIFY_OPS(name) \
int name(struct fsnotify_group *group, \
struct inode *inode, struct fsnotify_mark *inode_mark, \
struct fsnotify_mark *vfsmount_mark, \
u32 mask, const void *data, int data_type, \
ksu_fname_t file_name, u32 cookie, \
struct fsnotify_iter_info *iter_info)
#else
#define KSU_DECL_FSNOTIFY_OPS(name) \
int name(struct fsnotify_group *group, \
struct inode *inode, \
struct fsnotify_mark *inode_mark, \
struct fsnotify_mark *vfsmount_mark, \
u32 mask, void *data, int data_type, \
ksu_fname_t file_name, u32 cookie)
#endif