diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-22 18:16:59 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-22 18:16:59 +0200 |
| commit | 40ce5bc1d9da31b49f42e488d2ab5633e7c6a3fb (patch) | |
| tree | 33c6197180648d80f0e71b14803e102522059be5 /integrationtests/cmd/ioworkload/scenario_sync.go | |
| parent | 3ec3c117bb280a377fea1a3eef84a70e2a3d4150 (diff) | |
Implement sync_file_range coverage and document mage world bootstrap
Diffstat (limited to 'integrationtests/cmd/ioworkload/scenario_sync.go')
| -rw-r--r-- | integrationtests/cmd/ioworkload/scenario_sync.go | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/integrationtests/cmd/ioworkload/scenario_sync.go b/integrationtests/cmd/ioworkload/scenario_sync.go index 214c783..db6b08f 100644 --- a/integrationtests/cmd/ioworkload/scenario_sync.go +++ b/integrationtests/cmd/ioworkload/scenario_sync.go @@ -77,6 +77,29 @@ func syncSyncFileRange() error { return syscall.SyncFileRange(fd, 0, int64(len(data)), 0) } +// syncSyncFileRangeToEOF calls sync_file_range(2) with nbytes=0. +// Per sync_file_range(2), nbytes=0 means "sync from offset through end-of-file". +func syncSyncFileRangeToEOF() error { + dir, cleanup, err := makeTempDir("sync-sync-file-range-to-eof") + if err != nil { + return err + } + defer cleanup() + + path := filepath.Join(dir, "syncrangeeoffile.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) + + if _, err := syscall.Write(fd, []byte("sync file range to eof")); err != nil { + return fmt.Errorf("write: %w", err) + } + + return syscall.SyncFileRange(fd, 0, 0, 0) +} + // syncFsyncEbadf calls fsync on an invalid fd. // The syscall fails with EBADF, but ior captures the enter_fsync tracepoint. func syncFsyncEbadf() error { |
