[skip ci]kernel: Migrating KPM to ioctl
This commit is contained in:
@@ -209,3 +209,16 @@ int sukisu_is_kpm_control_code(unsigned long arg2) {
|
||||
return (arg2 >= CMD_KPM_CONTROL &&
|
||||
arg2 <= CMD_KPM_CONTROL_MAX) ? 1 : 0;
|
||||
}
|
||||
|
||||
int do_kpm(void __user *arg)
|
||||
{
|
||||
struct ksu_kpm_cmd cmd;
|
||||
|
||||
if (copy_from_user(&cmd, arg, sizeof(cmd))) {
|
||||
pr_err("kpm: copy_from_user failed\n");
|
||||
return -EFAULT;
|
||||
}
|
||||
|
||||
return sukisu_handle_kpm(cmd.arg2, cmd.arg3, cmd.arg4, cmd.arg5);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,58 +1,70 @@
|
||||
#ifndef __SUKISU_KPM_H
|
||||
#define __SUKISU_KPM_H
|
||||
|
||||
extern int sukisu_handle_kpm(unsigned long arg2, unsigned long arg3, unsigned long arg4,
|
||||
unsigned long arg5);
|
||||
extern int sukisu_is_kpm_control_code(unsigned long arg2);
|
||||
#include <linux/types.h>
|
||||
#include <linux/ioctl.h>
|
||||
|
||||
struct ksu_kpm_cmd {
|
||||
__aligned_u64 arg2;
|
||||
__aligned_u64 arg3;
|
||||
__aligned_u64 arg4;
|
||||
__aligned_u64 arg5;
|
||||
};
|
||||
|
||||
int sukisu_handle_kpm(unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5);
|
||||
int sukisu_is_kpm_control_code(unsigned long arg2);
|
||||
int do_kpm(void __user *arg);
|
||||
|
||||
#define KSU_IOCTL_KPM _IOC(_IOC_READ|_IOC_WRITE, 'K', 200, 0)
|
||||
|
||||
/* KPM Control Code */
|
||||
#define CMD_KPM_CONTROL 28
|
||||
#define CMD_KPM_CONTROL_MAX 35
|
||||
#define CMD_KPM_CONTROL 1
|
||||
#define CMD_KPM_CONTROL_MAX 10
|
||||
|
||||
/* Control Code */
|
||||
/*
|
||||
* prctl(xxx, 28, "PATH", "ARGS")
|
||||
* prctl(xxx, 1, "PATH", "ARGS")
|
||||
* success return 0, error return -N
|
||||
*/
|
||||
#define SUKISU_KPM_LOAD 28
|
||||
#define SUKISU_KPM_LOAD 1
|
||||
|
||||
/*
|
||||
* prctl(xxx, 29, "NAME")
|
||||
* prctl(xxx, 2, "NAME")
|
||||
* success return 0, error return -N
|
||||
*/
|
||||
#define SUKISU_KPM_UNLOAD 29
|
||||
#define SUKISU_KPM_UNLOAD 2
|
||||
|
||||
/*
|
||||
* num = prctl(xxx, 30)
|
||||
* num = prctl(xxx, 3)
|
||||
* error return -N
|
||||
* success return +num or 0
|
||||
*/
|
||||
#define SUKISU_KPM_NUM 30
|
||||
#define SUKISU_KPM_NUM 3
|
||||
|
||||
/*
|
||||
* prctl(xxx, 31, Buffer, BufferSize)
|
||||
* prctl(xxx, 4, Buffer, BufferSize)
|
||||
* success return +out, error return -N
|
||||
*/
|
||||
#define SUKISU_KPM_LIST 31
|
||||
#define SUKISU_KPM_LIST 4
|
||||
|
||||
/*
|
||||
* prctl(xxx, 32, "NAME", Buffer[256])
|
||||
* prctl(xxx, 5, "NAME", Buffer[256])
|
||||
* success return +out, error return -N
|
||||
*/
|
||||
#define SUKISU_KPM_INFO 32
|
||||
#define SUKISU_KPM_INFO 5
|
||||
|
||||
/*
|
||||
* prctl(xxx, 33, "NAME", "ARGS")
|
||||
* prctl(xxx, 6, "NAME", "ARGS")
|
||||
* success return KPM's result value
|
||||
* error return -N
|
||||
*/
|
||||
#define SUKISU_KPM_CONTROL 33
|
||||
#define SUKISU_KPM_CONTROL 6
|
||||
|
||||
/*
|
||||
* prctl(xxx, 34, buffer, bufferSize)
|
||||
* prctl(xxx, 7, buffer, bufferSize)
|
||||
* success return KPM's result value
|
||||
* error return -N
|
||||
*/
|
||||
#define SUKISU_KPM_VERSION 34
|
||||
#define SUKISU_KPM_VERSION 7
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user