os

Imports

Imports #

"runtime"
"slices"
"sync"
"syscall"
"syscall"
"unsafe"
"errors"
"internal/stringslite"
"runtime"
"errors"
"runtime"
"internal/poll"
"syscall"
"syscall"
"syscall"
"syscall"
"unsafe"
"syscall"
"internal/filepathlite"
"syscall"
"time"
"internal/bytealg"
"internal/poll"
"internal/stringslite"
"io"
"runtime"
"sync"
"sync/atomic"
"syscall"
"time"
"internal/filepathlite"
"syscall"
"time"
"syscall"
"unsafe"
"internal/bytealg"
"internal/filepathlite"
"io"
"io/fs"
"slices"
"syscall"
"errors"
"sync/atomic"
"internal/filepathlite"
"syscall"
"time"
"internal/filepathlite"
"syscall"
"time"
"internal/filepathlite"
"syscall"
"time"
"io"
"runtime"
"syscall"
"unsafe"
"syscall"
"unsafe"
"internal/itoa"
"runtime"
"syscall"
"time"
"internal/filepathlite"
"syscall"
"time"
"internal/filepathlite"
"internal/syscall/windows"
"syscall"
"runtime"
"internal/testlog"
"errors"
"internal/testlog"
"runtime"
"sync"
"sync/atomic"
"syscall"
"time"
"errors"
"internal/filepathlite"
"internal/stringslite"
"internal/syscall/windows"
"runtime"
"syscall"
"unsafe"
"internal/poll"
"io"
"internal/poll"
"internal/syscall/unix"
"io/fs"
"runtime"
"sync/atomic"
"syscall"
_ "unsafe"
"errors"
"internal/bytealg"
"internal/stringslite"
"internal/testlog"
"io/fs"
"runtime"
"slices"
"syscall"
"unsafe"
"syscall"
"unsafe"
"errors"
"internal/syscall/unix"
"runtime"
"sync"
"syscall"
_ "unsafe"
"syscall"
"internal/testlog"
"runtime"
"syscall"
"syscall"
"internal/poll"
"syscall"
"unsafe"
"io"
"runtime"
"syscall"
"errors"
"internal/syscall/windows"
"runtime"
"syscall"
"time"
"internal/syscall/unix"
"runtime"
"syscall"
"syscall"
"unsafe"
"syscall"
"unsafe"
"errors"
"internal/filepathlite"
"internal/godebug"
"internal/poll"
"internal/syscall/windows"
"runtime"
"sync"
"sync/atomic"
"syscall"
"unsafe"
"internal/filepathlite"
"syscall"
"time"
"internal/filepathlite"
"syscall"
"time"
"syscall"
"time"
"errors"
"runtime"
"syscall"
"time"
"syscall"
_ "unsafe"
"internal/poll"
"syscall"
"internal/filepathlite"
"syscall"
"io"
"io/fs"
"syscall"
"internal/byteorder"
"internal/goarch"
"io"
"runtime"
"sync"
"syscall"
"unsafe"
"internal/syscall/unix"
"io"
"syscall"
"syscall"
"unsafe"
"runtime"
"sync"
"syscall"
"errors"
"internal/syscall/unix"
"runtime"
"syscall"
"internal/syscall/windows"
"syscall"
"syscall"
"unsafe"
"syscall"
"syscall"
"time"
"internal/poll"
"io/fs"
"internal/filepathlite"
"internal/godebug"
"internal/syscall/windows"
"sync"
"syscall"
"time"
"unsafe"
"internal/poll"
"io"
"runtime"
"syscall"
"syscall"
"time"
"syscall"
"unsafe"
"internal/testlog"
"syscall"
"runtime"
"syscall"
"syscall"
"unsafe"
"internal/filepathlite"
"syscall"
"syscall"
"internal/filepathlite"
"syscall"
"time"
"internal/filepathlite"
"internal/syscall/windows"
"syscall"
"unsafe"
"internal/syscall/windows"
"io"
"io/fs"
"runtime"
"sync"
"syscall"
"unsafe"
"syscall"
"unsafe"
"syscall"
"internal/filepathlite"
"syscall"
"time"
"errors"
"internal/bytealg"
"internal/itoa"
_ "unsafe"
"io/fs"
"syscall"
"internal/itoa"
"internal/syscall/execenv"
"runtime"
"syscall"
"errors"
"internal/filepathlite"
"internal/poll"
"internal/testlog"
"io"
"io/fs"
"runtime"
"syscall"
"time"
"unsafe"
"runtime"
"syscall"
"internal/poll"
"io"
"syscall"
"io"
"syscall"
"runtime"
"syscall"
"time"
"syscall"
"io"
"syscall"
"runtime"
"syscall"
"internal/itoa"
"syscall"
"internal/syscall/windows"
"syscall"
"errors"
_ "unsafe"
"syscall"
"unsafe"
"errors"
"slices"
"syscall"

Constants & Variables

Args var #

Args hold the command-line arguments, starting with the program name.

var Args []string

DevNull const #

DevNull is the name of the operating system's “null device.” On Unix-like systems, it is "/dev/null"; on Windows, "NUL".

const DevNull = "/dev/null"

DevNull const #

DevNull is the name of the operating system's “null device.” On Unix-like systems, it is "/dev/null"; on Windows, "NUL".

const DevNull = "NUL"

DevNull const #

DevNull is the name of the operating system's “null device.” On Unix-like systems, it is "/dev/null"; on Windows, "NUL".

const DevNull = "/dev/null"

ErrClosed var #

Portable analogs of some common system call errors. Errors returned from this package may be tested against these errors with [errors.Is].

var ErrClosed = fs.ErrClosed

ErrDeadlineExceeded var #

Portable analogs of some common system call errors. Errors returned from this package may be tested against these errors with [errors.Is].

var ErrDeadlineExceeded = *ast.CallExpr

ErrExist var #

Portable analogs of some common system call errors. Errors returned from this package may be tested against these errors with [errors.Is].

var ErrExist = fs.ErrExist

ErrInvalid var #

ErrInvalid indicates an invalid argument. Methods on File will return this error when the receiver is nil.

var ErrInvalid = fs.ErrInvalid

ErrNoDeadline var #

Portable analogs of some common system call errors. Errors returned from this package may be tested against these errors with [errors.Is].

var ErrNoDeadline = *ast.CallExpr

ErrNotExist var #

Portable analogs of some common system call errors. Errors returned from this package may be tested against these errors with [errors.Is].

var ErrNotExist = fs.ErrNotExist

ErrPermission var #

Portable analogs of some common system call errors. Errors returned from this package may be tested against these errors with [errors.Is].

var ErrPermission = fs.ErrPermission

ErrProcessDone var #

ErrProcessDone indicates a [Process] has finished.

var ErrProcessDone = *ast.CallExpr

Interrupt var #

The only signal values guaranteed to be present in the os package on all systems are os.Interrupt (send the process an interrupt) and os.Kill (force the process to exit). On Windows, sending os.Interrupt to a process with os.Process.Signal is not implemented; it will return an error instead of sending a signal.

var Interrupt Signal = syscall.SIGINT

Interrupt var #

The only signal values guaranteed to be present in the os package on all systems are Interrupt (send the process an interrupt) and Kill (force the process to exit). Interrupt is not implemented on Windows; using it with [os.Process.Signal] will return an error.

var Interrupt Signal = *ast.CallExpr

Kill var #

The only signal values guaranteed to be present in the os package on all systems are Interrupt (send the process an interrupt) and Kill (force the process to exit). Interrupt is not implemented on Windows; using it with [os.Process.Signal] will return an error.

var Kill Signal = *ast.CallExpr

Kill var #

The only signal values guaranteed to be present in the os package on all systems are os.Interrupt (send the process an interrupt) and os.Kill (force the process to exit). On Windows, sending os.Interrupt to a process with os.Process.Signal is not implemented; it will return an error instead of sending a signal.

var Kill Signal = syscall.SIGKILL

ModeAppend const #

The defined file mode bits are the most significant bits of the [FileMode]. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.

const ModeAppend = fs.ModeAppend

ModeCharDevice const #

The defined file mode bits are the most significant bits of the [FileMode]. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.

const ModeCharDevice = fs.ModeCharDevice

ModeDevice const #

The defined file mode bits are the most significant bits of the [FileMode]. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.

const ModeDevice = fs.ModeDevice

ModeDir const #

The single letters are the abbreviations used by the String method's formatting.

const ModeDir = fs.ModeDir

ModeExclusive const #

The defined file mode bits are the most significant bits of the [FileMode]. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.

const ModeExclusive = fs.ModeExclusive

ModeIrregular const #

The defined file mode bits are the most significant bits of the [FileMode]. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.

const ModeIrregular = fs.ModeIrregular

ModeNamedPipe const #

The defined file mode bits are the most significant bits of the [FileMode]. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.

const ModeNamedPipe = fs.ModeNamedPipe

ModePerm const #

The defined file mode bits are the most significant bits of the [FileMode]. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.

const ModePerm = fs.ModePerm

ModeSetgid const #

The defined file mode bits are the most significant bits of the [FileMode]. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.

const ModeSetgid = fs.ModeSetgid

ModeSetuid const #

The defined file mode bits are the most significant bits of the [FileMode]. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.

const ModeSetuid = fs.ModeSetuid

ModeSocket const #

The defined file mode bits are the most significant bits of the [FileMode]. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.

const ModeSocket = fs.ModeSocket

ModeSticky const #

The defined file mode bits are the most significant bits of the [FileMode]. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.

const ModeSticky = fs.ModeSticky

ModeTemporary const #

The defined file mode bits are the most significant bits of the [FileMode]. The nine least-significant bits are the standard Unix rwxrwxrwx permissions. The values of these bits should be considered part of the public API and may be used in wire protocols or disk representations: they must not be changed, although new bits might be added.

const ModeTemporary = fs.ModeTemporary

ModeType const #

Mask for the type bits. For regular files, none will be set.

const ModeType = fs.ModeType

O_APPEND const #

The remaining values may be or'ed in to control behavior.

const O_APPEND int = syscall.O_APPEND

O_CREATE const #

Flags to OpenFile wrapping those of the underlying system. Not all flags may be implemented on a given system.

const O_CREATE int = syscall.O_CREAT

O_EXCL const #

Flags to OpenFile wrapping those of the underlying system. Not all flags may be implemented on a given system.

const O_EXCL int = syscall.O_EXCL

O_RDONLY const #

Exactly one of O_RDONLY, O_WRONLY, or O_RDWR must be specified.

const O_RDONLY int = syscall.O_RDONLY

O_RDWR const #

Flags to OpenFile wrapping those of the underlying system. Not all flags may be implemented on a given system.

const O_RDWR int = syscall.O_RDWR

O_SYNC const #

Flags to OpenFile wrapping those of the underlying system. Not all flags may be implemented on a given system.

const O_SYNC int = syscall.O_SYNC

O_TRUNC const #

Flags to OpenFile wrapping those of the underlying system. Not all flags may be implemented on a given system.

const O_TRUNC int = syscall.O_TRUNC

O_WRONLY const #

Flags to OpenFile wrapping those of the underlying system. Not all flags may be implemented on a given system.

const O_WRONLY int = syscall.O_WRONLY

PathListSeparator const #

const PathListSeparator = ':'

PathListSeparator const #

const PathListSeparator = ';'

PathListSeparator const #

const PathListSeparator = '\000'

PathSeparator const #

const PathSeparator = '/'

PathSeparator const #

const PathSeparator = '/'

PathSeparator const #

const PathSeparator = '\\'

SEEK_CUR const #

Seek whence values. Deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.

const SEEK_CUR int = 1

SEEK_END const #

Seek whence values. Deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.

const SEEK_END int = 2

SEEK_SET const #

Seek whence values. Deprecated: Use io.SeekStart, io.SeekCurrent, and io.SeekEnd.

const SEEK_SET int = 0

Stderr var #

Stdin, Stdout, and Stderr are open Files pointing to the standard input, standard output, and standard error file descriptors. Note that the Go runtime writes to standard error for panics and crashes; closing Stderr may cause those messages to go elsewhere, perhaps to a file opened later.

var Stderr = *ast.CallExpr

Stdin var #

Stdin, Stdout, and Stderr are open Files pointing to the standard input, standard output, and standard error file descriptors. Note that the Go runtime writes to standard error for panics and crashes; closing Stderr may cause those messages to go elsewhere, perhaps to a file opened later.

var Stdin = *ast.CallExpr

Stdout var #

Stdin, Stdout, and Stderr are open Files pointing to the standard input, standard output, and standard error file descriptors. Note that the Go runtime writes to standard error for panics and crashes; closing Stderr may cause those messages to go elsewhere, perhaps to a file opened later.

var Stdout = *ast.CallExpr

_CTL_KERN const #

From DragonFly's

const _CTL_KERN = 1

_CTL_KERN const #

From FreeBSD's

const _CTL_KERN = 1

_CTL_KERN const #

From NetBSD's

const _CTL_KERN = 1

_KERN_PROC const #

From DragonFly's

const _KERN_PROC = 14

_KERN_PROC const #

From FreeBSD's

const _KERN_PROC = 14

_KERN_PROC_ARGS const #

From NetBSD's

const _KERN_PROC_ARGS = 48

_KERN_PROC_PATHNAME const #

From DragonFly's

const _KERN_PROC_PATHNAME = 9

_KERN_PROC_PATHNAME const #

From FreeBSD's

const _KERN_PROC_PATHNAME = 12

_KERN_PROC_PATHNAME const #

From NetBSD's

const _KERN_PROC_PATHNAME = 5

_P_PID const #

const _P_PID = 0

_P_PID const #

const _P_PID = 0

_P_PID const #

const _P_PID = 0

_P_PID const #

const _P_PID = 0

_P_PID const #

const _P_PID = 1

_S_IFDOOR const #

These constants aren't in the syscall package, which is frozen. Values taken from golang.org/x/sys/unix.

const _S_IFDOOR = 0xd000

_S_IFNAM const #

These constants aren't in the syscall package, which is frozen. Values taken from golang.org/x/sys/unix.

const _S_IFNAM = 0x5000

_S_IFPORT const #

These constants aren't in the syscall package, which is frozen. Values taken from golang.org/x/sys/unix.

const _S_IFPORT = 0xe000

_UTIME_OMIT const #

This matches the value in syscall/syscall_windows.go.

const _UTIME_OMIT = *ast.UnaryExpr

_UTIME_OMIT const #

const _UTIME_OMIT = unix.UTIME_OMIT

allowReadDirFileID var #

allowReadDirFileID indicates whether File.readdir should try to use FILE_ID_BOTH_DIR_INFO if the underlying file system supports it. Useful for testing purposes.

var allowReadDirFileID = true

bitSize16 const #

const bitSize16 = 2

blockSize const #

More than 5760 to work around https://golang.org/issue/24015.

const blockSize = 8192

checkPidfdOnce var #

var checkPidfdOnce = *ast.CallExpr

checkWrapErr var #

checkWrapErr is the test hook to enable checking unexpected wrapped errors of poll.ErrFileClosing. It is set to true in the export_test.go for tests (including fuzz tests).

var checkWrapErr = false

chmodMask const #

const chmodMask = *ast.CallExpr

dirBufPool var #

var dirBufPool = sync.Pool{...}

dirBufPool var #

var dirBufPool = sync.Pool{...}

dirBufSize const #

dirBufSize is the size of the dirInfo buffer. The buffer must be big enough to hold at least a single entry. The filename alone can be 512 bytes (MAX_PATH*2), and the fixed part of the FILE_ID_BOTH_DIR_INFO structure is 105 bytes, so dirBufSize should not be set below 1024 bytes (512+105+safety buffer). Windows 8.1 and earlier only works with buffer sizes up to 64 kB.

const dirBufSize = *ast.BinaryExpr

errENOMEM const #

const errENOMEM = syscall.ENOMEM

errENOMEM var #

var errENOMEM = *ast.CallExpr

errENOSYS var #

var errENOSYS = *ast.CallExpr

errENOSYS const #

const errENOSYS = syscall.ENOSYS

errERANGE const #

const errERANGE = syscall.ERANGE

errERANGE var #

var errERANGE = *ast.CallExpr

errPathEscapes var #

var errPathEscapes = *ast.CallExpr

errPatternHasSeparator var #

var errPatternHasSeparator = *ast.CallExpr

errWd var #

We query the working directory at init, to use it later to search for the executable file errWd will be checked later, if we need to use initWd

var errWd

errWriteAtInAppendMode var #

var errWriteAtInAppendMode = *ast.CallExpr

executableMIB var #

var executableMIB = [4]int32{...}

executableMIB var #

var executableMIB = [4]int32{...}

executableMIB var #

var executableMIB = [4]int32{...}

executablePath var #

go:linkname executablePath

var executablePath string

executablePath var #

go:linkname executablePath

var executablePath string

getwdCache var #

var getwdCache struct{...}

initCwd var #

var initCwd = *ast.CallExpr

initCwd var #

var initCwd = *ast.CallExpr

initCwdErr var #

var initCwdErr

initCwdErr var #

var initCwdErr

initWd var #

We query the working directory at init, to use it later to search for the executable file errWd will be checked later, if we need to use initWd

var initWd = *ast.CallExpr

kindNewFile const #

kindNewFile means that the descriptor was passed to us via NewFile.

const kindNewFile newFileKind = iota

kindNoPoll const #

kindNoPoll means that we should not put the descriptor into non-blocking mode, because we know it is not a pipe or FIFO. Used by openDirAt and openDirNolog for directories.

const kindNoPoll

kindOpenFile const #

kindOpenFile means that the descriptor was opened using Open, Create, or OpenFile.

const kindOpenFile

kindPipe const #

kindPipe means that the descriptor was opened using Pipe.

const kindPipe

kindSock const #

kindSock means that the descriptor is a network file descriptor that was created from net package and was opened using net_newUnixFile.

const kindSock

lstat var #

lstat is overridden in tests.

var lstat = Lstat

modeHandle const #

modeHandle means that Process operations use handle, which is initialized with an OS process handle. Note that Release and Wait will deactivate and eventually close the handle, so acquire may fail, indicating the reason.

const modeHandle

modePID const #

modePID means that Process operations such use the raw PID from the Pid field. handle is not used. This may be due to the host not supporting handles, or because Process was created as a literal, leaving handle unset. This must be the zero value so Process literals get modePID.

const modePID processMode = iota

pidReleased const #

const pidReleased = *ast.UnaryExpr

pidUnset const #

Special values for Process.Pid.

const pidUnset = 0

pollCopyFileRange var #

var pollCopyFileRange = poll.CopyFileRange

pollCopyFileRange var #

var pollCopyFileRange = poll.CopyFileRange

pollSplice var #

var pollSplice = poll.Splice

processStatusMask const #

const processStatusMask = *ast.BinaryExpr

readdirDirEntry const #

const readdirDirEntry

readdirFileInfo const #

const readdirFileInfo

readdirName const #

const readdirName readdirMode = iota

sizeOfDirent const #

https://github.com/WebAssembly/WASI/blob/main/legacy/preview1/docs.md#-dirent-record

const sizeOfDirent = 24

statusDone const #

statusDone indicates that the PID/handle should not be used because the process is done (has been successfully Wait'd on).

const statusDone processStatus = *ast.BinaryExpr

statusOK const #

PID/handle OK to use.

const statusOK processStatus = 0

statusReleased const #

statusReleased indicates that the PID/handle should not be used because the process is released.

const statusReleased processStatus = *ast.BinaryExpr

supportsCloseOnExec const #

supportsCloseOnExec reports whether the platform supports the O_CLOEXEC flag. On Darwin, the O_CLOEXEC flag was introduced in OS X 10.7 (Darwin 11.0.0). See https://support.apple.com/kb/HT1633. On FreeBSD, the O_CLOEXEC flag was introduced in version 8.3.

const supportsCloseOnExec = true

supportsCloseOnExec const #

supportsCloseOnExec reports whether the platform supports the O_CLOEXEC flag.

const supportsCloseOnExec = false

supportsCloseOnExec const #

supportsCloseOnExec reports whether the platform supports the O_CLOEXEC flag.

const supportsCloseOnExec = false

supportsCreateWithStickyBit const #

const supportsCreateWithStickyBit = true

supportsCreateWithStickyBit const #

According to sticky(8), neither open(2) nor mkdir(2) will create a file with the sticky bit set.

const supportsCreateWithStickyBit = false

testingForceReadDirLstat var #

testingForceReadDirLstat forces ReadDir to call Lstat, for testing that code path. This can be difficult to provoke on some Unix systems otherwise.

var testingForceReadDirLstat bool

useGetTempPath2 var #

var useGetTempPath2 = *ast.CallExpr

winreadlinkvolume var #

var winreadlinkvolume = *ast.CallExpr

Type Aliases

DirEntry type #

A DirEntry is an entry read from a directory (using the [ReadDir] function or a [File.ReadDir] method).

type DirEntry fs.DirEntry

FileInfo type #

A FileInfo describes a file and is returned by [Stat] and [Lstat].

type FileInfo fs.FileInfo

FileMode type #

A FileMode represents a file's mode and permission bits. The bits have the same definition on all systems, so that information about files can be moved from one system to another portably. Not all bits apply to all systems. The only required bit is [ModeDir] for directories.

type FileMode fs.FileMode

PathError type #

PathError records an error and the operation and file path that caused it.

type PathError fs.PathError

dirFS type #

type dirFS string

newFileKind type #

newFileKind describes the kind of file to newFile.

type newFileKind int

processMode type #

type processMode uint8

processStatus type #

type processStatus uint64

readdirMode type #

type readdirMode int

rootFS type #

type rootFS Root

syscallErrorType type #

type syscallErrorType syscall.ErrorString

syscallErrorType type #

type syscallErrorType syscall.Errno

sysfdType type #

type sysfdType int

sysfdType type #

type sysfdType syscall.Handle

Interfaces

Signal interface #

A Signal represents an operating system signal. The usual underlying implementation is operating system-dependent: on Unix it is syscall.Signal.

type Signal interface {
String() string
Signal()
}

timeout interface #

type timeout interface {
Timeout() bool
}

Structs

File struct #

File represents an open file descriptor. The methods of File are safe for concurrent use.

type File struct {
*file
}

LinkError struct #

LinkError records an error during a link or symlink or rename system call and the paths that caused it.

type LinkError struct {
Op string
Old string
New string
Err error
}

ProcAttr struct #

ProcAttr holds the attributes that will be applied to a new process started by StartProcess.

type ProcAttr struct {
Dir string
Env []string
Files []*File
Sys *syscall.SysProcAttr
}

Process struct #

Process stores the information about a process created by [StartProcess].

type Process struct {
Pid int
mode processMode
state atomic.Uint64
sigMu sync.RWMutex
handle uintptr
}

ProcessState struct #

ProcessState stores information about a process, as reported by Wait.

type ProcessState struct {
pid int
status syscall.WaitStatus
rusage *syscall.Rusage
}

ProcessState struct #

ProcessState stores information about a process, as reported by Wait.

type ProcessState struct {
pid int
status *syscall.Waitmsg
}

Root struct #

Root may be used to only access files within a single directory tree. Methods on Root can only access files and directories beneath a root directory. If any component of a file name passed to a method of Root references a location outside the root, the method returns an error. File names may reference the directory itself (.). Methods on Root will follow symbolic links, but symbolic links may not reference a location outside the root. Symbolic links must not be absolute. Methods on Root do not prohibit traversal of filesystem boundaries, Linux bind mounts, /proc special files, or access to Unix device files. Methods on Root are safe to be used from multiple goroutines simultaneously. On most platforms, creating a Root opens a file descriptor or handle referencing the directory. If the directory is moved, methods on Root reference the original directory in its new location. Root's behavior differs on some platforms: - When GOOS=windows, file names may not reference Windows reserved device names such as NUL and COM1. - When GOOS=js, Root is vulnerable to TOCTOU (time-of-check-time-of-use) attacks in symlink validation, and cannot ensure that operations will not escape the root. - When GOOS=plan9 or GOOS=js, Root does not track directories across renames. On these platforms, a Root references a directory name, not a file descriptor.

type Root struct {
root *root
}

SyscallError struct #

SyscallError records an error from a specific system call.

type SyscallError struct {
Syscall string
Err error
}

dirEntry struct #

type dirEntry struct {
fs *fileStat
}

dirEntry struct #

type dirEntry struct {
fs *fileStat
}

dirInfo struct #

Auxiliary information if the File describes a directory

type dirInfo struct {
dir uintptr
}

dirInfo struct #

Auxiliary information if the File describes a directory

type dirInfo struct {
mu sync.Mutex
buf [syscall.STATMAX]byte
nbuf int
bufp int
}

dirInfo struct #

Auxiliary information if the File describes a directory

type dirInfo struct {
mu sync.Mutex
buf *[]byte
bufp int
h syscall.Handle
vol uint32
class uint32
path string
}

dirInfo struct #

Auxiliary information if the File describes a directory

type dirInfo struct {
mu sync.Mutex
buf *[]byte
nbuf int
bufp int
}

file struct #

file is the real representation of *File. The extra level of indirection ensures that no clients of os can overwrite this data, which could cause the finalizer to close the wrong file descriptor.

type file struct {
fdmu poll.FDMutex
fd int
name string
dirinfo *ast.IndexExpr
appendMode bool
}

file struct #

file is the real representation of *File. The extra level of indirection ensures that no clients of os can overwrite this data, which could cause the finalizer to close the wrong file descriptor.

type file struct {
pfd poll.FD
name string
dirinfo *ast.IndexExpr
nonblock bool
stdoutOrErr bool
appendMode bool
}

file struct #

file is the real representation of *File. The extra level of indirection ensures that no clients of os can overwrite this data, which could cause the finalizer to close the wrong file descriptor.

type file struct {
pfd poll.FD
name string
dirinfo *ast.IndexExpr
appendMode bool
}

fileStat struct #

A fileStat is the implementation of FileInfo returned by Stat and Lstat.

type fileStat struct {
name string
size int64
mode FileMode
modTime time.Time
sys any
}

fileStat struct #

A fileStat is the implementation of FileInfo returned by Stat and Lstat.

type fileStat struct {
name string
FileAttributes uint32
CreationTime syscall.Filetime
LastAccessTime syscall.Filetime
LastWriteTime syscall.Filetime
FileSizeHigh uint32
FileSizeLow uint32
ReparseTag uint32
filetype uint32
sync.Mutex
path string
vol uint32
idxhi uint32
idxlo uint32
appendNameToPath bool
}

fileStat struct #

A fileStat is the implementation of FileInfo returned by Stat and Lstat.

type fileStat struct {
name string
size int64
mode FileMode
modTime time.Time
sys syscall.Stat_t
}

fileWithoutReadFrom struct #

fileWithoutReadFrom implements all the methods of *File other than ReadFrom. This is used to permit ReadFrom to call io.Copy without leading to a recursive call to ReadFrom.

type fileWithoutReadFrom struct {
noReadFrom
*File
}

fileWithoutWriteTo struct #

fileWithoutWriteTo implements all the methods of *File other than WriteTo. This is used to permit WriteTo to call io.Copy without leading to a recursive call to WriteTo.

type fileWithoutWriteTo struct {
noWriteTo
*File
}

noReadFrom struct #

noReadFrom can be embedded alongside another type to hide the ReadFrom method of that other type.

type noReadFrom struct {

}

noWriteTo struct #

noWriteTo can be embedded alongside another type to hide the WriteTo method of that other type.

type noWriteTo struct {

}

rawConn struct #

rawConn implements syscall.RawConn.

type rawConn struct {
file *File
}

rawConn struct #

type rawConn struct {

}

root struct #

root implementation for platforms with a function to open a file relative to a directory.

type root struct {
name string
mu sync.Mutex
fd sysfdType
refs int
closed bool
}

root struct #

root implementation for platforms with no openat. Currently plan9 and js.

type root struct {
name string
closed atomic.Bool
}

unixDirent struct #

type unixDirent struct {
parent string
name string
typ FileMode
info FileInfo
}

Functions

Chdir method #

Chdir changes the current working directory to the file, which must be a directory. If there is an error, it will be of type *PathError.

func (f *File) Chdir() error

Chdir function #

Chdir changes the current working directory to the named directory. If there is an error, it will be of type *PathError.

func Chdir(dir string) error

Chdir method #

Chdir changes the current working directory to the file, which must be a directory. If there is an error, it will be of type [*PathError].

func (f *File) Chdir() error

Chmod method #

Chmod changes the mode of the file to mode. If there is an error, it will be of type *PathError.

func (f *File) Chmod(mode FileMode) error

Chmod function #

Chmod changes the mode of the named file to mode. If the file is a symbolic link, it changes the mode of the link's target. If there is an error, it will be of type *PathError. A different subset of the mode bits are used, depending on the operating system. On Unix, the mode's permission bits, ModeSetuid, ModeSetgid, and ModeSticky are used. On Windows, only the 0o200 bit (owner writable) of mode is used; it controls whether the file's read-only attribute is set or cleared. The other bits are currently unused. For compatibility with Go 1.12 and earlier, use a non-zero mode. Use mode 0o400 for a read-only file and 0o600 for a readable+writable file. On Plan 9, the mode's permission bits, ModeAppend, ModeExclusive, and ModeTemporary are used.

func Chmod(name string, mode FileMode) error

Chown method #

Chown changes the numeric uid and gid of the named file. If there is an error, it will be of type *PathError.

func (f *File) Chown(uid int, gid int) error

Chown function #

Chown changes the numeric uid and gid of the named file. If the file is a symbolic link, it changes the uid and gid of the link's target. A uid or gid of -1 means to not change that value. If there is an error, it will be of type [*PathError]. On Windows or Plan 9, Chown always returns the [syscall.EWINDOWS] or EPLAN9 error, wrapped in *PathError.

func Chown(name string, uid int, gid int) error

Chown method #

Chown changes the numeric uid and gid of the named file. If there is an error, it will be of type [*PathError]. On Windows, it always returns the [syscall.EWINDOWS] error, wrapped in *PathError.

func (f *File) Chown(uid int, gid int) error

Chown function #

Chown changes the numeric uid and gid of the named file. If the file is a symbolic link, it changes the uid and gid of the link's target. A uid or gid of -1 means to not change that value. If there is an error, it will be of type *PathError. On Windows or Plan 9, Chown always returns the syscall.EWINDOWS or EPLAN9 error, wrapped in *PathError.

func Chown(name string, uid int, gid int) error

Chtimes function #

Chtimes changes the access and modification times of the named file, similar to the Unix utime() or utimes() functions. A zero [time.Time] value will leave the corresponding file time unchanged. The underlying filesystem may truncate or round the values to a less precise time unit. If there is an error, it will be of type [*PathError].

func Chtimes(name string, atime time.Time, mtime time.Time) error

Chtimes function #

Chtimes changes the access and modification times of the named file, similar to the Unix utime() or utimes() functions. A zero time.Time value will leave the corresponding file time unchanged. The underlying filesystem may truncate or round the values to a less precise time unit. If there is an error, it will be of type *PathError.

func Chtimes(name string, atime time.Time, mtime time.Time) error

Clearenv function #

Clearenv deletes all environment variables.

func Clearenv()

Close method #

Close closes the File, rendering it unusable for I/O. On files that support SetDeadline, any pending I/O operations will be canceled and return immediately with an ErrClosed error. Close will return an error if it has already been called.

func (f *File) Close() error

Close method #

Close closes the [File], rendering it unusable for I/O. On files that support [File.SetDeadline], any pending I/O operations will be canceled and return immediately with an [ErrClosed] error. Close will return an error if it has already been called.

func (f *File) Close() error

Close method #

func (r *root) Close() error

Close method #

func (r *root) Close() error

Close method #

Close closes the Root. After Close is called, methods on Root return errors.

func (r *Root) Close() error

Control method #

func (c *rawConn) Control(f func(uintptr)) error

Control method #

func (c *rawConn) Control(f func(uintptr)) error

CopyFS function #

CopyFS copies the file system fsys into the directory dir, creating dir if necessary. Files are created with mode 0o666 plus any execute permissions from the source, and directories are created with mode 0o777 (before umask). CopyFS will not overwrite existing files. If a file name in fsys already exists in the destination, CopyFS will return an error such that errors.Is(err, fs.ErrExist) will be true. Symbolic links in fsys are not supported. A *PathError with Err set to ErrInvalid is returned when copying from a symbolic link. Symbolic links in dir are followed. New files added to fsys (including if dir is a subdirectory of fsys) while CopyFS is running are not guaranteed to be copied. Copying stops at and returns the first error encountered.

func CopyFS(dir string, fsys fs.FS) error

Create function #

Create creates or truncates the named file. If the file already exists, it is truncated. If the file does not exist, it is created with mode 0o666 (before umask). If successful, methods on the returned File can be used for I/O; the associated file descriptor has mode O_RDWR. The directory containing the file must already exist. If there is an error, it will be of type *PathError.

func Create(name string) (*File, error)

Create method #

Create creates or truncates the named file in the root. See [Create] for more details.

func (r *Root) Create(name string) (*File, error)

CreateTemp function #

CreateTemp creates a new temporary file in the directory dir, opens the file for reading and writing, and returns the resulting file. The filename is generated by taking pattern and adding a random string to the end. If pattern includes a "*", the random string replaces the last "*". The file is created with mode 0o600 (before umask). If dir is the empty string, CreateTemp uses the default directory for temporary files, as returned by [TempDir]. Multiple programs or goroutines calling CreateTemp simultaneously will not choose the same file. The caller can use the file's Name method to find the pathname of the file. It is the caller's responsibility to remove the file when it is no longer needed.

func CreateTemp(dir string, pattern string) (*File, error)

DirFS function #

DirFS returns a file system (an fs.FS) for the tree of files rooted at the directory dir. Note that DirFS("/prefix") only guarantees that the Open calls it makes to the operating system will begin with "/prefix": DirFS("/prefix").Open("file") is the same as os.Open("/prefix/file"). So if /prefix/file is a symbolic link pointing outside the /prefix tree, then using DirFS does not stop the access any more than using os.Open does. Additionally, the root of the fs.FS returned for a relative path, DirFS("prefix"), will be affected by later calls to Chdir. DirFS is therefore not a general substitute for a chroot-style security mechanism when the directory tree contains arbitrary content. Use [Root.FS] to obtain a fs.FS that prevents escapes from the tree via symbolic links. The directory dir must not be "". The result implements [io/fs.StatFS], [io/fs.ReadFileFS] and [io/fs.ReadDirFS].

func DirFS(dir string) fs.FS

Environ function #

Environ returns a copy of strings representing the environment, in the form "key=value".

func Environ() []string

Error method #

func (e *SyscallError) Error() string

Error method #

func (errSymlink) Error() string

Error method #

func (e *LinkError) Error() string

Executable function #

Executable returns the path name for the executable that started the current process. There is no guarantee that the path is still pointing to the correct executable. If a symlink was used to start the process, depending on the operating system, the result might be the symlink or the path it pointed to. If a stable result is needed, [path/filepath.EvalSymlinks] might help. Executable returns an absolute path unless an error occurred. The main use case is finding resources located relative to an executable.

func Executable() (string, error)

Exit function #

Exit causes the current program to exit with the given status code. Conventionally, code zero indicates success, non-zero an error. The program terminates immediately; deferred functions are not run. For portability, the status code should be in the range [0, 125].

func Exit(code int)

ExitCode method #

ExitCode returns the exit code of the exited process, or -1 if the process hasn't exited or was terminated by a signal.

func (p *ProcessState) ExitCode() int

ExitCode method #

ExitCode returns the exit code of the exited process, or -1 if the process hasn't exited or was terminated by a signal.

func (p *ProcessState) ExitCode() int

Exited method #

Exited reports whether the program has exited. On Unix systems this reports true if the program exited due to calling exit, but false if the program terminated due to a signal.

func (p *ProcessState) Exited() bool

Expand function #

Expand replaces ${var} or $var in the string based on the mapping function. For example, [os.ExpandEnv](s) is equivalent to [os.Expand](s, [os.Getenv]).

func Expand(s string, mapping func(string) string) string

ExpandEnv function #

ExpandEnv replaces ${var} or $var in the string according to the values of the current environment variables. References to undefined variables are replaced by the empty string.

func ExpandEnv(s string) string

FS method #

FS returns a file system (an fs.FS) for the tree of files in the root. The result implements [io/fs.StatFS], [io/fs.ReadFileFS] and [io/fs.ReadDirFS].

func (r *Root) FS() fs.FS

Fd method #

Fd returns the Windows handle referencing the open file. If f is closed, the file descriptor becomes invalid. If f is garbage collected, a finalizer may close the file descriptor, making it invalid; see [runtime.SetFinalizer] for more information on when a finalizer might be run. On Unix systems this will cause the [File.SetDeadline] methods to stop working.

func (file *File) Fd() uintptr

Fd method #

Fd returns the integer Unix file descriptor referencing the open file. If f is closed, the file descriptor becomes invalid. If f is garbage collected, a finalizer may close the file descriptor, making it invalid; see [runtime.SetFinalizer] for more information on when a finalizer might be run. On Unix systems this will cause the [File.SetDeadline] methods to stop working. Because file descriptors can be reused, the returned file descriptor may only be closed through the [File.Close] method of f, or by its finalizer during garbage collection. Otherwise, during garbage collection the finalizer may close an unrelated file descriptor with the same (reused) number. As an alternative, see the f.SyscallConn method.

func (f *File) Fd() uintptr

Fd method #

Fd returns the integer Plan 9 file descriptor referencing the open file. If f is closed, the file descriptor becomes invalid. If f is garbage collected, a finalizer may close the file descriptor, making it invalid; see [runtime.SetFinalizer] for more information on when a finalizer might be run. On Unix systems this will cause the [File.SetDeadline] methods to stop working. As an alternative, see the f.SyscallConn method.

func (f *File) Fd() uintptr

FindProcess function #

FindProcess looks for a running process by its pid. The [Process] it returns can be used to obtain information about the underlying operating system process. On Unix systems, FindProcess always succeeds and returns a Process for the given pid, regardless of whether the process exists. To test whether the process actually exists, see whether p.Signal(syscall.Signal(0)) reports an error.

func FindProcess(pid int) (*Process, error)

Getegid function #

Getegid returns the numeric effective group id of the caller. On Windows, it returns -1.

func Getegid() int

Getenv function #

Getenv retrieves the value of the environment variable named by the key. It returns the value, which will be empty if the variable is not present. To distinguish between an empty value and an unset value, use [LookupEnv].

func Getenv(key string) string

Geteuid function #

Geteuid returns the numeric effective user id of the caller. On Windows, it returns -1.

func Geteuid() int

Getgid function #

Getgid returns the numeric group id of the caller. On Windows, it returns -1.

func Getgid() int

Getgroups function #

Getgroups returns a list of the numeric ids of groups that the caller belongs to. On Windows, it returns [syscall.EWINDOWS]. See the [os/user] package for a possible alternative.

func Getgroups() ([]int, error)

Getpagesize function #

Getpagesize returns the underlying system's memory page size.

func Getpagesize() int

Getpid function #

Getpid returns the process id of the caller.

func Getpid() int

Getppid function #

Getppid returns the process id of the caller's parent.

func Getppid() int

Getuid function #

Getuid returns the numeric user id of the caller. On Windows, it returns -1.

func Getuid() int

Getwd function #

Getwd returns an absolute path name corresponding to the current directory. If the current directory can be reached via multiple paths (due to symbolic links), Getwd may return any one of them. On Unix platforms, if the environment variable PWD provides an absolute name, and it is a name of the current directory, it is returned.

func Getwd() (dir string, err error)

Hostname function #

Hostname returns the host name reported by the kernel.

func Hostname() (name string, err error)

Info method #

func (de dirEntry) Info() (FileInfo, error)

Info method #

func (d *unixDirent) Info() (FileInfo, error)

Info method #

func (de dirEntry) Info() (FileInfo, error)

IsDir method #

func (d *unixDirent) IsDir() bool

IsDir method #

func (fs *fileStat) IsDir() bool

IsDir method #

func (de dirEntry) IsDir() bool

IsDir method #

func (de dirEntry) IsDir() bool

IsExist function #

IsExist returns a boolean indicating whether its argument is known to report that a file or directory already exists. It is satisfied by [ErrExist] as well as some syscall errors. This function predates [errors.Is]. It only supports errors returned by the os package. New code should use errors.Is(err, fs.ErrExist).

func IsExist(err error) bool

IsNotExist function #

IsNotExist returns a boolean indicating whether its argument is known to report that a file or directory does not exist. It is satisfied by [ErrNotExist] as well as some syscall errors. This function predates [errors.Is]. It only supports errors returned by the os package. New code should use errors.Is(err, fs.ErrNotExist).

func IsNotExist(err error) bool

IsPathSeparator function #

IsPathSeparator reports whether c is a directory separator character.

func IsPathSeparator(c uint8) bool

IsPathSeparator function #

IsPathSeparator reports whether c is a directory separator character.

func IsPathSeparator(c uint8) bool

IsPathSeparator function #

IsPathSeparator reports whether c is a directory separator character.

func IsPathSeparator(c uint8) bool

IsPermission function #

IsPermission returns a boolean indicating whether its argument is known to report that permission is denied. It is satisfied by [ErrPermission] as well as some syscall errors. This function predates [errors.Is]. It only supports errors returned by the os package. New code should use errors.Is(err, fs.ErrPermission).

func IsPermission(err error) bool

IsTimeout function #

IsTimeout returns a boolean indicating whether its argument is known to report that a timeout occurred. This function predates [errors.Is], and the notion of whether an error indicates a timeout can be ambiguous. For example, the Unix error EWOULDBLOCK sometimes indicates a timeout and sometimes does not. New code should use errors.Is with a value appropriate to the call returning the error, such as [os.ErrDeadlineExceeded].

func IsTimeout(err error) bool

Kill method #

Kill causes the [Process] to exit immediately. Kill does not wait until the Process has actually exited. This only kills the Process itself, not any other processes it may have started.

func (p *Process) Kill() error

Lchown function #

Lchown changes the numeric uid and gid of the named file. If the file is a symbolic link, it changes the uid and gid of the link itself. If there is an error, it will be of type *PathError.

func Lchown(name string, uid int, gid int) error

Lchown function #

Lchown changes the numeric uid and gid of the named file. If the file is a symbolic link, it changes the uid and gid of the link itself. If there is an error, it will be of type [*PathError]. On Windows, it always returns the [syscall.EWINDOWS] error, wrapped in *PathError.

func Lchown(name string, uid int, gid int) error

LookupEnv function #

LookupEnv retrieves the value of the environment variable named by the key. If the variable is present in the environment the value (which may be empty) is returned and the boolean is true. Otherwise the returned value will be empty and the boolean will be false.

func LookupEnv(key string) (string, bool)

Lstat method #

Lstat returns a [FileInfo] describing the named file in the root. If the file is a symbolic link, the returned FileInfo describes the symbolic link. See [Lstat] for more details.

func (r *Root) Lstat(name string) (FileInfo, error)

Lstat function #

Lstat returns a [FileInfo] describing the named file. If the file is a symbolic link, the returned FileInfo describes the symbolic link. Lstat makes no attempt to follow the link. If there is an error, it will be of type [*PathError]. On Windows, if the file is a reparse point that is a surrogate for another named entity (such as a symbolic link or mounted folder), the returned FileInfo describes the reparse point, and makes no attempt to resolve it.

func Lstat(name string) (FileInfo, error)

Mkdir function #

Mkdir creates a new directory with the specified name and permission bits (before umask). If there is an error, it will be of type *PathError.

func Mkdir(name string, perm FileMode) error

Mkdir method #

Mkdir creates a new directory in the root with the specified name and permission bits (before umask). See [Mkdir] for more details. If perm contains bits other than the nine least-significant bits (0o777), OpenFile returns an error.

func (r *Root) Mkdir(name string, perm FileMode) error

MkdirAll function #

MkdirAll creates a directory named path, along with any necessary parents, and returns nil, or else returns an error. The permission bits perm (before umask) are used for all directories that MkdirAll creates. If path is already a directory, MkdirAll does nothing and returns nil.

func MkdirAll(path string, perm FileMode) error

MkdirTemp function #

MkdirTemp creates a new temporary directory in the directory dir and returns the pathname of the new directory. The new directory's name is generated by adding a random string to the end of pattern. If pattern includes a "*", the random string replaces the last "*" instead. The directory is created with mode 0o700 (before umask). If dir is the empty string, MkdirTemp uses the default directory for temporary files, as returned by TempDir. Multiple programs or goroutines calling MkdirTemp simultaneously will not choose the same directory. It is the caller's responsibility to remove the directory when it is no longer needed.

func MkdirTemp(dir string, pattern string) (string, error)

ModTime method #

func (fs *fileStat) ModTime() time.Time

ModTime method #

func (fs *fileStat) ModTime() time.Time

ModTime method #

func (fs *fileStat) ModTime() time.Time

Mode method #

func (fs *fileStat) Mode() FileMode

Mode method #

func (fs *fileStat) Mode() FileMode

Mode method #

func (fs *fileStat) Mode() FileMode

Name method #

func (de dirEntry) Name() string

Name method #

func (r *root) Name() string

Name method #

func (de dirEntry) Name() string

Name method #

Name returns the name of the file as presented to Open. It is safe to call Name after [Close].

func (f *File) Name() string

Name method #

func (d *unixDirent) Name() string

Name method #

Name returns the name of the directory presented to OpenRoot. It is safe to call Name after [Close].

func (r *Root) Name() string

Name method #

func (r *root) Name() string

Name method #

func (fs *fileStat) Name() string

NewFile function #

NewFile returns a new File with the given file descriptor and name. The returned value will be nil if fd is not a valid file descriptor.

func NewFile(fd uintptr, name string) *File

NewFile function #

NewFile returns a new File with the given file descriptor and name. The returned value will be nil if fd is not a valid file descriptor. On Unix systems, if the file descriptor is in non-blocking mode, NewFile will attempt to return a pollable File (one for which the SetDeadline methods work). After passing it to NewFile, fd may become invalid under the same conditions described in the comments of the Fd method, and the same constraints apply.

func NewFile(fd uintptr, name string) *File

NewFile function #

NewFile returns a new File with the given file descriptor and name. The returned value will be nil if fd is not a valid file descriptor.

func NewFile(fd uintptr, name string) *File

NewSyscallError function #

NewSyscallError returns, as an error, a new [SyscallError] with the given system call name and error details. As a convenience, if err is nil, NewSyscallError returns nil.

func NewSyscallError(syscall string, err error) error

Open function #

Open opens the named file for reading. If successful, methods on the returned file can be used for reading; the associated file descriptor has mode O_RDONLY. If there is an error, it will be of type *PathError.

func Open(name string) (*File, error)

Open method #

Open opens the named file in the root for reading. See [Open] for more details.

func (r *Root) Open(name string) (*File, error)

Open method #

func (rfs *rootFS) Open(name string) (fs.File, error)

Open method #

func (dir dirFS) Open(name string) (fs.File, error)

OpenFile method #

OpenFile opens the named file in the root. See [OpenFile] for more details. If perm contains bits other than the nine least-significant bits (0o777), OpenFile returns an error.

func (r *Root) OpenFile(name string, flag int, perm FileMode) (*File, error)

OpenFile function #

OpenFile is the generalized open call; most users will use Open or Create instead. It opens the named file with specified flag (O_RDONLY etc.). If the file does not exist, and the O_CREATE flag is passed, it is created with mode perm (before umask); the containing directory must exist. If successful, methods on the returned File can be used for I/O. If there is an error, it will be of type *PathError.

func OpenFile(name string, flag int, perm FileMode) (*File, error)

OpenInRoot function #

OpenInRoot opens the file name in the directory dir. It is equivalent to OpenRoot(dir) followed by opening the file in the root. OpenInRoot returns an error if any component of the name references a location outside of dir. See [Root] for details and limitations.

func OpenInRoot(dir string, name string) (*File, error)

OpenRoot function #

OpenRoot opens the named directory. If there is an error, it will be of type *PathError.

func OpenRoot(name string) (*Root, error)

OpenRoot method #

OpenRoot opens the named directory in the root. If there is an error, it will be of type *PathError.

func (r *Root) OpenRoot(name string) (*Root, error)

Pid method #

Pid returns the process id of the exited process.

func (p *ProcessState) Pid() int

Pid method #

Pid returns the process id of the exited process.

func (p *ProcessState) Pid() int

Pipe function #

Pipe returns a connected pair of Files; reads from r return bytes written to w. It returns the files and an error, if any. The Windows handles underlying the returned files are marked as inheritable by child processes.

func Pipe() (r *File, w *File, err error)

Pipe function #

Pipe returns a connected pair of Files; reads from r return bytes written to w. It returns the files and an error, if any.

func Pipe() (r *File, w *File, err error)

Pipe function #

Pipe returns a connected pair of Files; reads from r return bytes written to w. It returns the files and an error, if any.

func Pipe() (r *File, w *File, err error)

Pipe function #

Pipe returns a connected pair of Files; reads from r return bytes written to w. It returns the files and an error, if any.

func Pipe() (r *File, w *File, err error)

Pipe function #

Pipe returns a connected pair of Files; reads from r return bytes written to w. It returns the files and an error, if any.

func Pipe() (r *File, w *File, err error)

PollFD method #

PollFD returns the poll.FD of the file. Other packages in std that also import internal/poll (such as net) can use a type assertion to access this extension method so that they can pass the *poll.FD to functions like poll.Splice. There is an equivalent function in net.rawConn. PollFD is not intended for use outside the standard library.

func (f *file) PollFD() *poll.FD

Read method #

func (c *rawConn) Read(f func(uintptr) bool) error

Read method #

func (c *rawConn) Read(f func(uintptr) bool) error

Read method #

Read reads up to len(b) bytes from the File and stores them in b. It returns the number of bytes read and any error encountered. At end of file, Read returns 0, io.EOF.

func (f *File) Read(b []byte) (n int, err error)

ReadAt method #

ReadAt reads len(b) bytes from the File starting at byte offset off. It returns the number of bytes read and the error, if any. ReadAt always returns a non-nil error when n < len(b). At end of file, that error is io.EOF.

func (f *File) ReadAt(b []byte, off int64) (n int, err error)

ReadDir function #

ReadDir reads the named directory, returning all its directory entries sorted by filename. If an error occurs reading the directory, ReadDir returns the entries it was able to read before the error, along with the error.

func ReadDir(name string) ([]DirEntry, error)

ReadDir method #

ReadDir reads the contents of the directory associated with the file f and returns a slice of [DirEntry] values in directory order. Subsequent calls on the same file will yield later DirEntry records in the directory. If n > 0, ReadDir returns at most n DirEntry records. In this case, if ReadDir returns an empty slice, it will return an error explaining why. At the end of a directory, the error is [io.EOF]. If n <= 0, ReadDir returns all the DirEntry records remaining in the directory. When it succeeds, it returns a nil error (not io.EOF).

func (f *File) ReadDir(n int) ([]DirEntry, error)

ReadDir method #

ReadDir reads the named directory, returning all its directory entries sorted by filename. Through this method, dirFS implements [io/fs.ReadDirFS].

func (dir dirFS) ReadDir(name string) ([]DirEntry, error)

ReadDir method #

func (rfs *rootFS) ReadDir(name string) ([]DirEntry, error)

ReadFile method #

func (rfs *rootFS) ReadFile(name string) ([]byte, error)

ReadFile method #

The ReadFile method calls the [ReadFile] function for the file with the given name in the directory. The function provides robust handling for small files and special file systems. Through this method, dirFS implements [io/fs.ReadFileFS].

func (dir dirFS) ReadFile(name string) ([]byte, error)

ReadFile function #

ReadFile reads the named file and returns the contents. A successful call returns err == nil, not err == EOF. Because ReadFile reads the whole file, it does not treat an EOF from Read as an error to be reported.

func ReadFile(name string) ([]byte, error)

ReadFrom method #

ReadFrom implements io.ReaderFrom.

func (f *File) ReadFrom(r io.Reader) (n int64, err error)

ReadFrom method #

ReadFrom hides another ReadFrom method. It should never be called.

func (noReadFrom) ReadFrom(io.Reader) (int64, error)

Readdir method #

Readdir reads the contents of the directory associated with file and returns a slice of up to n [FileInfo] values, as would be returned by [Lstat], in directory order. Subsequent calls on the same file will yield further FileInfos. If n > 0, Readdir returns at most n FileInfo structures. In this case, if Readdir returns an empty slice, it will return a non-nil error explaining why. At the end of a directory, the error is [io.EOF]. If n <= 0, Readdir returns all the FileInfo from the directory in a single slice. In this case, if Readdir succeeds (reads all the way to the end of the directory), it returns the slice and a nil error. If it encounters an error before the end of the directory, Readdir returns the FileInfo read until that point and a non-nil error. Most clients are better served by the more efficient ReadDir method.

func (f *File) Readdir(n int) ([]FileInfo, error)

Readdirnames method #

Readdirnames reads the contents of the directory associated with file and returns a slice of up to n names of files in the directory, in directory order. Subsequent calls on the same file will yield further names. If n > 0, Readdirnames returns at most n names. In this case, if Readdirnames returns an empty slice, it will return a non-nil error explaining why. At the end of a directory, the error is [io.EOF]. If n <= 0, Readdirnames returns all the names from the directory in a single slice. In this case, if Readdirnames succeeds (reads all the way to the end of the directory), it returns the slice and a nil error. If it encounters an error before the end of the directory, Readdirnames returns the names read until that point and a non-nil error.

func (f *File) Readdirnames(n int) (names []string, err error)

Release method #

Release releases any resources associated with the [Process] p, rendering it unusable in the future. Release only needs to be called if [Process.Wait] is not.

func (p *Process) Release() error

Remove function #

Remove removes the named file or directory. If there is an error, it will be of type *PathError.

func Remove(name string) error

Remove function #

Remove removes the named file or (empty) directory. If there is an error, it will be of type *PathError.

func Remove(name string) error

Remove method #

Remove removes the named file or (empty) directory in the root. See [Remove] for more details.

func (r *Root) Remove(name string) error

Remove function #

Remove removes the named file or directory. If there is an error, it will be of type *PathError.

func Remove(name string) error

RemoveAll function #

RemoveAll removes path and any children it contains. It removes everything it can but returns the first error it encounters. If the path does not exist, RemoveAll returns nil (no error). If there is an error, it will be of type [*PathError].

func RemoveAll(path string) error

Rename function #

Rename renames (moves) oldpath to newpath. If newpath already exists and is not a directory, Rename replaces it. If newpath already exists and is a directory, Rename returns an error. OS-specific restrictions may apply when oldpath and newpath are in different directories. Even within the same directory, on non-Unix platforms Rename is not an atomic operation. If there is an error, it will be of type *LinkError.

func Rename(oldpath string, newpath string) error

SameFile function #

SameFile reports whether fi1 and fi2 describe the same file. For example, on Unix this means that the device and inode fields of the two underlying structures are identical; on other systems the decision may be based on the path names. SameFile only applies to results returned by this package's [Stat]. It returns false in other cases.

func SameFile(fi1 FileInfo, fi2 FileInfo) bool

Seek method #

Seek sets the offset for the next Read or Write on file to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. It returns the new offset and an error, if any. The behavior of Seek on a file opened with O_APPEND is not specified.

func (f *File) Seek(offset int64, whence int) (ret int64, err error)

SetDeadline method #

SetDeadline sets the read and write deadlines for a File. It is equivalent to calling both SetReadDeadline and SetWriteDeadline. Only some kinds of files support setting a deadline. Calls to SetDeadline for files that do not support deadlines will return ErrNoDeadline. On most systems ordinary files do not support deadlines, but pipes do. A deadline is an absolute time after which I/O operations fail with an error instead of blocking. The deadline applies to all future and pending I/O, not just the immediately following call to Read or Write. After a deadline has been exceeded, the connection can be refreshed by setting a deadline in the future. If the deadline is exceeded a call to Read or Write or to other I/O methods will return an error that wraps ErrDeadlineExceeded. This can be tested using errors.Is(err, os.ErrDeadlineExceeded). That error implements the Timeout method, and calling the Timeout method will return true, but there are other possible errors for which the Timeout will return true even if the deadline has not been exceeded. An idle timeout can be implemented by repeatedly extending the deadline after successful Read or Write calls. A zero value for t means I/O operations will not time out.

func (f *File) SetDeadline(t time.Time) error

SetReadDeadline method #

SetReadDeadline sets the deadline for future Read calls and any currently-blocked Read call. A zero value for t means Read will not time out. Not all files support setting deadlines; see SetDeadline.

func (f *File) SetReadDeadline(t time.Time) error

SetWriteDeadline method #

SetWriteDeadline sets the deadline for any future Write calls and any currently-blocked Write call. Even if Write times out, it may return n > 0, indicating that some of the data was successfully written. A zero value for t means Write will not time out. Not all files support setting deadlines; see SetDeadline.

func (f *File) SetWriteDeadline(t time.Time) error

Setenv function #

Setenv sets the value of the environment variable named by the key. It returns an error, if any.

func Setenv(key string, value string) error

Signal method #

Signal sends a signal to the [Process]. Sending [Interrupt] on Windows is not implemented.

func (p *Process) Signal(sig Signal) error

Size method #

func (fs *fileStat) Size() int64

Size method #

func (fs *fileStat) Size() int64

Size method #

func (fs *fileStat) Size() int64

StartProcess function #

StartProcess starts a new process with the program, arguments and attributes specified by name, argv and attr. The argv slice will become [os.Args] in the new process, so it normally starts with the program name. If the calling goroutine has locked the operating system thread with [runtime.LockOSThread] and modified any inheritable OS-level thread state (for example, Linux or Plan 9 name spaces), the new process will inherit the caller's thread state. StartProcess is a low-level interface. The [os/exec] package provides higher-level interfaces. If there is an error, it will be of type [*PathError].

func StartProcess(name string, argv []string, attr *ProcAttr) (*Process, error)

Stat method #

Stat returns a [FileInfo] describing the named file in the root. See [Stat] for more details.

func (r *Root) Stat(name string) (FileInfo, error)

Stat method #

Stat returns the [FileInfo] structure describing file. If there is an error, it will be of type [*PathError].

func (f *File) Stat() (FileInfo, error)

Stat function #

Stat returns a [FileInfo] describing the named file. If there is an error, it will be of type [*PathError].

func Stat(name string) (FileInfo, error)

Stat method #

func (dir dirFS) Stat(name string) (fs.FileInfo, error)

Stat method #

Stat returns the FileInfo structure describing file. If there is an error, it will be of type *PathError.

func (f *File) Stat() (FileInfo, error)

Stat method #

Stat returns the [FileInfo] structure describing file. If there is an error, it will be of type [*PathError].

func (file *File) Stat() (FileInfo, error)

Stat method #

func (rfs *rootFS) Stat(name string) (FileInfo, error)

String method #

func (de dirEntry) String() string

String method #

func (p *ProcessState) String() string

String method #

func (d *unixDirent) String() string

String method #

func (de dirEntry) String() string

String method #

func (p *ProcessState) String() string

Success method #

Success reports whether the program exited successfully, such as with exit status 0 on Unix.

func (p *ProcessState) Success() bool

Sync method #

Sync commits the current contents of the file to stable storage. Typically, this means flushing the file system's in-memory copy of recently written data to disk.

func (f *File) Sync() error

Sync method #

Sync commits the current contents of the file to stable storage. Typically, this means flushing the file system's in-memory copy of recently written data to disk.

func (f *File) Sync() error

Sys method #

Sys returns system-dependent exit information about the process. Convert it to the appropriate underlying type, such as [syscall.WaitStatus] on Unix, to access its contents.

func (p *ProcessState) Sys() any

Sys method #

func (fs *fileStat) Sys() any

Sys method #

func (fs *fileStat) Sys() any

Sys method #

Sys returns syscall.Win32FileAttributeData for file fs.

func (fs *fileStat) Sys() any

SysUsage method #

SysUsage returns system-dependent resource usage information about the exited process. Convert it to the appropriate underlying type, such as [*syscall.Rusage] on Unix, to access its contents. (On Unix, *syscall.Rusage matches struct rusage as defined in the getrusage(2) manual page.)

func (p *ProcessState) SysUsage() any

SyscallConn method #

SyscallConn returns a raw file. This implements the syscall.Conn interface.

func (f *File) SyscallConn() (syscall.RawConn, error)

SystemTime method #

SystemTime returns the system CPU time of the exited process and its children.

func (p *ProcessState) SystemTime() time.Duration

TempDir function #

TempDir returns the default directory to use for temporary files. On Unix systems, it returns $TMPDIR if non-empty, else /tmp. On Windows, it uses GetTempPath, returning the first non-empty value from %TMP%, %TEMP%, %USERPROFILE%, or the Windows directory. On Plan 9, it returns /tmp. The directory is neither guaranteed to exist nor have accessible permissions.

func TempDir() string

Timeout method #

Timeout reports whether this error represents a timeout.

func (e *SyscallError) Timeout() bool

Truncate method #

Truncate changes the size of the file. It does not change the I/O offset. If there is an error, it will be of type *PathError.

func (f *File) Truncate(size int64) error

Truncate function #

Truncate changes the size of the named file. If the file is a symbolic link, it changes the size of the link's target. If there is an error, it will be of type *PathError.

func Truncate(name string, size int64) error

Truncate function #

Truncate changes the size of the named file. If the file is a symbolic link, it changes the size of the link's target. If there is an error, it will be of type *PathError.

func Truncate(name string, size int64) error

Truncate method #

Truncate changes the size of the file. It does not change the I/O offset. If there is an error, it will be of type [*PathError].

func (f *File) Truncate(size int64) error

Truncate function #

Truncate changes the size of the named file. If the file is a symbolic link, it changes the size of the link's target.

func Truncate(name string, size int64) error

Type method #

func (de dirEntry) Type() FileMode

Type method #

func (de dirEntry) Type() FileMode

Type method #

func (d *unixDirent) Type() FileMode

Unsetenv function #

Unsetenv unsets a single environment variable.

func Unsetenv(key string) error

Unwrap method #

func (e *SyscallError) Unwrap() error

Unwrap method #

func (e *LinkError) Unwrap() error

UserCacheDir function #

UserCacheDir returns the default root directory to use for user-specific cached data. Users should create their own application-specific subdirectory within this one and use that. On Unix systems, it returns $XDG_CACHE_HOME as specified by https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html if non-empty, else $HOME/.cache. On Darwin, it returns $HOME/Library/Caches. On Windows, it returns %LocalAppData%. On Plan 9, it returns $home/lib/cache. If the location cannot be determined (for example, $HOME is not defined) or the path in $XDG_CACHE_HOME is relative, then it will return an error.

func UserCacheDir() (string, error)

UserConfigDir function #

UserConfigDir returns the default root directory to use for user-specific configuration data. Users should create their own application-specific subdirectory within this one and use that. On Unix systems, it returns $XDG_CONFIG_HOME as specified by https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html if non-empty, else $HOME/.config. On Darwin, it returns $HOME/Library/Application Support. On Windows, it returns %AppData%. On Plan 9, it returns $home/lib. If the location cannot be determined (for example, $HOME is not defined) or the path in $XDG_CONFIG_HOME is relative, then it will return an error.

func UserConfigDir() (string, error)

UserHomeDir function #

UserHomeDir returns the current user's home directory. On Unix, including macOS, it returns the $HOME environment variable. On Windows, it returns %USERPROFILE%. On Plan 9, it returns the $home environment variable. If the expected variable is not set in the environment, UserHomeDir returns either a platform-specific default value or a non-nil error.

func UserHomeDir() (string, error)

UserTime method #

UserTime returns the user CPU time of the exited process and its children.

func (p *ProcessState) UserTime() time.Duration

Wait method #

Wait waits for the [Process] to exit, and then returns a ProcessState describing its status and an error, if any. Wait releases any resources associated with the Process. On most operating systems, the Process must be a child of the current process or an error will be returned.

func (p *Process) Wait() (*ProcessState, error)

Write method #

func (c *rawConn) Write(f func(uintptr) bool) error

Write method #

Write writes len(b) bytes from b to the File. It returns the number of bytes written and an error, if any. Write returns a non-nil error when n != len(b).

func (f *File) Write(b []byte) (n int, err error)

Write method #

func (c *rawConn) Write(f func(uintptr) bool) error

WriteAt method #

WriteAt writes len(b) bytes to the File starting at byte offset off. It returns the number of bytes written and an error, if any. WriteAt returns a non-nil error when n != len(b). If file was opened with the O_APPEND flag, WriteAt returns an error.

func (f *File) WriteAt(b []byte, off int64) (n int, err error)

WriteFile function #

WriteFile writes data to the named file, creating it if necessary. If the file does not exist, WriteFile creates it with permissions perm (before umask); otherwise WriteFile truncates it before writing, without changing permissions. Since WriteFile requires multiple system calls to complete, a failure mid-operation can leave the file in a partially written state.

func WriteFile(name string, data []byte, perm FileMode) error

WriteString method #

WriteString is like Write, but writes the contents of string s rather than a slice of bytes.

func (f *File) WriteString(s string) (n int, err error)

WriteTo method #

WriteTo hides another WriteTo method. It should never be called.

func (noWriteTo) WriteTo(io.Writer) (int64, error)

WriteTo method #

WriteTo implements io.WriterTo.

func (f *File) WriteTo(w io.Writer) (n int64, err error)

addExtendedPrefix function #

addExtendedPrefix adds the extended path prefix (\\?\) to path.

func addExtendedPrefix(path string) string

appendBSBytes function #

appendBSBytes appends n '\\' bytes to b and returns the resulting slice.

func appendBSBytes(b []byte, n int) []byte

atime function #

For testing.

func atime(fi FileInfo) time.Time

atime function #

For testing.

func atime(fi FileInfo) time.Time

atime function #

For testing.

func atime(fi FileInfo) time.Time

atime function #

For testing.

func atime(fi FileInfo) time.Time

atime function #

For testing.

func atime(fi FileInfo) time.Time

atime function #

For testing.

func atime(fi FileInfo) time.Time

atime function #

For testing.

func atime(fi FileInfo) time.Time

atime function #

For testing.

func atime(fi FileInfo) time.Time

atime function #

For testing.

func atime(fi FileInfo) time.Time

atime function #

For testing.

func atime(fi FileInfo) time.Time

atime function #

For testing.

func atime(fi FileInfo) time.Time

atime function #

For testing.

func atime(fi FileInfo) time.Time

blockUntilWaitable method #

blockUntilWaitable attempts to block until a call to p.Wait will succeed immediately, and reports whether it has done so. It does not actually call p.Wait. This version is used on systems that do not implement waitid, or where we have not implemented it yet. Note that this is racy: a call to Process.Signal can in an extremely unlikely case send a signal to the wrong process, see issue #13987.

func (p *Process) blockUntilWaitable() (bool, error)

blockUntilWaitable method #

blockUntilWaitable attempts to block until a call to p.Wait will succeed immediately, and reports whether it has done so. It does not actually call p.Wait.

func (p *Process) blockUntilWaitable() (bool, error)

blockUntilWaitable method #

blockUntilWaitable attempts to block until a call to p.Wait will succeed immediately, and reports whether it has done so. It does not actually call p.Wait.

func (p *Process) blockUntilWaitable() (bool, error)

checkClonePidfd function #

Provided by syscall. go:linkname checkClonePidfd

func checkClonePidfd() error

checkPathEscapes function #

func checkPathEscapes(r *Root, name string) error

checkPathEscapes function #

checkPathEscapes reports whether name escapes the root. Due to the lack of openat, checkPathEscapes is subject to TOCTOU races when symlinks change during the resolution process.

func checkPathEscapes(r *Root, name string) error

checkPathEscapesInternal function #

func checkPathEscapesInternal(r *Root, name string, lstat bool) error

checkPathEscapesLstat function #

checkPathEscapesLstat reports whether name escapes the root. It does not resolve symlinks in the final path component. Due to the lack of openat, checkPathEscapes is subject to TOCTOU races when symlinks change during the resolution process.

func checkPathEscapesLstat(r *Root, name string) error

checkPathEscapesLstat function #

func checkPathEscapesLstat(r *Root, name string) error

checkPidfd function #

checkPidfd checks whether all required pidfd-related syscalls work. This consists of pidfd_open and pidfd_send_signal syscalls, waitid syscall with idtype of P_PIDFD, and clone(CLONE_PIDFD). Reasons for non-working pidfd syscalls include an older kernel and an execution environment in which the above system calls are restricted by seccomp or a similar technology.

func checkPidfd() error

checkValid method #

checkValid checks whether f is valid for use. If not, it returns an appropriate error, perhaps incorporating the operation name op.

func (f *File) checkValid(op string) error

checkValid method #

checkValid checks whether f is valid for use, but does not prepare to actually use it. If f is not ready checkValid returns an appropriate error, perhaps incorporating the operation name op.

func (f *File) checkValid(op string) error

chmod function #

See docs in file.go:Chmod.

func chmod(name string, mode FileMode) error

chmod function #

See docs in file.go:Chmod.

func chmod(name string, mode FileMode) error

chmod method #

See docs in file.go:(*File).Chmod.

func (f *File) chmod(mode FileMode) error

chmod method #

func (f *File) chmod(mode FileMode) error

close method #

func (d *dirInfo) close()

close method #

func (d *dirInfo) close()

close method #

func (file *file) close() error

close method #

func (file *file) close() error

close method #

func (d *dirInfo) close()

close method #

func (file *file) close() error

closeHandle method #

func (p *Process) closeHandle()

closeHandle method #

func (p *Process) closeHandle()

closeHandle method #

func (p *Process) closeHandle()

closedir function #

go:linkname closedir syscall.closedir

func closedir(dir uintptr) (err error)

commandLineToArgv function #

commandLineToArgv splits a command line into individual argument strings, following the Windows conventions documented at http://daviddeley.com/autohotkey/parameters/parameters.htm#WINARGV

func commandLineToArgv(cmd string) []string

convertESRCH function #

func convertESRCH(err error) error

copyFileRange method #

func (f *File) copyFileRange(r io.Reader) (written int64, handled bool, err error)

decref method #

func (r *root) decref()

decref method #

decref removes a reference to the file. If this is the last remaining reference, and the file has been marked to be closed, then actually close it.

func (file *file) decref() error

destroy method #

destroy actually closes the descriptor. This is called when there are no remaining references, by the decref, readUnlock, and writeUnlock methods.

func (file *file) destroy() error

direntIno function #

func direntIno(buf []byte) (uint64, bool)

direntIno function #

func direntIno(buf []byte) (uint64, bool)

direntIno function #

func direntIno(buf []byte) (uint64, bool)

direntIno function #

func direntIno(buf []byte) (uint64, bool)

direntIno function #

func direntIno(buf []byte) (uint64, bool)

direntIno function #

func direntIno(buf []byte) (uint64, bool)

direntIno function #

func direntIno(buf []byte) (uint64, bool)

direntIno function #

func direntIno(buf []byte) (uint64, bool)

direntIno function #

func direntIno(buf []byte) (uint64, bool)

direntNamlen function #

func direntNamlen(buf []byte) (uint64, bool)

direntNamlen function #

func direntNamlen(buf []byte) (uint64, bool)

direntNamlen function #

func direntNamlen(buf []byte) (uint64, bool)

direntNamlen function #

func direntNamlen(buf []byte) (uint64, bool)

direntNamlen function #

func direntNamlen(buf []byte) (uint64, bool)

direntNamlen function #

func direntNamlen(buf []byte) (uint64, bool)

direntNamlen function #

func direntNamlen(buf []byte) (uint64, bool)

direntNamlen function #

func direntNamlen(buf []byte) (uint64, bool)

direntNamlen function #

func direntNamlen(buf []byte) (uint64, bool)

direntReclen function #

func direntReclen(buf []byte) (uint64, bool)

direntReclen function #

func direntReclen(buf []byte) (uint64, bool)

direntReclen function #

func direntReclen(buf []byte) (uint64, bool)

direntReclen function #

func direntReclen(buf []byte) (uint64, bool)

direntReclen function #

func direntReclen(buf []byte) (uint64, bool)

direntReclen function #

func direntReclen(buf []byte) (uint64, bool)

direntReclen function #

func direntReclen(buf []byte) (uint64, bool)

direntReclen function #

func direntReclen(buf []byte) (uint64, bool)

direntReclen function #

func direntReclen(buf []byte) (uint64, bool)

direntType function #

func direntType(buf []byte) FileMode

direntType function #

func direntType(buf []byte) FileMode

direntType function #

func direntType(buf []byte) FileMode

direntType function #

func direntType(buf []byte) FileMode

direntType function #

func direntType(buf []byte) FileMode

direntType function #

func direntType(buf []byte) FileMode

direntType function #

func direntType(buf []byte) FileMode

direntType function #

func direntType(buf []byte) FileMode

direntType function #

func direntType(buf []byte) FileMode

dirname function #

func dirname(path string) string

dirstat function #

arg is an open *File or a path string.

func dirstat(arg any) (*syscall.Dir, error)

doInRoot function #

doInRoot performs an operation on a path in a Root. It opens the directory containing the final element of the path, and calls f with the directory FD and name of the final element. If the path refers to a symlink which should be followed, then f must return errSymlink. doInRoot will follow the symlink and call f again.

func doInRoot(r *Root, name string, f func(parent sysfdType, name string) (T, error)) (ret T, err error)

dtToType function #

func dtToType(typ uint8) FileMode

endsWithDot function #

endsWithDot reports whether the final component of path is ".".

func endsWithDot(path string) bool

ensurePidfd function #

func ensurePidfd(sysAttr *syscall.SysProcAttr) (*syscall.SysProcAttr, bool)

ensurePidfd function #

ensurePidfd initializes the PidFD field in sysAttr if it is not already set. It returns the original or modified SysProcAttr struct and a flag indicating whether the PidFD should be duplicated before using.

func ensurePidfd(sysAttr *syscall.SysProcAttr) (*syscall.SysProcAttr, bool)

epipecheck function #

func epipecheck(file *File, e error)

epipecheck function #

func epipecheck(file *File, e error)

epipecheck function #

epipecheck raises SIGPIPE if we get an EPIPE error on standard output or standard error. See the SIGPIPE docs in os/signal, and issue 11845.

func epipecheck(file *File, e error)

errDeadlineExceeded function #

errDeadlineExceeded returns the value for os.ErrDeadlineExceeded. This error comes from the internal/poll package, which is also used by package net. Doing it this way ensures that the net package will return os.ErrDeadlineExceeded for an exceeded deadline, as documented by net.Conn.SetDeadline, without requiring any extra work in the net package and without requiring the internal/poll package to import os (which it can't, because that would be circular).

func errDeadlineExceeded() error

errNoDeadline function #

func errNoDeadline() error

executable function #

func executable() (string, error)

executable function #

func executable() (string, error)

executable function #

func executable() (string, error)

executable function #

func executable() (string, error)

executable function #

func executable() (string, error)

executable function #

func executable() (string, error)

executable function #

func executable() (string, error)

executable function #

func executable() (string, error)

exited method #

func (p *ProcessState) exited() bool

exited method #

func (p *ProcessState) exited() bool

fileInfoFromStat function #

func fileInfoFromStat(d *syscall.Dir) *fileStat

fillFileStatFromSys function #

func fillFileStatFromSys(fs *fileStat, name string)

fillFileStatFromSys function #

func fillFileStatFromSys(fs *fileStat, name string)

fillFileStatFromSys function #

func fillFileStatFromSys(fs *fileStat, name string)

fillFileStatFromSys function #

func fillFileStatFromSys(fs *fileStat, name string)

fillFileStatFromSys function #

func fillFileStatFromSys(fs *fileStat, name string)

fillFileStatFromSys function #

func fillFileStatFromSys(fs *fileStat, name string)

fillFileStatFromSys function #

func fillFileStatFromSys(fs *fileStat, name string)

fillFileStatFromSys function #

func fillFileStatFromSys(fs *fileStat, name string)

fillFileStatFromSys function #

func fillFileStatFromSys(fs *fileStat, name string)

fillFileStatFromSys function #

func fillFileStatFromSys(fs *fileStat, name string)

findProcess function #

func findProcess(pid int) (p *Process, err error)

findProcess function #

func findProcess(pid int) (p *Process, err error)

findProcess function #

func findProcess(pid int) (p *Process, err error)

fixCount function #

Many functions in package syscall return a count of -1 instead of 0. Using fixCount(call()) instead of call() corrects the count.

func fixCount(n int, err error) (int, error)

fixLongPath function #

fixLongPath is a noop on non-Windows platforms.

func fixLongPath(path string) string

fixLongPath function #

fixLongPath is a noop on non-Windows platforms.

func fixLongPath(path string) string

fixLongPath function #

fixLongPath returns the extended-length (\\?\-prefixed) form of path when needed, in order to avoid the default 260 character file path limit imposed by Windows. If the path is short enough or already has the extended-length prefix, fixLongPath returns path unmodified. If the path is relative and joining it with the current working directory results in a path that is too long, fixLongPath returns the absolute path with the extended-length prefix. See https://learn.microsoft.com/en-us/windows/win32/fileio/naming-a-file#maximum-path-length-limitation

func fixLongPath(path string) string

ftToDuration function #

func ftToDuration(ft *syscall.Filetime) time.Duration

genericReadFrom function #

func genericReadFrom(f *File, r io.Reader) (int64, error)

genericWriteTo function #

func genericWriteTo(f *File, w io.Writer) (int64, error)

getModuleFileName function #

func getModuleFileName(handle syscall.Handle) (string, error)

getPidfd function #

getPidfd returns the value of sysAttr.PidFD (or its duplicate if needDup is set) and a flag indicating whether the value can be used.

func getPidfd(sysAttr *syscall.SysProcAttr, needDup bool) (uintptr, bool)

getPidfd function #

func getPidfd(_ *syscall.SysProcAttr, _ bool) (uintptr, bool)

getPollFDAndNetwork function #

getPollFDAndNetwork tries to get the poll.FD and network type from the given interface by expecting the underlying type of i to be the implementation of syscall.Conn that contains a *net.rawConn.

func getPollFDAndNetwork(i any) (*poll.FD, poll.String)

getShellName function #

getShellName returns the name that begins the string and the number of bytes consumed to extract it. If the name is enclosed in {}, it's part of a ${} expansion and two more bytes are needed than the length of the name.

func getShellName(s string) (string, int)

handlePersistentRelease method #

Drop the Process' persistent reference on the handle, deactivating future Wait/Signal calls with the passed reason. Returns the status prior to this call. If this is not statusOK, then the reference was not dropped or status changed.

func (p *Process) handlePersistentRelease(reason processStatus) processStatus

handleTransientAcquire method #

func (p *Process) handleTransientAcquire() (uintptr, processStatus)

handleTransientRelease method #

func (p *Process) handleTransientRelease()

hostname function #

func hostname() (name string, err error)

hostname function #

func hostname() (name string, err error)

hostname function #

func hostname() (name string, err error)

hostname function #

func hostname() (name string, err error)

hostname function #

func hostname() (name string, err error)

hostname function #

func hostname() (name string, err error)

ignoreSIGSYS function #

Provided by runtime. go:linkname ignoreSIGSYS

func ignoreSIGSYS()

ignoringEINTR function #

func ignoringEINTR(fn func() error) error

ignoringEINTR function #

ignoringEINTR makes a function call and repeats it if it returns an EINTR error. This appears to be required even though we install all signal handlers with SA_RESTART: see #22838, #38033, #38836, #40846. Also #20400 and #36644 are issues in which a signal handler is installed without setting SA_RESTART. None of these are the common case, but there are enough of them that it seems that we can't avoid an EINTR loop.

func ignoringEINTR(fn func() error) error

ignoringEINTR2 function #

ignoringEINTR2 is ignoringEINTR, but returning an additional value.

func ignoringEINTR2(fn func() (T, error)) (T, error)

ignoringEINTR2 function #

func ignoringEINTR2(fn func() (T, error)) (T, error)

incref method #

incref adds a reference to the file. It returns an error if the file is already closed. This method is on File so that we can incorporate a nil test.

func (f *File) incref(op string) (err error)

incref method #

func (r *root) incref() error

init function #

func init()

init function #

func init()

init method #

func (d *dirInfo) init(h syscall.Handle)

isAlphaNum function #

isAlphaNum reports whether the byte is an ASCII letter, number, or underscore.

func isAlphaNum(c uint8) bool

isExecutable function #

isExecutable returns an error if a given file is not an executable.

func isExecutable(path string) error

isNoFollowErr function #

isNoFollowErr reports whether err may result from O_NOFOLLOW blocking an open operation.

func isNoFollowErr(err error) bool

isNoFollowErr function #

isNoFollowErr reports whether err may result from O_NOFOLLOW blocking an open operation.

func isNoFollowErr(err error) bool

isReparseTagNameSurrogate method #

isReparseTagNameSurrogate determines whether a tag's associated reparse point is a surrogate for another named entity (for example, a mounted folder). See https://learn.microsoft.com/en-us/windows/win32/api/winnt/nf-winnt-isreparsetagnamesurrogate and https://learn.microsoft.com/en-us/windows/win32/fileio/reparse-point-tags.

func (fs *fileStat) isReparseTagNameSurrogate() bool

isShellSpecialVar function #

isShellSpecialVar reports whether the character identifies a special shell variable such as $*.

func isShellSpecialVar(c uint8) bool

isUnixOrTCP function #

func isUnixOrTCP(network string) bool

isValidRootFSPath function #

isValidRootFSPath reprots whether name is a valid filename to pass a Root.FS method.

func isValidRootFSPath(name string) bool

join method #

join returns the path for name in dir.

func (dir dirFS) join(name string) (string, error)

joinPath function #

func joinPath(dir string, name string) string

kill method #

func (p *Process) kill() error

kill method #

func (p *Process) kill() error

loadFileId method #

func (fs *fileStat) loadFileId() error

logOpen method #

func (r *Root) logOpen(name string)

logStat method #

func (r *Root) logStat(name string)

lstatNolog function #

lstatNolog implements Lstat for Windows.

func lstatNolog(name string) (FileInfo, error)

lstatNolog function #

lstatNolog implements Lstat for Plan 9.

func lstatNolog(name string) (FileInfo, error)

lstatNolog function #

lstatNolog lstats a file with no test logging.

func lstatNolog(name string) (FileInfo, error)

mkdirat function #

func mkdirat(fd int, name string, perm FileMode) error

mkdirat function #

func mkdirat(dirfd syscall.Handle, name string, perm FileMode) error

mode method #

func (fs *fileStat) mode() (m FileMode)

modePreGo1_23 method #

modePreGo1_23 returns the FileMode for the fileStat, using the pre-Go 1.23 logic for determining the file mode. The logic is subtle and not well-documented, so it is better to keep it separate from the new logic.

func (fs *fileStat) modePreGo1_23() (m FileMode)

net_newUnixFile function #

net_newUnixFile is a hidden entry point called by net.conn.File. This is used so that a nonblocking network connection will become blocking if code calls the Fd method. We don't want that for direct calls to NewFile: passing a nonblocking descriptor to NewFile should remain nonblocking if you get it back using Fd. But for net.conn.File the call to NewFile is hidden from the user. Historically in that case the Fd method has returned a blocking descriptor, and we want to retain that behavior because existing code expects it and depends on it. go:linkname net_newUnixFile net.newUnixFile

func net_newUnixFile(fd int, name string) *File

newConsoleFile function #

newConsoleFile creates new File that will be used as console.

func newConsoleFile(h syscall.Handle, name string) *File

newDoneProcess function #

func newDoneProcess(pid int) *Process

newFile function #

newFile returns a new File with the given file handle and name. Unlike NewFile, it does not check that h is syscall.InvalidHandle.

func newFile(h syscall.Handle, name string, kind string) *File

newFile function #

newFile is like NewFile, but if called from OpenFile or Pipe (as passed in the kind parameter) it tries to add the file to the runtime poller.

func newFile(fd int, name string, kind newFileKind, nonBlocking bool) *File

newFileStatFromFileFullDirInfo function #

newFileStatFromFileFullDirInfo copies all required information from windows.FILE_FULL_DIR_INFO d into the newly created fileStat.

func newFileStatFromFileFullDirInfo(d *windows.FILE_FULL_DIR_INFO) *fileStat

newFileStatFromFileIDBothDirInfo function #

newFileStatFromFileIDBothDirInfo copies all required information from windows.FILE_ID_BOTH_DIR_INFO d into the newly created fileStat.

func newFileStatFromFileIDBothDirInfo(d *windows.FILE_ID_BOTH_DIR_INFO) *fileStat

newFileStatFromGetFileInformationByHandle function #

newFileStatFromGetFileInformationByHandle calls GetFileInformationByHandle to gather all required information about the file handle h.

func newFileStatFromGetFileInformationByHandle(path string, h syscall.Handle) (fs *fileStat, err error)

newFileStatFromWin32FileAttributeData function #

newFileStatFromWin32FileAttributeData copies all required information from syscall.Win32FileAttributeData d into the newly created fileStat.

func newFileStatFromWin32FileAttributeData(d *syscall.Win32FileAttributeData) *fileStat

newFileStatFromWin32finddata function #

newFileStatFromWin32finddata copies all required information from syscall.Win32finddata d into the newly created fileStat.

func newFileStatFromWin32finddata(d *syscall.Win32finddata) *fileStat

newHandleProcess function #

func newHandleProcess(pid int, handle uintptr) *Process

newPIDProcess function #

func newPIDProcess(pid int) *Process

newRawConn function #

func newRawConn(file *File) (*rawConn, error)

newRawConn function #

func newRawConn(file *File) (*rawConn, error)

newRoot function #

newRoot returns a new Root. If fd is not a directory, it closes it and returns an error.

func newRoot(fd int, name string) (*Root, error)

newRoot function #

newRoot returns a new Root. If fd is not a directory, it closes it and returns an error.

func newRoot(fd syscall.Handle, name string) (*Root, error)

newRoot function #

newRoot returns a new Root. If fd is not a directory, it closes it and returns an error.

func newRoot(name string) (*Root, error)

newUnixDirent function #

func newUnixDirent(parent string, name string, typ FileMode) (DirEntry, error)

nextRandom function #

func nextRandom() string

normaliseLinkPath function #

normaliseLinkPath converts absolute paths returned by DeviceIoControl(h, FSCTL_GET_REPARSE_POINT, ...) into paths acceptable by all Windows APIs. For example, it converts \??\C:\foo\bar into C:\foo\bar \??\UNC\foo\bar into \\foo\bar \??\Volume{abc}\ into \\?\Volume{abc}\

func normaliseLinkPath(path string) (string, error)

open function #

func open(filePath string, flag int, perm uint32) (int, poll.SysFile, error)

open function #

func open(path string, flag int, perm uint32) (int, poll.SysFile, error)

openDir function #

openDir opens a file which is assumed to be a directory. As such, it skips the syscalls that make the file descriptor non-blocking as these take time and will fail on file descriptors for directories.

func openDir(name string) (*File, error)

openDirAt function #

openDirAt opens a directory name relative to the directory referred to by the file descriptor dirfd. If name is anything but a directory (this includes a symlink to one), it should return an error. Other than that this should act like openFileNolog. This acts like openFileNolog rather than OpenFile because we are going to (try to) remove the file. The contents of this file are not relevant for test caching.

func openDirAt(dirfd int, name string) (*File, error)

openDirNolog function #

func openDirNolog(name string) (*File, error)

openDirNolog function #

func openDirNolog(name string) (*File, error)

openDirNolog function #

func openDirNolog(name string) (*File, error)

openFileNolog function #

openFileNolog is the Plan 9 implementation of OpenFile.

func openFileNolog(name string, flag int, perm FileMode) (*File, error)

openFileNolog function #

openFileNolog is the Unix implementation of OpenFile. Changes here should be reflected in openDirAt and openDirNolog, if relevant.

func openFileNolog(name string, flag int, perm FileMode) (*File, error)

openFileNolog function #

openFileNolog is the Windows implementation of OpenFile.

func openFileNolog(name string, flag int, perm FileMode) (*File, error)

openRootInRoot function #

openRootInRoot is Root.OpenRoot.

func openRootInRoot(r *Root, name string) (*Root, error)

openRootInRoot function #

openRootInRoot is Root.OpenRoot.

func openRootInRoot(r *Root, name string) (*Root, error)

openRootInRoot function #

openRootInRoot is Root.OpenRoot.

func openRootInRoot(r *Root, name string) (*Root, error)

openRootNolog function #

openRootNolog is OpenRoot.

func openRootNolog(name string) (*Root, error)

openRootNolog function #

openRootNolog is OpenRoot.

func openRootNolog(name string) (*Root, error)

openRootNolog function #

openRootNolog is OpenRoot.

func openRootNolog(name string) (*Root, error)

openat function #

func openat(dirfd syscall.Handle, name string, flag int, perm FileMode) (syscall.Handle, error)

pidDeactivate method #

func (p *Process) pidDeactivate(reason processStatus)

pidSignal method #

func (p *Process) pidSignal(s syscall.Signal) error

pidStatus method #

func (p *Process) pidStatus() processStatus

pidWait method #

func (p *Process) pidWait() (*ProcessState, error)

pidfdFind function #

func pidfdFind(_ int) (uintptr, error)

pidfdFind function #

func pidfdFind(pid int) (uintptr, error)

pidfdSendSignal method #

func (p *Process) pidfdSendSignal(s syscall.Signal) error

pidfdSendSignal method #

func (_ *Process) pidfdSendSignal(_ syscall.Signal) error

pidfdWait method #

func (p *Process) pidfdWait() (*ProcessState, error)

pidfdWait method #

func (_ *Process) pidfdWait() (*ProcessState, error)

pidfdWorks function #

func pidfdWorks() bool

pread method #

pread reads len(b) bytes from the File starting at byte offset off. It returns the number of bytes read and the error, if any. EOF is signaled by a zero count with err set to nil.

func (f *File) pread(b []byte, off int64) (n int, err error)

pread method #

pread reads len(b) bytes from the File starting at byte offset off. It returns the number of bytes read and the error, if any. EOF is signaled by a zero count with err set to nil.

func (f *File) pread(b []byte, off int64) (n int, err error)

prefixAndSuffix function #

prefixAndSuffix splits pattern by the last wildcard "*", if applicable, returning prefix as the part before "*" and suffix as the part after "*".

func prefixAndSuffix(pattern string) (prefix string, suffix string, err error)

pwrite method #

pwrite writes len(b) bytes to the File starting at byte offset off. It returns the number of bytes written and an error, if any. Since Plan 9 preserves message boundaries, never allow a zero-byte write.

func (f *File) pwrite(b []byte, off int64) (n int, err error)

pwrite method #

pwrite writes len(b) bytes to the File starting at byte offset off. It returns the number of bytes written and an error, if any.

func (f *File) pwrite(b []byte, off int64) (n int, err error)

read method #

read reads up to len(b) bytes from the File. It returns the number of bytes read and an error, if any.

func (f *File) read(b []byte) (n int, err error)

read method #

read reads up to len(b) bytes from the File. It returns the number of bytes read and an error, if any.

func (f *File) read(b []byte) (n int, err error)

readFileContents function #

func readFileContents(f *File) ([]byte, error)

readFrom method #

readFrom is basically a refactor of net.sendFile, but adapted to work for the target of *File.

func (f *File) readFrom(r io.Reader) (written int64, handled bool, err error)

readFrom method #

func (f *File) readFrom(r io.Reader) (n int64, handled bool, err error)

readFrom method #

func (f *File) readFrom(r io.Reader) (written int64, handled bool, err error)

readFrom method #

func (f *File) readFrom(r io.Reader) (written int64, handled bool, err error)

readInt function #

readInt returns the size-bytes unsigned integer in native byte order at offset off.

func readInt(b []byte, off uintptr, size uintptr) (u uint64, ok bool)

readIntBE function #

func readIntBE(b []byte, size uintptr) uint64

readIntLE function #

func readIntLE(b []byte, size uintptr) uint64

readLock method #

readLock adds a reference to the file and locks it for reading. It returns an error if the file is already closed.

func (file *file) readLock() error

readNextArg function #

readNextArg splits command line string cmd into next argument and command line remainder.

func readNextArg(cmd string) (arg []byte, rest string)

readReparseLinkAt function #

func readReparseLinkAt(dirfd syscall.Handle, name string) (string, error)

readReparseLinkHandle function #

func readReparseLinkHandle(h syscall.Handle) (string, error)

readUnlock method #

readUnlock removes a reference from the file and unlocks it for reading. It also closes the file if it marked as closed and there is no remaining reference.

func (file *file) readUnlock()

readdir method #

func (f *File) readdir(n int, mode readdirMode) (names []string, dirents []DirEntry, infos []FileInfo, err error)

readdir method #

func (file *File) readdir(n int, mode readdirMode) (names []string, dirents []DirEntry, infos []FileInfo, err error)

readdir method #

func (f *File) readdir(n int, mode readdirMode) (names []string, dirents []DirEntry, infos []FileInfo, err error)

readdir method #

func (file *File) readdir(n int, mode readdirMode) (names []string, dirents []DirEntry, infos []FileInfo, err error)

readdir_r function #

go:linkname readdir_r syscall.readdir_r

func readdir_r(dir uintptr, entry *syscall.Dirent, result **syscall.Dirent) (res syscall.Errno)

readlinkat function #

func readlinkat(fd int, name string) (string, error)

release method #

func (p *Process) release() error

release method #

func (p *Process) release() error

release method #

func (p *Process) release() error

removeAll function #

func removeAll(path string) error

removeAll function #

func removeAll(path string) error

removeAllFrom function #

func removeAllFrom(parent *File, base string) error

removeat function #

func removeat(dirfd syscall.Handle, name string) error

removeat function #

func removeat(fd int, name string) error

rename function #

func rename(oldname string, newname string) error

rename function #

func rename(oldname string, newname string) error

rename function #

func rename(oldname string, newname string) error

restoreSIGSYS function #

go:linkname restoreSIGSYS

func restoreSIGSYS()

rootCleanPath function #

func rootCleanPath(s string, prefix []string, suffix []string) (string, error)

rootCleanPath function #

rootCleanPath uses GetFullPathName to perform lexical path cleaning. On Windows, file names are lexically cleaned at the start of a file operation. For example, on Windows the path `a\..\b` is exactly equivalent to `b` alone, even if `a` does not exist or is not a directory. We use the Windows API function GetFullPathName to perform this cleaning. We could do this ourselves, but there are a number of subtle behaviors here, and deferring to the OS maintains consistency. (For example, `a\.\` cleans to `a\`.) GetFullPathName operates on absolute paths, and our input path is relative. We make the path absolute by prepending a fixed prefix of \\?\?\. We want to detect paths which use .. components to escape the root. We do this by ensuring the cleaned path still begins with \\?\?\. We catch the corner case of a path which includes a ..\?\. component by rejecting any input paths which contain a ?, which is not a valid character in a Windows filename.

func rootCleanPath(s string, prefix []string, suffix []string) (string, error)

rootMkdir function #

func rootMkdir(r *Root, name string, perm FileMode) error

rootMkdir function #

func rootMkdir(r *Root, name string, perm FileMode) error

rootOpenDir function #

func rootOpenDir(parent int, name string) (int, error)

rootOpenDir function #

func rootOpenDir(parent syscall.Handle, name string) (syscall.Handle, error)

rootOpenFileNolog function #

rootOpenFileNolog is Root.OpenFile.

func rootOpenFileNolog(root *Root, name string, flag int, perm FileMode) (*File, error)

rootOpenFileNolog function #

rootOpenFileNolog is Root.OpenFile.

func rootOpenFileNolog(root *Root, name string, flag int, perm FileMode) (*File, error)

rootOpenFileNolog function #

rootOpenFileNolog is Root.OpenFile.

func rootOpenFileNolog(r *Root, name string, flag int, perm FileMode) (*File, error)

rootRemove function #

func rootRemove(r *Root, name string) error

rootRemove function #

func rootRemove(r *Root, name string) error

rootStat function #

func rootStat(r *Root, name string, lstat bool) (FileInfo, error)

rootStat function #

func rootStat(r *Root, name string, lstat bool) (FileInfo, error)

rootStat function #

func rootStat(r *Root, name string, lstat bool) (FileInfo, error)

runtime_args function #

func runtime_args() []string

runtime_beforeExit function #

func runtime_beforeExit(exitCode int)

runtime_rand function #

random number source provided by runtime. We generate random temporary file names so that there's a good chance the file doesn't exist yet - keeps the number of tries in TempFile to a minimum. go:linkname runtime_rand runtime.rand

func runtime_rand() uint64

sameFile function #

func sameFile(fs1 *fileStat, fs2 *fileStat) bool

sameFile function #

func sameFile(fs1 *fileStat, fs2 *fileStat) bool

sameFile function #

func sameFile(fs1 *fileStat, fs2 *fileStat) bool

saveInfoFromPath method #

saveInfoFromPath saves full path of the file to be used by os.SameFile later, and set name from path.

func (fs *fileStat) saveInfoFromPath(path string) error

seek method #

seek sets the offset for the next Read or Write on file to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. It returns the new offset and an error, if any.

func (f *File) seek(offset int64, whence int) (ret int64, err error)

seek method #

seek sets the offset for the next Read or Write on file to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. It returns the new offset and an error, if any.

func (f *File) seek(offset int64, whence int) (ret int64, err error)

seek method #

seek sets the offset for the next Read or Write on file to offset, interpreted according to whence: 0 means relative to the origin of the file, 1 means relative to the current offset, and 2 means relative to the end. It returns the new offset and an error, if any.

func (f *File) seek(offset int64, whence int) (ret int64, err error)

setDeadline method #

setDeadline sets the read and write deadline.

func (f *File) setDeadline(t time.Time) error

setDeadline method #

setDeadline sets the read and write deadline.

func (f *File) setDeadline(time.Time) error

setReadDeadline method #

setReadDeadline sets the read deadline.

func (f *File) setReadDeadline(time.Time) error

setReadDeadline method #

setReadDeadline sets the read deadline.

func (f *File) setReadDeadline(t time.Time) error

setStickyBit function #

setStickyBit adds ModeSticky to the permission bits of path, non atomic.

func setStickyBit(name string) error

setWriteDeadline method #

setWriteDeadline sets the write deadline.

func (f *File) setWriteDeadline(t time.Time) error

setWriteDeadline method #

setWriteDeadline sets the write deadline.

func (f *File) setWriteDeadline(time.Time) error

signal method #

func (p *Process) signal(sig Signal) error

signal method #

func (p *Process) signal(sig Signal) error

signal method #

func (p *Process) signal(sig Signal) error

sigpipe function #

func sigpipe()

spliceToFile method #

func (f *File) spliceToFile(r io.Reader) (written int64, handled bool, err error)

splitPath function #

splitPath returns the base name and parent directory.

func splitPath(path string) (string, string)

splitPathInRoot function #

splitPathInRoot splits a path into components and joins it with the given prefix and suffix. The path is relative to a Root, and must not be absolute, volume-relative, or "". "." components are removed, except in the last component. Path separators following the last component are returned in suffixSep.

func splitPathInRoot(s string, prefix []string, suffix []string) (_ []string, suffixSep string, err error)

splitPathList function #

splitPathList splits a path list. This is based on genSplit from strings/strings.go

func splitPathList(pathList string) []string

stTimespecToTime function #

func stTimespecToTime(ts syscall.StTimespec_t) time.Time

startProcess function #

func startProcess(name string, argv []string, attr *ProcAttr) (p *Process, err error)

startProcess function #

func startProcess(name string, argv []string, attr *ProcAttr) (p *Process, err error)

stat function #

stat implements both Stat and Lstat of a file.

func stat(funcname string, name string, followSurrogates bool) (FileInfo, error)

statHandle function #

func statHandle(name string, h syscall.Handle) (FileInfo, error)

statNolog function #

statNolog implements Stat for Plan 9.

func statNolog(name string) (FileInfo, error)

statNolog function #

statNolog stats a file with no test logging.

func statNolog(name string) (FileInfo, error)

statNolog function #

statNolog implements Stat for Windows.

func statNolog(name string) (FileInfo, error)

success method #

func (p *ProcessState) success() bool

success method #

func (p *ProcessState) success() bool

sys method #

func (p *ProcessState) sys() any

sys method #

func (p *ProcessState) sys() any

sysUsage method #

func (p *ProcessState) sysUsage() any

sysUsage method #

func (p *ProcessState) sysUsage() any

syscallMode function #

syscallMode returns the syscall-specific mode bits from Go's portable mode bits.

func syscallMode(i FileMode) (o uint32)

syscallMode function #

syscallMode returns the syscall-specific mode bits from Go's portable mode bits.

func syscallMode(i FileMode) (o uint32)

systemTime method #

func (p *ProcessState) systemTime() time.Duration

systemTime method #

func (p *ProcessState) systemTime() time.Duration

systemTime method #

func (p *ProcessState) systemTime() time.Duration

tempDir function #

func tempDir() string

tempDir function #

func tempDir() string

tempDir function #

func tempDir() string

tryLimitedReader function #

tryLimitedReader tries to assert the io.Reader to io.LimitedReader, it returns the io.LimitedReader, the underlying io.Reader and the remaining amount of bytes if the assertion succeeds, otherwise it just returns the original io.Reader and the theoretical unlimited remaining amount of bytes.

func tryLimitedReader(r io.Reader) (*io.LimitedReader, io.Reader, int64)

underlyingError function #

underlyingError returns the underlying error for known os error types.

func underlyingError(err error) error

underlyingErrorIs function #

func underlyingErrorIs(err error, target error) bool

userTime method #

func (p *ProcessState) userTime() time.Duration

userTime method #

func (p *ProcessState) userTime() time.Duration

userTime method #

func (p *ProcessState) userTime() time.Duration

wait method #

func (p *Process) wait() (ps *ProcessState, err error)

wait method #

func (p *Process) wait() (ps *ProcessState, err error)

wait method #

func (p *Process) wait() (ps *ProcessState, err error)

wait6 function #

func wait6(idtype int, id int, options int) (status int, errno syscall.Errno)

wait6 function #

func wait6(idtype int, id int, options int) (status int, errno syscall.Errno)

wait6 function #

func wait6(idtype int, id int, options int) (status int, errno syscall.Errno)

wait6 function #

func wait6(idtype int, id int, options int) (status int, errno syscall.Errno)

wait6 function #

func wait6(idtype int, id int, options int) (status int, errno syscall.Errno)

wrapErr method #

wrapErr wraps an error that occurred during an operation on an open file. It passes io.EOF through unchanged, otherwise converts poll.ErrFileClosing to ErrClosed and wraps the error in a PathError.

func (f *File) wrapErr(op string, err error) error

wrapSyscallError function #

wrapSyscallError takes an error and a syscall name. If the error is a syscall.Errno, it wraps it in an os.SyscallError using the syscall name.

func wrapSyscallError(name string, err error) error

write method #

write writes len(b) bytes to the File. It returns the number of bytes written and an error, if any.

func (f *File) write(b []byte) (n int, err error)

write method #

write writes len(b) bytes to the File. It returns the number of bytes written and an error, if any. Since Plan 9 preserves message boundaries, never allow a zero-byte write.

func (f *File) write(b []byte) (n int, err error)

writeLock method #

writeLock adds a reference to the file and locks it for writing. It returns an error if the file is already closed.

func (file *file) writeLock() error

writeProcFile method #

func (p *Process) writeProcFile(file string, data string) error

writeTo method #

func (f *File) writeTo(w io.Writer) (written int64, handled bool, err error)

writeTo method #

func (f *File) writeTo(w io.Writer) (written int64, handled bool, err error)

writeTo method #

func (f *File) writeTo(w io.Writer) (written int64, handled bool, err error)

writeTo method #

func (f *File) writeTo(w io.Writer) (written int64, handled bool, err error)

writeUnlock method #

writeUnlock removes a reference from the file and unlocks it for writing. It also closes the file if it is marked as closed and there is no remaining reference.

func (file *file) writeUnlock()

Generated with Arrow