Documentation ¶
Overview ¶
Package pipe provides a pipe implementation.
Index ¶
- Constants
- func NewConnectedPipe(ctx context.Context, sizeBytes, atomicIOBytes int64) (*fs.File, *fs.File)
- func NewInodeOperations(ctx context.Context, perms fs.FilePermissions, p *Pipe) *inodeOperations
- 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) Readiness(mask waiter.EventMask) waiter.EventMask
- func (p *Pipe) Release()
- 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 Reader
- 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) 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
- type VFSPipeFD
- func (fd *VFSPipeFD) Ioctl(ctx context.Context, uio usermem.IO, args arch.SyscallArguments) (uintptr, error)
- func (fd *VFSPipeFD) OnClose(_ context.Context) error
- func (fd *VFSPipeFD) PRead(_ context.Context, _ usermem.IOSequence, _ int64, _ vfs.ReadOptions) (int64, error)
- func (fd *VFSPipeFD) PWrite(_ context.Context, _ usermem.IOSequence, _ int64, _ vfs.WriteOptions) (int64, error)
- func (fd *VFSPipeFD) Read(ctx context.Context, dst usermem.IOSequence, _ vfs.ReadOptions) (int64, error)
- func (fd *VFSPipeFD) Release()
- func (fd *VFSPipeFD) Write(ctx context.Context, src usermem.IOSequence, _ vfs.WriteOptions) (int64, error)
- type Writer
Constants ¶
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 ¶
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 NewPipe ¶
NewPipe initializes and returns a pipe.
N.B. The size and atomicIOBytes will be bounded.
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) SetFifoSize ¶
SetFifoSize implements fs.FifoSizer.SetFifoSize.
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
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.
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 ¶
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) PRead ¶
func (fd *VFSPipeFD) PRead(_ context.Context, _ usermem.IOSequence, _ int64, _ vfs.ReadOptions) (int64, error)
PRead implements vfs.FileDescriptionImpl.PRead.
func (*VFSPipeFD) PWrite ¶
func (fd *VFSPipeFD) PWrite(_ context.Context, _ usermem.IOSequence, _ int64, _ vfs.WriteOptions) (int64, error)
PWrite implements vfs.FileDescriptionImpl.PWrite.
func (*VFSPipeFD) Read ¶
func (fd *VFSPipeFD) Read(ctx context.Context, dst usermem.IOSequence, _ vfs.ReadOptions) (int64, error)
Read implements vfs.FileDescriptionImpl.Read.
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