pipe

package
v0.0.0-...-522126a Latest Latest
Warning

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

Go to latest
Published: Dec 23, 2019 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Overview

Package pipe provides a pipe implementation.

Index

Constants

View Source
const (
	// MinimumPipeSize is a hard limit of the minimum size of a pipe.
	MinimumPipeSize = 64 << 10

	// DefaultPipeSize is the system-wide default size of a pipe in bytes.
	DefaultPipeSize = MinimumPipeSize

	// MaximumPipeSize is a hard limit on the maximum size of a pipe.
	MaximumPipeSize = 8 << 20
)

Variables

This section is empty.

Functions

func NewConnectedPipe

func NewConnectedPipe(ctx context.Context, sizeBytes, atomicIOBytes int64) (*fs.File, *fs.File)

NewConnectedPipe initializes a pipe and returns a pair of objects representing the read and write ends of the pipe.

func NewInodeOperations

func NewInodeOperations(ctx context.Context, perms fs.FilePermissions, p *Pipe) *inodeOperations

NewInodeOperations returns a new fs.InodeOperations for a given pipe.

Types

type Pipe

type Pipe struct {
	waiter.Queue `state:"nosave"`
	// contains filtered or unexported fields
}

Pipe is an encapsulation of a platform-independent pipe. It manages a buffered byte queue shared between a reader/writer pair.

+stateify savable

func NewPipe

func NewPipe(isNamed bool, sizeBytes, atomicIOBytes int64) *Pipe

NewPipe initializes and returns a pipe.

N.B. The size and atomicIOBytes will be bounded.

func (*Pipe) FifoSize

func (p *Pipe) FifoSize(context.Context, *fs.File) (int64, error)

FifoSize implements fs.FifoSizer.FifoSize.

func (*Pipe) HasReaders

func (p *Pipe) HasReaders() bool

HasReaders returns whether the pipe has any active readers.

func (*Pipe) HasWriters

func (p *Pipe) HasWriters() bool

HasWriters returns whether the pipe has any active writers.

func (*Pipe) Ioctl

func (p *Pipe) Ioctl(ctx context.Context, io usermem.IO, args arch.SyscallArguments) (uintptr, error)

Ioctl implements ioctls on the Pipe.

func (*Pipe) Open

func (p *Pipe) Open(ctx context.Context, d *fs.Dirent, flags fs.FileFlags) *fs.File

Open opens the pipe and returns a new file.

Precondition: at least one of flags.Read or flags.Write must be set.

func (*Pipe) Read

func (p *Pipe) Read(ctx context.Context, dst usermem.IOSequence) (int64, error)

Read reads from the Pipe into dst.

func (*Pipe) ReadFrom

func (p *Pipe) ReadFrom(ctx context.Context, r io.Reader, count int64) (int64, error)

ReadFrom reads from r to the Pipe.

func (*Pipe) Readiness

func (p *Pipe) Readiness(mask waiter.EventMask) waiter.EventMask

Readiness returns the ready events in the underlying pipe.

func (*Pipe) Release

func (p *Pipe) Release()

Release cleans up the pipe's state.

func (*Pipe) SetFifoSize

func (p *Pipe) SetFifoSize(size int64) (int64, error)

SetFifoSize implements fs.FifoSizer.SetFifoSize.

func (*Pipe) Write

func (p *Pipe) Write(ctx context.Context, src usermem.IOSequence) (int64, error)

Write writes to the Pipe from src.

func (*Pipe) WriteTo

func (p *Pipe) WriteTo(ctx context.Context, w io.Writer, count int64, dup bool) (int64, error)

WriteTo writes to w from the Pipe.

type Reader

type Reader struct {
	ReaderWriter
}

Reader satisfies the fs.FileOperations interface for read-only pipes. Reader should be used with !fs.FileFlags.Write to reject writes.

+stateify savable

func (*Reader) Readiness

func (r *Reader) Readiness(mask waiter.EventMask) waiter.EventMask

Readiness returns the ready events in the underlying pipe.

func (*Reader) Release

func (r *Reader) Release()

Release implements fs.FileOperations.Release.

This overrides ReaderWriter.Release.

type ReaderWriter

type ReaderWriter struct {
	fsutil.FilePipeSeek             `state:"nosave"`
	fsutil.FileNotDirReaddir        `state:"nosave"`
	fsutil.FileNoFsync              `state:"nosave"`
	fsutil.FileNoMMap               `state:"nosave"`
	fsutil.FileNoSplice             `state:"nosave"`
	fsutil.FileNoopFlush            `state:"nosave"`
	fsutil.FileUseInodeUnstableAttr `state:"nosave"`
	*Pipe
}

ReaderWriter satisfies the FileOperations interface and services both read and write requests. This should only be used directly for named pipes. pipe(2) and pipe2(2) only support unidirectional pipes and should use either pipe.Reader or pipe.Writer.

+stateify savable

func (*ReaderWriter) Ioctl

func (rw *ReaderWriter) Ioctl(ctx context.Context, _ *fs.File, io usermem.IO, args arch.SyscallArguments) (uintptr, error)

Ioctl implements fs.FileOperations.Ioctl.

func (*ReaderWriter) Read

func (rw *ReaderWriter) Read(ctx context.Context, _ *fs.File, dst usermem.IOSequence, _ int64) (int64, error)

Read implements fs.FileOperations.Read.

func (*ReaderWriter) ReadFrom

func (rw *ReaderWriter) ReadFrom(ctx context.Context, _ *fs.File, r io.Reader, count int64) (int64, error)

ReadFrom implements fs.FileOperations.WriteTo.

func (*ReaderWriter) Write

func (rw *ReaderWriter) Write(ctx context.Context, _ *fs.File, src usermem.IOSequence, _ int64) (int64, error)

Write implements fs.FileOperations.Write.

func (*ReaderWriter) WriteTo

func (rw *ReaderWriter) WriteTo(ctx context.Context, _ *fs.File, w io.Writer, count int64, dup bool) (int64, error)

WriteTo implements fs.FileOperations.WriteTo.

type VFSPipe

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

VFSPipe represents the actual pipe, analagous to an inode. VFSPipes should not be copied.

func NewVFSPipe

func NewVFSPipe(sizeBytes, atomicIOBytes int64) *VFSPipe

NewVFSPipe returns an initialized VFSPipe.

func (*VFSPipe) NewVFSPipeFD

func (vp *VFSPipe) NewVFSPipeFD(ctx context.Context, rp *vfs.ResolvingPath, vfsd *vfs.Dentry, vfsfd *vfs.FileDescription, flags uint32) (*VFSPipeFD, error)

NewVFSPipeFD opens a named pipe. Named pipes have special blocking semantics during open:

"Normally, opening the FIFO blocks until the other end is opened also. A process can open a FIFO in nonblocking mode. In this case, opening for read-only will succeed even if no-one has opened on the write side yet, opening for write-only will fail with ENXIO (no such device or address) unless the other end has already been opened. Under Linux, opening a FIFO for read and write will succeed both in blocking and nonblocking mode. POSIX leaves this behavior undefined. This can be used to open a FIFO for writing while there are no readers available." - fifo(7)

type VFSPipeFD

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

VFSPipeFD implements a subset of vfs.FileDescriptionImpl for pipes. It is expected that filesystesm will use this in a struct implementing vfs.FileDescriptionImpl.

func (*VFSPipeFD) Ioctl

func (fd *VFSPipeFD) Ioctl(ctx context.Context, uio usermem.IO, args arch.SyscallArguments) (uintptr, error)

Ioctl implements vfs.FileDescriptionImpl.Ioctl.

func (*VFSPipeFD) OnClose

func (fd *VFSPipeFD) OnClose(_ context.Context) error

OnClose implements vfs.FileDescriptionImpl.OnClose.

func (*VFSPipeFD) PRead

PRead implements vfs.FileDescriptionImpl.PRead.

func (*VFSPipeFD) PWrite

PWrite implements vfs.FileDescriptionImpl.PWrite.

func (*VFSPipeFD) Read

Read implements vfs.FileDescriptionImpl.Read.

func (*VFSPipeFD) Release

func (fd *VFSPipeFD) Release()

Release implements vfs.FileDescriptionImpl.Release.

func (*VFSPipeFD) Write

Write implements vfs.FileDescriptionImpl.Write.

type Writer

type Writer struct {
	ReaderWriter
}

Writer satisfies the fs.FileOperations interface for write-only pipes. Writer should be used with !fs.FileFlags.Read to reject reads.

+stateify savable

func (*Writer) Readiness

func (w *Writer) Readiness(mask waiter.EventMask) waiter.EventMask

Readiness returns the ready events in the underlying pipe.

func (*Writer) Release

func (w *Writer) Release()

Release implements fs.FileOperations.Release.

This overrides ReaderWriter.Release.

Jump to

Keyboard shortcuts

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