Documentation ¶
Index ¶
- Constants
- func Abs(path string) string
- func CloseMemMappedFile(f *os.File, mem []byte) error
- func CloseSharedMemFile(f *os.File) error
- func Command(bin string, args ...string) *exec.Cmd
- func CommandContext(ctx context.Context, bin string, args ...string) *exec.Cmd
- func CopyDirRecursively(srcDir, dstDir string) error
- func CopyFile(oldFile, newFile string) error
- func CopyFiles(srcDir, dstDir string, files map[string]bool) error
- func CreateMemMappedFile(size int) (f *os.File, mem []byte, err error)
- func CreateSharedMemFile(size int) (f *os.File, err error)
- func FilesExist(dir string, files map[string]bool) bool
- func GraciousCommand(bin string, args ...string) *exec.Cmd
- func HandleInterrupts(shutdown chan struct{})
- func IsAccessible(name string) error
- func IsDir(name string) bool
- func IsExist(name string) bool
- func IsWritable(name string) error
- func LinkFiles(srcDir, dstDir string, files map[string]bool) error
- func ListDir(dir string) ([]string, error)
- func LongPipe() (io.ReadCloser, io.WriteCloser, error)
- func MkdirAll(dir string) error
- func MonotonicNano() time.Duration
- func PrependContext(ctx string, err error) error
- func ProcessExitStatus(ps *os.ProcessState) int
- func ProcessTempDir(where string) (string, error)
- func RemoveAll(dir string) error
- func Rename(oldFile, newFile string) error
- func Run(timeout time.Duration, cmd *exec.Cmd) ([]byte, error)
- func RunCmd(timeout time.Duration, dir, bin string, args ...string) ([]byte, error)
- func Sandbox(cmd *exec.Cmd, user, net bool) error
- func SandboxChown(file string) error
- func SystemMemorySize() uint64
- func TempFile(prefix string) (string, error)
- func WriteExecFile(filename string, data []byte) error
- func WriteFile(filename string, data []byte) error
- func WriteGzipStream(filename string, reader io.Reader) error
- func WriteJSON[T any](filename string, obj T) error
- func WriteTempFile(data []byte) (string, error)
- type VerboseError
Constants ¶
const ( DefaultDirPerm = 0755 DefaultFilePerm = 0644 DefaultExecPerm = 0755 )
Variables ¶
This section is empty.
Functions ¶
func CloseMemMappedFile ¶
CloseMemMappedFile destroys memory mapping created by CreateMemMappedFile.
func CloseSharedMemFile ¶
func Command ¶
Command is similar to os/exec.Command, but also sets PDEATHSIG to SIGKILL on linux, i.e. the child will be killed immediately.
func CommandContext ¶
CommandContext is similar to os/exec.CommandContext, but also sets PDEATHSIG to SIGKILL on linux, i.e. the child will be killed immediately.
func CopyDirRecursively ¶
func CopyFile ¶
CopyFile atomically copies oldFile to newFile preserving permissions and modification time.
func CopyFiles ¶
CopyFiles copies files from srcDir to dstDir as atomically as possible. Files are assumed to be relative glob patterns in slash notation in srcDir. All other files in dstDir are removed.
func CreateMemMappedFile ¶
CreateMemMappedFile creates a temp file with the requested size and maps it into memory.
func CreateSharedMemFile ¶
In the case of Linux, we can just use the memfd_create syscall.
func FilesExist ¶
FilesExist returns true if all files exist in dir. Files are assumed to be relative names in slash notation.
func GraciousCommand ¶
Command is similar to os/exec.Command, but also sets PDEATHSIG to SIGTERM on linux, i.e. the child has a chance to exit gracefully. This may be important when running e.g. syz-manager. If it is killed immediately, it can leak GCE instances.
func HandleInterrupts ¶
func HandleInterrupts(shutdown chan struct{})
HandleInterrupts closes shutdown chan on first SIGINT (expecting that the program will gracefully shutdown and exit) and terminates the process on third SIGINT.
func IsAccessible ¶
IsAccessible checks if the file can be opened.
func LinkFiles ¶
LinkFiles creates hard links for files from dstDir to srcDir. Files are assumed to be relative names in slash notation. All other files in dstDir are removed.
func LongPipe ¶
func LongPipe() (io.ReadCloser, io.WriteCloser, error)
func MonotonicNano ¶
MonotonicNano returns monotonic time in nanoseconds from some unspecified point in time. Useful mostly to measure time intervals. This function should be used inside of tested VMs b/c time.Now may reject to use monotonic time if the fuzzer messes with system time (sets time past Y2157, see comments in time/time.go). This is a hacky way to use the private runtime function. If this ever breaks, we can either provide specializations for different Go versions using build tags, or fall back to time.Now.
func PrependContext ¶
func ProcessExitStatus ¶
func ProcessExitStatus(ps *os.ProcessState) int
ProcessExitStatus returns process exit status. This is here only because of fuchsia that does not implement WaitStatus.
func ProcessTempDir ¶
ProcessTempDir creates a new temp dir in where and returns its path and an unique index. It also cleans up old, unused temp dirs after dead processes.
func Run ¶
Run runs cmd with the specified timeout. Returns combined output. If the command fails, err includes output.
func SandboxChown ¶
func SystemMemorySize ¶
func SystemMemorySize() uint64
func TempFile ¶
TempFile creates a unique temp filename. Note: the file already exists when the function returns.
func WriteExecFile ¶
func WriteTempFile ¶
WriteTempFile writes data to a temp file and returns its name.
Types ¶
type VerboseError ¶
func (*VerboseError) Error ¶
func (err *VerboseError) Error() string