Documentation ¶
Overview ¶
Package pipe provides a pipe implementation.
Index ¶
- Constants
- func Splice(ctx context.Context, dst, src *VFSPipeFD, count int64) (int64, error)
- func Tee(ctx context.Context, dst, src *VFSPipeFD, count int64) (int64, error)
- type Pipe
- func (p *Pipe) EventRegister(e *waiter.Entry) error
- func (p *Pipe) EventUnregister(e *waiter.Entry)
- func (p *Pipe) HasReaders() bool
- func (p *Pipe) HasWriters() bool
- func (p *Pipe) Ioctl(ctx context.Context, io usermem.IO, sysno uintptr, args arch.SyscallArguments) (uintptr, error)
- func (p *Pipe) Read(ctx context.Context, dst usermem.IOSequence) (int64, error)
- func (p *Pipe) ReadFrom(ctx context.Context, r io.Reader, count int64) (int64, error)
- func (p *Pipe) Readiness(mask waiter.EventMask) waiter.EventMask
- func (p *Pipe) Release(context.Context)
- func (p *Pipe) SetFifoSize(size int64) (int64, error)
- func (p *Pipe) Write(ctx context.Context, src usermem.IOSequence) (int64, error)
- func (p *Pipe) WriteTo(ctx context.Context, w io.Writer, count int64, dup bool) (int64, error)
- type VFSPipe
- func (*VFSPipe) Allocate(context.Context, uint64, uint64, uint64) error
- func (vp *VFSPipe) Open(ctx context.Context, mnt *vfs.Mount, vfsd *vfs.Dentry, statusFlags uint32, ...) (*vfs.FileDescription, error)
- func (vp *VFSPipe) ReaderWriterPair(ctx context.Context, mnt *vfs.Mount, vfsd *vfs.Dentry, statusFlags uint32) (*vfs.FileDescription, *vfs.FileDescription, error)
- type VFSPipeFD
- func (fd *VFSPipeFD) Allocate(ctx context.Context, mode, offset, length uint64) error
- func (fd *VFSPipeFD) CompareAndSwapUint32(ctx context.Context, addr hostarch.Addr, old, new uint32, opts usermem.IOOpts) (uint32, error)
- func (fd *VFSPipeFD) CopyIn(ctx context.Context, addr hostarch.Addr, dst []byte, opts usermem.IOOpts) (int, error)
- func (fd *VFSPipeFD) CopyInTo(ctx context.Context, ars hostarch.AddrRangeSeq, dst safemem.Writer, ...) (int64, error)
- func (fd *VFSPipeFD) CopyOut(ctx context.Context, addr hostarch.Addr, src []byte, opts usermem.IOOpts) (int, error)
- func (fd *VFSPipeFD) CopyOutFrom(ctx context.Context, ars hostarch.AddrRangeSeq, src safemem.Reader, ...) (int64, error)
- func (fd *VFSPipeFD) Epollable() bool
- func (fd *VFSPipeFD) EventRegister(e *waiter.Entry) error
- func (fd *VFSPipeFD) EventUnregister(e *waiter.Entry)
- func (fd *VFSPipeFD) Ioctl(ctx context.Context, uio usermem.IO, sysno uintptr, args arch.SyscallArguments) (uintptr, error)
- func (fd *VFSPipeFD) LoadUint32(ctx context.Context, addr hostarch.Addr, opts usermem.IOOpts) (uint32, error)
- func (fd *VFSPipeFD) PipeSize() int64
- func (fd *VFSPipeFD) Read(ctx context.Context, dst usermem.IOSequence, _ vfs.ReadOptions) (int64, error)
- func (fd *VFSPipeFD) Readiness(mask waiter.EventMask) waiter.EventMask
- func (fd *VFSPipeFD) Release(context.Context)
- func (fd *VFSPipeFD) SetPipeSize(size int64) (int64, error)
- func (fd *VFSPipeFD) SpliceFromNonPipe(ctx context.Context, in *vfs.FileDescription, off, count int64) (int64, error)
- func (fd *VFSPipeFD) SpliceToNonPipe(ctx context.Context, out *vfs.FileDescription, off, count int64) (int64, error)
- func (fd *VFSPipeFD) SwapUint32(ctx context.Context, addr hostarch.Addr, new uint32, opts usermem.IOOpts) (uint32, error)
- func (fd *VFSPipeFD) Write(ctx context.Context, src usermem.IOSequence, _ vfs.WriteOptions) (int64, error)
- func (fd *VFSPipeFD) ZeroOut(ctx context.Context, addr hostarch.Addr, toZero int64, opts usermem.IOOpts) (int64, error)
Constants ¶
const ( // MinimumPipeSize is a hard limit of the minimum size of a pipe. // It corresponds to fs/pipe.c:pipe_min_size. MinimumPipeSize = hostarch.PageSize // MaximumPipeSize is a hard limit on the maximum size of a pipe. // It corresponds to fs/pipe.c:pipe_max_size. MaximumPipeSize = 1048576 // DefaultPipeSize is the system-wide default size of a pipe in bytes. // It corresponds to pipe_fs_i.h:PIPE_DEF_BUFFERS. DefaultPipeSize = 16 * hostarch.PageSize )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Pipe ¶
type Pipe struct {
// 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 (*Pipe) EventRegister ¶
EventRegister implements waiter.Waitable.EventRegister.
func (*Pipe) EventUnregister ¶
EventUnregister implements waiter.Waitable.EventUnregister.
func (*Pipe) HasReaders ¶
HasReaders returns whether the pipe has any active readers.
func (*Pipe) HasWriters ¶
HasWriters returns whether the pipe has any active writers.
func (*Pipe) Ioctl ¶
func (p *Pipe) Ioctl(ctx context.Context, io usermem.IO, sysno uintptr, args arch.SyscallArguments) (uintptr, error)
Ioctl implements ioctls on the Pipe.
func (*Pipe) SetFifoSize ¶
SetFifoSize implements fs.FifoSizer.SetFifoSize.
type VFSPipe ¶
type VFSPipe struct {
// contains filtered or unexported fields
}
VFSPipe represents the actual pipe, analogous to an inode. VFSPipes should not be copied.
+stateify savable
func NewVFSPipe ¶
NewVFSPipe returns an initialized VFSPipe.
func (*VFSPipe) Open ¶
func (vp *VFSPipe) Open(ctx context.Context, mnt *vfs.Mount, vfsd *vfs.Dentry, statusFlags uint32, locks *vfs.FileLocks) (*vfs.FileDescription, error)
Open opens the pipe represented by vp.
func (*VFSPipe) ReaderWriterPair ¶
func (vp *VFSPipe) ReaderWriterPair(ctx context.Context, mnt *vfs.Mount, vfsd *vfs.Dentry, statusFlags uint32) (*vfs.FileDescription, *vfs.FileDescription, error)
ReaderWriterPair returns read-only and write-only FDs for vp.
Preconditions: statusFlags should not contain an open access mode.
type VFSPipeFD ¶
type VFSPipeFD struct { vfs.FileDescriptionDefaultImpl vfs.DentryMetadataFileDescriptionImpl vfs.LockFD // contains filtered or unexported fields }
VFSPipeFD implements vfs.FileDescriptionImpl for pipes. It also implements non-atomic usermem.IO methods, allowing it to be passed as usermem.IO to other FileDescriptions for splice(2) and tee(2).
+stateify savable
func (*VFSPipeFD) CompareAndSwapUint32 ¶
func (fd *VFSPipeFD) CompareAndSwapUint32(ctx context.Context, addr hostarch.Addr, old, new uint32, opts usermem.IOOpts) (uint32, error)
CompareAndSwapUint32 implements usermem.IO.CompareAndSwapUint32.
func (*VFSPipeFD) CopyIn ¶
func (fd *VFSPipeFD) CopyIn(ctx context.Context, addr hostarch.Addr, dst []byte, opts usermem.IOOpts) (int, error)
CopyIn implements usermem.IO.CopyIn. Note that it is the caller's responsibility to call fd.pipe.Notify(waiter.WritableEvents) after the read is completed.
Preconditions: fd.pipe.mu must be locked.
func (*VFSPipeFD) CopyInTo ¶
func (fd *VFSPipeFD) CopyInTo(ctx context.Context, ars hostarch.AddrRangeSeq, dst safemem.Writer, opts usermem.IOOpts) (int64, error)
CopyInTo implements usermem.IO.CopyInTo. Note that it is the caller's responsibility to call fd.pipe.consumeLocked() and fd.pipe.queue.Notify(waiter.WritableEvents) after the read is completed.
Preconditions: fd.pipe.mu must be locked.
func (*VFSPipeFD) CopyOut ¶
func (fd *VFSPipeFD) CopyOut(ctx context.Context, addr hostarch.Addr, src []byte, opts usermem.IOOpts) (int, error)
CopyOut implements usermem.IO.CopyOut. Note that it is the caller's responsibility to call fd.pipe.queue.Notify(waiter.ReadableEvents) after the write is completed.
Preconditions: fd.pipe.mu must be locked.
func (*VFSPipeFD) CopyOutFrom ¶
func (fd *VFSPipeFD) CopyOutFrom(ctx context.Context, ars hostarch.AddrRangeSeq, src safemem.Reader, opts usermem.IOOpts) (int64, error)
CopyOutFrom implements usermem.IO.CopyOutFrom. Note that it is the caller's responsibility to call fd.pipe.queue.Notify(waiter.ReadableEvents) after the write is completed.
Preconditions: fd.pipe.mu must be locked.
func (*VFSPipeFD) EventRegister ¶
EventRegister implements waiter.Waitable.EventRegister.
func (*VFSPipeFD) EventUnregister ¶
EventUnregister implements waiter.Waitable.EventUnregister.
func (*VFSPipeFD) Ioctl ¶
func (fd *VFSPipeFD) Ioctl(ctx context.Context, uio usermem.IO, sysno uintptr, args arch.SyscallArguments) (uintptr, error)
Ioctl implements vfs.FileDescriptionImpl.Ioctl.
func (*VFSPipeFD) LoadUint32 ¶
func (fd *VFSPipeFD) LoadUint32(ctx context.Context, addr hostarch.Addr, opts usermem.IOOpts) (uint32, error)
LoadUint32 implements usermem.IO.LoadUint32.
func (*VFSPipeFD) Read ¶
func (fd *VFSPipeFD) Read(ctx context.Context, dst usermem.IOSequence, _ vfs.ReadOptions) (int64, error)
Read implements vfs.FileDescriptionImpl.Read.
func (*VFSPipeFD) SetPipeSize ¶
SetPipeSize implements fcntl(F_SETPIPE_SZ).
func (*VFSPipeFD) SpliceFromNonPipe ¶
func (fd *VFSPipeFD) SpliceFromNonPipe(ctx context.Context, in *vfs.FileDescription, off, count int64) (int64, error)
SpliceFromNonPipe performs a splice operation from a non-pipe file to fd.
func (*VFSPipeFD) SpliceToNonPipe ¶
func (fd *VFSPipeFD) SpliceToNonPipe(ctx context.Context, out *vfs.FileDescription, off, count int64) (int64, error)
SpliceToNonPipe performs a splice operation from fd to a non-pipe file.
func (*VFSPipeFD) SwapUint32 ¶
func (fd *VFSPipeFD) SwapUint32(ctx context.Context, addr hostarch.Addr, new uint32, opts usermem.IOOpts) (uint32, error)
SwapUint32 implements usermem.IO.SwapUint32.