devicemapper

package
v0.12.4 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateDevice

func CreateDevice(name string, flags CreateFlags, targets []Target) (_ string, err error)

CreateDevice creates a device-mapper device with the given target spec. It returns the path of the new device node.

func CreateDeviceWithRetryErrors

func CreateDeviceWithRetryErrors(
	ctx context.Context,
	name string,
	flags CreateFlags,
	targets []Target,
	errs ...error,
) (string, error)

CreateDeviceWithRetryErrors keeps retrying to create device mapper target

func CreateVerityTarget

func CreateVerityTarget(ctx context.Context, devPath, devName string, verityInfo *guestresource.DeviceVerityInfo) (_ string, err error)

CreateVerityTarget creates a dm-verity target for a given device and returns created virtual block device path.

Example verity target table:

  0 417792 verity 1 /dev/sdb /dev/sdc 4096 4096 52224 1 sha256 2aa4f7b7b6...f4952060e8 762307f4bc8...d2a6b7595d8..
  |   |      |    |     |        |    |     |     |   |    |              |                        |
start |      |    | data_dev     |    |     | #blocks | hash_alg      root_digest                salt
     size    |  version      hash_dev | hash_block_sz |
           target              data_block_sz      hash_offset

See dm-verity for more information

func CreateZeroSectorLinearTarget

func CreateZeroSectorLinearTarget(ctx context.Context, devPath, devName string, mappingInfo *guestresource.LCOWVPMemMappingInfo) (_ string, err error)

CreateZeroSectorLinearTarget creates dm-linear target for a device at `devPath` and `mappingInfo`, returns virtual block device path.

func RemoveDevice

func RemoveDevice(name string) (err error)

RemoveDevice removes a device-mapper device and its associated device node.

Types

type CreateFlags

type CreateFlags int

CreateFlags modify the operation of CreateDevice

const (
	// CreateReadOnly specifies that the device is not writable
	CreateReadOnly CreateFlags = 1 << iota
)

type Target

type Target struct {
	Type           string
	SectorStart    int64
	LengthInBlocks int64
	Params         string
}

Target specifies a single entry in a device's target specification.

func LinearTarget

func LinearTarget(sectorStart, lengthBlocks int64, path string, deviceStart int64) Target

LinearTarget constructs a device-mapper target that maps a portion of a block device at the specified offset.

Example linear target table:
0 20971520 linear /dev/hda 384
|     |      |        |     |
start |   target   data_dev |
     size                 offset

Jump to

Keyboard shortcuts

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