Documentation
¶
Index ¶
Constants ¶
const ( SuperblockOffset int64 = 0x10000 // 64KB SuperblockBackup1 int64 = 0x4000000 // 64MB SuperblockBackup2 int64 = 0x4000000000 // 256GB )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockCache ¶
type BlockCache struct {
// contains filtered or unexported fields
}
BlockCache is an LRU block cache.
func (*BlockCache) Capacity ¶
func (c *BlockCache) Capacity() int
Capacity returns the cache capacity.
type BlockDevice ¶
type BlockDevice interface {
// ReadAt reads data at the specified offset.
ReadAt(p []byte, off int64) (n int, err error)
// Size returns the device size.
Size() int64
// DeviceID returns the unique device identifier.
DeviceID() uint64
// Close closes the device.
Close() error
}
BlockDevice is the block device interface.
type CacheStats ¶
CacheStats holds cache statistics.
type FileDevice ¶
type FileDevice struct {
// contains filtered or unexported fields
}
FileDevice is a file-backed block device.
func NewFileDevice ¶
func NewFileDevice(path string) (*FileDevice, error)
NewFileDevice creates a file device.
func (*FileDevice) DeviceID ¶
func (d *FileDevice) DeviceID() uint64
DeviceID returns the device ID.
func (*FileDevice) ReadAt ¶
func (d *FileDevice) ReadAt(p []byte, off int64) (int, error)
ReadAt implements io.ReaderAt.
func (*FileDevice) SetDeviceID ¶
func (d *FileDevice) SetDeviceID(id uint64)
SetDeviceID sets the device ID (after reading from the superblock).
type SuperblockReader ¶
type SuperblockReader struct {
// contains filtered or unexported fields
}
SuperblockReader reads superblocks.
func NewSuperblockReader ¶
func NewSuperblockReader(dev BlockDevice) *SuperblockReader
NewSuperblockReader creates a reader.
func (*SuperblockReader) ReadBackup ¶
func (r *SuperblockReader) ReadBackup(index int) (*ondisk.Superblock, error)
ReadBackup reads a backup superblock at the given index. index: 0 = primary, 1 = backup1 (64MB), 2 = backup2 (256GB)
func (*SuperblockReader) ReadLatest ¶
func (r *SuperblockReader) ReadLatest() (*ondisk.Superblock, error)
ReadLatest reads the newest valid superblock (primary then backups).
func (*SuperblockReader) ReadPrimary ¶
func (r *SuperblockReader) ReadPrimary() (*ondisk.Superblock, error)
ReadPrimary reads the primary superblock.