From c66010e29c49bc1a7e955dfd07ec2a5ad506bfc6 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 13 Feb 2024 10:32:57 +0200 Subject: use explicit types --- cmd/ioriotng/main.go | 8 ++++---- maps.bpf.h | 18 ++++++++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/cmd/ioriotng/main.go b/cmd/ioriotng/main.go index cf9c4a0..e353cc0 100644 --- a/cmd/ioriotng/main.go +++ b/cmd/ioriotng/main.go @@ -27,7 +27,7 @@ type openEvent struct { TID uint32 EnterTime uint64 ExitTime uint64 - Filename [256]byte + Filename [256]byte // TODO, use same value as in ioriot.bpf.h Comm [16]byte } @@ -35,8 +35,8 @@ func (e openEvent) String() string { filename := e.Filename[:] comm := e.Comm[:] duration := (e.ExitTime - e.EnterTime) / 1000000000000.0 - return fmt.Sprintf("%vms %v %v opId:%d tid:%v fd:%v filename:%s, comm:%s", - duration, e.ExitTime, e.EnterTime, e.OpID, e.TID, e.FD, string(filename), string(comm)) + return fmt.Sprintf("%vms opId:%d tid:%d fd:%d filename:%s, comm:%s", + duration, e.OpID, e.TID, e.FD, string(filename), string(comm)) } type fdEvent struct { @@ -49,7 +49,7 @@ type fdEvent struct { func (e fdEvent) String() string { duration := (e.ExitTime - e.EnterTime) / 1000000000000.0 - return fmt.Sprintf("%vms %v %v opId:%d tid:%v fd:%v", duration, e.ExitTime, e.EnterTime, e.OpID, e.TID, e.FD) + return fmt.Sprintf("%vms opId:%d tid:%v fd:%v", duration, e.OpID, e.TID, e.FD) } func resizeMap(module *bpf.Module, name string, size uint32) error { diff --git a/maps.bpf.h b/maps.bpf.h index d0bcb2f..355bba6 100644 --- a/maps.bpf.h +++ b/maps.bpf.h @@ -1,15 +1,17 @@ //+build ignore #define TEMP_MAP_SIZES 1024 // Adjust size as needed +#define MAX_FILENAME_LENGTH 256 +#define MAX_PROGNAME_LENGTH 16 struct open_event { - int fd; - int op_id; - u32 tid; + __s32 fd; + __s32 op_id; + __u32 tid; __u64 enter_time; __u64 exit_time; - char filename[256]; - char comm[16]; + char filename[MAX_FILENAME_LENGTH]; + char comm[MAX_PROGNAME_LENGTH]; }; struct { @@ -27,9 +29,9 @@ struct { } open_event_temp_map SEC(".maps"); struct fd_event { - int fd; - int op_id; - u32 tid; + __s32 fd; + __s32 op_id; + __u32 tid; __u64 enter_time; __u64 exit_time; }; -- cgit v1.2.3