add workqueue

This commit is contained in:
zy
2023-11-23 18:12:57 +08:00
parent 316174b71e
commit 1df11cd6e4
3 changed files with 92 additions and 78 deletions

View File

@@ -49,7 +49,7 @@ typedef struct {
static long device_ioctl(struct file *file, unsigned int ioctl_num,
unsigned long ioctl_param) {
int ret = 0;
// watch_arg warg;
watch_arg warg;
ioctl_dump_param dump_param;
ioctl_pid wpid;
@@ -58,19 +58,19 @@ static long device_ioctl(struct file *file, unsigned int ioctl_num,
ioctl_num);
switch (ioctl_num) {
// case 0:
// // copy watch_arg
// if (copy_from_user(&warg, (watch_arg *)ioctl_param, sizeof(warg))) {
// return -EACCES;
// }
// printk(KERN_INFO
// "Watch_arg: task_id=%d, name=%s, ptr=%p, length_byte=%d, "
// "time_ns=%ld, threshold=%lld\n",
// warg.task_id, warg.name, warg.ptr, warg.length_byte, warg.time_ns,
// warg.threshold);
// // start watch variable
// start_watch_variable(warg);
// break;
case 0:
// copy watch_arg
if (copy_from_user(&warg, (watch_arg *)ioctl_param, sizeof(warg))) {
return -EACCES;
}
printk(KERN_INFO
"Watch_arg: task_id=%d, name=%s, ptr=%p, length_byte=%d, "
"time_ns=%ld, threshold=%lld\n",
warg.task_id, warg.name, warg.ptr, warg.length_byte, warg.time_ns,
warg.threshold);
// start watch variable
start_watch_variable(warg);
break;
case 1:
printk(KERN_INFO "variable_monitor 1\n");
ret = copy_from_user(&dump_param, (ioctl_dump_param *)ioctl_param,
@@ -86,16 +86,16 @@ static long device_ioctl(struct file *file, unsigned int ioctl_num,
}
printk(KERN_INFO "copy_to_user \n");
break;
case 0:
printk(KERN_INFO "variable_monitor test 2\n");
ret = copy_from_user(&wpid, (ioctl_pid *)ioctl_param, sizeof(ioctl_pid));
diag_test(wpid.pid);
/* code */
break;
// case 0:
// printk(KERN_INFO "variable_monitor test 2\n");
// ret = copy_from_user(&wpid, (ioctl_pid *)ioctl_param, sizeof(ioctl_pid));
// diag_test(wpid.pid);
// /* code */
// break;
default:
printk(KERN_INFO "variable_monitor test default\n");
ret = copy_from_user(&wpid, (ioctl_pid *)ioctl_param, sizeof(ioctl_pid));
diag_test(wpid.pid);
// printk(KERN_INFO "variable_monitor test default\n");
// ret = copy_from_user(&wpid, (ioctl_pid *)ioctl_param, sizeof(ioctl_pid));
// diag_test(wpid.pid);
break;
}
return 0;