summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2025-03-22 23:27:28 +0200
committerPaul Buetow <paul@buetow.org>2025-03-22 23:27:28 +0200
commit5fa2439de2cedfaef6aca125769facd4bc3bc9b5 (patch)
tree44e3cd78bf7219a0f22207bc9e922258dd4cf30c
parentdb7cdf67d04c96b7cf9d993d76f5911cf6eb234a (diff)
SETFL
-rw-r--r--README.md4
-rw-r--r--cmd/ior/main.go4
-rw-r--r--internal/eventloop.go10
3 files changed, 13 insertions, 5 deletions
diff --git a/README.md b/README.md
index 598e5ec..5a2abc2 100644
--- a/README.md
+++ b/README.md
@@ -1,4 +1,4 @@
-# I/O Riot NG
+# I/O Riot NG (aka ior)
<img src=assets/ior-small.png />
@@ -8,6 +8,8 @@ I/O Riot NG is an experiments with BPF. This program traces for I/O syscalls and
Maybe this is a spiritual successor of one of my previous projects, I/O Riot https://codeberg.org/snonux/ioriot, the latter was based on SystemTap and C. The NG is based on Go, C and BPF (via libbpfgo).
+This works only on Linux!
+
## Fedora
To get this running on Fedora 39, run:
diff --git a/cmd/ior/main.go b/cmd/ior/main.go
index 025abbb..2d8584a 100644
--- a/cmd/ior/main.go
+++ b/cmd/ior/main.go
@@ -3,8 +3,12 @@ package main
import (
"ior/internal"
"ior/internal/flags"
+ "runtime"
)
func main() {
+ if runtime.GOOS != "linux" {
+ panic("Unsupported OS")
+ }
internal.Run(flags.New())
}
diff --git a/internal/eventloop.go b/internal/eventloop.go
index 01ba90c..b451b69 100644
--- a/internal/eventloop.go
+++ b/internal/eventloop.go
@@ -249,16 +249,18 @@ func (e *eventLoop) syscallExit(exitEv event.Event, ch chan<- *event.Pair) {
ev.File = file.NewFdWithPid(fd, v.Pid)
}
switch v.Cmd {
- case syscall.F_SETFD:
+ case syscall.F_SETFL:
fdFile, ok := ev.File.(file.FdFile)
if !ok {
panic("expected a file.FdFile")
}
- fdFile.Flags = int32(v.Arg)
+ fmt.Println("DEBUG BEFORE", fdFile.FlagsString())
+ // fcntl(2)
+ canChange := syscall.O_APPEND | syscall.O_ASYNC | syscall.O_DIRECT | syscall.O_NOATIME | syscall.O_NONBLOCK
+ fdFile.Flags |= (int32(v.Arg) & int32(canChange))
ev.File = fdFile
e.files[fd] = fdFile
- case syscall.F_SETFL:
- fmt.Println("TODO: F_SETFL with fcntl not yet implememented")
+ fmt.Println("DEBUG AFTER", fdFile.FlagsString())
case syscall.F_DUPFD:
fmt.Println("TODO: F_DUPFD with fcntl not yet implememented")
case syscall.F_DUPFD_CLOEXEC: