Documentation
¶
Overview ¶
Package slots provides a simple "postbox" type filesystem.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockReaderWriter ¶
type BlockReaderWriter interface {
// BlockSize returns the block size of the underlying storage system.
BlockSize() uint
// ReadBlocks reads len(b) bytes into b from contiguous storage blocks starting
// at the given block address.
// b must be an integer multiple of the device's block size.
ReadBlocks(lba uint, b []byte) error
// WriteBlocks writes len(b) bytes from b to contiguous storage blocks starting
// at the given block address.
// b must be an integer multiple of the device's block size.
// Returns the number of blocks written, or an error.
WriteBlocks(lba uint, b []byte) (uint, error)
}
BlockReaderWriter describes a type which knows how to read and write whole blocks to some backing storage.
type Geometry ¶
type Geometry struct {
// Start identifies the address of first block which is part of a partition.
Start uint
// Length is the number of blocks covered by this partition.
// i.e. [Start, Start+Length) is the range of blocks covered by this partition.
Length uint
// SlotLengths is an ordered list containing the lengths of the slot(s)
// allocated within this partition.
// For obvious reasons, great care must be taken if, once data has been written
// to one or more slots, the values specified in this list at the time the data
// was written are changed.
SlotLengths []uint
}
Geometry describes the physical layout of a Partition and its slots on the underlying storage.
type Journal ¶
type Journal struct {
// contains filtered or unexported fields
}
Journal implements a record-based format which provides a resilient storage. This structure is not thread-safe, so concurrent access must be enforced at a higher level.
func OpenJournal ¶
func OpenJournal(dev BlockReaderWriter, start, length uint) (*Journal, error)
OpenJournal returns a new journal structure for interacting with a journal stored in the [start, start+length) range of blocks accessible via dev. Journal ranges should not overlap with one another, or corruption will almost certainly occur.
type Partition ¶
type Partition struct {
// contains filtered or unexported fields
}
Partition describes the extent and layout of a single contiguous region of underlying block storage.
func OpenPartition ¶
func OpenPartition(rw BlockReaderWriter, geo Geometry) (*Partition, error)
OpenPartition returns a partition struct for accessing the slots described by the given geometry using the provided read/write methods.
func (*Partition) Erase ¶
Erase destroys the data stored in all slots configured in this partition. WARNING: Data Loss!
type Slot ¶
type Slot struct {
// contains filtered or unexported fields
}
Slot represents the current data in a slot.
func (*Slot) CheckAndWrite ¶
CheckAndWrite behaves like Write, with the exception that it will immediately return an error if the slot has been successfully written to since the Read call which produced the passed-in token.
func (*Slot) Open ¶
func (s *Slot) Open(dev BlockReaderWriter) error
Open prepares the slot for use. This method is idempotent and will not return an error if called multiple times.
func (*Slot) Read ¶
Read returns the last data successfully written to the slot, along with a token which can be used with CheckAndWrite.