fat32

package
v0.0.0-...-8d377ce Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package fat32 implements a writer for the FAT32 filesystem.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteFS

func WriteFS(w io.Writer, rootInode Inode, opts Options) error

WriteFS writes a filesystem described by a root inode and its children to a given io.Writer.

Types

type Attribute

type Attribute uint8

Attribute is a bitset of flags set on an inode. See also the spec page 24

const (
	// AttrReadOnly marks a file as read-only
	AttrReadOnly Attribute = 0x01
	// AttrHidden indicates that directory listings should not show this file.
	AttrHidden Attribute = 0x02
	// AttrSystem indicates that this is an operating system file.
	AttrSystem Attribute = 0x04
	// AttrDirectory indicates that this is a directory and not a file.
	AttrDirectory Attribute = 0x10
	// AttrArchive canonically indicates that a file has been created/modified
	// since the last backup. Its use in practice is inconsistent.
	AttrArchive Attribute = 0x20
)

type Inode

type Inode struct {
	// Name of the file or directory (not including its path)
	Name string
	// Time the file or directory was last modified
	ModTime time.Time
	// Time the file or directory was created
	CreateTime time.Time
	// Attributes
	Attrs Attribute
	// Children of this directory (only valid when Attrs has AttrDirectory set)
	Children []*Inode
	// Content of this file
	// Only valid when Attrs doesn't have AttrDirectory set.
	Content SizedReader
	// contains filtered or unexported fields
}

Inode is file or directory on the FAT32 filesystem. Note that the concept of an inode doesn't really exist on FAT32, its directories are just special files.

func (*Inode) PlaceFile

func (i *Inode) PlaceFile(path string, reader SizedReader) error

type Options

type Options struct {
	// Size of a logical block on the block device. Needs to be a power of two
	// equal or bigger than 512. If left at zero, defaults to 512.
	BlockSize uint16

	// Number of blocks the filesystem should span. If zero, it will be exactly
	// as large as it needs to be.
	BlockCount uint32

	// Human-readable filesystem label. Maximum 10 bytes (gets cut off), should
	// be uppercase alphanumeric.
	Label string

	// Filesystem identifier. If unset (i.e. left at zero) a random value will
	// be assigned by WriteFS.
	ID uint32
}

type SizedReader

type SizedReader interface {
	io.Reader
	Size() int64
}

SizedReader is an io.Reader with a known size

Jump to

Keyboard shortcuts

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