fat

package
v0.0.0-...-bbc9ce3 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2021 License: BSD-2-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package fat contains the actual File Allocation Table used by the FAT filesystem.

Methods which modify the FAT itself are NOT thread-safe (Allocate / Set / Close), and must be write-locked.

Methods which read from the FAT are thread-safe (Get) among themselves, and can be read-locked.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrHardIO indicates there was an unrecoverable error.
	ErrHardIO = errors.New("FAT: Hard Error I/O bit set. Run 'fsck <device> fat' on the partition containing this filesystem")

	// ErrDirtyFAT indicates the FAT was not unmounted properly.
	ErrDirtyFAT = errors.New("FAT: Dirty volume bit set. Run 'fsck <device> fat' on the partition containing this filesystem")

	// ErrNotOpen indicates the FAT cannot be accessed because it is not open.
	ErrNotOpen = errors.New("FAT: FAT not open")

	// ErrInvalidCluster indicates the provided cluster is invalid.
	ErrInvalidCluster = errors.New("FAT: Attempting to access FAT with invalid cluster")

	// ErrNoSpace indicates there is no remaining space in the FAT.
	ErrNoSpace = fs.ErrNoSpace
)

Functions

This section is empty.

Types

type FAT

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

FAT holds the File Allocation Table.

func Open

func Open(d *thinio.Conductor, br *bootrecord.Bootrecord, readonly bool) (*FAT, error)

Open opens a new File Allocation Table. This FAT will NOT be thread-safe; thread safety will need to be implemented by the layer above the FAT.

If the filesystem is writeable, also marks the dirty bit as "dirty".

func (*FAT) Allocate

func (f *FAT) Allocate() (uint32, error)

Allocate returns the next known free cluster, starting from cluster "start". If a cluster is found, it is set to an EOF value (instead of free).

If start is invalid, it is ignored. If no entries remain, an error is returned.

func (*FAT) Close

func (f *FAT) Close() error

Close closes a File Allocation Table.

If the filesystem was writeable, this marks the dirty bit as "clean".

func (*FAT) EOFValue

func (f *FAT) EOFValue() uint32

EOFValue returns the FAT value that means "end of file". Notably, there are multiple values that mean EOF to FAT.

func (*FAT) FreeCount

func (f *FAT) FreeCount() (int64, error)

FreeCount returns the number of free clusters stored in fsinfo.

func (*FAT) FreeValue

func (f *FAT) FreeValue() uint32

FreeValue returns the FAT value that means "free cluster".

func (*FAT) Get

func (f *FAT) Get(cluster uint32) (uint32, error)

Get gets the value of a cluster entry. Can only be used to access clusters which are not reserved. Returns an error if accessing out-of-bounds cluster.

func (*FAT) IsEOF

func (f *FAT) IsEOF(e uint32) bool

IsEOF describes if the entry signifies "End of File".

func (*FAT) IsFree

func (f *FAT) IsFree(e uint32) bool

IsFree describes if the entry signifies "free cluster".

func (*FAT) Set

func (f *FAT) Set(value uint32, cluster uint32) error

Set sets the value of a cluster entry.

Returns an error if accessing an out-of-bounds cluster, or setting a cluster to point to itself.

func (*FAT) SetHardError

func (f *FAT) SetHardError() error

SetHardError marks that the volume has encountered a disk I/O error.

Directories

Path Synopsis
Package fsinfo describes the FAT32-exclusive FSInfo structure
Package fsinfo describes the FAT32-exclusive FSInfo structure

Jump to

Keyboard shortcuts

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