host

package
v0.0.0-...-a3e5887 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: Apache-2.0, MIT Imports: 30 Imported by: 15

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 MakeRestoreID

func MakeRestoreID(containerName string, fd int) vfs.RestoreID

MakeRestoreID creates a RestoreID for a given application FD. The application FD remains the same between restores, e.g. stdout=2 before and after restore, but the host FD that is maps to can change between restores. This ID is used to map application FDs to their respective FD after a restore happens.

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. RestoreKey is used to map the FD after restore.
	Savable bool

	// RestoreKey is only used when Savable==true. It uniquely identifies the
	// host FD so that a mapping to the corresponding FD can be provided during
	// restore.
	RestoreKey vfs.RestoreID

	// 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.

It implements kernel.TTYOperations.

+stateify savable

func NewTTYFileDescription

func NewTTYFileDescription(i *inode) *TTYFileDescription

NewTTYFileDescription returns a new TTYFileDescription.

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

Ioctl implements vfs.FileDescriptionImpl.Ioctl.

func (*TTYFileDescription) Open

Open re-opens the tty fd, for example via open(/dev/tty). See Linux's tty_repoen().

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

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

Sync implements vfs.FileDescriptionImpl.Sync.

func (*TTYFileDescription) TTY

func (t *TTYFileDescription) TTY() *kernel.TTY

TTY returns the kernel.TTY.

func (*TTYFileDescription) ThreadGroup

func (t *TTYFileDescription) ThreadGroup() *kernel.ThreadGroup

ThreadGroup returns the kernel.ThreadGroup associated with this tty.

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