diff options
| author | Paul Buetow <paul@buetow.org> | 2026-05-20 23:42:12 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-05-20 23:42:12 +0300 |
| commit | be6d4e8ffc722bf0d36c5b01ff46f817539a1525 (patch) | |
| tree | 7bb0aeb51e29cfbc6735af15bb812b888f4b3574 /cmd | |
| parent | 2156d6e51b18e29fe8dfe8e1a519e1a84e0a1fe6 (diff) | |
task-47: add KindExec for execve paths
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/ioworkload/scenario_process.go | 76 | ||||
| -rw-r--r-- | cmd/ioworkload/scenarios.go | 1 |
2 files changed, 77 insertions, 0 deletions
diff --git a/cmd/ioworkload/scenario_process.go b/cmd/ioworkload/scenario_process.go new file mode 100644 index 0000000..c2c5bbd --- /dev/null +++ b/cmd/ioworkload/scenario_process.go @@ -0,0 +1,76 @@ +package main + +import ( + "fmt" + "runtime" + "syscall" + "time" + "unsafe" + + "golang.org/x/sys/unix" +) + +const processExecEmitFor = 2 * time.Second + +func processExecLifecycle() error { + deadline := time.Now().Add(processExecEmitFor) + for time.Now().Before(deadline) { + if err := callExecveMissing(); err != nil { + return err + } + if err := callExecveatMissing(); err != nil { + return err + } + time.Sleep(10 * time.Millisecond) + } + return nil +} + +func callExecveMissing() error { + filename, err := syscall.BytePtrFromString("/tmp/ior-missing-execve-only") + if err != nil { + return fmt.Errorf("execve filename: %w", err) + } + argv := []uintptr{uintptr(unsafe.Pointer(filename)), 0} + envp := []uintptr{0} + _, _, errno := syscall.RawSyscall( + syscall.SYS_EXECVE, + uintptr(unsafe.Pointer(filename)), + uintptr(unsafe.Pointer(&argv[0])), + uintptr(unsafe.Pointer(&envp[0])), + ) + runtime.KeepAlive(filename) + runtime.KeepAlive(argv) + runtime.KeepAlive(envp) + if errno != syscall.ENOENT { + return fmt.Errorf("execve errno=%v, want ENOENT", errno) + } + return nil +} + +func callExecveatMissing() error { + filename, err := syscall.BytePtrFromString("ior-missing-execveat-only") + if err != nil { + return fmt.Errorf("execveat filename: %w", err) + } + argv := []uintptr{uintptr(unsafe.Pointer(filename)), 0} + envp := []uintptr{0} + dirfdSigned := int64(unix.AT_FDCWD) + dirfd := uintptr(dirfdSigned) + _, _, errno := syscall.RawSyscall6( + unix.SYS_EXECVEAT, + dirfd, + uintptr(unsafe.Pointer(filename)), + uintptr(unsafe.Pointer(&argv[0])), + uintptr(unsafe.Pointer(&envp[0])), + 0, + 0, + ) + runtime.KeepAlive(filename) + runtime.KeepAlive(argv) + runtime.KeepAlive(envp) + if errno != syscall.ENOENT { + return fmt.Errorf("execveat errno=%v, want ENOENT", errno) + } + return nil +} diff --git a/cmd/ioworkload/scenarios.go b/cmd/ioworkload/scenarios.go index a1039e0..1ec8e6d 100644 --- a/cmd/ioworkload/scenarios.go +++ b/cmd/ioworkload/scenarios.go @@ -38,6 +38,7 @@ var scenarios = map[string]func() error{ "mountfs-management": mountfsManagement, "polling-epoll": pollingEpoll, "sleep-syscalls": sleepSyscalls, + "process-exec-lifecycle": processExecLifecycle, "family-mixed": familyMixed, "close-basic": closeBasic, "close-range": closeRange, |
