Bump ghw and fix state (#1073)

Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
This commit is contained in:
Itxaka
2023-03-09 17:18:37 +01:00
parent e3269dc88d
commit 227677ba92
2 changed files with 26 additions and 24 deletions

View File

@@ -16,14 +16,14 @@ func PrepareWrite(partition state.PartitionState, mountpath string) error {
if err != nil {
return err
}
return machine.Mount(partition.Label, mountpath)
return machine.Mount(partition.FilesystemLabel, mountpath)
}
return machine.Mount(partition.Label, mountpath)
return machine.Mount(partition.FilesystemLabel, mountpath)
}
func Mount(partition state.PartitionState, mountpath string) error {
return machine.Mount(partition.Label, mountpath)
return machine.Mount(partition.FilesystemLabel, mountpath)
}
func Umount(partition state.PartitionState) error {

View File

@@ -27,15 +27,16 @@ const (
type Boot string
type PartitionState struct {
Mounted bool `yaml:"mounted" json:"mounted"`
Name string `yaml:"name" json:"name"`
Label string `yaml:"label" json:"label"`
MountPoint string `yaml:"mount_point" json:"mount_point"`
SizeBytes uint64 `yaml:"size_bytes" json:"size_bytes"`
Type string `yaml:"type" json:"type"`
IsReadOnly bool `yaml:"read_only" json:"read_only"`
Found bool `yaml:"found" json:"found"`
UUID string `yaml:"uuid" json:"uuid"` // This would be volume UUID on macOS, PartUUID on linux, empty on Windows
Mounted bool `yaml:"mounted" json:"mounted"`
Name string `yaml:"name" json:"name"`
Label string `yaml:"label" json:"label"`
FilesystemLabel string `yaml:"filesystemlabel" json:"filesystemlabel"`
MountPoint string `yaml:"mount_point" json:"mount_point"`
SizeBytes uint64 `yaml:"size_bytes" json:"size_bytes"`
Type string `yaml:"type" json:"type"`
IsReadOnly bool `yaml:"read_only" json:"read_only"`
Found bool `yaml:"found" json:"found"`
UUID string `yaml:"uuid" json:"uuid"` // This would be volume UUID on macOS, PartUUID on linux, empty on Windows
}
type Kairos struct {
@@ -66,8 +67,8 @@ func detectPartition(b *block.Partition) PartitionState {
// This is a current shortcoming of ghw which only identifies mountpoints via device, not by label/uuid/anything else
mountpoint := b.MountPoint
readOnly := b.IsReadOnly
if b.MountPoint == "" && b.Label != "" {
out, err := utils.SH(fmt.Sprintf("findmnt /dev/disk/by-label/%s -f -J -o TARGET,FS-OPTIONS", b.Label))
if b.MountPoint == "" && b.FilesystemLabel != "" {
out, err := utils.SH(fmt.Sprintf("findmnt /dev/disk/by-label/%s -f -J -o TARGET,FS-OPTIONS", b.FilesystemLabel))
fmt.Println(out)
mnt := &FndMnt{}
if err == nil {
@@ -88,15 +89,16 @@ func detectPartition(b *block.Partition) PartitionState {
}
}
return PartitionState{
Type: b.Type,
IsReadOnly: readOnly,
UUID: b.UUID,
Name: fmt.Sprintf("/dev/%s", b.Name),
SizeBytes: b.SizeBytes,
Label: b.Label,
MountPoint: mountpoint,
Mounted: mountpoint != "",
Found: true,
Type: b.Type,
IsReadOnly: readOnly,
UUID: b.UUID,
Name: fmt.Sprintf("/dev/%s", b.Name),
SizeBytes: b.SizeBytes,
Label: b.Label,
FilesystemLabel: b.FilesystemLabel,
MountPoint: mountpoint,
Mounted: mountpoint != "",
Found: true,
}
}
@@ -129,7 +131,7 @@ func detectRuntimeState(r *Runtime) error {
}
for _, d := range blockDevices.Disks {
for _, part := range d.Partitions {
switch part.Label {
switch part.FilesystemLabel {
case "COS_PERSISTENT":
r.Persistent = detectPartition(part)
case "COS_RECOVERY":