Documentation ¶
Overview ¶
Package host supports file descriptors imported directly.
Index ¶
- Constants
- Variables
- func ImportFile(ctx context.Context, fd int, isTTY bool) (*fs.File, error)
- func NewFile(ctx context.Context, fd int) (*fs.File, error)
- func NewSocketWithDirent(ctx context.Context, d *fs.Dirent, f *fd.FD, flags fs.FileFlags) (*fs.File, error)
- type ConnectedEndpoint
- func (c *ConnectedEndpoint) CloseNotify()
- func (c *ConnectedEndpoint) CloseRecv()
- func (c *ConnectedEndpoint) CloseSend()
- func (c *ConnectedEndpoint) CloseUnread()
- func (c *ConnectedEndpoint) EventUpdate() error
- func (c *ConnectedEndpoint) GetLocalAddress() (tcpip.FullAddress, tcpip.Error)
- func (c *ConnectedEndpoint) Init()
- func (c *ConnectedEndpoint) Passcred() bool
- func (c *ConnectedEndpoint) Readable() bool
- func (c *ConnectedEndpoint) Recv(ctx context.Context, data [][]byte, creds bool, numRights int, peek bool) (int64, int64, transport.ControlMessages, bool, tcpip.FullAddress, bool, ...)
- func (c *ConnectedEndpoint) RecvMaxQueueSize() int64
- func (c *ConnectedEndpoint) RecvNotify()
- func (c *ConnectedEndpoint) RecvQueuedSize() int64
- func (c *ConnectedEndpoint) Release(ctx context.Context)
- func (c *ConnectedEndpoint) Send(ctx context.Context, data [][]byte, controlMessages transport.ControlMessages, ...) (int64, bool, *syserr.Error)
- func (c *ConnectedEndpoint) SendMaxQueueSize() int64
- func (c *ConnectedEndpoint) SendNotify()
- func (c *ConnectedEndpoint) SendQueuedSize() int64
- func (c *ConnectedEndpoint) SetReceiveBufferSize(v int64) (newSz int64)
- func (c *ConnectedEndpoint) SetSendBufferSize(v int64) (newSz int64)
- func (c *ConnectedEndpoint) Writable() bool
- type TTYFileOperations
- func (f *TTYFileOperations) ConfigureMMap(ctx context.Context, file *fs.File, opts *memmap.MMapOpts) error
- func (f *TTYFileOperations) EventRegister(e *waiter.Entry) error
- func (f *TTYFileOperations) EventUnregister(e *waiter.Entry)
- func (f *TTYFileOperations) Flush(context.Context, *fs.File) error
- func (t *TTYFileOperations) ForegroundProcessGroup() *kernel.ProcessGroup
- func (f *TTYFileOperations) Fsync(ctx context.Context, file *fs.File, start int64, end int64, ...) error
- func (t *TTYFileOperations) InitForegroundProcessGroup(pg *kernel.ProcessGroup)
- func (t *TTYFileOperations) Ioctl(ctx context.Context, _ *fs.File, io usermem.IO, args arch.SyscallArguments) (uintptr, error)
- func (f *TTYFileOperations) IterateDir(ctx context.Context, d *fs.Dirent, dirCtx *fs.DirCtx, offset int) (int, error)
- func (t *TTYFileOperations) Read(ctx context.Context, file *fs.File, dst usermem.IOSequence, offset int64) (int64, error)
- func (f *TTYFileOperations) Readdir(ctx context.Context, file *fs.File, serializer fs.DentrySerializer) (int64, error)
- func (f *TTYFileOperations) Readiness(mask waiter.EventMask) waiter.EventMask
- func (t *TTYFileOperations) Release(ctx context.Context)
- func (f *TTYFileOperations) Seek(ctx context.Context, file *fs.File, whence fs.SeekWhence, offset int64) (int64, error)
- func (t *TTYFileOperations) Write(ctx context.Context, file *fs.File, src usermem.IOSequence, offset int64) (int64, error)
Constants ¶
const FilesystemName = "host"
FilesystemName is the name under which the filesystem is registered.
Variables ¶
var NulByte byte = '\x00'
NulByte is a single NUL byte. It is passed to readlinkat as an empty string.
Functions ¶
func ImportFile ¶
ImportFile creates a new File backed by the provided host file descriptor. Unlike NewFile, the file descriptor used by the File is duped from FD to ensure that later changes to FD are not reflected by the fs.File.
If the returned file is saved, it will be restored by re-importing the FD originally passed to ImportFile. It is the restorer's responsibility to ensure that the FD represents the same file.
func NewFile ¶
NewFile creates a new File backed by the provided host file descriptor. If NewFile succeeds, ownership of the FD is transferred to the returned File.
The returned File cannot be saved, since there is no guarantee that the same FD will exist or represent the same file at time of restore. If such a guarantee does exist, use ImportFile instead.
func NewSocketWithDirent ¶
func NewSocketWithDirent(ctx context.Context, d *fs.Dirent, f *fd.FD, flags fs.FileFlags) (*fs.File, error)
NewSocketWithDirent allocates a new unix socket with host endpoint.
This is currently only used by unsaveable Gofer nodes.
NewSocketWithDirent takes ownership of f on success.
Types ¶
type ConnectedEndpoint ¶
type ConnectedEndpoint struct {
// contains filtered or unexported fields
}
ConnectedEndpoint is a host FD backed implementation of transport.ConnectedEndpoint and transport.Receiver.
+stateify savable
func NewConnectedEndpoint ¶
func NewConnectedEndpoint(ctx context.Context, file *fd.FD, queue *waiter.Queue, path string) (*ConnectedEndpoint, *syserr.Error)
NewConnectedEndpoint creates a new ConnectedEndpoint backed by a host FD that will pretend to be bound at a given sentry path.
The caller is responsible for calling Init(). Additionaly, Release needs to be called twice because ConnectedEndpoint is both a transport.Receiver and transport.ConnectedEndpoint.
func (*ConnectedEndpoint) CloseNotify ¶
func (c *ConnectedEndpoint) CloseNotify()
CloseNotify implements transport.ConnectedEndpoint.CloseNotify.
func (*ConnectedEndpoint) CloseRecv ¶
func (c *ConnectedEndpoint) CloseRecv()
CloseRecv implements transport.Receiver.CloseRecv.
func (*ConnectedEndpoint) CloseSend ¶
func (c *ConnectedEndpoint) CloseSend()
CloseSend implements transport.ConnectedEndpoint.CloseSend.
func (*ConnectedEndpoint) CloseUnread ¶
func (c *ConnectedEndpoint) CloseUnread()
CloseUnread implements transport.ConnectedEndpoint.CloseUnread.
func (*ConnectedEndpoint) EventUpdate ¶
func (c *ConnectedEndpoint) EventUpdate() error
EventUpdate implements transport.ConnectedEndpoint.EventUpdate.
func (*ConnectedEndpoint) GetLocalAddress ¶
func (c *ConnectedEndpoint) GetLocalAddress() (tcpip.FullAddress, tcpip.Error)
GetLocalAddress implements transport.ConnectedEndpoint.GetLocalAddress.
func (*ConnectedEndpoint) Init ¶
func (c *ConnectedEndpoint) Init()
Init will do initialization required without holding other locks.
func (*ConnectedEndpoint) Passcred ¶
func (c *ConnectedEndpoint) Passcred() bool
Passcred implements transport.ConnectedEndpoint.Passcred.
func (*ConnectedEndpoint) Readable ¶
func (c *ConnectedEndpoint) Readable() bool
Readable implements transport.Receiver.Readable.
func (*ConnectedEndpoint) Recv ¶
func (c *ConnectedEndpoint) Recv(ctx context.Context, data [][]byte, creds bool, numRights int, peek bool) (int64, int64, transport.ControlMessages, bool, tcpip.FullAddress, bool, *syserr.Error)
Recv implements transport.Receiver.Recv.
func (*ConnectedEndpoint) RecvMaxQueueSize ¶
func (c *ConnectedEndpoint) RecvMaxQueueSize() int64
RecvMaxQueueSize implements transport.Receiver.RecvMaxQueueSize.
func (*ConnectedEndpoint) RecvNotify ¶
func (c *ConnectedEndpoint) RecvNotify()
RecvNotify implements transport.Receiver.RecvNotify.
func (*ConnectedEndpoint) RecvQueuedSize ¶
func (c *ConnectedEndpoint) RecvQueuedSize() int64
RecvQueuedSize implements transport.Receiver.RecvQueuedSize.
func (*ConnectedEndpoint) Release ¶
func (c *ConnectedEndpoint) Release(ctx context.Context)
Release implements transport.ConnectedEndpoint.Release and transport.Receiver.Release.
func (*ConnectedEndpoint) Send ¶
func (c *ConnectedEndpoint) Send(ctx context.Context, data [][]byte, controlMessages transport.ControlMessages, from tcpip.FullAddress) (int64, bool, *syserr.Error)
Send implements transport.ConnectedEndpoint.Send.
func (*ConnectedEndpoint) SendMaxQueueSize ¶
func (c *ConnectedEndpoint) SendMaxQueueSize() int64
SendMaxQueueSize implements transport.Receiver.SendMaxQueueSize.
func (*ConnectedEndpoint) SendNotify ¶
func (c *ConnectedEndpoint) SendNotify()
SendNotify implements transport.ConnectedEndpoint.SendNotify.
func (*ConnectedEndpoint) SendQueuedSize ¶
func (c *ConnectedEndpoint) SendQueuedSize() int64
SendQueuedSize implements transport.Receiver.SendQueuedSize.
func (*ConnectedEndpoint) SetReceiveBufferSize ¶
func (c *ConnectedEndpoint) SetReceiveBufferSize(v int64) (newSz int64)
SetReceiveBufferSize implements transport.ConnectedEndpoint.SetReceiveBufferSize.
func (*ConnectedEndpoint) SetSendBufferSize ¶
func (c *ConnectedEndpoint) SetSendBufferSize(v int64) (newSz int64)
SetSendBufferSize implements transport.ConnectedEndpoint.SetSendBufferSize.
func (*ConnectedEndpoint) Writable ¶
func (c *ConnectedEndpoint) Writable() bool
Writable implements transport.ConnectedEndpoint.Writable.
type TTYFileOperations ¶
type TTYFileOperations struct {
// contains filtered or unexported fields
}
TTYFileOperations implements fs.FileOperations for a host file descriptor that wraps a TTY FD.
+stateify savable
func (*TTYFileOperations) ConfigureMMap ¶
func (f *TTYFileOperations) ConfigureMMap(ctx context.Context, file *fs.File, opts *memmap.MMapOpts) error
ConfigureMMap implements fs.FileOperations.ConfigureMMap.
func (*TTYFileOperations) EventRegister ¶
EventRegister implements waiter.Waitable.EventRegister.
func (*TTYFileOperations) EventUnregister ¶
EventUnregister implements waiter.Waitable.EventUnregister.
func (*TTYFileOperations) ForegroundProcessGroup ¶
func (t *TTYFileOperations) ForegroundProcessGroup() *kernel.ProcessGroup
ForegroundProcessGroup returns the foreground process for the TTY.
func (*TTYFileOperations) Fsync ¶
func (f *TTYFileOperations) Fsync(ctx context.Context, file *fs.File, start int64, end int64, syncType fs.SyncType) error
Fsync implements fs.FileOperations.Fsync.
func (*TTYFileOperations) InitForegroundProcessGroup ¶
func (t *TTYFileOperations) InitForegroundProcessGroup(pg *kernel.ProcessGroup)
InitForegroundProcessGroup sets the foreground process group and session for the TTY. This should only be called once, after the foreground process group has been created, but before it has started running.
func (*TTYFileOperations) Ioctl ¶
func (t *TTYFileOperations) Ioctl(ctx context.Context, _ *fs.File, io usermem.IO, args arch.SyscallArguments) (uintptr, error)
Ioctl implements fs.FileOperations.Ioctl.
func (*TTYFileOperations) IterateDir ¶
func (f *TTYFileOperations) IterateDir(ctx context.Context, d *fs.Dirent, dirCtx *fs.DirCtx, offset int) (int, error)
IterateDir implements fs.DirIterator.IterateDir.
func (*TTYFileOperations) Read ¶
func (t *TTYFileOperations) Read(ctx context.Context, file *fs.File, dst usermem.IOSequence, offset int64) (int64, error)
Read implements fs.FileOperations.Read.
Reading from a TTY is only allowed for foreground process groups. Background process groups will either get EIO or a SIGTTIN.
See drivers/tty/n_tty.c:n_tty_read()=>job_control().
func (*TTYFileOperations) Readdir ¶
func (f *TTYFileOperations) Readdir(ctx context.Context, file *fs.File, serializer fs.DentrySerializer) (int64, error)
Readdir implements fs.FileOperations.Readdir.
func (*TTYFileOperations) Readiness ¶
Readiness uses the poll() syscall to check the status of the underlying FD.
func (*TTYFileOperations) Release ¶
func (t *TTYFileOperations) Release(ctx context.Context)
Release implements fs.FileOperations.Release.