Documentation ¶
Overview ¶
Package to allow direct IO in Go. Currently only works on Linux
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AlignedBuffer ¶
type AlignedBuffer interface { Close() CreateSlice() []byte }
func NewAlignedBuffer ¶
func NewAlignedBuffer(alignment int64, size int) (AlignedBuffer, error)
The function allocates size bytes. The address of the allocated memory will be a multiple of alignment, which must be a power of two and a multiple of sizeof(void *). Alignment or size must not be 0 or the method will intentionally panic.
type DeviceTopology ¶
type DeviceTopology struct { AlignmentOffset uint64 // Meomory alignment required direct IO MinimumIOSize uint64 // Minimal IO allowed OptimalIOSize uint64 // Optimal IO for device LogicalSectorSize uint64 // Logical sector size PhysicalSectorSize uint64 // Physical sector size }
func DetectDeviceTopology ¶
func DetectDeviceTopology(file File) DeviceTopology
Detects the topology data of a device. In case of an error getting any of the topology properties the field will be set to 0
type Reader ¶
type Reader struct {
// contains filtered or unexported fields
}
A high level wrapper that allows reading direct IO in arbitrary locations and chunk sizes. This implementation prefers simplicity over performance. It is meant to be easily integrated with other IO operations in Go that might not expect the constraints that direct IO demands.
func NewReader ¶
Creates a new Reader for that specified file It is assumed that the file has been opened with the O_DIRECT flag
type Writer ¶
type Writer struct {
// contains filtered or unexported fields
}
Writer implements buffering on top of a specially allocated buffer to allow for direct IO writes. If an error occurs writing to a Writer, no more data will be accepted and all subsequent writes will return the error. The user can force a write by using Flush() but the writer will fill the ramainder of the buffer with '\0' before writing.
func NewWriter ¶
NewWriter returns a new Writer with an internal buffer that is suitable for direct IO operations.
func (*Writer) Buffered ¶
Buffered returns the number of bytes that have been written into the current buffer.
func (*Writer) Close ¶
func (w *Writer) Close()
Frees all internal buffers but does not close the underlying file.