Documentation ¶
Overview ¶
Package pipe provides a pipe implementation.
Index ¶
- Constants
- func NewConnectedPipe(ctx context.Context, sizeBytes int64) (*fs.File, *fs.File)
- func NewInodeOperations(ctx context.Context, perms fs.FilePermissions, p *Pipe) *inodeOperations
- 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) FifoSize(context.Context, *fs.File) (int64, error)
- func (p *Pipe) HasReaders() bool
- func (p *Pipe) HasWriters() bool
- func (p *Pipe) Ioctl(ctx context.Context, io usermem.IO, args arch.SyscallArguments) (uintptr, error)
- func (p *Pipe) Open(ctx context.Context, d *fs.Dirent, flags fs.FileFlags) *fs.File
- 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) ReadToBlocks(dsts safemem.BlockSeq) (uint64, 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) StateFields() []string
- func (p *Pipe) StateLoad(stateSourceObject state.Source)
- func (p *Pipe) StateSave(stateSinkObject state.Sink)
- func (p *Pipe) StateTypeName() string
- func (p *Pipe) Write(ctx context.Context, src usermem.IOSequence) (int64, error)
- func (p *Pipe) WriteFromBlocks(srcs safemem.BlockSeq) (uint64, error)
- func (p *Pipe) WriteTo(ctx context.Context, w io.Writer, count int64, dup bool) (int64, error)
- type Reader
- func (r *Reader) Readiness(mask waiter.EventMask) waiter.EventMask
- func (r *Reader) Release(context.Context)
- func (r *Reader) StateFields() []string
- func (r *Reader) StateLoad(stateSourceObject state.Source)
- func (r *Reader) StateSave(stateSinkObject state.Sink)
- func (r *Reader) StateTypeName() string
- type ReaderWriter
- func (rw *ReaderWriter) Ioctl(ctx context.Context, _ *fs.File, io usermem.IO, args arch.SyscallArguments) (uintptr, error)
- func (rw *ReaderWriter) Read(ctx context.Context, _ *fs.File, dst usermem.IOSequence, _ int64) (int64, error)
- func (rw *ReaderWriter) ReadFrom(ctx context.Context, _ *fs.File, r io.Reader, count int64) (int64, error)
- func (rw *ReaderWriter) StateFields() []string
- func (rw *ReaderWriter) StateLoad(stateSourceObject state.Source)
- func (rw *ReaderWriter) StateSave(stateSinkObject state.Sink)
- func (rw *ReaderWriter) StateTypeName() string
- func (rw *ReaderWriter) Write(ctx context.Context, _ *fs.File, src usermem.IOSequence, _ int64) (int64, error)
- func (rw *ReaderWriter) WriteTo(ctx context.Context, _ *fs.File, 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)
- func (vp *VFSPipe) StateFields() []string
- func (vp *VFSPipe) StateLoad(stateSourceObject state.Source)
- func (vp *VFSPipe) StateSave(stateSinkObject state.Sink)
- func (vp *VFSPipe) StateTypeName() string
- type VFSPipeFD
- func (fd *VFSPipeFD) Allocate(ctx context.Context, mode, offset, length uint64) error
- func (fd *VFSPipeFD) CompareAndSwapUint32(ctx context.Context, addr usermem.Addr, old, new uint32, opts usermem.IOOpts) (uint32, error)
- func (fd *VFSPipeFD) CopyIn(ctx context.Context, addr usermem.Addr, dst []byte, opts usermem.IOOpts) (int, error)
- func (fd *VFSPipeFD) CopyInTo(ctx context.Context, ars usermem.AddrRangeSeq, dst safemem.Writer, ...) (int64, error)
- func (fd *VFSPipeFD) CopyOut(ctx context.Context, addr usermem.Addr, src []byte, opts usermem.IOOpts) (int, error)
- func (fd *VFSPipeFD) CopyOutFrom(ctx context.Context, ars usermem.AddrRangeSeq, src safemem.Reader, ...) (int64, error)
- func (fd *VFSPipeFD) EventRegister(e *waiter.Entry, mask waiter.EventMask)
- func (fd *VFSPipeFD) EventUnregister(e *waiter.Entry)
- func (fd *VFSPipeFD) Ioctl(ctx context.Context, uio usermem.IO, args arch.SyscallArguments) (uintptr, error)
- func (fd *VFSPipeFD) LoadUint32(ctx context.Context, addr usermem.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) StateFields() []string
- func (fd *VFSPipeFD) StateLoad(stateSourceObject state.Source)
- func (fd *VFSPipeFD) StateSave(stateSinkObject state.Sink)
- func (fd *VFSPipeFD) StateTypeName() string
- func (fd *VFSPipeFD) SwapUint32(ctx context.Context, addr usermem.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 usermem.Addr, toZero int64, opts usermem.IOOpts) (int64, error)
- type Writer
- func (w *Writer) Readiness(mask waiter.EventMask) waiter.EventMask
- func (w *Writer) Release(context.Context)
- func (w *Writer) StateFields() []string
- func (w *Writer) StateLoad(stateSourceObject state.Source)
- func (w *Writer) StateSave(stateSinkObject state.Sink)
- func (w *Writer) StateTypeName() string
Constants ¶
const ( // MinimumPipeSize is a hard limit of the minimum size of a pipe. // It corresponds to fs/pipe.c:pipe_min_size. MinimumPipeSize = usermem.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 * usermem.PageSize )
Variables ¶
This section is empty.
Functions ¶
func NewConnectedPipe ¶
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 ¶
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) 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, args arch.SyscallArguments) (uintptr, error)
Ioctl implements ioctls on the Pipe.
func (*Pipe) Open ¶
Open opens the pipe and returns a new file.
Precondition: at least one of flags.Read or flags.Write must be set.
func (*Pipe) ReadToBlocks ¶
ReadToBlocks implements safemem.Reader.ReadToBlocks for Pipe.Read.
func (*Pipe) SetFifoSize ¶
SetFifoSize implements fs.FifoSizer.SetFifoSize.
func (*Pipe) StateFields ¶
func (*Pipe) StateTypeName ¶
func (*Pipe) WriteFromBlocks ¶
WriteFromBlocks implements safemem.Writer.WriteFromBlocks for Pipe.Write.
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) Release ¶
Release implements fs.FileOperations.Release.
This overrides ReaderWriter.Release.
func (*Reader) StateFields ¶
func (*Reader) StateTypeName ¶
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) StateFields ¶
func (rw *ReaderWriter) StateFields() []string
func (*ReaderWriter) StateLoad ¶
func (rw *ReaderWriter) StateLoad(stateSourceObject state.Source)
func (*ReaderWriter) StateSave ¶
func (rw *ReaderWriter) StateSave(stateSinkObject state.Sink)
func (*ReaderWriter) StateTypeName ¶
func (rw *ReaderWriter) StateTypeName() string
type VFSPipe ¶
type VFSPipe struct {
// contains filtered or unexported fields
}
VFSPipe represents the actual pipe, analagous 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.
func (*VFSPipe) StateFields ¶
func (*VFSPipe) StateTypeName ¶
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 usermem.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 usermem.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.consumeLocked() and fd.pipe.Notify(waiter.EventOut) after the read is completed.
Preconditions: fd.pipe.mu must be locked.
func (*VFSPipeFD) CopyInTo ¶
func (fd *VFSPipeFD) CopyInTo(ctx context.Context, ars usermem.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.Notify(waiter.EventOut) after the read is completed.
Preconditions: fd.pipe.mu must be locked.
func (*VFSPipeFD) CopyOut ¶
func (fd *VFSPipeFD) CopyOut(ctx context.Context, addr usermem.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.Notify(waiter.EventIn) after the write is completed.
Preconditions: fd.pipe.mu must be locked.
func (*VFSPipeFD) CopyOutFrom ¶
func (fd *VFSPipeFD) CopyOutFrom(ctx context.Context, ars usermem.AddrRangeSeq, src safemem.Reader, opts usermem.IOOpts) (int64, error)
CopyOutFrom implements usermem.IO.CopyOutFrom.
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, args arch.SyscallArguments) (uintptr, error)
Ioctl implements vfs.FileDescriptionImpl.Ioctl.
func (*VFSPipeFD) LoadUint32 ¶
func (fd *VFSPipeFD) LoadUint32(ctx context.Context, addr usermem.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) StateFields ¶
func (*VFSPipeFD) StateTypeName ¶
func (*VFSPipeFD) SwapUint32 ¶
func (fd *VFSPipeFD) SwapUint32(ctx context.Context, addr usermem.Addr, new uint32, opts usermem.IOOpts) (uint32, error)
SwapUint32 implements usermem.IO.SwapUint32.
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) Release ¶
Release implements fs.FileOperations.Release.
This overrides ReaderWriter.Release.