host

package
v0.0.0-...-a858404 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: Apache-2.0, MIT Imports: 31 Imported by: 0

Documentation

Overview

Package host provides a filesystem implementation for host files imported as file descriptors.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewFD

func NewFD(ctx context.Context, mnt *vfs.Mount, hostFD int, opts *NewFDOptions) (*vfs.FileDescription, error)

NewFD returns a vfs.FileDescription representing the given host file descriptor. mnt must be Kernel.HostMount().

func NewFilesystem

func NewFilesystem(vfsObj *vfs.VirtualFilesystem) (*vfs.Filesystem, error)

NewFilesystem sets up and returns a new hostfs filesystem.

Note that there should only ever be one instance of host.filesystem, a global mount for host fds.

Types

type NewFDOptions

type NewFDOptions struct {
	// If Savable is true, the host file descriptor may be saved/restored by
	// numeric value; the sandbox API requires a corresponding host FD with the
	// same numeric value to be provided at time of restore.
	Savable bool

	// If IsTTY is true, the file descriptor is a TTY.
	IsTTY bool

	// If HaveFlags is true, use Flags for the new file description. Otherwise,
	// the new file description will inherit flags from hostFD.
	HaveFlags bool
	Flags     uint32

	// VirtualOwner allow the host file to have owner and permissions different
	// than the underlying host file.
	VirtualOwner bool
	UID          auth.KUID
	GID          auth.KGID

	// If Readonly is true, we disallow operations that can potentially change
	// the host file associated with the file descriptor.
	Readonly bool
}

NewFDOptions contains options to NewFD.

type TTYFileDescription

type TTYFileDescription struct {
	// contains filtered or unexported fields
}

TTYFileDescription implements vfs.FileDescriptionImpl for a host file descriptor that wraps a TTY FD.

+stateify savable

func (*TTYFileDescription) Allocate

func (f *TTYFileDescription) Allocate(ctx context.Context, mode, offset, length uint64) error

Allocate implements vfs.FileDescriptionImpl.Allocate.

func (*TTYFileDescription) ConfigureMMap

func (f *TTYFileDescription) ConfigureMMap(_ context.Context, opts *memmap.MMapOpts) error

ConfigureMMap implements vfs.FileDescriptionImpl.ConfigureMMap.

func (*TTYFileDescription) Epollable

func (f *TTYFileDescription) Epollable() bool

Epollable implements FileDescriptionImpl.Epollable.

func (*TTYFileDescription) EventRegister

func (f *TTYFileDescription) EventRegister(e *waiter.Entry) error

EventRegister implements waiter.Waitable.EventRegister.

func (*TTYFileDescription) EventUnregister

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

EventUnregister implements waiter.Waitable.EventUnregister.

func (*TTYFileDescription) ForegroundProcessGroup

func (t *TTYFileDescription) ForegroundProcessGroup() *kernel.ProcessGroup

ForegroundProcessGroup returns the foreground process for the TTY.

func (*TTYFileDescription) InitForegroundProcessGroup

func (t *TTYFileDescription) 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 (*TTYFileDescription) Ioctl

Ioctl implements vfs.FileDescriptionImpl.Ioctl.

func (*TTYFileDescription) PRead

func (t *TTYFileDescription) PRead(ctx context.Context, dst usermem.IOSequence, offset int64, opts vfs.ReadOptions) (int64, error)

PRead implements vfs.FileDescriptionImpl.PRead.

Reading from a TTY is only allowed for foreground process groups. Background process groups will either get EIO or a SIGTTIN.

func (*TTYFileDescription) PWrite

func (t *TTYFileDescription) PWrite(ctx context.Context, src usermem.IOSequence, offset int64, opts vfs.WriteOptions) (int64, error)

PWrite implements vfs.FileDescriptionImpl.PWrite.

func (*TTYFileDescription) Read

Read implements vfs.FileDescriptionImpl.Read.

Reading from a TTY is only allowed for foreground process groups. Background process groups will either get EIO or a SIGTTIN.

func (*TTYFileDescription) Readiness

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

Readiness uses the poll() syscall to check the status of the underlying FD.

func (*TTYFileDescription) Release

func (t *TTYFileDescription) Release(ctx context.Context)

Release implements fs.FileOperations.Release.

func (*TTYFileDescription) Seek

func (f *TTYFileDescription) Seek(_ context.Context, offset int64, whence int32) (int64, error)

Seek implements vfs.FileDescriptionImpl.Seek.

Note that we do not support seeking on directories, since we do not even allow directory fds to be imported at all.

func (*TTYFileDescription) SetStat

func (f *TTYFileDescription) SetStat(ctx context.Context, opts vfs.SetStatOptions) error

SetStat implements vfs.FileDescriptionImpl.SetStat.

func (*TTYFileDescription) Stat

func (f *TTYFileDescription) Stat(ctx context.Context, opts vfs.StatOptions) (linux.Statx, error)

Stat implements vfs.FileDescriptionImpl.Stat.

func (*TTYFileDescription) StateFields

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

func (*TTYFileDescription) StateLoad

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

+checklocksignore

func (*TTYFileDescription) StateSave

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

+checklocksignore

func (*TTYFileDescription) StateTypeName

func (t *TTYFileDescription) StateTypeName() string

func (*TTYFileDescription) Sync

func (f *TTYFileDescription) Sync(ctx context.Context) error

Sync implements vfs.FileDescriptionImpl.Sync.

func (*TTYFileDescription) Write

Write implements vfs.FileDescriptionImpl.Write.

Jump to

Keyboard shortcuts

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