File tree Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Expand file tree Collapse file tree 2 files changed +4
-5
lines changed Original file line number Diff line number Diff line change 15
15
#define READ_STR "read "
16
16
#define WRITE_STR "write "
17
17
#define OP_NAME_LEN 7
18
- #define DEV_NAME_LEN 8
19
18
#define NAME_LENGTH (OP_NAME_LEN + 1)
20
- #define AXIS_LENGTH (DEV_NAME_LEN + 1)
19
+ #define AXIS_LENGTH (DISK_NAME_LEN + 1)
21
20
22
21
// Structure to hold thread local data
23
22
typedef struct {
24
23
u64 ts ;
25
24
unsigned int size ;
26
25
unsigned int cmd_flags ;
27
26
u32 err ;
28
- char device [DEV_NAME_LEN ];
27
+ char device [DISK_NAME_LEN ];
29
28
} io_data_t ;
30
29
31
30
BPF_HASH (io_base_data , u64 , io_data_t );
@@ -40,7 +39,7 @@ disk_io_start(struct pt_regs *ctx, struct request *reqp)
40
39
data .ts = bpf_ktime_get_ns ();
41
40
data .cmd_flags = reqp -> cmd_flags ;
42
41
data .size = reqp -> __data_len ;
43
- __builtin_memcpy (& data .device , diskp -> disk_name , DEV_NAME_LEN );
42
+ bpf_probe_read_str (& data .device , DISK_NAME_LEN , diskp -> disk_name );
44
43
io_base_data .update ((u64 * ) & reqp , & data );
45
44
return (0 );
46
45
}
Original file line number Diff line number Diff line change @@ -69,7 +69,7 @@ int disk_io_start(struct pt_regs *ctx, struct request *reqp)
69
69
data.ts = bpf_ktime_get_ns();
70
70
data.cmd_flags = reqp->cmd_flags;
71
71
data.size = reqp->__data_len;
72
- __builtin_memcpy (&data.device, diskp->disk_name, DISK_NAME_LEN );
72
+ bpf_probe_read_str (&data.device, DISK_NAME_LEN, diskp->disk_name);
73
73
io_base_data.update((u64 *) &reqp, &data);
74
74
return 0;
75
75
}
You can’t perform that action at this time.
0 commit comments