syzkaller: Index | Files

package osutil

import ""


Package Files

fileutil.go osutil.go osutil_linux.go osutil_unix.go


const (
    DefaultDirPerm  = 0755
    DefaultFilePerm = 0644
    DefaultExecPerm = 0755

func Abs Uses

func Abs(path string) string

func CloseMemMappedFile Uses

func CloseMemMappedFile(f *os.File, mem []byte) error

CloseMemMappedFile destroys memory mapping created by CreateMemMappedFile.

func Command Uses

func Command(bin string, args ...string) *exec.Cmd

Command is similar to os/exec.Command, but also sets PDEATHSIG on linux.

func CopyDirRecursively Uses

func CopyDirRecursively(srcDir, dstDir string) error

func CopyFile Uses

func CopyFile(oldFile, newFile string) error

CopyFile atomically copies oldFile to newFile preserving permissions and modification time.

func CopyFiles Uses

func CopyFiles(srcDir, dstDir string, files map[string]bool) error

CopyFiles copies files from srcDir to dstDir as atomically as possible. Files are assumed to be relative names in slash notation. All other files in dstDir are removed.

func CreateMemMappedFile Uses

func CreateMemMappedFile(size int) (f *os.File, mem []byte, err error)

CreateMemMappedFile creates a temp file with the requested size and maps it into memory.

func FilesExist Uses

func FilesExist(dir string, files map[string]bool) bool

FilesExist returns true if all files exist in dir. Files are assumed to be relative names in slash notation.

func HandleInterrupts Uses

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 Uses

func IsAccessible(name string) error

IsAccessible checks if the file can be opened.

func IsExist Uses

func IsExist(name string) bool

IsExist returns true if the file name exists.

func LinkFiles Uses

func LinkFiles(srcDir, dstDir string, files map[string]bool) error

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 ListDir Uses

func ListDir(dir string) ([]string, error)

Return all files in a directory.

func LongPipe Uses

func LongPipe() (io.ReadCloser, io.WriteCloser, error)

func MkdirAll Uses

func MkdirAll(dir string) error

func PrependContext Uses

func PrependContext(ctx string, err error) error

func ProcessExitStatus Uses

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 Uses

func ProcessTempDir(where string) (string, error)

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 RemoveAll Uses

func RemoveAll(dir string) error

RemoveAll is similar to os.RemoveAll, but can handle more cases.

func Rename Uses

func Rename(oldFile, newFile string) error

Rename is similar to os.Rename but handles cross-device renaming (by copying).

func Run Uses

func Run(timeout time.Duration, cmd *exec.Cmd) ([]byte, error)

Run runs cmd with the specified timeout. Returns combined output. If the command fails, err includes output.

func RunCmd Uses

func RunCmd(timeout time.Duration, dir, bin string, args ...string) ([]byte, error)

RunCmd runs "bin args..." in dir with timeout and returns its output.

func Sandbox Uses

func Sandbox(cmd *exec.Cmd, user, net bool) error

func SandboxChown Uses

func SandboxChown(file string) error

func SystemMemorySize Uses

func SystemMemorySize() uint64

func TempFile Uses

func TempFile(prefix string) (string, error)

TempFile creates a unique temp filename. Note: the file already exists when the function returns.

func WriteExecFile Uses

func WriteExecFile(filename string, data []byte) error

func WriteFile Uses

func WriteFile(filename string, data []byte) error

func WriteTempFile Uses

func WriteTempFile(data []byte) (string, error)

WriteTempFile writes data to a temp file and returns its name.

type VerboseError Uses

type VerboseError struct {
    Title    string
    Output   []byte
    ExitCode int

func (*VerboseError) Error Uses

func (err *VerboseError) Error() string

Package osutil imports 14 packages (graph) and is imported by 73 packages. Updated 2020-07-07. Refresh now. Tools for package owners.