Functions
Accept
method
#
Accept wraps the accept network call.
func (fd *FD) Accept() (int, syscall.Sockaddr, string, error)
Accept
method
#
Accept handles accepting a socket. The sysSocket parameter is used
to allocate the net socket.
func (fd *FD) Accept(sysSocket func() (syscall.Handle, error)) (syscall.Handle, []syscall.RawSockaddrAny, uint32, string, error)
Cancel
method
#
Cancel interrupts the I/O operation, causing
the Wait function to return.
func (aio *asyncIO) Cancel()
ClearBufs
method
#
ClearBufs clears all pointers to Buffers parameter captured
by InitBufs, so it can be released by garbage collector.
func (o *operation) ClearBufs()
Close
method
#
Close closes the FD. The underlying file descriptor is closed by the
destroy method when there are no remaining references.
func (fd *FD) Close() error
Close
method
#
Close closes the FD. The underlying file descriptor is closed by
the destroy method when there are no remaining references.
func (fd *FD) Close() error
Close
method
#
Close handles the locking for closing an FD. The real operation
is in the net package.
func (fd *FD) Close() error
ConnectEx
method
#
Call ConnectEx. This doesn't need any locking, since it is only
called when the descriptor is first created. This is here rather
than in the net package so that it can use fd.wop.
func (fd *FD) ConnectEx(ra syscall.Sockaddr) error
Copy
method
#
Copy creates a copy of the FD.
The FD instance points to the same underlying file descriptor. The file
descriptor isn't closed until all FD instances that refer to it have been
closed/destroyed.
func (fd *FD) Copy() FD
CopyFileRange
function
#
CopyFileRange copies at most remain bytes of data from src to dst, using
the copy_file_range system call. dst and src must refer to regular files.
func CopyFileRange(dst *FD, src *FD, remain int64) (written int64, handled bool, err error)
Decref
method
#
func (fdmu *FDMutex) Decref() bool
Dup
method
#
Dup duplicates the file descriptor.
func (fd *FD) Dup() (int, string, error)
DupCloseOnExec
function
#
func DupCloseOnExec(fd int) (int, string, error)
DupCloseOnExec
function
#
DupCloseOnExec dups fd and marks it close-on-exec.
func DupCloseOnExec(fd int) (int, string, error)
DupCloseOnExec
function
#
func DupCloseOnExec(fd int) (int, string, error)
Error
method
#
Error returns the error message for ErrNetClosing.
Keep this string consistent because of issue #4373:
since historically programs have not been able to detect
this error, they look for the string.
func (e errNetClosing) Error() string
Error
method
#
Implement the net.Error interface.
The string is "i/o timeout" because that is what was returned
by earlier Go versions. Changing it may break programs that
match on error strings.
func (e *DeadlineExceededError) Error() string
Fchdir
method
#
Fchdir wraps syscall.Fchdir.
func (fd *FD) Fchdir() error
Fchdir
method
#
Fchdir wraps syscall.Fchdir.
func (fd *FD) Fchdir() error
Fchdir
method
#
Fchdir wraps syscall.Fchdir.
func (fd *FD) Fchdir() error
Fchmod
method
#
Fchmod updates syscall.ByHandleFileInformation.Fileattributes when needed.
func (fd *FD) Fchmod(mode uint32) error
Fchmod
method
#
Fchmod wraps syscall.Fchmod.
func (fd *FD) Fchmod(mode uint32) error
Fchown
method
#
Fchown wraps syscall.Fchown.
func (fd *FD) Fchown(uid int, gid int) error
Fstat
method
#
Fstat wraps syscall.Fstat
func (fd *FD) Fstat(s *syscall.Stat_t) error
Fsync
method
#
Fsync wraps syscall.Fsync.
func (fd *FD) Fsync() error
Fsync
method
#
Fsync invokes SYS_FCNTL with SYS_FULLFSYNC because
on OS X, SYS_FSYNC doesn't fully flush contents to disk.
See Issue #26650 as well as the man page for fsync on OS X.
func (fd *FD) Fsync() error
Fsync
method
#
Fsync wraps syscall.Fsync.
func (fd *FD) Fsync() error
Ftruncate
method
#
Ftruncate wraps syscall.Ftruncate.
func (fd *FD) Ftruncate(size int64) error
GetFileInformationByHandle
method
#
GetFileInformationByHandle wraps GetFileInformationByHandle.
func (fd *FD) GetFileInformationByHandle(data *syscall.ByHandleFileInformation) error
GetFileType
method
#
GetFileType wraps syscall.GetFileType.
func (fd *FD) GetFileType() (uint32, error)
GetsockoptInt
method
#
GetsockoptInt wraps the getsockopt network call with an int argument.
func (fd *FD) GetsockoptInt(level int, name int) (int, error)
Incref
method
#
func (fdmu *FDMutex) Incref() bool
IncrefAndClose
method
#
func (fdmu *FDMutex) IncrefAndClose() bool
Init
method
#
Init initializes the FD. The Sysfd field should already be set.
This can be called multiple times on a single FD.
The net argument is a network name from the net package (e.g., "tcp"),
or "file" or "console" or "dir".
Set pollable to true if fd should be managed by runtime netpoll.
func (fd *FD) Init(net string, pollable bool) (string, error)
Init
method
#
Init initializes the FD. The Sysfd field should already be set.
This can be called multiple times on a single FD.
The net argument is a network name from the net package (e.g., "tcp"),
or "file".
Set pollable to true if fd should be managed by runtime netpoll.
func (fd *FD) Init(net string, pollable bool) error
InitBuf
method
#
func (o *operation) InitBuf(buf []byte)
InitBufs
method
#
func (o *operation) InitBufs(buf *[][]byte)
InitMsg
method
#
func (o *operation) InitMsg(p []byte, oob []byte)
IsPollDescriptor
function
#
IsPollDescriptor reports whether fd is the descriptor being used by the poller.
This is only used for testing.
func IsPollDescriptor(fd uintptr) bool
IsPollDescriptor
function
#
IsPollDescriptor reports whether fd is the descriptor being used by the poller.
This is only used for testing.
func IsPollDescriptor(fd uintptr) bool
IsPollDescriptor
function
#
IsPollDescriptor reports whether fd is the descriptor being used by the poller.
This is only used for testing.
IsPollDescriptor should be an internal detail,
but widely used packages access it using linkname.
Notable members of the hall of shame include:
- github.com/opencontainers/runc
Do not remove or change the type signature.
See go.dev/issue/67401.
go:linkname IsPollDescriptor
func IsPollDescriptor(fd uintptr) bool
OpenDir
method
#
OpenDir returns a pointer to a DIR structure suitable for
ReadDir. In case of an error, the name of the failed
syscall is returned along with a syscall.Errno.
func (fd *FD) OpenDir() (uintptr, string, error)
Pread
method
#
Pread emulates the Unix pread system call.
func (fd *FD) Pread(b []byte, off int64) (int, error)
Pread
method
#
Pread wraps the pread system call.
func (fd *FD) Pread(p []byte, off int64) (int, error)
Pwrite
method
#
Pwrite wraps the pwrite system call.
func (fd *FD) Pwrite(p []byte, off int64) (int, error)
Pwrite
method
#
Pwrite emulates the Unix pwrite system call.
func (fd *FD) Pwrite(buf []byte, off int64) (int, error)
RawControl
method
#
RawControl invokes the user-defined function f for a non-IO
operation.
func (fd *FD) RawControl(f func(uintptr)) error
RawControl
method
#
RawControl invokes the user-defined function f for a non-IO
operation.
func (fd *FD) RawControl(f func(uintptr)) error
RawRead
method
#
RawRead invokes the user-defined function f for a read operation.
func (fd *FD) RawRead(f func(uintptr) bool) error
RawRead
method
#
RawRead invokes the user-defined function f for a read operation.
func (fd *FD) RawRead(f func(uintptr) bool) error
RawRead
method
#
RawRead invokes the user-defined function f for a read operation.
func (fd *FD) RawRead(f func(uintptr) bool) error
RawWrite
method
#
RawWrite invokes the user-defined function f for a write operation.
func (fd *FD) RawWrite(f func(uintptr) bool) error
RawWrite
method
#
RawWrite invokes the user-defined function f for a write operation.
func (fd *FD) RawWrite(f func(uintptr) bool) error
RawWrite
method
#
RawWrite invokes the user-defined function f for a write operation.
func (fd *FD) RawWrite(f func(uintptr) bool) error
Read
method
#
Read implements io.Reader.
func (fd *FD) Read(p []byte) (int, error)
Read
method
#
Read implements io.Reader.
func (fd *FD) Read(fn func([]byte) (int, error), b []byte) (int, error)
Read
method
#
Read implements io.Reader.
func (fd *FD) Read(buf []byte) (int, error)
ReadDir
method
#
ReadDir wraps syscall.ReadDir.
We treat this like an ordinary system call rather than a call
that tries to fill the buffer.
func (fd *FD) ReadDir(buf []byte, cookie syscall.Dircookie) (int, error)
ReadDirent
method
#
ReadDirent wraps syscall.ReadDirent.
We treat this like an ordinary system call rather than a call
that tries to fill the buffer.
func (fd *FD) ReadDirent(buf []byte) (int, error)
ReadDirent
method
#
func (fd *FD) ReadDirent(buf []byte) (int, error)
ReadFrom
method
#
ReadFrom wraps the recvfrom network call.
func (fd *FD) ReadFrom(buf []byte) (int, syscall.Sockaddr, error)
ReadFrom
method
#
ReadFrom wraps the recvfrom network call.
func (fd *FD) ReadFrom(p []byte) (int, syscall.Sockaddr, error)
ReadFromInet4
method
#
ReadFromInet4 wraps the recvfrom network call for IPv4.
func (fd *FD) ReadFromInet4(buf []byte, sa4 *syscall.SockaddrInet4) (int, error)
ReadFromInet4
method
#
ReadFromInet4 wraps the recvfrom network call for IPv4.
func (fd *FD) ReadFromInet4(p []byte, from *syscall.SockaddrInet4) (int, error)
ReadFromInet6
method
#
ReadFromInet6 wraps the recvfrom network call for IPv6.
func (fd *FD) ReadFromInet6(p []byte, from *syscall.SockaddrInet6) (int, error)
ReadFromInet6
method
#
ReadFromInet6 wraps the recvfrom network call for IPv6.
func (fd *FD) ReadFromInet6(buf []byte, sa6 *syscall.SockaddrInet6) (int, error)
ReadLock
method
#
func (fdmu *FDMutex) ReadLock() bool
ReadLock
method
#
ReadLock wraps FD.readLock.
func (fd *FD) ReadLock() error
ReadMsg
method
#
ReadMsg wraps the WSARecvMsg network call.
func (fd *FD) ReadMsg(p []byte, oob []byte, flags int) (int, int, int, syscall.Sockaddr, error)
ReadMsg
method
#
ReadMsg wraps the recvmsg network call.
func (fd *FD) ReadMsg(p []byte, oob []byte, flags int) (int, int, int, syscall.Sockaddr, error)
ReadMsgInet4
method
#
ReadMsgInet4 is ReadMsg, but specialized for syscall.SockaddrInet4.
func (fd *FD) ReadMsgInet4(p []byte, oob []byte, flags int, sa4 *syscall.SockaddrInet4) (int, int, int, error)
ReadMsgInet4
method
#
ReadMsgInet4 is ReadMsg, but specialized to return a syscall.SockaddrInet4.
func (fd *FD) ReadMsgInet4(p []byte, oob []byte, flags int, sa4 *syscall.SockaddrInet4) (int, int, int, error)
ReadMsgInet6
method
#
ReadMsgInet6 is ReadMsg, but specialized for syscall.SockaddrInet6.
func (fd *FD) ReadMsgInet6(p []byte, oob []byte, flags int, sa6 *syscall.SockaddrInet6) (int, int, int, error)
ReadMsgInet6
method
#
ReadMsgInet6 is ReadMsg, but specialized to return a syscall.SockaddrInet6.
func (fd *FD) ReadMsgInet6(p []byte, oob []byte, flags int, sa6 *syscall.SockaddrInet6) (int, int, int, error)
ReadUnlock
method
#
ReadUnlock wraps FD.readUnlock.
func (fd *FD) ReadUnlock()
ReadUnlock
method
#
func (fdmu *FDMutex) ReadUnlock() bool
Seek
method
#
Seek wraps syscall.Seek.
func (fd *FD) Seek(offset int64, whence int) (int64, error)
Seek
method
#
Seek wraps syscall.Seek.
func (fd *FD) Seek(offset int64, whence int) (int64, error)
Seek
method
#
Seek wraps syscall.Seek.
func (fd *FD) Seek(offset int64, whence int) (int64, error)
SendFile
function
#
SendFile wraps the TransmitFile call.
func SendFile(fd *FD, src syscall.Handle, n int64) (written int64, err error)
SendFile
function
#
SendFile wraps the sendfile system call.
It copies data from src (a file descriptor) to dstFD,
starting at the current position of src.
It updates the current position of src to after the
copied data.
If size is zero, it copies the rest of src.
Otherwise, it copies up to size bytes.
The handled return parameter indicates whether SendFile
was able to handle some or all of the operation.
If handled is false, sendfile was unable to perform the copy,
has not modified the source or destination,
and the caller should perform the copy using a fallback implementation.
func SendFile(dstFD *FD, src int, size int64) (n int64, err error, handled bool)
SetBlocking
method
#
SetBlocking puts the file into blocking mode.
func (fd *FD) SetBlocking() error
SetDeadline
method
#
SetDeadline sets the read and write deadlines associated with fd.
func (fd *FD) SetDeadline(t time.Time) error
SetDeadline
method
#
SetDeadline sets the read and write deadlines associated with fd.
func (fd *FD) SetDeadline(t time.Time) error
SetDeadline
method
#
SetDeadline sets the read and write deadlines associated with fd.
func (fd *FD) SetDeadline(t time.Time) error
SetReadDeadline
method
#
SetReadDeadline sets the read deadline associated with fd.
func (fd *FD) SetReadDeadline(t time.Time) error
SetReadDeadline
method
#
SetReadDeadline sets the read deadline associated with fd.
func (fd *FD) SetReadDeadline(t time.Time) error
SetReadDeadline
method
#
SetReadDeadline sets the read deadline associated with fd.
func (fd *FD) SetReadDeadline(t time.Time) error
SetWriteDeadline
method
#
SetWriteDeadline sets the write deadline associated with fd.
func (fd *FD) SetWriteDeadline(t time.Time) error
SetWriteDeadline
method
#
SetWriteDeadline sets the write deadline associated with fd.
func (fd *FD) SetWriteDeadline(t time.Time) error
SetWriteDeadline
method
#
SetWriteDeadline sets the write deadline associated with fd.
func (fd *FD) SetWriteDeadline(t time.Time) error
SetsockoptByte
method
#
SetsockoptByte wraps the setsockopt network call with a byte argument.
func (fd *FD) SetsockoptByte(level int, name int, arg byte) error
SetsockoptIPMreq
method
#
SetsockoptIPMreq wraps the setsockopt network call with an IPMreq argument.
func (fd *FD) SetsockoptIPMreq(level int, name int, mreq *syscall.IPMreq) error
SetsockoptIPMreqn
method
#
SetsockoptIPMreqn wraps the setsockopt network call with an IPMreqn argument.
func (fd *FD) SetsockoptIPMreqn(level int, name int, mreq *syscall.IPMreqn) error
SetsockoptIPv6Mreq
method
#
SetsockoptIPv6Mreq wraps the setsockopt network call with an IPv6Mreq argument.
func (fd *FD) SetsockoptIPv6Mreq(level int, name int, mreq *syscall.IPv6Mreq) error
SetsockoptInet4Addr
method
#
SetsockoptInet4Addr wraps the setsockopt network call with an IPv4 address.
func (fd *FD) SetsockoptInet4Addr(level int, name int, arg [4]byte) error
SetsockoptInt
method
#
SetsockoptInt wraps the setsockopt network call with an int argument.
func (fd *FD) SetsockoptInt(level int, name int, arg int) error
SetsockoptLinger
method
#
SetsockoptLinger wraps the setsockopt network call with a Linger argument.
func (fd *FD) SetsockoptLinger(level int, name int, l *syscall.Linger) error
Shutdown
method
#
Shutdown wraps syscall.Shutdown.
func (fd *FD) Shutdown(how int) error
Splice
function
#
Splice transfers at most remain bytes of data from src to dst, using the
splice system call to minimize copies of data from and to userspace.
Splice gets a pipe buffer from the pool or creates a new one if needed, to serve as a buffer for the data transfer.
src and dst must both be stream-oriented sockets.
func Splice(dst *FD, src *FD, remain int64) (written int64, handled bool, err error)
Temporary
method
#
func (e *DeadlineExceededError) Temporary() bool
Temporary
method
#
func (e errNetClosing) Temporary() bool
Timeout
method
#
func (e *DeadlineExceededError) Timeout() bool
Timeout
method
#
func (e errNetClosing) Timeout() bool
WSAIoctl
method
#
WSAIoctl wraps the WSAIoctl network call.
func (fd *FD) WSAIoctl(iocc uint32, inbuf *byte, cbif uint32, outbuf *byte, cbob uint32, cbbr *uint32, overlapped *syscall.Overlapped, completionRoutine uintptr) error
Wait
method
#
Wait for the I/O operation to complete.
func (aio *asyncIO) Wait() (int, error)
WaitWrite
method
#
WaitWrite waits until data can be written to fd.
func (fd *FD) WaitWrite() error
Write
method
#
Write implements io.Writer.
func (fd *FD) Write(fn func([]byte) (int, error), b []byte) (int, error)
Write
method
#
Write implements io.Writer.
func (fd *FD) Write(p []byte) (int, error)
Write
method
#
Write implements io.Writer.
func (fd *FD) Write(buf []byte) (int, error)
WriteLock
method
#
func (fdmu *FDMutex) WriteLock() bool
WriteMsg
method
#
WriteMsg wraps the WSASendMsg network call.
func (fd *FD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (int, int, error)
WriteMsg
method
#
WriteMsg wraps the sendmsg network call.
func (fd *FD) WriteMsg(p []byte, oob []byte, sa syscall.Sockaddr) (int, int, error)
WriteMsgInet4
method
#
WriteMsgInet4 is WriteMsg specialized for syscall.SockaddrInet4.
func (fd *FD) WriteMsgInet4(p []byte, oob []byte, sa *syscall.SockaddrInet4) (int, int, error)
WriteMsgInet4
method
#
WriteMsgInet4 is WriteMsg specialized for syscall.SockaddrInet4.
func (fd *FD) WriteMsgInet4(p []byte, oob []byte, sa *syscall.SockaddrInet4) (int, int, error)
WriteMsgInet6
method
#
WriteMsgInet6 is WriteMsg specialized for syscall.SockaddrInet6.
func (fd *FD) WriteMsgInet6(p []byte, oob []byte, sa *syscall.SockaddrInet6) (int, int, error)
WriteMsgInet6
method
#
WriteMsgInet6 is WriteMsg specialized for syscall.SockaddrInet6.
func (fd *FD) WriteMsgInet6(p []byte, oob []byte, sa *syscall.SockaddrInet6) (int, int, error)
WriteOnce
method
#
WriteOnce is for testing only. It makes a single write call.
func (fd *FD) WriteOnce(p []byte) (int, error)
WriteTo
method
#
WriteTo wraps the sendto network call.
func (fd *FD) WriteTo(buf []byte, sa syscall.Sockaddr) (int, error)
WriteTo
method
#
WriteTo wraps the sendto network call.
func (fd *FD) WriteTo(p []byte, sa syscall.Sockaddr) (int, error)
WriteToInet4
method
#
WriteToInet4 is WriteTo, specialized for syscall.SockaddrInet4.
func (fd *FD) WriteToInet4(buf []byte, sa4 *syscall.SockaddrInet4) (int, error)
WriteToInet4
method
#
WriteToInet4 wraps the sendto network call for IPv4 addresses.
func (fd *FD) WriteToInet4(p []byte, sa *syscall.SockaddrInet4) (int, error)
WriteToInet6
method
#
WriteToInet6 is WriteTo, specialized for syscall.SockaddrInet6.
func (fd *FD) WriteToInet6(buf []byte, sa6 *syscall.SockaddrInet6) (int, error)
WriteToInet6
method
#
WriteToInet6 wraps the sendto network call for IPv6 addresses.
func (fd *FD) WriteToInet6(p []byte, sa *syscall.SockaddrInet6) (int, error)
WriteUnlock
method
#
func (fdmu *FDMutex) WriteUnlock() bool
Writev
method
#
Writev emulates the Unix writev system call.
func (fd *FD) Writev(buf *[][]byte) (int64, error)
Writev
method
#
Writev wraps the writev system call.
func (fd *FD) Writev(v *[][]byte) (int64, error)
accept
function
#
Wrapper around the accept system call that marks the returned file
descriptor as nonblocking and close-on-exec.
func accept(s int) (int, syscall.Sockaddr, string, error)
accept
function
#
Wrapper around the accept system call that marks the returned file
descriptor as nonblocking and close-on-exec.
func accept(s int) (int, syscall.Sockaddr, string, error)
accept
function
#
Wrapper around the accept system call that marks the returned file
descriptor as nonblocking and close-on-exec.
func accept(s int) (int, syscall.Sockaddr, string, error)
acceptOne
method
#
func (fd *FD) acceptOne(s syscall.Handle, rawsa []syscall.RawSockaddrAny, o *operation) (string, error)
checkSetFileCompletionNotificationModes
function
#
checkSetFileCompletionNotificationModes verifies that
SetFileCompletionNotificationModes Windows API is present
on the system and is safe to use.
See https://support.microsoft.com/kb/2568167 for details.
func checkSetFileCompletionNotificationModes()
close
method
#
func (pd *pollDesc) close()
close
method
#
func (pd *pollDesc) close()
consume
function
#
consume removes data from a slice of byte slices, for writev.
func consume(v *[][]byte, n int64)
convertErr
function
#
func convertErr(res int, isFile bool) error
copyFileRange
function
#
copyFileRange performs one round of copy_file_range(2).
func copyFileRange(dst *FD, src *FD, max int) (written int64, err error)
decref
method
#
decref removes a reference from mu.
It reports whether there is no remaining reference.
func (mu *fdMutex) decref() bool
decref
method
#
decref removes a reference from fd.
It also closes fd when the state of fd is set to closed and there
is no remaining reference.
func (fd *FD) decref() error
destroy
method
#
func (s *SysFile) destroy(fd int) error
destroy
method
#
func (fd *FD) destroy() error
destroy
method
#
func (s *SysFile) destroy(fd int) error
destroy
method
#
Destroy closes the file descriptor. This is called when there are
no remaining references.
func (fd *FD) destroy() error
destroy
method
#
We need this to close out a file descriptor when it is unlocked,
but the real implementation has to live in the net package because
it uses os.File's.
func (fd *FD) destroy() error
destroyPipe
function
#
destroyPipe destroys a pipe.
func destroyPipe(p *splicePipe)
direntNamlen
function
#
func direntNamlen(buf []byte) (uint64, bool)
direntNext
function
#
func direntNext(buf []byte) (uint64, bool)
direntReclen
function
#
func direntReclen(buf []byte) (uint64, bool)
dupCloseOnExecOld
function
#
dupCloseOnExecOld is the traditional way to dup an fd and
set its O_CLOEXEC bit, using two system calls.
func dupCloseOnExecOld(fd int) (int, string, error)
dupCloseOnExecOld
function
#
dupCloseOnExecOld always errors on wasip1 because there is no mechanism to
duplicate file descriptors.
func dupCloseOnExecOld(fd int) (int, string, error)
eofError
method
#
eofError returns io.EOF when fd is available for reading end of
file.
func (fd *FD) eofError(n int, err error) error
errClosing
function
#
Return the appropriate closing error based on isFile.
func errClosing(isFile bool) error
errnoErr
function
#
errnoErr returns common boxed Errno values, to prevent
allocations at runtime.
func errnoErr(e syscall.Errno) error
errnoErr
function
#
errnoErr returns common boxed Errno values, to prevent
allocations at runtime.
func errnoErr(e syscall.Errno) error
evict
method
#
func (pd *pollDesc) evict()
evict
method
#
Evict evicts fd from the pending list, unblocking any I/O running on fd.
func (pd *pollDesc) evict()
execIO
function
#
execIO executes a single IO operation o. It submits and cancels
IO in the current thread for systems where Windows CancelIoEx API
is available. Alternatively, it passes the request onto
runtime netpoll and waits for completion or cancels request.
func execIO(o *operation, submit func(o *operation) error) (int, error)
fdopendir
function
#
Implemented in syscall/syscall_darwin.go.
go:linkname fdopendir syscall.fdopendir
func fdopendir(fd int) (dir uintptr, err error)
getPipe
function
#
getPipe tries to acquire a pipe buffer from the pool or create a new one with newPipe() if it gets nil from the cache.
func getPipe() (*splicePipe, error)
handleCopyFileRangeErr
function
#
func handleCopyFileRangeErr(err error, copied int64, written int64) (bool, error)
handleCopyFileRangeErr
function
#
func handleCopyFileRangeErr(err error, copied int64, written int64) (bool, 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)
ignoringEINTRIO
function
#
ignoringEINTRIO is like ignoringEINTR, but just for IO calls.
func ignoringEINTRIO(fn func(fd int, p []byte) (int, error), fd int, p []byte) (int, error)
incref
method
#
incref adds a reference to mu.
It reports whether mu is available for reading or writing.
func (mu *fdMutex) incref() bool
incref
method
#
incref adds a reference to fd.
It returns an error when fd cannot be used.
func (fd *FD) incref() error
increfAndClose
method
#
increfAndClose sets the state of mu to closed.
It returns false if the file was already closed.
func (mu *fdMutex) increfAndClose() bool
init
method
#
func (pd *pollDesc) init(fd *FD) error
init
method
#
func (pd *pollDesc) init(fd *FD) error
init
method
#
func (s *SysFile) init()
init
method
#
func (s *SysFile) init()
isHangup
function
#
func isHangup(err error) bool
isInterrupted
function
#
func isInterrupted(err error) bool
newAsyncIO
function
#
newAsyncIO returns a new asyncIO that performs an I/O
operation by calling fn, which must do one and only one
interruptible system call.
func newAsyncIO(fn func([]byte) (int, error), b []byte) *asyncIO
newIovecWithBase
function
#
func newIovecWithBase(base *byte) syscall.Iovec
newIovecWithBase
function
#
func newIovecWithBase(base *byte) syscall.Iovec
newPipe
function
#
newPipe sets up a pipe for a splice operation.
func newPipe() *splicePipe
newPoolPipe
function
#
func newPoolPipe() any
pollable
method
#
func (pd *pollDesc) pollable() bool
pollable
method
#
func (pd *pollDesc) pollable() bool
prepare
method
#
func (pd *pollDesc) prepare(mode int, isFile bool) error
prepare
method
#
func (pd *pollDesc) prepare(mode int, isFile bool) error
prepareRead
method
#
func (pd *pollDesc) prepareRead(isFile bool) error
prepareRead
method
#
func (pd *pollDesc) prepareRead(isFile bool) error
prepareWrite
method
#
func (pd *pollDesc) prepareWrite(isFile bool) error
prepareWrite
method
#
func (pd *pollDesc) prepareWrite(isFile bool) error
putPipe
function
#
func putPipe(p *splicePipe)
rawToSockaddrInet4
function
#
func rawToSockaddrInet4(rsa *syscall.RawSockaddrAny, sa *syscall.SockaddrInet4)
rawToSockaddrInet6
function
#
func rawToSockaddrInet6(rsa *syscall.RawSockaddrAny, sa *syscall.SockaddrInet6)
readConsole
method
#
readConsole reads utf16 characters from console File,
encodes them into utf8 and stores them in buffer b.
It returns the number of utf8 bytes read and an error, if any.
func (fd *FD) readConsole(b []byte) (int, 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)
readIntLE
function
#
func readIntLE(b []byte, size uintptr) uint64
readLock
method
#
readLock adds a reference to fd and locks fd for reading.
It returns an error when fd cannot be used for reading.
func (fd *FD) readLock() error
readUnlock
method
#
readUnlock removes a reference from fd and unlocks fd for reading.
It also closes fd when the state of fd is set to closed and there
is no remaining reference.
func (fd *FD) readUnlock()
ref
method
#
func (s *SysFile) ref() SysFile
runtimeNano
function
#
runtimeNano returns the current value of the runtime clock in nanoseconds.
go:linkname runtimeNano runtime.nanotime
func runtimeNano() int64
runtime_Semacquire
function
#
Implemented in runtime package.
func runtime_Semacquire(sema *uint32)
runtime_Semrelease
function
#
func runtime_Semrelease(sema *uint32)
runtime_ignoreHangup
function
#
The following functions, provided by the runtime, are used to
ignore and unignore the "hangup" signal received by the process.
func runtime_ignoreHangup()
runtime_isPollServerDescriptor
function
#
func runtime_isPollServerDescriptor(fd uintptr) bool
runtime_pollClose
function
#
func runtime_pollClose(ctx uintptr)
runtime_pollOpen
function
#
func runtime_pollOpen(fd uintptr) (uintptr, int)
runtime_pollReset
function
#
func runtime_pollReset(ctx uintptr, mode int) int
runtime_pollServerInit
function
#
func runtime_pollServerInit()
runtime_pollSetDeadline
function
#
func runtime_pollSetDeadline(ctx uintptr, d int64, mode int)
runtime_pollUnblock
function
#
func runtime_pollUnblock(ctx uintptr)
runtime_pollWait
function
#
func runtime_pollWait(ctx uintptr, mode int) int
runtime_pollWaitCanceled
function
#
func runtime_pollWaitCanceled(ctx uintptr, mode int)
runtime_unignoreHangup
function
#
func runtime_unignoreHangup()
rwlock
method
#
lock adds a reference to mu and locks mu.
It reports whether mu is available for reading or writing.
func (mu *fdMutex) rwlock(read bool) bool
rwunlock
method
#
unlock removes a reference from mu and unlocks mu.
It reports whether there is no remaining reference.
func (mu *fdMutex) rwunlock(read bool) bool
sendFile
function
#
sendFile wraps the sendfile system call.
func sendFile(dstFD *FD, src int, offset *int64, size int64) (written int64, err error, handled bool)
sendFileChunk
function
#
func sendFileChunk(dst int, src int, offset *int64, size int, written int64) (n int, err error)
setDeadlineImpl
function
#
func setDeadlineImpl(fd *FD, t time.Time, mode int) error
setDeadlineImpl
function
#
func setDeadlineImpl(fd *FD, t time.Time, mode int) error
setDeadlineImpl
function
#
func setDeadlineImpl(fd *FD, t time.Time, mode int) error
sockaddrInet4ToRaw
function
#
func sockaddrInet4ToRaw(rsa *syscall.RawSockaddrAny, sa *syscall.SockaddrInet4) int32
sockaddrInet6ToRaw
function
#
func sockaddrInet6ToRaw(rsa *syscall.RawSockaddrAny, sa *syscall.SockaddrInet6) int32
sockaddrToRaw
function
#
func sockaddrToRaw(rsa *syscall.RawSockaddrAny, sa syscall.Sockaddr) (int32, error)
splice
function
#
splice wraps the splice system call. Since the current implementation
only uses splice on sockets and pipes, the offset arguments are unused.
splice returns int instead of int64, because callers never ask it to
move more data in a single call than can fit in an int32.
func splice(out int, in int, max int, flags int) (int, error)
spliceDrain
function
#
spliceDrain moves data from a socket to a pipe.
Invariant: when entering spliceDrain, the pipe is empty. It is either in its
initial state, or splicePump has emptied it previously.
Given this, spliceDrain can reasonably assume that the pipe is ready for
writing, so if splice returns EAGAIN, it must be because the socket is not
ready for reading.
If spliceDrain returns (0, nil), src is at EOF.
func spliceDrain(pipefd int, sock *FD, max int) (int, error)
splicePump
function
#
splicePump moves all the buffered data from a pipe to a socket.
Invariant: when entering splicePump, there are exactly inPipe
bytes of data in the pipe, from a previous call to spliceDrain.
By analogy to the condition from spliceDrain, splicePump
only needs to poll the socket for readiness, if splice returns
EAGAIN.
If splicePump cannot move all the data in a single call to
splice(2), it loops over the buffered data until it has written
all of it to the socket. This behavior is similar to the Write
step of an io.Copy in userspace.
func splicePump(sock *FD, pipefd int, inPipe int) (int, error)
supportCopyFileRange
function
#
func supportCopyFileRange() bool
supportCopyFileRange
function
#
func supportCopyFileRange() bool
wait
method
#
func (pd *pollDesc) wait(mode int, isFile bool) error
wait
method
#
func (pd *pollDesc) wait(mode int, isFile bool) error
waitCanceled
method
#
func (pd *pollDesc) waitCanceled(mode int)
waitCanceled
method
#
func (pd *pollDesc) waitCanceled(mode int)
waitRead
method
#
func (pd *pollDesc) waitRead(isFile bool) error
waitRead
method
#
func (pd *pollDesc) waitRead(isFile bool) error
waitWrite
method
#
func (pd *pollDesc) waitWrite(isFile bool) error
waitWrite
method
#
func (pd *pollDesc) waitWrite(isFile bool) error
writeConsole
method
#
writeConsole writes len(b) bytes to the console File.
It returns the number of bytes written and an error, if any.
func (fd *FD) writeConsole(b []byte) (int, error)
writeLock
method
#
writeLock adds a reference to fd and locks fd for writing.
It returns an error when fd cannot be used for writing.
func (fd *FD) writeLock() error
writeUnlock
method
#
writeUnlock removes a reference from fd and unlocks fd for writing.
It also closes fd when the state of fd is set to closed and there
is no remaining reference.
func (fd *FD) writeUnlock()
writev
function
#
func writev(fd int, iovecs []syscall.Iovec) (uintptr, error)
writev
function
#
go:linkname writev syscall.writev
func writev(fd int, iovecs []syscall.Iovec) (uintptr, error)