lfs

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: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BlockBit  = 12
	BlockSize = 1 << BlockBit
	Ones52    = 0xFFFFFFFFFFFFF
	Ones12    = 0xFFF
)
View Source
const AddressSize = 8
View Source
const InodeSize = 128
View Source
const InodeTableSize = 128
View Source
const (
	ReservedAreaSize = 128 * BlockSize
)

ReservedArea

Variables

View Source
var (
	InodeTableMagic        = []byte{0x8a, 0x9c, 0x0, 0x1}
	ErrDecodeNotInodeTable = logex.Define("not inodeTable")
)
View Source
var (
	InodeMagic        = []byte{0x8a, 0x9c, 0x0, 0x2}
	ErrDecodeNotInode = logex.Define("not inode")
)
View Source
var (
	ErrInodeHasNotPrev         = logex.Define("the prev of inode is nil")
	ErrVolumeFileNotExists     = logex.Define("file is not exists")
	ErrVolumeFileAlreadyExists = logex.Define("file is already exists")
)
View Source
var (
	ErrFileClosed = logex.Define("file is closed")
)

Functions

This section is empty.

Types

type Address

type Address int64

func FakeAddress

func FakeAddress(ptr uintptr) Address

func InodeAddress

func InodeAddress(i *Inode) Address

func InodeTableAddress

func InodeTableAddress(i *InodeTable) Address

func (Address) InMemory

func (i Address) InMemory() bool

func (Address) ReadAddr

func (i Address) ReadAddr(raw bio.RawDisker, b []byte) (int, error)

func (*Address) ReadDisk

func (i *Address) ReadDisk(r bio.DiskReader) error

func (Address) Size

func (i Address) Size() int

func (*Address) Update

func (i *Address) Update(val Address)

func (Address) Valid

func (i Address) Valid() bool

func (Address) WriteDisk

func (i Address) WriteDisk(w bio.DiskWriter)

type BlockMeta

type BlockMeta int64

func (*BlockMeta) AddLength

func (b *BlockMeta) AddLength(n int)

func (BlockMeta) GetAddr

func (b BlockMeta) GetAddr() int64

func (BlockMeta) GetLength

func (b BlockMeta) GetLength() int

func (BlockMeta) IsEmpty

func (b BlockMeta) IsEmpty() bool

func (*BlockMeta) Set

func (b *BlockMeta) Set(length int, addr int64)

func (*BlockMeta) SetLength

func (b *BlockMeta) SetLength(n int)

func (*BlockMeta) SetPadding

func (b *BlockMeta) SetPadding(n int16)

func (BlockMeta) String

func (b BlockMeta) String() string

type File

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

func NewFile

func NewFile(f *flow.Flow, delegate FileDelegate, ino int32, name string) (*File, error)

func (*File) Close

func (f *File) Close()

func (*File) Flush

func (f *File) Flush()

func (*File) Name

func (f *File) Name() string

func (*File) Read

func (f *File) Read(b []byte) (n int, err error)

func (*File) ReadAt

func (f *File) ReadAt(b []byte, offset int64) (n int, err error)

func (*File) Write

func (f *File) Write(b []byte) (n int, err error)

type FileDelegate

type FileDelegate interface {
	GetFlushNotify() chan struct{}
	MallocWriter(n int) *bio.DeviceWriter
	NextInode(*Inode) (*Inode, error)
	PrevInode(*Inode) (*Inode, error)
	ForceFlush()
	ReadDeviceAt([]byte, int64) (int, error)
	GetInode(ino int32) (*Inode, error)
	DoneFlush()
}

type Inode

type Inode struct {
	Magic [4]byte
	Ino   int32

	Start  int64
	End    int64
	Create int64
	// the address of previous IndirectBlock/Inode/IndirectIndo
	Prev      int64
	BlockMeta [11]BlockMeta
}

1G 要读1万个 ...

func (*Inode) AddBlockSize

func (n *Inode) AddBlockSize(idx int, size int)

func (*Inode) FindAvailable

func (n *Inode) FindAvailable() int

func (*Inode) InitBlock

func (n *Inode) InitBlock(idx int, addr int64)

func (*Inode) ReadDisk

func (n *Inode) ReadDisk(r bio.DiskReader) error

func (*Inode) SetBlock

func (n *Inode) SetBlock(idx int, size int, addr int64)

func (*Inode) Size

func (n *Inode) Size() int

func (*Inode) String

func (n *Inode) String() string

func (*Inode) WriteDisk

func (n *Inode) WriteDisk(w bio.DiskWriter)

type RootDir

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

func NewRootDir

func NewRootDir(v *Volume) (*RootDir, error)

func (*RootDir) Add

func (r *RootDir) Add(name string, ino int32) error

func (*RootDir) Find

func (r *RootDir) Find(name string) int32

type Volume

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

func NewVolume

func NewVolume(f *flow.Flow, raw bio.RawDisker) (*Volume, error)

func (*Volume) Close

func (v *Volume) Close()

func (*Volume) DoneFlush

func (v *Volume) DoneFlush()

func (*Volume) ForceFlush

func (v *Volume) ForceFlush()

func (*Volume) GetFlushNotify

func (v *Volume) GetFlushNotify() chan struct{}

func (*Volume) GetInode

func (v *Volume) GetInode(ino int32) (*Inode, error)

func (*Volume) MallocWriter

func (v *Volume) MallocWriter(n int) *bio.DeviceWriter

func (*Volume) NextInode

func (v *Volume) NextInode(i *Inode) (*Inode, error)

func (*Volume) OpenFile

func (v *Volume) OpenFile(name string, autoCreate bool) (*File, error)

func (*Volume) PrevInode

func (v *Volume) PrevInode(i *Inode) (*Inode, error)

func (*Volume) ReadDeviceAt

func (v *Volume) ReadDeviceAt(b []byte, off int64) (int, error)

Jump to

Keyboard shortcuts

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