summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2024-02-28 01:17:48 +0200
committerPaul Buetow <paul@buetow.org>2024-02-28 01:17:48 +0200
commit42f8733fc7c3fe23543d9da258b7ec91e11c9a63 (patch)
treefb323dc36d11011570b25ba1d86d64e9515d0810
parent105ee65a32d8c2ab456d7b246d3e8808b07880c4 (diff)
no need of debugfs package.
older kernels may not have some of the tracepoints.
-rw-r--r--internal/debugfs/debugfs.go57
-rw-r--r--internal/ioriotng.go8
2 files changed, 3 insertions, 62 deletions
diff --git a/internal/debugfs/debugfs.go b/internal/debugfs/debugfs.go
deleted file mode 100644
index 80ac436..0000000
--- a/internal/debugfs/debugfs.go
+++ /dev/null
@@ -1,57 +0,0 @@
-package debugfs
-
-import (
- "bufio"
- "fmt"
- "os"
- "path/filepath"
- "strings"
-)
-
-// Return tracepoints with 'unsigned int fd', which are I/O tracepoints on FDs
-func TracepointsWithFd() ([]string, error) {
- return tracepointsWith("unsigned int fd")
-}
-
-func tracepointsWith(field string) ([]string, error) {
- var tracepoints []string
-
- matches, err := filepath.Glob("/sys/kernel/debug/tracing/events/syscalls/*/format")
- if err != nil {
- return tracepoints, err
- }
- if len(matches) == 0 {
- return tracepoints, fmt.Errorf("Unable to gather tracepoints with FDs")
- }
-
- for _, formatPath := range matches {
- has, err := hasField(formatPath, field)
- if err != nil {
- return tracepoints, err
- }
- if !has {
- continue
- }
- tracepoints = append(tracepoints, filepath.Base(filepath.Dir(formatPath)))
- }
-
- return tracepoints, nil
-}
-
-func hasField(formatPath, field string) (bool, error) {
- file, err := os.Open(formatPath)
- if err != nil {
- return false, err
- }
- defer file.Close()
-
- scanner := bufio.NewScanner(file)
- for scanner.Scan() {
- line := scanner.Text()
- if strings.Contains(line, fmt.Sprintf("field:%s;", field)) {
- return true, nil
- }
- }
-
- return false, nil
-}
diff --git a/internal/ioriotng.go b/internal/ioriotng.go
index d252030..46cc0e5 100644
--- a/internal/ioriotng.go
+++ b/internal/ioriotng.go
@@ -5,7 +5,6 @@ import "C"
import (
"fmt"
- "ioriotng/internal/debugfs"
"ioriotng/internal/flags"
"ioriotng/internal/generated/tracepoints"
@@ -21,7 +20,9 @@ func attachTracepoints(bpfModule *bpf.Module) error {
fmt.Println("Attached prog handle_" + name)
if _, err = prog.AttachTracepoint("syscalls", name); err != nil {
- return fmt.Errorf("Failed to attach to %s tracepoint: %v", name, err)
+ // OK, older Kernel versions may not have this tracepoint!
+ fmt.Println(fmt.Errorf("Failed to attach to %s tracepoint: %v", name, err))
+ continue
}
fmt.Println("Attached tracepoint " + name)
}
@@ -30,9 +31,6 @@ func attachTracepoints(bpfModule *bpf.Module) error {
}
func Run(flags flags.Flags) {
- // Print out tracepoints with fd to consider for implementation!
- fmt.Println(debugfs.TracepointsWithFd())
-
bpfModule, err := bpf.NewModuleFromFile("ioriotng.bpf.o")
if err != nil {
panic(err)