buffer

package
Version: v0.0.0-...-83118d4 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2017 License: Apache-2.0, BSD-2-Clause, BSD-3-Clause, HPND Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const MaxReadSize = 1 << 17

The maximum read size that we expect to ever see from the kernel, used for calculating the size of out messages.

For 4 KiB pages, this is 128 KiB (cf. https://goo.gl/HOiEYo)

View Source
const MaxWriteSize = 1 << 17

The maximum fuse write request size that InMessage can acommodate.

Experimentally, Linux appears to refuse to honor a MaxWrite setting in an INIT response of more than 128 KiB.

View Source
const OutMessageHeaderSize = int(unsafe.Sizeof(fusekernel.OutHeader{}))

OutMessageHeaderSize is the size of the leading header in every properly-constructed OutMessage. Reset brings the message back to this size.

Variables

This section is empty.

Functions

This section is empty.

Types

type InMessage

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

An incoming message from the kernel, including leading fusekernel.InHeader struct. Provides storage for messages and convenient access to their contents.

func (*InMessage) Consume

func (m *InMessage) Consume(n uintptr) (p unsafe.Pointer)

Consume the next n bytes from the message, returning a nil pointer if there are fewer than n bytes available.

func (*InMessage) ConsumeBytes

func (m *InMessage) ConsumeBytes(n uintptr) (b []byte)

Equivalent to Consume, except returns a slice of bytes. The result will be nil if Consume would fail.

func (*InMessage) Header

func (m *InMessage) Header() (h *fusekernel.InHeader)

Return a reference to the header read in the most recent call to Init.

func (*InMessage) Init

func (m *InMessage) Init(r io.Reader) (err error)

Initialize with the data read by a single call to r.Read. The first call to Consume will consume the bytes directly after the fusekernel.InHeader struct.

func (*InMessage) Len

func (m *InMessage) Len() uintptr

Return the number of bytes left to consume.

type OutMessage

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

OutMessage provides a mechanism for constructing a single contiguous fuse message from multiple segments, where the first segment is always a fusekernel.OutHeader message.

Must be initialized with Reset.

func (*OutMessage) Append

func (m *OutMessage) Append(src []byte)

Append is equivalent to growing by len(src), then copying src over the new segment. Int panics if there is not enough room available.

func (*OutMessage) AppendString

func (m *OutMessage) AppendString(src string)

AppendString is like Append, but accepts string input.

func (*OutMessage) Bytes

func (m *OutMessage) Bytes() []byte

Bytes returns a reference to the current contents of the buffer, including the leading header.

func (*OutMessage) Grow

func (m *OutMessage) Grow(n int) (p unsafe.Pointer)

Grow grows m's buffer by the given number of bytes, returning a pointer to the start of the new segment, which is guaranteed to be zeroed. If there is insufficient space, it returns nil.

func (*OutMessage) GrowNoZero

func (m *OutMessage) GrowNoZero(n int) (p unsafe.Pointer)

GrowNoZero is equivalent to Grow, except the new segment is not zeroed. Use with caution!

func (*OutMessage) Len

func (m *OutMessage) Len() int

Len returns the current size of the message, including the leading header.

func (*OutMessage) OutHeader

func (m *OutMessage) OutHeader() *fusekernel.OutHeader

OutHeader returns a pointer to the header at the start of the message.

func (*OutMessage) Reset

func (m *OutMessage) Reset()

Reset resets m so that it's ready to be used again. Afterward, the contents are solely a zeroed fusekernel.OutHeader struct.

func (*OutMessage) ShrinkTo

func (m *OutMessage) ShrinkTo(n int)

ShrinkTo shrinks m to the given size. It panics if the size is greater than Len() or less than OutMessageHeaderSize.

Jump to

Keyboard shortcuts

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