utils

package
v0.0.0-...-159c384 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlignUp

func AlignUp(x, align uint64) uint64

func ApplySalt

func ApplySalt(saltHex string, maxSaltSize int) ([]byte, uint16, error)

func ApplyUUID

func ApplyUUID(uuidStr string, generateIfEmpty bool, noSuperblock bool, generateUUIDFunc func() (string, error)) ([16]byte, error)

func AttachLoopDevice

func AttachLoopDevice(backingFile string) (string, error)

AttachLoopDevice attaches a specified backing file to a loop device

func CalculateDataBlocks

func CalculateDataBlocks(dataPath string, userSpecified uint64, dataBlockSize uint32) (uint64, error)

func CreateFormattedFiles

func CreateFormattedFiles(t *testing.T) (dataPath, hashPath, rootHex string)

func DetachLoopDevice

func DetachLoopDevice(devices ...string) error

DetachLoopDevice detaches the provided loop devices

func ExtractRootHex

func ExtractRootHex(t *testing.T, out string) string

func FirstLine

func FirstLine(s string) string

func GetBitsDown

func GetBitsDown(u uint32) uint

func GetBlockOrFileSize

func GetBlockOrFileSize(path string) (int64, error)

func IsBlockSizeValid

func IsBlockSizeValid(size uint32) bool

func MakeTempFile

func MakeTempFile(t *testing.T, size int64) string

func MaskVerityDevices

func MaskVerityDevices(s string) string

func OpenVerityDevice

func OpenVerityDevice(t *testing.T, params VerityTestParams, dataLoop, name, hashLoop, rootHex string)

func ParseRootHash

func ParseRootHash(rootHex string) ([]byte, error)

func ParseSaltHex

func ParseSaltHex(saltHex string, maxSaltSize int) ([]byte, error)

func RequireRoot

func RequireRoot(t *testing.T)

func RequireTool

func RequireTool(t *testing.T, name string) string

func RunCmd

func RunCmd(t *testing.T, name string, args ...string) (string, string)

func RunGoCLI

func RunGoCLI(t *testing.T, args ...string) (string, string)

func SelectHashSize

func SelectHashSize(name string) int

func SetupLoopDevice

func SetupLoopDevice(path string) (string, func(), error)

func Uint64MultOverflow

func Uint64MultOverflow(a, b uint64) bool

func ValidateDataHashOverlap

func ValidateDataHashOverlap(dataBlocks uint64, dataBlockSize uint32, hashAreaOffset uint64, dataPath, hashPath string) error

func ValidateHashOffset

func ValidateHashOffset(hashAreaOffset uint64, hashBlockSize uint32, noSuperblock bool) error

func ValidateRootHashSize

func ValidateRootHashSize(rootDigest []byte, hashName string) error

func VerifyDeviceRemoved

func VerifyDeviceRemoved(t *testing.T, name string)

Types

type DMDeviceCleanup

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

func NewDMDeviceCleanup

func NewDMDeviceCleanup(t *testing.T) *DMDeviceCleanup

func (*DMDeviceCleanup) Add

func (c *DMDeviceCleanup) Add(device string) string

func (*DMDeviceCleanup) Cleanup

func (c *DMDeviceCleanup) Cleanup()

type LoopParams

type LoopParams struct {
	// Loop device should forbid write
	Readonly bool
	// Loop device is automatically cleared by kernel when the
	// last opener closes it
	Autoclear bool
	// Use direct IO to access the loop backing file
	Direct bool
}

LoopParams parameters to control loop device setup

type VerityTestParams

type VerityTestParams struct {
	Hash          string
	DataBlockSize string
	HashBlockSize string
	Salt          string
	NoSuperblock  bool
	HashOffset    string
}

func DefaultVerityTestParams

func DefaultVerityTestParams() VerityTestParams

func (VerityTestParams) BuildCVeritysetupOpenArgs

func (p VerityTestParams) BuildCVeritysetupOpenArgs(dataLoop, name, hashLoop, rootHex string) []string

func (VerityTestParams) BuildCVeritysetupVerifyArgs

func (p VerityTestParams) BuildCVeritysetupVerifyArgs(data, hash, rootHex string) []string

func (VerityTestParams) BuildOpenArgs

func (p VerityTestParams) BuildOpenArgs(dataLoop, name, hashLoop, rootHex string) []string

func (VerityTestParams) BuildVerifyArgs

func (p VerityTestParams) BuildVerifyArgs(data, hash, rootHex string) []string

Jump to

Keyboard shortcuts

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