fmap

package
v0.0.0-...-c4da75d Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2017 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FmapAreaStatic = 1 << iota
	FmapAreaCompressed
	FmapAreaReadOnly
)

Flags which can be applied to Area.Flags.

Variables

This section is empty.

Functions

func FlagNames

func FlagNames(flags uint16) string

FlagNames returns human readable representation of the flags.

func Read

func Read(f io.Reader) (*FMap, *Metadata, error)

Read an FMap into the data structure.

func Write

func Write(f io.WriteSeeker, fmap *FMap, m *Metadata) error

Write overwrites the fmap in the flash file.

Types

type Area

type Area struct {
	Offset uint32
	Size   uint32
	Name   String
	Flags  uint16
}

Area describes each area.

type FMap

type FMap struct {
	Header
	Areas []Area
}

FMap structure serializable using encoding.Binary.

func (*FMap) Checksum

func (f *FMap) Checksum(r io.ReadSeeker, h hash.Hash) ([]byte, error)

Checksum performs a hash of the static areas.

func (*FMap) ReadArea

func (f *FMap) ReadArea(r io.ReadSeeker, i int) (io.Reader, error)

ReadArea reads an area from the fmap as a binary stream.

type Header struct {
	Signature [8]uint8
	VerMajor  uint8
	VerMinor  uint8
	Base      uint64
	Size      uint32
	Name      String
	NAreas    uint16
}

Header describes the flash part.

type Metadata

type Metadata struct {
	Start uint64
}

Metadata contains additional data not part of the FMap.

type String

type String struct {
	Value [32]uint8
}

String wraps around byte array to give us more control over how strings are serialized.

func (*String) MarshalJSON

func (s *String) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (*String) String

func (s *String) String() string

func (*String) UnmarshalJSON

func (s *String) UnmarshalJSON(b []byte) error

UnmarshalJSON implements json.Unmarshaler.

Jump to

Keyboard shortcuts

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