fs

package
v0.0.0-...-bc08256 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockBit  = 18
	BlockSize = 1 << BlockBit
)
View Source
const InodePadding = 44

Variables

View Source
var (
	MagicEOF   = Magic{0x8a, 0x9c, 0x0, 0x1}
	MagicInode = Magic{0x8a, 0x9c, 0x0, 0x2}
)

Functions

func MakeRoom

func MakeRoom(b []byte, n int) []byte

Types

type DiskBuffer

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

func NewDiskBuffer

func NewDiskBuffer(rw io.ReadWriter) *DiskBuffer

func (*DiskBuffer) ReadItem

func (d *DiskBuffer) ReadItem(da Diskable) error

func (*DiskBuffer) WriteItem

func (d *DiskBuffer) WriteItem(da Diskable) error

type DiskItem

type DiskItem interface {
	DiskSize() int
	ReadDisk([]byte) error
	WriteDisk([]byte)
}

type DiskReadItem

type DiskReadItem interface {
	DiskSize() int
	ReadDisk([]byte) error
}

type DiskReader

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

func NewDiskReader

func NewDiskReader(b []byte) *DiskReader

func (*DiskReader) Peek

func (r *DiskReader) Peek(n int) []byte

func (*DiskReader) ReadBytes

func (r *DiskReader) ReadBytes(n int) []byte

func (*DiskReader) ReadItem

func (r *DiskReader) ReadItem(d DiskReadItem) error

func (*DiskReader) ReadItems

func (r *DiskReader) ReadItems(ds []DiskReadItem) error

func (*DiskReader) ReadMagic

func (r *DiskReader) ReadMagic(d Diskable) error

func (*DiskReader) Skip

func (r *DiskReader) Skip(n int)

type DiskWriteItem

type DiskWriteItem interface {
	DiskSize() int
	WriteDisk([]byte)
}

type DiskWriter

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

func NewDiskWriter

func NewDiskWriter(b []byte) *DiskWriter

func (*DiskWriter) Skip

func (w *DiskWriter) Skip(n int)

func (*DiskWriter) WriteBytes

func (w *DiskWriter) WriteBytes(b []byte)

func (*DiskWriter) WriteItem

func (w *DiskWriter) WriteItem(d DiskWriteItem)

func (*DiskWriter) WriteMagic

func (w *DiskWriter) WriteMagic(d Diskable)

type Diskable

type Diskable interface {
	Magic() Magic
	DiskItem
}

type Flusher

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

func NewFlusher

func NewFlusher(f *flow.Flow, interval time.Duration) *Flusher

func (*Flusher) Close

func (f *Flusher) Close()

func (*Flusher) WriteByInode

func (f *Flusher) WriteByInode(inoPool *InodePool, data []byte)

type Inode

type Inode struct {
	// Magic 4
	Ino   Int32
	Start Int32
	Size  Int32 // 8

	Prev,
	Prev2,
	Prev4,
	Prev8,
	Prev16,
	Prev32,
	PrevGroup Address // 7*8

	GroupSize Int32
	GroupIdx  Int32 // 8

	Offsets [150]ShortAddr
	// contains filtered or unexported fields
}

size: 1kB one inode can store 37.5MB

func (*Inode) DiskSize

func (i *Inode) DiskSize() int

func (*Inode) GetBlockSize

func (i *Inode) GetBlockSize(idx int) int

func (*Inode) GetOffsetIdx

func (i *Inode) GetOffsetIdx() int

func (*Inode) IsFull

func (i *Inode) IsFull() bool

func (*Inode) Magic

func (i *Inode) Magic() Magic

func (*Inode) ReadDisk

func (i *Inode) ReadDisk(b []byte) error

func (*Inode) WriteDisk

func (i *Inode) WriteDisk(b []byte)

type InodePool

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

Pool for one file

func NewInodePool

func NewInodePool(ino int32, delegate InodePoolDelegate) *InodePool

func (*InodePool) GetByAddr

func (i *InodePool) GetByAddr(addr Address) (*Inode, error)

func (*InodePool) GetLastest

func (i *InodePool) GetLastest() (*Inode, error)

get newest inode from memory or disk

func (*InodePool) RefPayloadBlock

func (i *InodePool) RefPayloadBlock() (*Inode, int, error)

type InodePoolDelegate

type InodePoolDelegate interface {
	GetInode(ino int32) (*Inode, error)
	GetInodeByAddr(addr Address) (*Inode, error)
}

type InodeScatter

type InodeScatter [32]*Inode

func (*InodeScatter) Current

func (s *InodeScatter) Current() *Inode

func (*InodeScatter) Push

func (is *InodeScatter) Push(i *Inode)

type Magic

type Magic []byte

func (Magic) String

func (m Magic) String() string

Jump to

Keyboard shortcuts

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