Documentation
¶
Index ¶
- Constants
- func DecodeDirectoryEntry(d *Directory, entries []*DirectoryClusterEntry) (*DirectoryEntry, []*DirectoryClusterEntry, error)
- func DecodeVolumeLabel(device ffs.BlockDevice, fatType FATType) (string, error)
- func FATEntryCount(bs *BootSectorCommon) uint32
- func Fatal(err error) error
- func Fatalf(format string, args ...interface{}) error
- func FormatSuperFloppy(device ffs.BlockDevice, config *SuperFloppyConfig) error
- type BootSectorCommon
- func (b *BootSectorCommon) Bytes() ([]byte, error)
- func (b *BootSectorCommon) BytesPerCluster() uint32
- func (b *BootSectorCommon) ClusterOffset(n int) uint32
- func (b *BootSectorCommon) DataOffset() uint32
- func (b *BootSectorCommon) FATOffset(n int) int
- func (b *BootSectorCommon) FATType() FATType
- func (b *BootSectorCommon) RootDirOffset() int
- type BootSectorFat16
- type BootSectorFat32
- type ClusterChain
- type Directory
- type DirectoryCluster
- func DecodeDirectoryCluster(startCluster uint32, device ffs.BlockDevice, fat *FAT) (*DirectoryCluster, error)
- func DecodeFAT16RootDirectoryCluster(device ffs.BlockDevice, bs *BootSectorCommon) (*DirectoryCluster, error)
- func DecodeFAT32RootDirectoryCluster(device ffs.BlockDevice, fat *FAT) (*DirectoryCluster, error)
- func NewDirectoryCluster(start uint32, parent uint32, t time.Time) *DirectoryCluster
- func NewFat16RootDirectoryCluster(bs *BootSectorCommon, label string) (*DirectoryCluster, error)
- type DirectoryClusterEntry
- type DirectoryEntry
- func (d *DirectoryEntry) Attr() ffs.DirectoryAttr
- func (d *DirectoryEntry) Dir() (ffs.Directory, error)
- func (d *DirectoryEntry) File() (ffs.File, error)
- func (d *DirectoryEntry) IsDir() bool
- func (d *DirectoryEntry) IsHidden() bool
- func (d *DirectoryEntry) IsReadOnly() bool
- func (d *DirectoryEntry) IsSystem() bool
- func (d *DirectoryEntry) IsVolumeId() bool
- func (d *DirectoryEntry) Name() string
- func (d *DirectoryEntry) SetAttr(attr ffs.DirectoryAttr, state bool) error
- func (d *DirectoryEntry) SetHidden(state bool) error
- func (d *DirectoryEntry) SetReadOnly(state bool) error
- func (d *DirectoryEntry) SetSystem(state bool) error
- func (d *DirectoryEntry) ShortName() string
- type FAT
- type FATType
- type File
- type FileSystem
- type MediaType
- type SuperFloppyConfig
Constants ¶
const DirectoryEntrySize = 32
The size in bytes of a single directory entry.
const FirstCluster = 2
The first cluster that can really hold user data is always 2
const LastLongEntryMask = 0x40
Mask applied to the ord of the last long entry.
Variables ¶
This section is empty.
Functions ¶
func DecodeDirectoryEntry ¶
func DecodeDirectoryEntry(d *Directory, entries []*DirectoryClusterEntry) (*DirectoryEntry, []*DirectoryClusterEntry, error)
DecodeDirectoryEntry takes a list of entries, decodes the next full DirectoryEntry, and returns the newly created entry, the remaining entries, and an error, if there was one.
func DecodeVolumeLabel ¶ added in v0.0.6
func DecodeVolumeLabel(device ffs.BlockDevice, fatType FATType) (string, error)
func FATEntryCount ¶
func FATEntryCount(bs *BootSectorCommon) uint32
FATEntryCount returns the number of entries per fat for the given boot sector.
func FormatSuperFloppy ¶
func FormatSuperFloppy(device ffs.BlockDevice, config *SuperFloppyConfig) error
Formats an ffs.BlockDevice with the "super floppy" format according to the given configuration. The "super floppy" standard means that the device will be formatted so that it does not contain a partition table. Instead, the entire device holds a single FAT file system.
Types ¶
type BootSectorCommon ¶
type BootSectorCommon struct {
OEMName string
BytesPerSector uint16
SectorsPerCluster uint8
ReservedSectorCount uint16
NumFATs uint8
RootEntryCount uint16
TotalSectors uint32
Media MediaType
SectorsPerFat uint32
SectorsPerTrack uint16
NumHeads uint16
}
func DecodeBootSector ¶
func DecodeBootSector(device ffs.BlockDevice) (*BootSectorCommon, error)
DecodeBootSector takes a BlockDevice and decodes the FAT boot sector from it.
func (*BootSectorCommon) Bytes ¶
func (b *BootSectorCommon) Bytes() ([]byte, error)
func (*BootSectorCommon) BytesPerCluster ¶
func (b *BootSectorCommon) BytesPerCluster() uint32
BytesPerCluster returns the number of bytes per cluster.
func (*BootSectorCommon) ClusterOffset ¶
func (b *BootSectorCommon) ClusterOffset(n int) uint32
ClusterOffset returns the offset of the data section of a particular cluster.
func (*BootSectorCommon) DataOffset ¶
func (b *BootSectorCommon) DataOffset() uint32
DataOffset returns the offset of the data section of the disk.
func (*BootSectorCommon) FATOffset ¶
func (b *BootSectorCommon) FATOffset(n int) int
FATOffset returns the offset in bytes for the given index of the FAT
func (*BootSectorCommon) FATType ¶
func (b *BootSectorCommon) FATType() FATType
Calculates the FAT type that this boot sector represents.
func (*BootSectorCommon) RootDirOffset ¶
func (b *BootSectorCommon) RootDirOffset() int
RootDirOffset returns the byte offset when the root directory entries for FAT12/16 filesystems start. NOTE: This is absolutely useless for FAT32 because the root directory is just the beginning of the data region.
type BootSectorFat16 ¶
type BootSectorFat16 struct {
BootSectorCommon
DriveNumber uint8
VolumeID uint32
VolumeLabel string
FileSystemTypeLabel string
}
BootSectorFat16 is the BootSector for FAT12 and FAT16 filesystems. It contains the common fields to all FAT filesystems and also some unique.
func (*BootSectorFat16) Bytes ¶
func (b *BootSectorFat16) Bytes() ([]byte, error)
type BootSectorFat32 ¶
type BootSectorFat32 struct {
BootSectorCommon
RootCluster uint32
FSInfoSector uint16
BackupBootSector uint16
DriveNumber uint8
VolumeID uint32
VolumeLabel string
FileSystemTypeLabel string
}
func (*BootSectorFat32) Bytes ¶
func (b *BootSectorFat32) Bytes() ([]byte, error)
type ClusterChain ¶
type ClusterChain struct {
// contains filtered or unexported fields
}
type Directory ¶
type Directory struct {
// contains filtered or unexported fields
}
Directory implements ffs.Directory and is used to interface with a directory on a FAT filesystem.
func (*Directory) AddDirectory ¶
func (d *Directory) AddDirectory(name string) (ffs.DirectoryEntry, error)
func (*Directory) Entries ¶
func (d *Directory) Entries() []ffs.DirectoryEntry
type DirectoryCluster ¶
type DirectoryCluster struct {
// contains filtered or unexported fields
}
DirectoryCluster represents a cluster on the disk that contains entries/contents.
func DecodeDirectoryCluster ¶
func DecodeDirectoryCluster(startCluster uint32, device ffs.BlockDevice, fat *FAT) (*DirectoryCluster, error)
func DecodeFAT16RootDirectoryCluster ¶
func DecodeFAT16RootDirectoryCluster(device ffs.BlockDevice, bs *BootSectorCommon) (*DirectoryCluster, error)
DecodeFAT16RootDirectory decodes the FAT16 root directory structure from the device.
func DecodeFAT32RootDirectoryCluster ¶
func DecodeFAT32RootDirectoryCluster(device ffs.BlockDevice, fat *FAT) (*DirectoryCluster, error)
DecodeFAT16RootDirectory decodes the FAT32 oroot directory structure from the device.
func NewDirectoryCluster ¶
func NewDirectoryCluster(start uint32, parent uint32, t time.Time) *DirectoryCluster
func NewFat16RootDirectoryCluster ¶
func NewFat16RootDirectoryCluster(bs *BootSectorCommon, label string) (*DirectoryCluster, error)
NewFat16RootDirectory creates a new DirectoryCluster that is meant only to be the root directory of a FAT12/FAT16 filesystem.
func (*DirectoryCluster) Bytes ¶
func (d *DirectoryCluster) Bytes() []byte
Bytes returns the on-disk byte data for this directory structure.
func (*DirectoryCluster) WriteToDevice ¶
func (d *DirectoryCluster) WriteToDevice(device ffs.BlockDevice, fat *FAT) error
WriteToDevice writes the cluster to the device.
type DirectoryClusterEntry ¶
type DirectoryClusterEntry struct {
// contains filtered or unexported fields
}
DirectoryClusterEntry is a single 32-byte entry that is part of the chain of entries in a directory cluster.
func DecodeDirectoryClusterEntry ¶
func DecodeDirectoryClusterEntry(data []byte) (*DirectoryClusterEntry, error)
DecodeDirectoryClusterEntry decodes a single directory entry in the Directory structure.
func NewLongDirectoryClusterEntry ¶
func NewLongDirectoryClusterEntry(name string, shortName string) ([]*DirectoryClusterEntry, error)
NewLongDirectoryClusterEntry returns the series of directory cluster entries that need to be written for a long directory entry. This list of entries does NOT contain the short name entry.
func (*DirectoryClusterEntry) Bytes ¶
func (d *DirectoryClusterEntry) Bytes() []byte
Bytes returns the on-disk byte data for this directory entry.
func (*DirectoryClusterEntry) IsLong ¶
func (d *DirectoryClusterEntry) IsLong() bool
IsLong returns true if this is a long entry.
func (*DirectoryClusterEntry) IsVolumeId ¶
func (d *DirectoryClusterEntry) IsVolumeId() bool
type DirectoryEntry ¶
type DirectoryEntry struct {
// contains filtered or unexported fields
}
DirectoryEntry implements ffs.DirectoryEntry and represents a single file/folder within a directory in a FAT filesystem. Note that there may be more than one underlying directory entry data structure on the disk to account for long filenames.
func (*DirectoryEntry) Attr ¶ added in v0.0.5
func (d *DirectoryEntry) Attr() ffs.DirectoryAttr
func (*DirectoryEntry) IsDir ¶
func (d *DirectoryEntry) IsDir() bool
func (*DirectoryEntry) IsHidden ¶ added in v0.0.5
func (d *DirectoryEntry) IsHidden() bool
func (*DirectoryEntry) IsReadOnly ¶ added in v0.0.5
func (d *DirectoryEntry) IsReadOnly() bool
func (*DirectoryEntry) IsSystem ¶ added in v0.0.5
func (d *DirectoryEntry) IsSystem() bool
func (*DirectoryEntry) IsVolumeId ¶ added in v0.0.5
func (d *DirectoryEntry) IsVolumeId() bool
func (*DirectoryEntry) Name ¶
func (d *DirectoryEntry) Name() string
func (*DirectoryEntry) SetAttr ¶ added in v0.0.5
func (d *DirectoryEntry) SetAttr(attr ffs.DirectoryAttr, state bool) error
func (*DirectoryEntry) SetHidden ¶ added in v0.0.5
func (d *DirectoryEntry) SetHidden(state bool) error
func (*DirectoryEntry) SetReadOnly ¶ added in v0.0.5
func (d *DirectoryEntry) SetReadOnly(state bool) error
func (*DirectoryEntry) SetSystem ¶ added in v0.0.5
func (d *DirectoryEntry) SetSystem(state bool) error
func (*DirectoryEntry) ShortName ¶
func (d *DirectoryEntry) ShortName() string
type FAT ¶
type FAT struct {
// contains filtered or unexported fields
}
FAT is the actual file allocation table data structure that is stored on disk to describe the various clusters on the disk.
func DecodeFAT ¶
func DecodeFAT(device ffs.BlockDevice, bs *BootSectorCommon, n int) (*FAT, error)
func NewFAT ¶
func NewFAT(bs *BootSectorCommon) (*FAT, error)
NewFAT creates a new FAT data structure, properly initialized.
func (*FAT) AllocChain ¶
func (*FAT) Bytes ¶
Bytes returns the raw bytes for the FAT that should be written to the block device.
func (*FAT) ResizeChain ¶
ResizeChain takes a given cluster number and resizes the chain to the given length. It returns the new chain of clusters.
func (*FAT) WriteToDevice ¶
func (f *FAT) WriteToDevice(device ffs.BlockDevice) error
type FATType ¶
type FATType uint8
FATType is a simple enum of the available FAT filesystem types.
func TypeForDevice ¶
func TypeForDevice(device ffs.BlockDevice) FATType
TypeForDevice determines the usable FAT type based solely on size information about the block device.
type FileSystem ¶
type FileSystem struct {
// contains filtered or unexported fields
}
FileSystem is the implementation of ffs.FileSystem that can read a FAT filesystem.
func New ¶
func New(device ffs.BlockDevice) (*FileSystem, error)
New returns a new FileSystem for accessing a previously created FAT filesystem.
func (*FileSystem) FATType ¶ added in v0.0.6
func (f *FileSystem) FATType() (int, error)
func (*FileSystem) OEMName ¶ added in v0.0.6
func (f *FileSystem) OEMName() (string, error)
func (*FileSystem) VolumeLabel ¶ added in v0.0.6
func (f *FileSystem) VolumeLabel() (string, error)
type MediaType ¶
type MediaType uint8
const MediaFixed MediaType = 0xF8
The standard value for "fixed", non-removable media, directly from the FAT specification.
type SuperFloppyConfig ¶
type SuperFloppyConfig struct {
// The type of FAT filesystem to use.
FATType FATType
// The label of the drive. Defaults to "NONAME"
Label string
// The OEM name for the FAT filesystem. Defaults to "gofs" if not set.
OEMName string
}
SuperFloppyConfig is the configuration for various properties of a new super floppy formatted block device. Once this configuration is used to format a device, it must not be modified.