host

package
v0.0.0-...-ff2c174 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 9, 2021 License: Apache-2.0, MIT Imports: 35 Imported by: 0

Documentation

Overview

Package host supports file descriptors imported directly.

Index

Constants

View Source
const FilesystemName = "host"

FilesystemName is the name under which the filesystem is registered.

Variables

View Source
var NulByte byte = '\x00'

NulByte is a single NUL byte. It is passed to readlinkat as an empty string.

Functions

func ImportFile

func ImportFile(ctx context.Context, fd int, isTTY bool) (*fs.File, error)

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

func NewFile(ctx context.Context, fd int) (*fs.File, error)

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()

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) StateFields

func (c *ConnectedEndpoint) StateFields() []string

func (*ConnectedEndpoint) StateLoad

func (c *ConnectedEndpoint) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*ConnectedEndpoint) StateSave

func (c *ConnectedEndpoint) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*ConnectedEndpoint) StateTypeName

func (c *ConnectedEndpoint) StateTypeName() string

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

func (f *TTYFileOperations) EventRegister(e *waiter.Entry, mask waiter.EventMask)

EventRegister implements waiter.Waitable.EventRegister.

func (*TTYFileOperations) EventUnregister

func (f *TTYFileOperations) EventUnregister(e *waiter.Entry)

EventUnregister implements waiter.Waitable.EventUnregister.

func (*TTYFileOperations) Flush

func (f *TTYFileOperations) Flush(context.Context, *fs.File) error

Flush implements fs.FileOperations.Flush.

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

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

func (f *TTYFileOperations) Readiness(mask waiter.EventMask) waiter.EventMask

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.

func (*TTYFileOperations) Seek

func (f *TTYFileOperations) Seek(ctx context.Context, file *fs.File, whence fs.SeekWhence, offset int64) (int64, error)

Seek implements fs.FileOperations.Seek.

func (*TTYFileOperations) StateFields

func (t *TTYFileOperations) StateFields() []string

func (*TTYFileOperations) StateLoad

func (t *TTYFileOperations) StateLoad(stateSourceObject state.Source)

+checklocksignore

func (*TTYFileOperations) StateSave

func (t *TTYFileOperations) StateSave(stateSinkObject state.Sink)

+checklocksignore

func (*TTYFileOperations) StateTypeName

func (t *TTYFileOperations) StateTypeName() string

func (*TTYFileOperations) Write

func (t *TTYFileOperations) Write(ctx context.Context, file *fs.File, src usermem.IOSequence, offset int64) (int64, error)

Write implements fs.FileOperations.Write.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL