/proc work

This commit is contained in:
zy
2023-11-27 22:22:30 -05:00
parent fd459340a7
commit 5e650478fb
7 changed files with 121 additions and 9 deletions

View File

@@ -56,7 +56,6 @@ static long device_ioctl(struct file *file, unsigned int ioctl_num,
printk(KERN_INFO "variable_monitor fun: %s with ioctl_num %d\n", __FUNCTION__,
ioctl_num);
//! todo check style
switch (ioctl_num) {
case IOCTL_WATCH_VARIABLE:
// copy watch_arg
@@ -67,7 +66,8 @@ static long device_ioctl(struct file *file, unsigned int ioctl_num,
"time_ns=%ld, threshold=%lld\n",
warg.task_id, warg.name, warg.ptr, warg.length_byte, warg.time_ns,
warg.threshold);
warg.time_ns = warg.time_ns == 0 ? 10000 : warg.time_ns; // default 10us
warg.time_ns =
warg.time_ns == 0 ? def_interval_ns : warg.time_ns; // default 10us
// start watch variable
start_watch_variable(warg);
break;
@@ -143,6 +143,9 @@ int init_module(void) {
printk(KERN_INFO "dev number: %d\n", dev_num);
printk(KERN_INFO "path: /dev/%s %d\n", DEVICE_NAME, dev_num);
// proc
monitor_proc_init();
// orig_X | buffer
monitor_init();
@@ -154,6 +157,9 @@ void cleanup_module(void) {
// clear all watch | free buffer
monitor_exit();
// proc
monitor_proc_exit();
// unmount
device_destroy(watch_class, dev_num);
class_destroy(watch_class);