Documentation
¶
Overview ¶
Package pipe provides an in-memory implementation of a unidirectional pipe.
The goal of this pipe is to emulate the pipe syscall in all of its edge cases and guarantees of atomic IO.
Index ¶
- Constants
- func NewConnectedPipe(ctx context.Context, sizeBytes int, atomicIOBytes int) (*fs.File, *fs.File)
- func NewInodeOperations(base fs.InodeOperations, p *Pipe) fs.InodeOperations
- type Buffer
- type Pipe
- type Reader
- type ReaderWriter
- func (rw *ReaderWriter) Ioctl(ctx context.Context, 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) Readiness(mask waiter.EventMask) waiter.EventMask
- func (rw *ReaderWriter) Release()
- func (rw *ReaderWriter) Write(ctx context.Context, _ *fs.File, src usermem.IOSequence, _ int64) (int64, error)
- type Writer
Constants ¶
const DefaultPipeSize = 65536
DefaultPipeSize is the system-wide default size of a pipe in bytes.
Variables ¶
This section is empty.
Functions ¶
func NewConnectedPipe ¶
NewConnectedPipe initializes a pipe and returns a pair of objects (which implement kio.File) representing the read and write ends of the pipe. A pipe created by this function becomes invalid as soon as either the read or write end is closed, and errors on subsequent operations on either end. Pipes for pipe(2) and pipe2(2) are generally created this way.
func NewInodeOperations ¶
func NewInodeOperations(base fs.InodeOperations, p *Pipe) fs.InodeOperations
NewInodeOperations creates a new pipe fs.InodeOperations.
Types ¶
type Buffer ¶
Buffer encapsulates a queueable byte buffer that can easily be truncated. It is designed only for use with pipes.
type Pipe ¶
Pipe is an encapsulation of a platform-independent pipe. It manages a buffered byte queue shared between a reader/writer pair.
func NewPipe ¶
NewPipe initializes and returns a pipe. A pipe created by this function is persistent, and will remain valid even without any open fds to it. Named pipes for mknod(2) are created via this function. Note that the implementation of blocking semantics for opening the read and write ends of a named pipe are left to filesystems.
func (*Pipe) HasReaders ¶
HasReaders returns whether the pipe has any active readers.
func (*Pipe) HasWriters ¶
HasWriters returns whether the pipe has any active writers.
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.
type ReaderWriter ¶
type ReaderWriter struct { fsutil.PipeSeek `state:"nosave"` fsutil.NotDirReaddir `state:"nosave"` fsutil.NoFsync `state:"nosave"` fsutil.NoopFlush `state:"nosave"` fsutil.NoMMap `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.
func (*ReaderWriter) Ioctl ¶
func (rw *ReaderWriter) Ioctl(ctx context.Context, 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) Readiness ¶
func (rw *ReaderWriter) Readiness(mask waiter.EventMask) waiter.EventMask
Readiness returns the ready events in the underlying pipe.
func (*ReaderWriter) Release ¶
func (rw *ReaderWriter) Release()
Release implements fs.FileOperations.Release.
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.