summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorzy <[email protected]>2023-11-08 05:51:11 -0500
committerzy <[email protected]>2023-11-08 05:51:11 -0500
commitb5e1952f29fcb8bd7f3f58701bd95832c912b4ed (patch)
tree86cbffe6123a062829707e344530b2ad930f71cf
parent99de9a90e8ce5fa3b6823f22b9ca24e9dfd19f1b (diff)
bit -> byte
-rw-r--r--README.md4
-rw-r--r--README_zh.md4
-rw-r--r--helloworld.c2
-rw-r--r--watch.h4
-rw-r--r--watch_module.c10
-rw-r--r--watch_module.h4
-rw-r--r--watch_module_lib.c2
7 files changed, 15 insertions, 15 deletions
diff --git a/README.md b/README.md
index 923b9de..cb3f665 100644
--- a/README.md
+++ b/README.md
@@ -39,7 +39,7 @@ typedef struct
{
pid_t task_id; // current process id
void *ptr; // virtual address
- int length_bit; // length_bit
+ int length_byte; // length_byte
long long threshold; // threshold value
unsigned char unsigned_flag; // unsigned flag (true: unsigned, false: signed)
unsigned char greater_flag; // reverse flag (true: >, false: <)
@@ -54,7 +54,7 @@ An initialization example:
watch_arg watch_arg = {
.task_id = getpid(),
.ptr = &temp,
- .length_bit = sizeof(int) * 8,
+ .length_byte = sizeof(int),
.threshold = 105,
.unsigned_flag = 1,
.greater_flag = 1,
diff --git a/README_zh.md b/README_zh.md
index 0f2d9cd..0cb2f80 100644
--- a/README_zh.md
+++ b/README_zh.md
@@ -39,7 +39,7 @@ typedef struct
{
pid_t task_id; // current process id
void *ptr; // virtual address
- int length_bit; // length_bit
+ int length_byte; // length_byte
long long threshold; // threshold value
unsigned char unsigned_flag; // unsigned flag (true: unsigned, false: signed)
unsigned char greater_flag; // reverse flag (true: >, false: <)
@@ -54,7 +54,7 @@ typedef struct
watch_arg watch_arg = {
.task_id = getpid(),
.ptr = &temp,
- .length_bit = sizeof(int) * 8,
+ .length_byte = sizeof(int),
.threshold = 105,
.unsigned_flag = 1,
.greater_flag = 1,
diff --git a/helloworld.c b/helloworld.c
index 703c45f..aef2ac4 100644
--- a/helloworld.c
+++ b/helloworld.c
@@ -11,7 +11,7 @@ int main()
watch_arg watch_arg = {
.task_id = getpid(),
.ptr = &temp,
- .length_bit = sizeof(int) * 8,
+ .length_byte = sizeof(int),
.threshold = 105,
.unsigned_flag = 1,
.greater_flag = 1,
diff --git a/watch.h b/watch.h
index 4eb9a90..4a0d032 100644
--- a/watch.h
+++ b/watch.h
@@ -5,11 +5,11 @@ typedef struct
{
pid_t task_id; // current process id
void *ptr; // virtual address
- int length_bit; // bit
+ int length_byte; // byte
long long threshold; // threshold value
unsigned char unsigned_flag; // unsigned flag (true: unsigned, false: signed)
unsigned char greater_flag; // reverse flag (true: >, false: <)
- unsigned long time_ns; // timer interval (ns)
+ unsigned long time_ns; // timer interval (ns)
} watch_arg;
// start watch
diff --git a/watch_module.c b/watch_module.c
index 6bdfb61..04aff1d 100644
--- a/watch_module.c
+++ b/watch_module.c
@@ -42,8 +42,8 @@ static long device_ioctl(struct file *file, unsigned int ioctl_num, unsigned lon
return -EACCES;
}
- printk(KERN_INFO "Received: task_id=%d, ptr=%p, length_bit=%d, time_ns=%ld, threshold=%lld\n", warg.task_id, warg.ptr,
- warg.length_bit, warg.time_ns, warg.threshold);
+ printk(KERN_INFO "Received: task_id=%d, ptr=%p, length_byte=%d, time_ns=%ld, threshold=%lld\n", warg.task_id, warg.ptr,
+ warg.length_byte, warg.time_ns, warg.threshold);
// user space address to kernel space address
ptr = access_user_space_ptr(warg.task_id, (unsigned long)warg.ptr);
@@ -53,15 +53,15 @@ static long device_ioctl(struct file *file, unsigned int ioctl_num, unsigned lon
return -EACCES;
}
// check length
- if (warg.length_bit != 8 && warg.length_bit != 16 && warg.length_bit != 32 && warg.length_bit != 64)
+ if (warg.length_byte != 1 && warg.length_byte != 2 && warg.length_byte != 4 && warg.length_byte != 8)
{
- printk(KERN_ERR "Invalid length %d\n", warg.length_bit);
+ printk(KERN_ERR "Invalid length %d\n", warg.length_byte);
return -EINVAL;
}
// k_watch_arg init
k_watch_arg.kptr = ptr;
- k_watch_arg.length_bit = warg.length_bit;
+ k_watch_arg.length_byte = warg.length_byte;
k_watch_arg.threshold = warg.threshold;
k_watch_arg.unsigned_flag = warg.unsigned_flag;
k_watch_arg.greater_flag = warg.greater_flag;
diff --git a/watch_module.h b/watch_module.h
index fac02a0..d4f48c5 100644
--- a/watch_module.h
+++ b/watch_module.h
@@ -15,7 +15,7 @@ typedef struct
{
pid_t task_id; // current process id
void *ptr; // virtual address
- int length_bit; // bit
+ int length_byte; // byte
long long threshold; // threshold value
unsigned char unsigned_flag; // unsigned flag (true: unsigned, false: signed)
unsigned char greater_flag; // reverse flag (true: >, false: <)
@@ -25,7 +25,7 @@ typedef struct
typedef struct
{
void *kptr; // kernel address + offset
- int length_bit; // bit
+ int length_byte; // byte
long long threshold; // threshold value
unsigned char unsigned_flag; // unsigned flag (true: unsigned, false: signed)
unsigned char greater_flag; // reverse flag (true: >, false: <)
diff --git a/watch_module_lib.c b/watch_module_lib.c
index 52c0f80..28bd3a0 100644
--- a/watch_module_lib.c
+++ b/watch_module_lib.c
@@ -141,7 +141,7 @@ static compare_func compare_funcs[2][4] = {
unsigned char read_and_compare(kernel_watch_arg *k_arg)
{
void *ptr = k_arg->kptr;
- int len = k_arg->length_bit / 8;
+ int len = k_arg->length_byte;
unsigned char is_unsigned = k_arg->unsigned_flag;
long long threshold = k_arg->threshold;