Documentation ¶
Overview ¶
Package host provides a filesystem implementation for host files imported as file descriptors.
Index ¶
- func MakeRestoreID(containerName string, fd int) vfs.RestoreID
- func NewFD(ctx context.Context, mnt *vfs.Mount, hostFD int, opts *NewFDOptions) (*vfs.FileDescription, error)
- func NewFilesystem(vfsObj *vfs.VirtualFilesystem) (*vfs.Filesystem, error)
- type NewFDOptions
- type TTYFileDescription
- func (f *TTYFileDescription) Allocate(ctx context.Context, mode, offset, length uint64) error
- func (f *TTYFileDescription) ConfigureMMap(_ context.Context, opts *memmap.MMapOpts) error
- func (f *TTYFileDescription) Epollable() bool
- func (f *TTYFileDescription) EventRegister(e *waiter.Entry) error
- func (f *TTYFileDescription) EventUnregister(e *waiter.Entry)
- func (t *TTYFileDescription) ForegroundProcessGroup() *kernel.ProcessGroup
- func (t *TTYFileDescription) InitForegroundProcessGroup(pg *kernel.ProcessGroup)
- func (t *TTYFileDescription) Ioctl(ctx context.Context, io usermem.IO, sysno uintptr, args arch.SyscallArguments) (uintptr, error)
- func (t *TTYFileDescription) PRead(ctx context.Context, dst usermem.IOSequence, offset int64, ...) (int64, error)
- func (t *TTYFileDescription) PWrite(ctx context.Context, src usermem.IOSequence, offset int64, ...) (int64, error)
- func (t *TTYFileDescription) Read(ctx context.Context, dst usermem.IOSequence, opts vfs.ReadOptions) (int64, error)
- func (f *TTYFileDescription) Readiness(mask waiter.EventMask) waiter.EventMask
- func (t *TTYFileDescription) Release(ctx context.Context)
- func (f *TTYFileDescription) Seek(_ context.Context, offset int64, whence int32) (int64, error)
- func (f *TTYFileDescription) SetStat(ctx context.Context, opts vfs.SetStatOptions) error
- func (f *TTYFileDescription) Stat(ctx context.Context, opts vfs.StatOptions) (linux.Statx, error)
- func (f *TTYFileDescription) Sync(ctx context.Context) error
- func (t *TTYFileDescription) Write(ctx context.Context, src usermem.IOSequence, opts vfs.WriteOptions) (int64, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeRestoreID ¶
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.
+stateify savable
func (*TTYFileDescription) ConfigureMMap ¶
ConfigureMMap implements vfs.FileDescriptionImpl.ConfigureMMap.
func (*TTYFileDescription) Epollable ¶
func (f *TTYFileDescription) Epollable() bool
Epollable implements FileDescriptionImpl.Epollable.
func (*TTYFileDescription) EventRegister ¶
EventRegister implements waiter.Waitable.EventRegister.
func (*TTYFileDescription) EventUnregister ¶
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 ¶
func (t *TTYFileDescription) Ioctl(ctx context.Context, io usermem.IO, sysno uintptr, args arch.SyscallArguments) (uintptr, error)
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 ¶
func (t *TTYFileDescription) Read(ctx context.Context, dst usermem.IOSequence, opts vfs.ReadOptions) (int64, error)
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 ¶
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 ¶
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) Write ¶
func (t *TTYFileDescription) Write(ctx context.Context, src usermem.IOSequence, opts vfs.WriteOptions) (int64, error)
Write implements vfs.FileDescriptionImpl.Write.