syswrap

package
v0.0.0-...-eec02a6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

README

syswrap

syswrap is a small program to wrap system calls with timeouts. In Go, syscalls cannot be cleaned up if they are blocked, for example if lstat is called on an inaccessible NFS mount, but because Go can create additional goroutines the calling application will not block. This can cause resource exhaustion if syscalls are not bounded.

Linux will clean up syscalls if the owning process ends, so syswrap exists to allow Trident to create a new process that owns a potentially blocking syscall.

The Trident-accessible interface is in this package.

Usage

syswrap <timeout> <syscall> <syscall args...>

<timeout> is in Go format, i.e. 30s

<syscall> is the name of the call, see cmd/syswrap/main.go

<syscall args...> are string representations of any arguments required by the call.

Adding Syscalls

See syswrap.Exists for a cross-platform example, and syswrap.Statfs for a Linux-only example.

There are 3 steps to adding a new syscall:

  1. Add func to internal/syswrap package. This func calls the syswrap binary, and it should also call the syscall itself if the syswrap binary is not found.
  2. Add func to internal/syswrap/unix package. The func must have the signature func(args []string) (output interface{}, err error), and parse its args then call the syscall. Any fields in output that need to be used by Trident must be exported.
  3. Add func name to cmd/syswrap/main.syscalls map.

Documentation

Overview

Package syswrap wraps syscalls that need to be canceled

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exists

func Exists(ctx context.Context, path string, timeout time.Duration) (bool, error)

func Statfs

func Statfs(ctx context.Context, path string, timeout time.Duration) (unix.Statfs_t, error)

Types

This section is empty.

Directories

Path Synopsis
Package unix parses string arguments and calls the system call
Package unix parses string arguments and calls the system call

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL