bootrecord

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

Documentation

Overview

Package bootrecord describes the first sectors of a partition, which hold filesystem metadata.

Index

Constants

View Source
const (
	// NumReservedClusters describes how many cluster numbers are reserved (FAT[0] and FAT[1]).
	NumReservedClusters uint32 = 2

	// BootrecordSize is the size of a bootrecord
	BootrecordSize = 512
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Bootrecord

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

Bootrecord describes the underlying boot record, independent of FAT type.

func New

func New(d *thinio.Conductor) (*Bootrecord, error)

New returns a new Bootrecord described by the first 512 bytes of a partition. Returns an error if the first 512 bytes of the partition do not match a known (or supported) FAT version.

func (*Bootrecord) ClusterInValidRange

func (b *Bootrecord) ClusterInValidRange(cluster uint32) bool

ClusterInValidRange checks that the cluster is in a valid range. It does not access the entry corresponding to the cluster.

func (*Bootrecord) ClusterLocationData

func (b *Bootrecord) ClusterLocationData(cluster uint32) int64

ClusterLocationData returns the device offset for a cluster's data.

func (*Bootrecord) ClusterLocationFAT

func (b *Bootrecord) ClusterLocationFAT(indexFAT, cluster uint32) int64

ClusterLocationFAT returns device offset for a particular cluster index in an arbitrary File Allocation Table.

func (*Bootrecord) ClusterLocationFATPrimary

func (b *Bootrecord) ClusterLocationFATPrimary(cluster uint32) int64

ClusterLocationFATPrimary returns device offset for a particular cluster index in the primary File Allocation Table.

func (*Bootrecord) ClusterSize

func (b *Bootrecord) ClusterSize() uint32

ClusterSize returns the size of a single cluster. The size of a single cluster should be a power of two multiple of the sector size.

func (*Bootrecord) FATEntrySize

func (b *Bootrecord) FATEntrySize() uint32

FATEntrySize returns the size (in bytes) of a single entry in the FAT.

func (*Bootrecord) FsInfoOffset

func (b *Bootrecord) FsInfoOffset() (int64, error)

FsInfoOffset returns the offset in the device of the FS Info structure, or an error if the value is invalid.

func (*Bootrecord) MirroringInfo

func (b *Bootrecord) MirroringInfo() (active bool, numFATs, primary uint32)

MirroringInfo describes if mirroring is necessary.

If mirroring is active, returns "true", along with the number of FATs which need to be mirrored. If mirroring is disabled, returns "false", along with the primary FAT which should be used.

func (*Bootrecord) NumUsableClusters

func (b *Bootrecord) NumUsableClusters() uint32

NumUsableClusters returns the number of non-reserved sectors.

func (*Bootrecord) RootCluster

func (b *Bootrecord) RootCluster() uint32

RootCluster returns the cluster number of the root directory. Returns an error if the root directory is not found in a cluster (as is the case for FAT12 and FAT16).

func (*Bootrecord) RootReservedInfo

func (b *Bootrecord) RootReservedInfo() (offsetStart int64, numRootEntriesMax int64)

RootReservedInfo provides information for the root directory on FAT12 and FAT16 filesystems.

func (*Bootrecord) Type

func (b *Bootrecord) Type() FATType

Type returns the type of the underlying Bootrecord.

func (*Bootrecord) VolumeSize

func (b *Bootrecord) VolumeSize() int64

VolumeSize returns the size of all sectors allocated to the FAT filesystem.

type FATType

type FATType int

FATType describes the type of underlying filesystem described by the boot record.

const (
	FATInvalid FATType = 0
	FAT12      FATType = 12
	FAT16      FATType = 16
	FAT32      FATType = 32
)

Identify the type of filesystem described by this boot record.

Jump to

Keyboard shortcuts

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