summaryrefslogtreecommitdiff
path: root/integrationtests/cmd/ioworkload/scenario_fcntl.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-04-24 20:36:26 +0300
committerPaul Buetow <paul@buetow.org>2026-04-24 20:36:26 +0300
commit92a36a8c5f23756b8c6d721e89450752409ddd75 (patch)
tree52adee49828831feb0ca557e7df736726faedac3 /integrationtests/cmd/ioworkload/scenario_fcntl.go
parentfadbf135d0b251387fd785083df79e27d1025cac (diff)
task a8: move all binaries under ./cmd/<name>/main.go
Relocates the two non-canonical main packages so every binary in the repo lives at ./cmd/<BINARY>/main.go: - tools/filewriter/ -> cmd/filewriter/ - integrationtests/cmd/ioworkload/ (20 files) -> cmd/ioworkload/ Consumers updated: - Magefile.go: workloadSourcePath now ./cmd/ioworkload - integrationtests/README.md: structure note points at ../cmd/ioworkload Files moved with git mv so git log --follow history is preserved. cmd/ior/main.go was already canonical and is untouched. Verified: mage build produces the ior binary; go build ./cmd/... builds filewriter and ioworkload; go test ./cmd/ioworkload passes; go vet ./cmd/filewriter ./cmd/ioworkload is clean. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Diffstat (limited to 'integrationtests/cmd/ioworkload/scenario_fcntl.go')
-rw-r--r--integrationtests/cmd/ioworkload/scenario_fcntl.go134
1 files changed, 0 insertions, 134 deletions
diff --git a/integrationtests/cmd/ioworkload/scenario_fcntl.go b/integrationtests/cmd/ioworkload/scenario_fcntl.go
deleted file mode 100644
index 0c97002..0000000
--- a/integrationtests/cmd/ioworkload/scenario_fcntl.go
+++ /dev/null
@@ -1,134 +0,0 @@
-package main
-
-import (
- "fmt"
- "path/filepath"
- "syscall"
-)
-
-// fcntlDupfd uses fcntl F_DUPFD to duplicate a file descriptor.
-func fcntlDupfd() error {
- dir, cleanup, err := makeTempDir("fcntl-dupfd")
- if err != nil {
- return err
- }
- defer cleanup()
-
- path := filepath.Join(dir, "fcntlfile.txt")
- fd, err := syscall.Open(path, syscall.O_RDWR|syscall.O_CREAT, 0o644)
- if err != nil {
- return fmt.Errorf("open: %w", err)
- }
- defer syscall.Close(fd)
-
- newFd, _, errno := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), syscall.F_DUPFD, 0)
- if errno != 0 {
- return fmt.Errorf("fcntl F_DUPFD: %w", errno)
- }
- defer syscall.Close(int(newFd))
-
- if _, err := syscall.Write(int(newFd), []byte("via fcntl")); err != nil {
- return fmt.Errorf("write via fcntl dup: %w", err)
- }
- return nil
-}
-
-// fcntlSetfl uses fcntl F_GETFL/F_SETFL to read and modify file status flags.
-func fcntlSetfl() error {
- dir, cleanup, err := makeTempDir("fcntl-setfl")
- if err != nil {
- return err
- }
- defer cleanup()
-
- path := filepath.Join(dir, "fcntlsetflfile.txt")
- fd, err := syscall.Open(path, syscall.O_RDWR|syscall.O_CREAT, 0o644)
- if err != nil {
- return fmt.Errorf("open: %w", err)
- }
- defer syscall.Close(fd)
-
- flags, _, errno := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), syscall.F_GETFL, 0)
- if errno != 0 {
- return fmt.Errorf("fcntl F_GETFL: %w", errno)
- }
-
- _, _, errno = syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), syscall.F_SETFL, flags|syscall.O_APPEND)
- if errno != 0 {
- return fmt.Errorf("fcntl F_SETFL: %w", errno)
- }
-
- if _, err := syscall.Write(fd, []byte("appended via fcntl setfl")); err != nil {
- return fmt.Errorf("write: %w", err)
- }
- return nil
-}
-
-// fcntlDupfdCloexec uses fcntl F_DUPFD_CLOEXEC to duplicate a file descriptor
-// with the close-on-exec flag set.
-func fcntlDupfdCloexec() error {
- dir, cleanup, err := makeTempDir("fcntl-dupfd-cloexec")
- if err != nil {
- return err
- }
- defer cleanup()
-
- path := filepath.Join(dir, "fcntlcloexecfile.txt")
- fd, err := syscall.Open(path, syscall.O_RDWR|syscall.O_CREAT, 0o644)
- if err != nil {
- return fmt.Errorf("open: %w", err)
- }
- defer syscall.Close(fd)
-
- newFd, _, errno := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), syscall.F_DUPFD_CLOEXEC, 0)
- if errno != 0 {
- return fmt.Errorf("fcntl F_DUPFD_CLOEXEC: %w", errno)
- }
- defer syscall.Close(int(newFd))
-
- if _, err := syscall.Write(int(newFd), []byte("via fcntl dupfd cloexec")); err != nil {
- return fmt.Errorf("write via fcntl dup cloexec: %w", err)
- }
- return nil
-}
-
-// fcntlInvalidFd calls fcntl F_GETFL on an invalid fd (99999).
-// The syscall fails with EBADF, but ior should capture the enter_fcntl
-// tracepoint because it is recorded on syscall entry.
-func fcntlInvalidFd() error {
- for i := 0; i < 5; i++ {
- _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, 99999, syscall.F_GETFL, 0)
- if errno == 0 {
- return fmt.Errorf("expected fcntl on invalid fd to fail")
- }
- }
- return nil
-}
-
-// fcntlDupfdMax opens a file and calls fcntl F_DUPFD with a minfd value
-// that exceeds the process RLIMIT_NOFILE. The kernel rejects this with
-// EINVAL, but ior should capture the enter_fcntl tracepoint.
-func fcntlDupfdMax() error {
- dir, cleanup, err := makeTempDir("fcntl-dupfd-max")
- if err != nil {
- return err
- }
- defer cleanup()
-
- path := filepath.Join(dir, "fcntldupfdmaxfile.txt")
- fd, err := syscall.Open(path, syscall.O_RDWR|syscall.O_CREAT, 0o644)
- if err != nil {
- return fmt.Errorf("open: %w", err)
- }
- defer syscall.Close(fd)
-
- // Retry the failing fcntl a few times to avoid a single one-shot call
- // racing early trace capture under parallel integration load.
- for i := 0; i < 5; i++ {
- _, _, errno := syscall.Syscall(syscall.SYS_FCNTL, uintptr(fd), syscall.F_DUPFD, 1<<30)
- if errno == 0 {
- return fmt.Errorf("expected fcntl F_DUPFD with extreme minfd to fail")
- }
- }
- return nil
-}