gadgettest

package
v0.0.0-...-ab92e14 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ExpectedLUKSEncryptedRaspiDiskVolumeDeviceTraitsJSON = `` /* 2346-byte string literal not displayed */
View Source
const ExpectedRaspiDiskVolumeDeviceTraitsJSON = `` /* 2190-byte string literal not displayed */
View Source
const ExpectedRaspiDiskVolumeMultiVolumeDeviceNoSaveTraitsJSON = `` /* 2469-byte string literal not displayed */
View Source
const ExpectedRaspiDiskVolumeMultiVolumeDeviceTraitsJSON = `` /* 2951-byte string literal not displayed */
View Source
const ExpectedRaspiDiskVolumeNoSaveDeviceTraitsJSON = `` /* 1708-byte string literal not displayed */
View Source
const MockExtraVolumeYAML = `` /* 352-byte string literal not displayed */
View Source
const MultiVolumeUC20GadgetYaml = SingleVolumeUC20GadgetYaml + `
  foo:
    schema: gpt
    structure:
      - name: barething
        type: bare
        size: 4096
      - name: nofspart
        type: A11D2A7C-D82A-4C2F-8A01-1805240E6626
        size: 4096
      - name: some-filesystem
        filesystem: ext4
        type: 83,0FC63DAF-8483-4772-8E79-3D69D8477DE4
        size: 1G
`
View Source
const MultiVolumeUC20GadgetYamlNoBIOS = SingleVolumeUC20GadgetYamlSeedNoBIOS + `
  foo:
    schema: gpt
    structure:
      - name: barething
        type: bare
        size: 4096
      - name: nofspart
        type: A11D2A7C-D82A-4C2F-8A01-1805240E6626
        size: 4096
      - name: some-filesystem
        filesystem: ext4
        type: 83,0FC63DAF-8483-4772-8E79-3D69D8477DE4
        size: 1G
`
View Source
const RaspiMultiVolumeAssignmentNoSaveYaml = `` /* 750-byte string literal not displayed */
View Source
const RaspiMultiVolumeAssignmentYaml = `` /* 889-byte string literal not displayed */
View Source
const RaspiSimplifiedNoSaveYaml = `` /* 418-byte string literal not displayed */

from a rpi without the kernel assets or content layout for simplicity's sake and without ubuntu-save

View Source
const RaspiSimplifiedVolumeAssignmentYaml = `` /* 673-byte string literal not displayed */
View Source
const RaspiSimplifiedYaml = `` /* 557-byte string literal not displayed */

from a rpi without the kernel assets or content layout for simplicity's sake

View Source
const RaspiUC18SimplifiedYaml = `` /* 169-byte string literal not displayed */

from UC18 image, for testing the implicit system data partition case

View Source
const SingleVolumeClassicWithModesAndSystemSeedGadgetYaml = `` /* 1325-byte string literal not displayed */
View Source
const SingleVolumeClassicWithModesFilledPartialGadgetYaml = `` /* 1143-byte string literal not displayed */
View Source
const SingleVolumeClassicWithModesGadgetYaml = `` /* 1630-byte string literal not displayed */
View Source
const SingleVolumeClassicWithModesPartialGadgetYaml = `` /* 613-byte string literal not displayed */
View Source
const SingleVolumeClassicwithModesEncryptGadgetYaml = `` /* 937-byte string literal not displayed */
View Source
const SingleVolumeClassicwithModesNoEncryptGadgetYaml = `` /* 788-byte string literal not displayed */
View Source
const SingleVolumeUC20GadgetYaml = `` /* 961-byte string literal not displayed */
View Source
const SingleVolumeUC20GadgetYamlSeedNoBIOS = `` /* 818-byte string literal not displayed */
View Source
const UC16YAMLImplicitSystemData = `` /* 408-byte string literal not displayed */

adapted from https://github.com/snapcore/pc-amd64-gadget/blob/16/gadget.yaml but without the content

View Source
const VMMultiVolumeUC20DiskTraitsJSON = `` /* 4006-byte string literal not displayed */
View Source
const VMSingleVolumeUC20DiskTraitsJSON = `` /* 3044-byte string literal not displayed */

like VMMultiVolumeUC20DiskTraitsJSON but without the foo volume

Variables

View Source
var ExpectedLUKSEncryptedRaspiDiskVolumeDeviceTraits = gadget.DiskVolumeDeviceTraits{
	OriginalDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0",
	OriginalKernelPath: "/dev/mmcblk0",
	DiskID:             "7c301cbd",
	Size:               30528 * quantity.SizeMiB,
	SectorSize:         512,
	Schema:             "dos",
	StructureEncryption: map[string]gadget.StructureEncryptionParameters{
		"ubuntu-data": {Method: gadget.EncryptionLUKS},
		"ubuntu-save": {Method: gadget.EncryptionLUKS},
	},
	Structure: []gadget.DiskStructureDeviceTraits{
		expPiSeedStructureTraits,
		expPiBootStructureTraits,
		expPiSaveEncStructureTraits,
		expPiDataEncStructureTraits,
	},
}

ExpectedLUKSEncryptedRaspiDiskVolumeDeviceTraits is like ExpectedRaspiDiskVolumeDeviceTraits, but it uses the "-enc" suffix for the filesystem labels and has crypto_LUKS as the filesystem types

View Source
var ExpectedLUKSEncryptedRaspiMockDiskMapping = &disks.MockDiskMapping{
	DevNode:             "/dev/mmcblk0",
	DevPath:             "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0",
	DevNum:              "179:0",
	DiskUsableSectorEnd: 30528 * oneMeg / 512,
	DiskSizeInBytes:     30528 * oneMeg,
	SectorSizeBytes:     512,
	DiskSchema:          "dos",
	ID:                  "7c301cbd",
	Structure: []disks.Partition{
		mockSeedPartition,
		mockBootPartition,

		{
			PartitionUUID:    "7c301cbd-03",
			PartitionType:    "83",
			FilesystemLabel:  "ubuntu-save-enc",
			FilesystemUUID:   "1cdd5826-e9de-4d27-83f7-20249e710590",
			FilesystemType:   "crypto_LUKS",
			Major:            179,
			Minor:            3,
			KernelDeviceNode: "/dev/mmcblk0p3",
			KernelDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p3",
			DiskIndex:        3,
			StartInBytes:     (1 + 1200 + 750) * oneMeg,
			SizeInBytes:      16 * oneMeg,
		},
		{
			PartitionUUID:    "7c301cbd-04",
			PartitionType:    "83",
			FilesystemLabel:  "ubuntu-data-enc",
			FilesystemUUID:   "d7f39661-1da0-48de-8967-ce41343d4345",
			FilesystemType:   "crypto_LUKS",
			Major:            179,
			Minor:            4,
			KernelDeviceNode: "/dev/mmcblk0p4",
			KernelDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p4",
			DiskIndex:        4,
			StartInBytes:     (1 + 1200 + 750 + 16) * oneMeg,
			SizeInBytes:      (30528 - (1 + 1200 + 750 + 16)) * oneMeg,
		},
	},
}

ExpectedLUKSEncryptedRaspiMockDiskMapping is like ExpectedRaspiMockDiskMapping, but it uses the "-enc" suffix for the filesystem labels and has crypto_LUKS as the filesystem types

View Source
var ExpectedRaspiDiskVolumeDeviceBackupTraits = gadget.DiskVolumeDeviceTraits{
	OriginalDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc1/mmc1:0001/block/mmcblk1",
	OriginalKernelPath: "/dev/mmcblk1",
	DiskID:             "7c301cbe",
	Size:               128 * quantity.SizeMiB,
	SectorSize:         512,
	Schema:             "dos",
	Structure: []gadget.DiskStructureDeviceTraits{
		expPiBackupStructureTraits,
	},
}
View Source
var ExpectedRaspiDiskVolumeDeviceNoSaveTraits = gadget.DiskVolumeDeviceTraits{
	OriginalDevicePath:  "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0",
	OriginalKernelPath:  "/dev/mmcblk0",
	DiskID:              "7c301cbd",
	Size:                30528 * quantity.SizeMiB,
	SectorSize:          512,
	Schema:              "dos",
	StructureEncryption: map[string]gadget.StructureEncryptionParameters{},
	Structure: []gadget.DiskStructureDeviceTraits{
		expPiSeedStructureTraits,
		expPiBootStructureTraits,
		expPiDataNoSaveStructureTraits,
	},
}
View Source
var ExpectedRaspiDiskVolumeDeviceTraits = gadget.DiskVolumeDeviceTraits{
	OriginalDevicePath:  "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0",
	OriginalKernelPath:  "/dev/mmcblk0",
	DiskID:              "7c301cbd",
	Size:                30528 * quantity.SizeMiB,
	SectorSize:          512,
	Schema:              "dos",
	StructureEncryption: map[string]gadget.StructureEncryptionParameters{},
	Structure: []gadget.DiskStructureDeviceTraits{
		expPiSeedStructureTraits,
		expPiBootStructureTraits,
		expPiSaveStructureTraits,
		expPiDataStructureTraits,
	},
}
View Source
var ExpectedRaspiMockBackupDiskMapping = &disks.MockDiskMapping{
	DevNode:             "/dev/mmcblk1",
	DevPath:             "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc1/mmc1:0001/block/mmcblk1",
	DevNum:              "180:0",
	DiskUsableSectorEnd: 128 * oneMeg / 512,
	DiskSizeInBytes:     128 * oneMeg,
	SectorSizeBytes:     512,
	DiskSchema:          "dos",
	ID:                  "7c301cbe",
	Structure: []disks.Partition{
		{
			PartitionUUID:    "7c301cbe-01",
			PartitionType:    "83",
			FilesystemLabel:  "system-backup",
			FilesystemUUID:   "1cdd5826-e9de-4d27-83f7-20249e710591",
			FilesystemType:   "ext4",
			Major:            180,
			Minor:            1,
			KernelDeviceNode: "/dev/mmcblk1p1",
			KernelDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc1/mmc1:0001/block/mmcblk1/mmcblk1p1",
			DiskIndex:        1,
			StartInBytes:     oneMeg,
			SizeInBytes:      127 * oneMeg,
		},
	},
}
View Source
var ExpectedRaspiMockDiskInstallModeMapping = &disks.MockDiskMapping{
	DevNode:             "/dev/mmcblk0",
	DevPath:             "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0",
	DevNum:              "179:0",
	DiskUsableSectorEnd: 30528 * oneMeg / 512,
	DiskSizeInBytes:     30528 * oneMeg,
	SectorSizeBytes:     512,
	DiskSchema:          "dos",
	ID:                  "7c301cbd",
	Structure: []disks.Partition{

		mockSeedPartition,
	},
}

ExpectedRaspiMockDiskInstallModeMapping is like ExpectedRaspiMockDiskMapping but for fresh install mode image where we only have the ubuntu-seed partition on disk.

View Source
var ExpectedRaspiMockDiskMapping = &disks.MockDiskMapping{
	DevNode:             "/dev/mmcblk0",
	DevPath:             "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0",
	DevNum:              "179:0",
	DiskUsableSectorEnd: 30528 * oneMeg / 512,
	DiskSizeInBytes:     30528 * oneMeg,
	SectorSizeBytes:     512,
	DiskSchema:          "dos",
	ID:                  "7c301cbd",
	Structure: []disks.Partition{
		mockSeedPartition,
		mockBootPartition,
		{
			PartitionUUID:    "7c301cbd-03",
			PartitionType:    "83",
			FilesystemLabel:  "ubuntu-save",
			FilesystemUUID:   "1cdd5826-e9de-4d27-83f7-20249e710590",
			FilesystemType:   "ext4",
			Major:            179,
			Minor:            3,
			KernelDeviceNode: "/dev/mmcblk0p3",
			KernelDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p3",
			DiskIndex:        3,
			StartInBytes:     (1 + 1200 + 750) * oneMeg,
			SizeInBytes:      16 * oneMeg,
		},
		{
			PartitionUUID:    "7c301cbd-04",
			PartitionType:    "83",
			FilesystemLabel:  "ubuntu-data",
			FilesystemUUID:   "d7f39661-1da0-48de-8967-ce41343d4345",
			FilesystemType:   "ext4",
			Major:            179,
			Minor:            4,
			KernelDeviceNode: "/dev/mmcblk0p4",
			KernelDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p4",
			DiskIndex:        4,
			StartInBytes:     (1 + 1200 + 750 + 16) * oneMeg,
			SizeInBytes:      (30528 - (1 + 1200 + 750 + 16)) * oneMeg,
		},
	},
}
View Source
var ExpectedRaspiMockDiskMappingNoSave = &disks.MockDiskMapping{
	DevNode:             "/dev/mmcblk0",
	DevPath:             "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0",
	DevNum:              "179:0",
	DiskUsableSectorEnd: 30528 * oneMeg / 512,
	DiskSizeInBytes:     30528 * oneMeg,
	SectorSizeBytes:     512,
	DiskSchema:          "dos",
	ID:                  "7c301cbd",
	Structure: []disks.Partition{
		mockSeedPartition,
		mockBootPartition,
		{
			PartitionUUID:    "7c301cbd-03",
			PartitionType:    "83",
			FilesystemLabel:  "ubuntu-data",
			FilesystemUUID:   "d7f39661-1da0-48de-8967-ce41343d4345",
			FilesystemType:   "ext4",
			Major:            179,
			Minor:            3,
			KernelDeviceNode: "/dev/mmcblk0p3",
			KernelDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p3",
			DiskIndex:        3,
			StartInBytes:     (1 + 1200 + 750) * oneMeg,
			SizeInBytes:      (30528 - (1 + 1200 + 750)) * oneMeg,
		},
	},
}
View Source
var ExpectedRaspiUC18DiskVolumeDeviceTraits = gadget.DiskVolumeDeviceTraits{
	OriginalDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0",
	OriginalKernelPath: "/dev/mmcblk0",
	DiskID:             "7c301cbd",
	Size:               32010928128,
	SectorSize:         512,
	Schema:             "dos",
	Structure: []gadget.DiskStructureDeviceTraits{
		{
			OriginalDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1",
			OriginalKernelPath: "/dev/mmcblk0p1",
			PartitionUUID:      "7c301cbd-01",
			PartitionType:      "0C",
			PartitionLabel:     "",
			FilesystemUUID:     "23F9-881F",
			FilesystemLabel:    "system-boot",
			FilesystemType:     "vfat",
			Offset:             quantity.OffsetMiB,
			Size:               256 * quantity.SizeMiB,
		},
	},
}

ExpectedRaspiUC18DiskVolumeDeviceTraits, for testing the implicit system data partition case

View Source
var ExpectedRaspiUC18MockDiskMapping = &disks.MockDiskMapping{
	DevNode:             "/dev/mmcblk0",
	DevPath:             "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0",
	DevNum:              "179:0",
	DiskUsableSectorEnd: 30528 * oneMeg / 512,
	DiskSizeInBytes:     30528 * oneMeg,
	SectorSizeBytes:     512,
	DiskSchema:          "dos",
	ID:                  "7c301cbd",
	Structure: []disks.Partition{
		{
			PartitionUUID:    "7c301cbd-01",
			PartitionType:    "0C",
			FilesystemLabel:  "system-boot",
			FilesystemUUID:   "23F9-881F",
			FilesystemType:   "vfat",
			Major:            179,
			Minor:            1,
			KernelDeviceNode: "/dev/mmcblk0p1",
			KernelDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p1",
			DiskIndex:        1,
			StartInBytes:     oneMeg,
			SizeInBytes:      256 * oneMeg,
		},
		{
			PartitionUUID:    "7c301cbd-02",
			PartitionType:    "83",
			FilesystemLabel:  "writable",
			FilesystemUUID:   "cba2b8b3-c2e4-4e51-9a57-d35041b7bf9a",
			FilesystemType:   "ext4",
			Major:            179,
			Minor:            2,
			KernelDeviceNode: "/dev/mmcblk0p2",
			KernelDevicePath: "/sys/devices/platform/emmc2bus/fe340000.emmc2/mmc_host/mmc0/mmc0:0001/block/mmcblk0/mmcblk0p2",
			DiskIndex:        2,
			StartInBytes:     (1 + 256) * oneMeg,
			SizeInBytes:      32270 * oneMeg,
		},
	},
}

ExpectedRaspiUC18MockDiskMapping, for testing the implicit system data partition case

View Source
var MockExtraVolumeDeviceTraits = gadget.DiskVolumeDeviceTraits{
	OriginalDevicePath: "/sys/block/foo",
	OriginalKernelPath: "/dev/foo",
	DiskID:             "651AC800-B9FB-4B9D-B6D3-A72EB54D9006",
	SectorSize:         512,
	Size:               6000 * quantity.SizeMiB,
	Schema:             "gpt",
	Structure: []gadget.DiskStructureDeviceTraits{

		{
			PartitionLabel:     "nofspart",
			PartitionUUID:      "C5A930DF-E86A-4BAE-A4C5-C861353796E6",
			PartitionType:      "EBBEADAF-22C9-E33B-8F5D-0E81686A68CB",
			OriginalDevicePath: "/sys/block/foo/foo1",
			OriginalKernelPath: "/dev/foo1",

			Offset: quantity.OffsetMiB + quantity.OffsetKiB,
			Size:   4096,
		},
		{
			PartitionLabel:     "some-filesystem",
			PartitionUUID:      "DA2ADBC8-90DF-4B1D-A93F-A92516C12E01",
			PartitionType:      "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			OriginalDevicePath: "/sys/block/foo/foo2",
			OriginalKernelPath: "/dev/foo2",
			FilesystemLabel:    "some-filesystem",
			FilesystemUUID:     "3E3D392C-5D50-4C84-8A6E-09B7A3FEA2C7",
			FilesystemType:     "ext4",
			Offset:             quantity.OffsetMiB + quantity.OffsetKiB + 4096,
			Size:               quantity.SizeGiB,
		},
	},
}
View Source
var MockExtraVolumeDiskMapping = &disks.MockDiskMapping{
	DevNode: "/dev/foo",
	DevPath: "/sys/block/foo",
	DevNum:  "525:1",

	DiskUsableSectorEnd: 6000*oneMeg/512 - 34,
	DiskSizeInBytes:     6000 * oneMeg,
	SectorSizeBytes:     512,
	DiskSchema:          "gpt",
	ID:                  "651AC800-B9FB-4B9D-B6D3-A72EB54D9006",
	Structure: []disks.Partition{

		{
			PartitionLabel:   "nofspart",
			PartitionUUID:    "C5A930DF-E86A-4BAE-A4C5-C861353796E6",
			PartitionType:    "EBBEADAF-22C9-E33B-8F5D-0E81686A68CB",
			FilesystemType:   "",
			Major:            525,
			Minor:            2,
			KernelDeviceNode: "/dev/foo1",
			KernelDevicePath: "/sys/block/foo/foo1",
			DiskIndex:        1,

			StartInBytes: oneMeg + 1024,
			SizeInBytes:  4096,
		},
		{
			PartitionLabel:   "some-filesystem",
			PartitionUUID:    "DA2ADBC8-90DF-4B1D-A93F-A92516C12E01",
			PartitionType:    "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			FilesystemLabel:  "some-filesystem",
			FilesystemUUID:   "3E3D392C-5D50-4C84-8A6E-09B7A3FEA2C7",
			FilesystemType:   "ext4",
			Major:            525,
			Minor:            3,
			KernelDeviceNode: "/dev/foo2",
			KernelDevicePath: "/sys/block/foo/foo2",
			DiskIndex:        2,
			StartInBytes:     oneMeg + 1024 + 4096,
			SizeInBytes:      1024 * oneMeg,
		},
	},
}
View Source
var MockGadgetPartitionedOnDiskVolume = gadget.OnDiskVolume{
	ID:               "f0eef013-a777-4a27-aaf0-dbb5cf68c2b6",
	Schema:           "gpt",
	Size:             7340032000,
	UsableSectorsEnd: 14335966,
	SectorSize:       512,
	Device:           "/dev/vda",
	Structure: []gadget.OnDiskStructure{
		{
			Name:             "BIOS Boot",
			Node:             "/dev/vda1",
			PartitionFSLabel: "",
			PartitionFSType:  "",
			Type:             "21686148-6449-6E6F-744E-656564454649",
			StartOffset:      quantity.OffsetMiB,
			DiskIndex:        1,
			Size:             quantity.SizeMiB,
		},
		{
			Name:             "EFI System partition",
			Node:             "/dev/vda2",
			PartitionFSLabel: "",
			PartitionFSType:  "vfat",
			Type:             "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
			StartOffset:      2 * quantity.OffsetMiB,
			DiskIndex:        2,
			Size:             99 * quantity.SizeMiB,
		},
		{
			Name:             "ubuntu-boot",
			Node:             "/dev/vda3",
			PartitionFSLabel: "ubuntu-boot",
			PartitionFSType:  "ext4",
			Type:             "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			StartOffset:      1202 * quantity.OffsetMiB,
			DiskIndex:        3,
			Size:             750 * quantity.SizeMiB,
		},
		{
			Name:             "ubuntu-save",
			Node:             "/dev/vda4",
			PartitionFSLabel: "ubuntu-save",
			PartitionFSType:  "ext4",
			Type:             "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			StartOffset:      1952 * quantity.OffsetMiB,
			DiskIndex:        4,
			Size:             16 * quantity.SizeMiB,
		},
		{
			Name:             "ubuntu-data",
			Node:             "/dev/vda5",
			PartitionFSLabel: "ubuntu-data",
			PartitionFSType:  "ext4",
			Type:             "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			StartOffset:      1968 * quantity.OffsetMiB,
			DiskIndex:        5,
			Size:             4096 * quantity.SizeMiB,
		},
	},
}

This matches the disk mapping set by MockGadgetPartitionedDisk

View Source
var UC16DeviceLayout = gadget.OnDiskVolume{
	Structure: []gadget.OnDiskStructure{
		{
			Name:        "BIOS Boot",
			Type:        "21686148-6449-6E6F-744E-656564454649",
			StartOffset: quantity.OffsetMiB,
			DiskIndex:   1,
			Node:        "/dev/sda1",
			Size:        quantity.SizeMiB,
		},
		{
			Name:             "EFI System",
			Type:             "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
			PartitionFSLabel: "system-boot",
			PartitionFSType:  "vfat",
			StartOffset:      2097152,
			DiskIndex:        2,
			Node:             "/dev/sda2",
			Size:             52428800,
		},
		{
			Name:             "writable",
			Type:             "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			PartitionFSLabel: "writable",
			PartitionFSType:  "ext4",
			Size:             10682875392,
			StartOffset:      54525952,
			DiskIndex:        3,
			Node:             "/dev/sda3",
		},
	},
	ID:               "2a9b0671-4597-433b-b3ad-be99950e8c5e",
	Device:           "/dev/sda",
	Schema:           "gpt",
	Size:             10737418240,
	UsableSectorsEnd: 20971487,
	SectorSize:       512,
}

uc16 layout from a VM that has an implicit system-data as the third partition

View Source
var UC16ImplicitSystemDataDeviceTraits = gadget.DiskVolumeDeviceTraits{
	OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:01.1/ata1/host0/target0:0:0/0:0:0:0/block/sda",
	OriginalKernelPath: "/dev/sda",
	DiskID:             "f69dbcfe-1258-4b36-9d1f-817fdeb61aa3",
	Size:               10737418240,
	SectorSize:         512,
	Schema:             "gpt",
	Structure: []gadget.DiskStructureDeviceTraits{
		{
			OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:01.1/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda1",
			OriginalKernelPath: "/dev/sda1",
			PartitionUUID:      "420e5a20-b888-42e2-b7df-ced5cbf14517",
			PartitionType:      "21686148-6449-6E6F-744E-656564454649",
			PartitionLabel:     "BIOS\\x20Boot",
			Offset:             quantity.OffsetMiB,
			Size:               quantity.SizeMiB,
		},
		{
			OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:01.1/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda2",
			OriginalKernelPath: "/dev/sda2",
			PartitionUUID:      "fc8626b9-af30-4b3c-83c4-05bed39bb82e",
			PartitionType:      "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
			PartitionLabel:     "EFI\\x20System",
			FilesystemType:     "vfat",
			FilesystemUUID:     "6D21-B3FE",
			FilesystemLabel:    "system-boot",
			Offset:             quantity.OffsetMiB + quantity.OffsetMiB,
			Size:               50 * quantity.SizeMiB,
		},
	},
}
View Source
var UC16ImplicitSystemDataMockDiskMapping = &disks.MockDiskMapping{
	DevNode: "/dev/sda",
	DevPath: "/sys/devices/pci0000:00/0000:00:01.1/ata1/host0/target0:0:0/0:0:0:0/block/sda",
	DevNum:  "600:1",

	DiskUsableSectorEnd: 10240*oneMeg/512 - 33,
	DiskSizeInBytes:     10240 * oneMeg,
	SectorSizeBytes:     512,
	DiskSchema:          "gpt",
	ID:                  "f69dbcfe-1258-4b36-9d1f-817fdeb61aa3",
	Structure: []disks.Partition{
		{
			KernelDeviceNode: "/dev/sda1",
			KernelDevicePath: "/sys/devices/pci0000:00/0000:00:01.1/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda1",
			PartitionUUID:    "420e5a20-b888-42e2-b7df-ced5cbf14517",
			PartitionLabel:   "BIOS\\x20Boot",
			PartitionType:    "21686148-6449-6E6F-744E-656564454649",
			StartInBytes:     oneMeg,
			SizeInBytes:      oneMeg,
			Major:            600,
			Minor:            2,
			DiskIndex:        1,
		},
		{
			KernelDeviceNode: "/dev/sda2",
			KernelDevicePath: "/sys/devices/pci0000:00/0000:00:01.1/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda2",
			PartitionUUID:    "fc8626b9-af30-4b3c-83c4-05bed39bb82e",
			PartitionLabel:   "EFI\\x20System",
			PartitionType:    "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
			FilesystemUUID:   "6D21-B3FE",
			FilesystemLabel:  "system-boot",
			FilesystemType:   "vfat",

			StartInBytes: (1 + 1) * oneMeg,
			SizeInBytes:  50 * oneMeg,
			Major:        600,
			Minor:        3,
			DiskIndex:    2,
		},

		{
			KernelDeviceNode: "/dev/sda3",
			KernelDevicePath: "/sys/devices/pci0000:00/0000:00:01.1/ata1/host0/target0:0:0/0:0:0:0/block/sda/sda3",
			PartitionUUID:    "ade3ba65-7831-fd40-bbe2-e01c9774ed5b",
			PartitionLabel:   "writable",
			PartitionType:    "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			FilesystemUUID:   "cba2b8b3-c2e4-4e51-9a57-d35041b7bf9a",
			FilesystemLabel:  "writable",
			FilesystemType:   "ext4",

			StartInBytes: (50 + 1 + 1) * oneMeg,
			SizeInBytes:  10682875392,
			Major:        600,
			Minor:        4,
			DiskIndex:    3,
		},
	},
}
View Source
var VMExtraVolumeDeviceTraits = gadget.DiskVolumeDeviceTraits{
	OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:04.0/virtio2/block/vdb",
	OriginalKernelPath: "/dev/vdb",
	DiskID:             "86964016-3b5c-477e-9828-24ba9c552d39",
	Size:               5120 * quantity.SizeMiB,
	SectorSize:         quantity.Size(512),
	Schema:             "gpt",
	Structure: []gadget.DiskStructureDeviceTraits{

		{
			OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:04.0/virtio2/block/vdb/vdb1",
			OriginalKernelPath: "/dev/vdb1",
			PartitionUUID:      "691d89b6-d4c1-4c08-a060-fc10d98337da",
			PartitionLabel:     "nofspart",
			PartitionType:      "A11D2A7C-D82A-4C2F-8A01-1805240E6626",
			Offset:             quantity.OffsetMiB + 4096,
			Size:               4096,
		},

		{
			OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:04.0/virtio2/block/vdb/vdb2",
			OriginalKernelPath: "/dev/vdb2",
			PartitionUUID:      "7a3c051c-eae2-4c36-bed8-1914709ebf4c",
			PartitionLabel:     "some-filesystem",
			PartitionType:      "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			FilesystemUUID:     "afb36b05-3796-4edf-87aa-9f9aa22f9324",
			FilesystemLabel:    "some-filesystem",
			FilesystemType:     "ext4",
			Offset:             quantity.OffsetMiB + 4096 + 4096,
			Size:               quantity.SizeGiB,
		},
	},
}
View Source
var VMExtraVolumeDiskMapping = &disks.MockDiskMapping{
	DevNode: "/dev/vdb",
	DevPath: "/sys/devices/pci0000:00/0000:00:04.0/virtio2/block/vdb",
	DevNum:  "525:1",

	DiskUsableSectorEnd: 5120*oneMeg/512 - 34,
	DiskSizeInBytes:     5120 * oneMeg,
	SectorSizeBytes:     512,
	DiskSchema:          "gpt",
	ID:                  "86964016-3b5c-477e-9828-24ba9c552d39",
	Structure: []disks.Partition{

		{
			PartitionLabel:   "nofspart",
			PartitionUUID:    "691d89b6-d4c1-4c08-a060-fc10d98337da",
			PartitionType:    "A11D2A7C-D82A-4C2F-8A01-1805240E6626",
			FilesystemType:   "",
			Major:            525,
			Minor:            2,
			KernelDeviceNode: "/dev/vdb1",
			KernelDevicePath: "/sys/devices/pci0000:00/0000:00:04.0/virtio2/block/vdb/vdb1",
			DiskIndex:        1,

			StartInBytes: oneMeg + 4096,
			SizeInBytes:  4096,
		},
		{
			PartitionLabel:   "some-filesystem",
			PartitionUUID:    "7a3c051c-eae2-4c36-bed8-1914709ebf4c",
			PartitionType:    "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			FilesystemLabel:  "some-filesystem",
			FilesystemUUID:   "afb36b05-3796-4edf-87aa-9f9aa22f9324",
			FilesystemType:   "ext4",
			Major:            525,
			Minor:            3,
			KernelDeviceNode: "/dev/vdb2",
			KernelDevicePath: "/sys/devices/pci0000:00/0000:00:04.0/virtio2/block/vdb/vdb2",
			DiskIndex:        2,
			StartInBytes:     4096 + oneMeg + 4096,
			SizeInBytes:      1024 * oneMeg,
		},
	},
}
View Source
var VMSystemVolumeDeviceTraits = gadget.DiskVolumeDeviceTraits{
	OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda",
	OriginalKernelPath: "/dev/vda",
	DiskID:             "f0eef013-a777-4a27-aaf0-dbb5cf68c2b6",
	Schema:             "gpt",
	Size:               5120 * quantity.SizeMiB,
	SectorSize:         quantity.Size(512),
	Structure: []gadget.DiskStructureDeviceTraits{
		{
			OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda1",
			OriginalKernelPath: "/dev/vda1",
			PartitionUUID:      "420e5a20-b888-42e2-b7df-ced5cbf14517",
			PartitionLabel:     "BIOS\\x20Boot",
			PartitionType:      "21686148-6449-6E6F-744E-656564454649",
			Offset:             quantity.OffsetMiB,
			Size:               quantity.SizeMiB,
		},
		{
			OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda2",
			OriginalKernelPath: "/dev/vda2",
			PartitionUUID:      "4b436628-71ba-43f9-aa12-76b84fe32728",
			PartitionLabel:     "ubuntu-seed",
			PartitionType:      "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
			FilesystemUUID:     "04D6-5AE2",
			FilesystemLabel:    "ubuntu-seed",
			FilesystemType:     "vfat",
			Offset:             (1 + 1) * quantity.OffsetMiB,
			Size:               1200 * quantity.SizeMiB,
		},
		{
			OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda3",
			OriginalKernelPath: "/dev/vda3",
			PartitionUUID:      "ade3ba65-7831-fd40-bbe2-e01c9774ed5b",
			PartitionLabel:     "ubuntu-boot",
			PartitionType:      "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			FilesystemUUID:     "5b3e775a-407d-4af7-aa16-b92a8b7507e6",
			FilesystemLabel:    "ubuntu-boot",
			FilesystemType:     "ext4",
			Offset:             (1 + 1 + 1200) * quantity.OffsetMiB,
			Size:               750 * quantity.SizeMiB,
		},
		{
			OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda4",
			OriginalKernelPath: "/dev/vda4",
			PartitionUUID:      "f1d01870-194b-8a45-84c0-0d1c90e17d9d",
			PartitionLabel:     "ubuntu-save",
			PartitionType:      "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			FilesystemUUID:     "6766b605-9cd5-47ae-bc48-807c778b9987",
			FilesystemLabel:    "ubuntu-save",
			FilesystemType:     "ext4",
			Offset:             (1 + 1 + 1200 + 750) * quantity.OffsetMiB,
			Size:               16 * quantity.SizeMiB,
		},
		{
			OriginalDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda5",
			OriginalKernelPath: "/dev/vda5",
			PartitionUUID:      "4994f0e5-1ead-1a4d-b696-2d8cb1fa980d",
			PartitionLabel:     "ubuntu-data",
			PartitionType:      "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			FilesystemUUID:     "4e29a1e9-526d-48fc-a5c2-4f97e7e011e2",
			FilesystemLabel:    "ubuntu-data",
			FilesystemType:     "ext4",
			Offset:             (1 + 1 + 1200 + 750 + 16) * quantity.OffsetMiB,

			Size: ((5120*quantity.SizeMiB - 33*512) - (1+1+1200+750+16)*quantity.SizeMiB),
		},
	},
}
View Source
var VMSystemVolumeDiskMapping = &disks.MockDiskMapping{
	DevNode: "/dev/vda",
	DevPath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda",
	DevNum:  "600:1",

	DiskUsableSectorEnd: 5120*oneMeg/512 - 34,
	DiskSizeInBytes:     5120 * oneMeg,
	SectorSizeBytes:     512,
	DiskSchema:          "gpt",
	ID:                  "f0eef013-a777-4a27-aaf0-dbb5cf68c2b6",
	Structure: []disks.Partition{
		{
			KernelDeviceNode: "/dev/vda1",
			KernelDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda1",
			PartitionUUID:    "420e5a20-b888-42e2-b7df-ced5cbf14517",
			PartitionLabel:   "BIOS\\x20Boot",
			PartitionType:    "21686148-6449-6E6F-744E-656564454649",
			StartInBytes:     oneMeg,
			SizeInBytes:      oneMeg,
			Major:            600,
			Minor:            2,
			DiskIndex:        1,
		},
		{
			KernelDeviceNode: "/dev/vda2",
			KernelDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda2",
			PartitionUUID:    "4b436628-71ba-43f9-aa12-76b84fe32728",
			PartitionLabel:   "ubuntu-seed",
			PartitionType:    "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
			FilesystemUUID:   "04D6-5AE2",
			FilesystemLabel:  "ubuntu-seed",
			FilesystemType:   "vfat",
			StartInBytes:     (1 + 1) * oneMeg,
			SizeInBytes:      1200 * oneMeg,
			Major:            600,
			Minor:            3,
			DiskIndex:        2,
		},
		{
			KernelDeviceNode: "/dev/vda3",
			KernelDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda3",
			PartitionUUID:    "ade3ba65-7831-fd40-bbe2-e01c9774ed5b",
			PartitionLabel:   "ubuntu-boot",
			PartitionType:    "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			FilesystemUUID:   "5b3e775a-407d-4af7-aa16-b92a8b7507e6",
			FilesystemLabel:  "ubuntu-boot",
			FilesystemType:   "ext4",
			StartInBytes:     (1200 + 1 + 1) * oneMeg,
			SizeInBytes:      750 * oneMeg,
			Major:            600,
			Minor:            4,
			DiskIndex:        3,
		},
		{
			KernelDeviceNode: "/dev/vda4",
			KernelDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda4",
			PartitionUUID:    "f1d01870-194b-8a45-84c0-0d1c90e17d9d",
			PartitionLabel:   "ubuntu-save",
			PartitionType:    "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			FilesystemUUID:   "6766b605-9cd5-47ae-bc48-807c778b9987",
			FilesystemLabel:  "ubuntu-save",
			FilesystemType:   "ext4",
			StartInBytes:     (1200 + 1 + 1 + 750) * oneMeg,
			SizeInBytes:      16 * oneMeg,
			Major:            600,
			Minor:            5,
			DiskIndex:        4,
		},
		{
			KernelDeviceNode: "/dev/vda5",
			KernelDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda5",
			PartitionUUID:    "4994f0e5-1ead-1a4d-b696-2d8cb1fa980d",
			PartitionLabel:   "ubuntu-data",
			PartitionType:    "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			FilesystemUUID:   "4e29a1e9-526d-48fc-a5c2-4f97e7e011e2",
			FilesystemLabel:  "ubuntu-data",
			FilesystemType:   "ext4",
			StartInBytes:     (1200 + 1 + 1 + 750 + 16) * oneMeg,

			SizeInBytes: ((5120*oneMeg - 33*512) - (1+1+1200+750+16)*oneMeg),
			Major:       600,
			Minor:       6,
			DiskIndex:   5,
		},
	},
}
View Source
var VMSystemVolumeDiskMappingSeedFsLabelCaps = &disks.MockDiskMapping{
	DevNode: "/dev/vda",
	DevPath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda",
	DevNum:  "600:1",

	DiskUsableSectorEnd: 5120*oneMeg/512 - 34,
	DiskSizeInBytes:     5120 * oneMeg,
	SectorSizeBytes:     512,
	DiskSchema:          "gpt",
	ID:                  "f0eef013-a777-4a27-aaf0-dbb5cf68c2b6",
	Structure: []disks.Partition{
		{
			KernelDeviceNode: "/dev/vda1",
			KernelDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda2",
			PartitionUUID:    "4b436628-71ba-43f9-aa12-76b84fe32728",
			PartitionLabel:   "ubuntu-seed",
			PartitionType:    "C12A7328-F81F-11D2-BA4B-00A0C93EC93B",
			FilesystemUUID:   "04D6-5AE2",
			FilesystemLabel:  "UBUNTU-SEED",
			FilesystemType:   "vfat",
			StartInBytes:     1 * oneMeg,
			SizeInBytes:      1200 * oneMeg,
			Major:            600,
			Minor:            3,
			DiskIndex:        1,
		},
		{
			KernelDeviceNode: "/dev/vda2",
			KernelDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda3",
			PartitionUUID:    "ade3ba65-7831-fd40-bbe2-e01c9774ed5b",
			PartitionLabel:   "ubuntu-boot",
			PartitionType:    "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			FilesystemUUID:   "5b3e775a-407d-4af7-aa16-b92a8b7507e6",
			FilesystemLabel:  "ubuntu-boot",
			FilesystemType:   "ext4",
			StartInBytes:     (1200 + 1) * oneMeg,
			SizeInBytes:      750 * oneMeg,
			Major:            600,
			Minor:            4,
			DiskIndex:        2,
		},
		{
			KernelDeviceNode: "/dev/vda3",
			KernelDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda4",
			PartitionUUID:    "f1d01870-194b-8a45-84c0-0d1c90e17d9d",
			PartitionLabel:   "ubuntu-save",
			PartitionType:    "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			FilesystemUUID:   "6766b605-9cd5-47ae-bc48-807c778b9987",
			FilesystemLabel:  "ubuntu-save",
			FilesystemType:   "ext4",
			StartInBytes:     (1200 + 1 + 750) * oneMeg,
			SizeInBytes:      16 * oneMeg,
			Major:            600,
			Minor:            5,
			DiskIndex:        3,
		},
		{
			KernelDeviceNode: "/dev/vda4",
			KernelDevicePath: "/sys/devices/pci0000:00/0000:00:03.0/virtio1/block/vda/vda5",
			PartitionUUID:    "4994f0e5-1ead-1a4d-b696-2d8cb1fa980d",
			PartitionLabel:   "ubuntu-data",
			PartitionType:    "0FC63DAF-8483-4772-8E79-3D69D8477DE4",
			FilesystemUUID:   "4e29a1e9-526d-48fc-a5c2-4f97e7e011e2",
			FilesystemLabel:  "ubuntu-data",
			FilesystemType:   "ext4",
			StartInBytes:     (1200 + 1 + 750 + 16) * oneMeg,

			SizeInBytes: ((5120*oneMeg - 33*512) - (1+1+1200+750+16)*oneMeg),
			Major:       600,
			Minor:       6,
			DiskIndex:   4,
		},
	},
}

Functions

func LaidOutVolumesFromGadget

func LaidOutVolumesFromGadget(gadgetRoot, kernelRoot string, model gadget.Model, encType secboot.EncryptionType, volToGadgetToDiskStruct map[string]map[int]*gadget.OnDiskStructure) (all map[string]*gadget.LaidOutVolume, err error)

func LayoutFromYaml

func LayoutFromYaml(newDir, gadgetYaml string, model gadget.Model) (*gadget.LaidOutVolume, error)

LayoutFromYaml returns a LaidOutVolume for the given gadget.yaml string. It currently only supports gadget.yaml's with a single volume in them. An empty directory to use to create a gadget.yaml file should be provided, such as c.MkDir() in tests.

func LayoutMultiVolumeFromYaml

func LayoutMultiVolumeFromYaml(newDir, kernelDir, gadgetYaml string, model gadget.Model) (map[string]*gadget.LaidOutVolume, error)

LayoutMultiVolumeFromYaml returns all LaidOutVolumes for the given gadget.yaml string and works for either single or multiple volume gadget.yaml's. An empty directory to use to create a gadget.yaml file should be provided, such as c.MkDir() in tests.

func MakeMockGadget

func MakeMockGadget(gadgetRoot, gadgetContent string) error

func MockGadgetPartitionedDisk

func MockGadgetPartitionedDisk(gadgetYaml, gadgetRoot string) (ginfo *gadget.Info, laidVols map[string]*gadget.LaidOutVolume, model *asserts.Model, restore func(), err error)

func MustLayOutSingleVolumeFromGadget

func MustLayOutSingleVolumeFromGadget(gadgetRoot, kernelRoot string, model gadget.Model) (*gadget.LaidOutVolume, error)

MustLayOutSingleVolumeFromGadget takes a gadget rootdir and lays out the partitions as specified. This function does not handle multiple volumes and is meant for test helpers only. For runtime users, with multiple volumes handled by choosing the ubuntu-* role volume, see LaidOutVolumesFromGadget

func VolumeFromYaml

func VolumeFromYaml(newDir, gadgetYaml string, model gadget.Model) (*gadget.Volume, error)

func WriteGadgetYaml

func WriteGadgetYaml(newDir, gadgetYaml string) (string, error)

func WriteGadgetYamlReadInfo

func WriteGadgetYamlReadInfo(newDir, gadgetYaml string, model gadget.Model) (*gadget.Info, string, error)

Types

type ModelCharacteristics

type ModelCharacteristics struct {
	IsClassic bool
	HasModes  bool
}

func (*ModelCharacteristics) Classic

func (m *ModelCharacteristics) Classic() bool

func (*ModelCharacteristics) Grade

Jump to

Keyboard shortcuts

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