|
|
|
@@ -5,7 +5,9 @@
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/err.h>
|
|
|
|
#include <linux/file.h>
|
|
|
|
#include <linux/file.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
#include <linux/fs.h>
|
|
|
|
|
|
|
|
#include <linux/poll.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
#include <linux/slab.h>
|
|
|
|
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/uaccess.h>
|
|
|
|
#include <linux/uaccess.h>
|
|
|
|
#include <linux/version.h>
|
|
|
|
#include <linux/version.h>
|
|
|
|
|
|
|
|
|
|
|
|
@@ -20,18 +22,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
#include "file_wrapper.h"
|
|
|
|
#include "file_wrapper.h"
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef KSU_NEED_POLL_T_DEF
|
|
|
|
#ifdef KSU_NO___POLL_T
|
|
|
|
typedef unsigned __bitwise __poll_t;
|
|
|
|
typedef unsigned int ksu_poll_t;
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
typedef __poll_t ksu_poll_t;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
static loff_t mksu_wrapper_llseek(struct file *fp, loff_t off, int flags)
|
|
|
|
static loff_t ksu_wrapper_llseek(struct file *fp, loff_t off, int flags)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
return orig->f_op->llseek(data->orig, off, flags);
|
|
|
|
return orig->f_op->llseek(data->orig, off, flags);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static ssize_t mksu_wrapper_read(struct file *fp, char __user *ptr, size_t sz,
|
|
|
|
static ssize_t ksu_wrapper_read(struct file *fp, char __user *ptr, size_t sz,
|
|
|
|
loff_t *off)
|
|
|
|
loff_t *off)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
@@ -39,7 +43,7 @@ static ssize_t mksu_wrapper_read(struct file *fp, char __user *ptr, size_t sz,
|
|
|
|
return orig->f_op->read(orig, ptr, sz, off);
|
|
|
|
return orig->f_op->read(orig, ptr, sz, off);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static ssize_t mksu_wrapper_write(struct file *fp, const char __user *ptr,
|
|
|
|
static ssize_t ksu_wrapper_write(struct file *fp, const char __user *ptr,
|
|
|
|
size_t sz, loff_t *off)
|
|
|
|
size_t sz, loff_t *off)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
@@ -48,7 +52,7 @@ static ssize_t mksu_wrapper_write(struct file *fp, const char __user *ptr,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
|
|
|
|
static ssize_t mksu_wrapper_read_iter(struct kiocb *iocb, struct iov_iter *iovi)
|
|
|
|
static ssize_t ksu_wrapper_read_iter(struct kiocb *iocb, struct iov_iter *iovi)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = iocb->ki_filp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = iocb->ki_filp->private_data;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
@@ -56,7 +60,7 @@ static ssize_t mksu_wrapper_read_iter(struct kiocb *iocb, struct iov_iter *iovi)
|
|
|
|
return orig->f_op->read_iter(iocb, iovi);
|
|
|
|
return orig->f_op->read_iter(iocb, iovi);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static ssize_t mksu_wrapper_write_iter(struct kiocb *iocb,
|
|
|
|
static ssize_t ksu_wrapper_write_iter(struct kiocb *iocb,
|
|
|
|
struct iov_iter *iovi)
|
|
|
|
struct iov_iter *iovi)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = iocb->ki_filp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = iocb->ki_filp->private_data;
|
|
|
|
@@ -67,7 +71,7 @@ static ssize_t mksu_wrapper_write_iter(struct kiocb *iocb,
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
|
|
|
static int mksu_wrapper_iopoll(struct kiocb *kiocb, struct io_comp_batch *icb,
|
|
|
|
static int ksu_wrapper_iopoll(struct kiocb *kiocb, struct io_comp_batch *icb,
|
|
|
|
unsigned int v)
|
|
|
|
unsigned int v)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = kiocb->ki_filp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = kiocb->ki_filp->private_data;
|
|
|
|
@@ -76,7 +80,7 @@ static int mksu_wrapper_iopoll(struct kiocb *kiocb, struct io_comp_batch *icb,
|
|
|
|
return orig->f_op->iopoll(kiocb, icb, v);
|
|
|
|
return orig->f_op->iopoll(kiocb, icb, v);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
|
|
|
|
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 1, 0)
|
|
|
|
static int mksu_wrapper_iopoll(struct kiocb *kiocb, bool spin)
|
|
|
|
static int ksu_wrapper_iopoll(struct kiocb *kiocb, bool spin)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = kiocb->ki_filp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = kiocb->ki_filp->private_data;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
@@ -86,7 +90,7 @@ static int mksu_wrapper_iopoll(struct kiocb *kiocb, bool spin)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)
|
|
|
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)
|
|
|
|
static int mksu_wrapper_iterate(struct file *fp, struct dir_context *dc)
|
|
|
|
static int ksu_wrapper_iterate(struct file *fp, struct dir_context *dc)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
@@ -95,7 +99,7 @@ static int mksu_wrapper_iterate(struct file *fp, struct dir_context *dc)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
|
|
|
|
static int mksu_wrapper_iterate_shared(struct file *fp, struct dir_context *dc)
|
|
|
|
static int ksu_wrapper_iterate_shared(struct file *fp, struct dir_context *dc)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
@@ -103,7 +107,7 @@ static int mksu_wrapper_iterate_shared(struct file *fp, struct dir_context *dc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
static __poll_t mksu_wrapper_poll(struct file *fp,
|
|
|
|
static ksu_poll_t ksu_wrapper_poll(struct file *fp,
|
|
|
|
struct poll_table_struct *pts)
|
|
|
|
struct poll_table_struct *pts)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
@@ -111,7 +115,7 @@ static __poll_t mksu_wrapper_poll(struct file *fp,
|
|
|
|
return orig->f_op->poll(orig, pts);
|
|
|
|
return orig->f_op->poll(orig, pts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static long mksu_wrapper_unlocked_ioctl(struct file *fp, unsigned int cmd,
|
|
|
|
static long ksu_wrapper_unlocked_ioctl(struct file *fp, unsigned int cmd,
|
|
|
|
unsigned long arg)
|
|
|
|
unsigned long arg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
@@ -119,7 +123,7 @@ static long mksu_wrapper_unlocked_ioctl(struct file *fp, unsigned int cmd,
|
|
|
|
return orig->f_op->unlocked_ioctl(orig, cmd, arg);
|
|
|
|
return orig->f_op->unlocked_ioctl(orig, cmd, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static long mksu_wrapper_compat_ioctl(struct file *fp, unsigned int cmd,
|
|
|
|
static long ksu_wrapper_compat_ioctl(struct file *fp, unsigned int cmd,
|
|
|
|
unsigned long arg)
|
|
|
|
unsigned long arg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
@@ -127,7 +131,7 @@ static long mksu_wrapper_compat_ioctl(struct file *fp, unsigned int cmd,
|
|
|
|
return orig->f_op->compat_ioctl(orig, cmd, arg);
|
|
|
|
return orig->f_op->compat_ioctl(orig, cmd, arg);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int mksu_wrapper_mmap(struct file *fp, struct vm_area_struct *vma)
|
|
|
|
static int ksu_wrapper_mmap(struct file *fp, struct vm_area_struct *vma)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
@@ -136,7 +140,7 @@ static int mksu_wrapper_mmap(struct file *fp, struct vm_area_struct *vma)
|
|
|
|
|
|
|
|
|
|
|
|
// static unsigned long mmap_supported_flags {}
|
|
|
|
// static unsigned long mmap_supported_flags {}
|
|
|
|
|
|
|
|
|
|
|
|
static int mksu_wrapper_open(struct inode *ino, struct file *fp)
|
|
|
|
static int ksu_wrapper_open(struct inode *ino, struct file *fp)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
@@ -144,14 +148,14 @@ static int mksu_wrapper_open(struct inode *ino, struct file *fp)
|
|
|
|
return orig->f_op->open(orig_ino, orig);
|
|
|
|
return orig->f_op->open(orig_ino, orig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int mksu_wrapper_flush(struct file *fp, fl_owner_t id)
|
|
|
|
static int ksu_wrapper_flush(struct file *fp, fl_owner_t id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
return orig->f_op->flush(orig, id);
|
|
|
|
return orig->f_op->flush(orig, id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int mksu_wrapper_fsync(struct file *fp, loff_t off1, loff_t off2,
|
|
|
|
static int ksu_wrapper_fsync(struct file *fp, loff_t off1, loff_t off2,
|
|
|
|
int datasync)
|
|
|
|
int datasync)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
@@ -159,14 +163,14 @@ static int mksu_wrapper_fsync(struct file *fp, loff_t off1, loff_t off2,
|
|
|
|
return orig->f_op->fsync(orig, off1, off2, datasync);
|
|
|
|
return orig->f_op->fsync(orig, off1, off2, datasync);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int mksu_wrapper_fasync(int arg, struct file *fp, int arg2)
|
|
|
|
static int ksu_wrapper_fasync(int arg, struct file *fp, int arg2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
return orig->f_op->fasync(arg, orig, arg2);
|
|
|
|
return orig->f_op->fasync(arg, orig, arg2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int mksu_wrapper_lock(struct file *fp, int arg1, struct file_lock *fl)
|
|
|
|
static int ksu_wrapper_lock(struct file *fp, int arg1, struct file_lock *fl)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
@@ -174,7 +178,7 @@ static int mksu_wrapper_lock(struct file *fp, int arg1, struct file_lock *fl)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)
|
|
|
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)
|
|
|
|
static ssize_t mksu_wrapper_sendpage(struct file *fp, struct page *pg, int arg1,
|
|
|
|
static ssize_t ksu_wrapper_sendpage(struct file *fp, struct page *pg, int arg1,
|
|
|
|
size_t sz, loff_t *off, int arg2)
|
|
|
|
size_t sz, loff_t *off, int arg2)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
@@ -186,7 +190,7 @@ static ssize_t mksu_wrapper_sendpage(struct file *fp, struct page *pg, int arg1,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
static unsigned long mksu_wrapper_get_unmapped_area(struct file *fp,
|
|
|
|
static unsigned long ksu_wrapper_get_unmapped_area(struct file *fp,
|
|
|
|
unsigned long arg1,
|
|
|
|
unsigned long arg1,
|
|
|
|
unsigned long arg2,
|
|
|
|
unsigned long arg2,
|
|
|
|
unsigned long arg3,
|
|
|
|
unsigned long arg3,
|
|
|
|
@@ -201,9 +205,9 @@ static unsigned long mksu_wrapper_get_unmapped_area(struct file *fp,
|
|
|
|
return -EINVAL;
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// static int mksu_wrapper_check_flags(int arg) {}
|
|
|
|
// static int ksu_wrapper_check_flags(int arg) {}
|
|
|
|
|
|
|
|
|
|
|
|
static int mksu_wrapper_flock(struct file *fp, int arg1, struct file_lock *fl)
|
|
|
|
static int ksu_wrapper_flock(struct file *fp, int arg1, struct file_lock *fl)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
@@ -213,7 +217,7 @@ static int mksu_wrapper_flock(struct file *fp, int arg1, struct file_lock *fl)
|
|
|
|
return -EINVAL;
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static ssize_t mksu_wrapper_splice_write(struct pipe_inode_info *pii,
|
|
|
|
static ssize_t ksu_wrapper_splice_write(struct pipe_inode_info *pii,
|
|
|
|
struct file *fp, loff_t *off,
|
|
|
|
struct file *fp, loff_t *off,
|
|
|
|
size_t sz, unsigned int arg1)
|
|
|
|
size_t sz, unsigned int arg1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -225,7 +229,7 @@ static ssize_t mksu_wrapper_splice_write(struct pipe_inode_info *pii,
|
|
|
|
return -EINVAL;
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static ssize_t mksu_wrapper_splice_read(struct file *fp, loff_t *off,
|
|
|
|
static ssize_t ksu_wrapper_splice_read(struct file *fp, loff_t *off,
|
|
|
|
struct pipe_inode_info *pii, size_t sz,
|
|
|
|
struct pipe_inode_info *pii, size_t sz,
|
|
|
|
unsigned int arg1)
|
|
|
|
unsigned int arg1)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -238,7 +242,7 @@ static ssize_t mksu_wrapper_splice_read(struct file *fp, loff_t *off,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
|
|
|
|
void mksu_wrapper_splice_eof(struct file *fp)
|
|
|
|
void ksu_wrapper_splice_eof(struct file *fp)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
@@ -249,7 +253,7 @@ void mksu_wrapper_splice_eof(struct file *fp)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0)
|
|
|
|
static int mksu_wrapper_setlease(struct file *fp, int arg1,
|
|
|
|
static int ksu_wrapper_setlease(struct file *fp, int arg1,
|
|
|
|
struct file_lease **fl, void **p)
|
|
|
|
struct file_lease **fl, void **p)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
@@ -260,7 +264,7 @@ static int mksu_wrapper_setlease(struct file *fp, int arg1,
|
|
|
|
return -EINVAL;
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
|
|
|
|
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
|
|
|
|
static int mksu_wrapper_setlease(struct file *fp, int arg1,
|
|
|
|
static int ksu_wrapper_setlease(struct file *fp, int arg1,
|
|
|
|
struct file_lock **fl, void **p)
|
|
|
|
struct file_lock **fl, void **p)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
@@ -270,11 +274,9 @@ static int mksu_wrapper_setlease(struct file *fp, int arg1,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return -EINVAL;
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#elif LINUX_VERSION_CODE >= \
|
|
|
|
// int (*setlease)(struct file *, long, struct file_lock **, void **);
|
|
|
|
KERNEL_VERSION( \
|
|
|
|
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(3, 18, 0)
|
|
|
|
3, 18, \
|
|
|
|
static int ksu_wrapper_setlease(struct file *fp, long arg1,
|
|
|
|
0) // int (*setlease)(struct file *, long, struct file_lock **, void **);
|
|
|
|
|
|
|
|
static int mksu_wrapper_setlease(struct file *fp, long arg1,
|
|
|
|
|
|
|
|
struct file_lock **fl, void **p)
|
|
|
|
struct file_lock **fl, void **p)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
@@ -285,7 +287,7 @@ static int mksu_wrapper_setlease(struct file *fp, long arg1,
|
|
|
|
return -EINVAL;
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else // int (*setlease)(struct file *, long, struct file_lock **);
|
|
|
|
#else // int (*setlease)(struct file *, long, struct file_lock **);
|
|
|
|
static int mksu_wrapper_setlease(struct file *fp, long arg1,
|
|
|
|
static int ksu_wrapper_setlease(struct file *fp, long arg1,
|
|
|
|
struct file_lock **fl)
|
|
|
|
struct file_lock **fl)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
@@ -297,7 +299,7 @@ static int mksu_wrapper_setlease(struct file *fp, long arg1,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
static long mksu_wrapper_fallocate(struct file *fp, int mode, loff_t offset,
|
|
|
|
static long ksu_wrapper_fallocate(struct file *fp, int mode, loff_t offset,
|
|
|
|
loff_t len)
|
|
|
|
loff_t len)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
@@ -309,7 +311,7 @@ static long mksu_wrapper_fallocate(struct file *fp, int mode, loff_t offset,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 19, 0)
|
|
|
|
static void mksu_wrapper_show_fdinfo(struct seq_file *m, struct file *f)
|
|
|
|
static void ksu_wrapper_show_fdinfo(struct seq_file *m, struct file *f)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = m->file->private_data;
|
|
|
|
struct ksu_file_wrapper *data = m->file->private_data;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
@@ -319,7 +321,7 @@ static void mksu_wrapper_show_fdinfo(struct seq_file *m, struct file *f)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
static int mksu_wrapper_show_fdinfo(struct seq_file *m, struct file *f)
|
|
|
|
static int ksu_wrapper_show_fdinfo(struct seq_file *m, struct file *f)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = m->file->private_data;
|
|
|
|
struct ksu_file_wrapper *data = m->file->private_data;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
struct file *orig = data->orig;
|
|
|
|
@@ -331,7 +333,7 @@ static int mksu_wrapper_show_fdinfo(struct seq_file *m, struct file *f)
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
|
|
|
|
static ssize_t mksu_wrapper_copy_file_range(struct file *f1, loff_t off1,
|
|
|
|
static ssize_t ksu_wrapper_copy_file_range(struct file *f1, loff_t off1,
|
|
|
|
struct file *f2, loff_t off2,
|
|
|
|
struct file *f2, loff_t off2,
|
|
|
|
size_t sz, unsigned int flags)
|
|
|
|
size_t sz, unsigned int flags)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
@@ -347,7 +349,7 @@ static ssize_t mksu_wrapper_copy_file_range(struct file *f1, loff_t off1,
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
|
|
|
|
static loff_t mksu_wrapper_remap_file_range(struct file *file_in, loff_t pos_in,
|
|
|
|
static loff_t ksu_wrapper_remap_file_range(struct file *file_in, loff_t pos_in,
|
|
|
|
struct file *file_out,
|
|
|
|
struct file *file_out,
|
|
|
|
loff_t pos_out, loff_t len,
|
|
|
|
loff_t pos_out, loff_t len,
|
|
|
|
unsigned int remap_flags)
|
|
|
|
unsigned int remap_flags)
|
|
|
|
@@ -364,7 +366,7 @@ static loff_t mksu_wrapper_remap_file_range(struct file *file_in, loff_t pos_in,
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
|
|
|
|
static int mksu_wrapper_fadvise(struct file *fp, loff_t off1, loff_t off2,
|
|
|
|
static int ksu_wrapper_fadvise(struct file *fp, loff_t off1, loff_t off2,
|
|
|
|
int flags)
|
|
|
|
int flags)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
struct ksu_file_wrapper *data = fp->private_data;
|
|
|
|
@@ -376,13 +378,13 @@ static int mksu_wrapper_fadvise(struct file *fp, loff_t off1, loff_t off2,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
static int mksu_wrapper_release(struct inode *inode, struct file *filp)
|
|
|
|
static int ksu_wrapper_release(struct inode *inode, struct file *filp)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
mksu_delete_file_wrapper(filp->private_data);
|
|
|
|
ksu_delete_file_wrapper(filp->private_data);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct ksu_file_wrapper *mksu_create_file_wrapper(struct file *fp)
|
|
|
|
struct ksu_file_wrapper *ksu_create_file_wrapper(struct file *fp)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct ksu_file_wrapper *p =
|
|
|
|
struct ksu_file_wrapper *p =
|
|
|
|
kcalloc(sizeof(struct ksu_file_wrapper), 1, GFP_KERNEL);
|
|
|
|
kcalloc(sizeof(struct ksu_file_wrapper), 1, GFP_KERNEL);
|
|
|
|
@@ -394,79 +396,79 @@ struct ksu_file_wrapper *mksu_create_file_wrapper(struct file *fp)
|
|
|
|
|
|
|
|
|
|
|
|
p->orig = fp;
|
|
|
|
p->orig = fp;
|
|
|
|
p->ops.owner = THIS_MODULE;
|
|
|
|
p->ops.owner = THIS_MODULE;
|
|
|
|
p->ops.llseek = fp->f_op->llseek ? mksu_wrapper_llseek : NULL;
|
|
|
|
p->ops.llseek = fp->f_op->llseek ? ksu_wrapper_llseek : NULL;
|
|
|
|
p->ops.read = fp->f_op->read ? mksu_wrapper_read : NULL;
|
|
|
|
p->ops.read = fp->f_op->read ? ksu_wrapper_read : NULL;
|
|
|
|
p->ops.write = fp->f_op->write ? mksu_wrapper_write : NULL;
|
|
|
|
p->ops.write = fp->f_op->write ? ksu_wrapper_write : NULL;
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 16, 0)
|
|
|
|
p->ops.read_iter = fp->f_op->read_iter ? mksu_wrapper_read_iter : NULL;
|
|
|
|
p->ops.read_iter = fp->f_op->read_iter ? ksu_wrapper_read_iter : NULL;
|
|
|
|
p->ops.write_iter =
|
|
|
|
p->ops.write_iter =
|
|
|
|
fp->f_op->write_iter ? mksu_wrapper_write_iter : NULL;
|
|
|
|
fp->f_op->write_iter ? ksu_wrapper_write_iter : NULL;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 1, 0)
|
|
|
|
p->ops.iopoll = fp->f_op->iopoll ? mksu_wrapper_iopoll : NULL;
|
|
|
|
p->ops.iopoll = fp->f_op->iopoll ? ksu_wrapper_iopoll : NULL;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)
|
|
|
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)
|
|
|
|
p->ops.iterate = fp->f_op->iterate ? mksu_wrapper_iterate : NULL;
|
|
|
|
p->ops.iterate = fp->f_op->iterate ? ksu_wrapper_iterate : NULL;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
|
|
|
|
p->ops.iterate_shared =
|
|
|
|
p->ops.iterate_shared =
|
|
|
|
fp->f_op->iterate_shared ? mksu_wrapper_iterate_shared : NULL;
|
|
|
|
fp->f_op->iterate_shared ? ksu_wrapper_iterate_shared : NULL;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
p->ops.poll = fp->f_op->poll ? mksu_wrapper_poll : NULL;
|
|
|
|
p->ops.poll = fp->f_op->poll ? ksu_wrapper_poll : NULL;
|
|
|
|
p->ops.unlocked_ioctl =
|
|
|
|
p->ops.unlocked_ioctl =
|
|
|
|
fp->f_op->unlocked_ioctl ? mksu_wrapper_unlocked_ioctl : NULL;
|
|
|
|
fp->f_op->unlocked_ioctl ? ksu_wrapper_unlocked_ioctl : NULL;
|
|
|
|
p->ops.compat_ioctl =
|
|
|
|
p->ops.compat_ioctl =
|
|
|
|
fp->f_op->compat_ioctl ? mksu_wrapper_compat_ioctl : NULL;
|
|
|
|
fp->f_op->compat_ioctl ? ksu_wrapper_compat_ioctl : NULL;
|
|
|
|
p->ops.mmap = fp->f_op->mmap ? mksu_wrapper_mmap : NULL;
|
|
|
|
p->ops.mmap = fp->f_op->mmap ? ksu_wrapper_mmap : NULL;
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 12, 0)
|
|
|
|
p->ops.fop_flags = fp->f_op->fop_flags;
|
|
|
|
p->ops.fop_flags = fp->f_op->fop_flags;
|
|
|
|
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
|
|
|
|
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(4, 15, 0)
|
|
|
|
p->ops.mmap_supported_flags = fp->f_op->mmap_supported_flags;
|
|
|
|
p->ops.mmap_supported_flags = fp->f_op->mmap_supported_flags;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
p->ops.open = fp->f_op->open ? mksu_wrapper_open : NULL;
|
|
|
|
p->ops.open = fp->f_op->open ? ksu_wrapper_open : NULL;
|
|
|
|
p->ops.flush = fp->f_op->flush ? mksu_wrapper_flush : NULL;
|
|
|
|
p->ops.flush = fp->f_op->flush ? ksu_wrapper_flush : NULL;
|
|
|
|
p->ops.release = mksu_wrapper_release;
|
|
|
|
p->ops.release = ksu_wrapper_release;
|
|
|
|
p->ops.fsync = fp->f_op->fsync ? mksu_wrapper_fsync : NULL;
|
|
|
|
p->ops.fsync = fp->f_op->fsync ? ksu_wrapper_fsync : NULL;
|
|
|
|
p->ops.fasync = fp->f_op->fasync ? mksu_wrapper_fasync : NULL;
|
|
|
|
p->ops.fasync = fp->f_op->fasync ? ksu_wrapper_fasync : NULL;
|
|
|
|
p->ops.lock = fp->f_op->lock ? mksu_wrapper_lock : NULL;
|
|
|
|
p->ops.lock = fp->f_op->lock ? ksu_wrapper_lock : NULL;
|
|
|
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)
|
|
|
|
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 6, 0)
|
|
|
|
p->ops.sendpage = fp->f_op->sendpage ? mksu_wrapper_sendpage : NULL;
|
|
|
|
p->ops.sendpage = fp->f_op->sendpage ? ksu_wrapper_sendpage : NULL;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
p->ops.get_unmapped_area = fp->f_op->get_unmapped_area ?
|
|
|
|
p->ops.get_unmapped_area = fp->f_op->get_unmapped_area ?
|
|
|
|
mksu_wrapper_get_unmapped_area :
|
|
|
|
ksu_wrapper_get_unmapped_area :
|
|
|
|
NULL;
|
|
|
|
NULL;
|
|
|
|
p->ops.check_flags = fp->f_op->check_flags;
|
|
|
|
p->ops.check_flags = fp->f_op->check_flags;
|
|
|
|
p->ops.flock = fp->f_op->flock ? mksu_wrapper_flock : NULL;
|
|
|
|
p->ops.flock = fp->f_op->flock ? ksu_wrapper_flock : NULL;
|
|
|
|
p->ops.splice_write =
|
|
|
|
p->ops.splice_write =
|
|
|
|
fp->f_op->splice_write ? mksu_wrapper_splice_write : NULL;
|
|
|
|
fp->f_op->splice_write ? ksu_wrapper_splice_write : NULL;
|
|
|
|
p->ops.splice_read =
|
|
|
|
p->ops.splice_read =
|
|
|
|
fp->f_op->splice_read ? mksu_wrapper_splice_read : NULL;
|
|
|
|
fp->f_op->splice_read ? ksu_wrapper_splice_read : NULL;
|
|
|
|
p->ops.setlease = fp->f_op->setlease ? mksu_wrapper_setlease : NULL;
|
|
|
|
p->ops.setlease = fp->f_op->setlease ? ksu_wrapper_setlease : NULL;
|
|
|
|
p->ops.fallocate = fp->f_op->fallocate ? mksu_wrapper_fallocate : NULL;
|
|
|
|
p->ops.fallocate = fp->f_op->fallocate ? ksu_wrapper_fallocate : NULL;
|
|
|
|
p->ops.show_fdinfo =
|
|
|
|
p->ops.show_fdinfo =
|
|
|
|
fp->f_op->show_fdinfo ? mksu_wrapper_show_fdinfo : NULL;
|
|
|
|
fp->f_op->show_fdinfo ? ksu_wrapper_show_fdinfo : NULL;
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 7, 0)
|
|
|
|
p->ops.copy_file_range =
|
|
|
|
p->ops.copy_file_range =
|
|
|
|
fp->f_op->copy_file_range ? mksu_wrapper_copy_file_range : NULL;
|
|
|
|
fp->f_op->copy_file_range ? ksu_wrapper_copy_file_range : NULL;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 20, 0)
|
|
|
|
p->ops.remap_file_range = fp->f_op->remap_file_range ?
|
|
|
|
p->ops.remap_file_range = fp->f_op->remap_file_range ?
|
|
|
|
mksu_wrapper_remap_file_range :
|
|
|
|
ksu_wrapper_remap_file_range :
|
|
|
|
NULL;
|
|
|
|
NULL;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 19, 0)
|
|
|
|
p->ops.fadvise = fp->f_op->fadvise ? mksu_wrapper_fadvise : NULL;
|
|
|
|
p->ops.fadvise = fp->f_op->fadvise ? ksu_wrapper_fadvise : NULL;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
|
|
|
|
#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 6, 0)
|
|
|
|
p->ops.splice_eof =
|
|
|
|
p->ops.splice_eof =
|
|
|
|
fp->f_op->splice_eof ? mksu_wrapper_splice_eof : NULL;
|
|
|
|
fp->f_op->splice_eof ? ksu_wrapper_splice_eof : NULL;
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
return p;
|
|
|
|
return p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void mksu_delete_file_wrapper(struct ksu_file_wrapper *data)
|
|
|
|
void ksu_delete_file_wrapper(struct ksu_file_wrapper *data)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
fput((struct file *)data->orig);
|
|
|
|
fput((struct file *)data->orig);
|
|
|
|
kfree(data);
|
|
|
|
kfree(data);
|
|
|
|
|