mirror of
https://github.com/kairos-io/kairos-sdk.git
synced 2025-09-24 12:27:06 +00:00
Bump ghw and fix state (#1073)
Signed-off-by: Itxaka <itxaka.garcia@spectrocloud.com>
This commit is contained in:
@@ -16,14 +16,14 @@ func PrepareWrite(partition state.PartitionState, mountpath string) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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 {
|
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 {
|
func Umount(partition state.PartitionState) error {
|
||||||
|
@@ -27,15 +27,16 @@ const (
|
|||||||
type Boot string
|
type Boot string
|
||||||
|
|
||||||
type PartitionState struct {
|
type PartitionState struct {
|
||||||
Mounted bool `yaml:"mounted" json:"mounted"`
|
Mounted bool `yaml:"mounted" json:"mounted"`
|
||||||
Name string `yaml:"name" json:"name"`
|
Name string `yaml:"name" json:"name"`
|
||||||
Label string `yaml:"label" json:"label"`
|
Label string `yaml:"label" json:"label"`
|
||||||
MountPoint string `yaml:"mount_point" json:"mount_point"`
|
FilesystemLabel string `yaml:"filesystemlabel" json:"filesystemlabel"`
|
||||||
SizeBytes uint64 `yaml:"size_bytes" json:"size_bytes"`
|
MountPoint string `yaml:"mount_point" json:"mount_point"`
|
||||||
Type string `yaml:"type" json:"type"`
|
SizeBytes uint64 `yaml:"size_bytes" json:"size_bytes"`
|
||||||
IsReadOnly bool `yaml:"read_only" json:"read_only"`
|
Type string `yaml:"type" json:"type"`
|
||||||
Found bool `yaml:"found" json:"found"`
|
IsReadOnly bool `yaml:"read_only" json:"read_only"`
|
||||||
UUID string `yaml:"uuid" json:"uuid"` // This would be volume UUID on macOS, PartUUID on linux, empty on Windows
|
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 {
|
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
|
// This is a current shortcoming of ghw which only identifies mountpoints via device, not by label/uuid/anything else
|
||||||
mountpoint := b.MountPoint
|
mountpoint := b.MountPoint
|
||||||
readOnly := b.IsReadOnly
|
readOnly := b.IsReadOnly
|
||||||
if b.MountPoint == "" && 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.Label))
|
out, err := utils.SH(fmt.Sprintf("findmnt /dev/disk/by-label/%s -f -J -o TARGET,FS-OPTIONS", b.FilesystemLabel))
|
||||||
fmt.Println(out)
|
fmt.Println(out)
|
||||||
mnt := &FndMnt{}
|
mnt := &FndMnt{}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -88,15 +89,16 @@ func detectPartition(b *block.Partition) PartitionState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return PartitionState{
|
return PartitionState{
|
||||||
Type: b.Type,
|
Type: b.Type,
|
||||||
IsReadOnly: readOnly,
|
IsReadOnly: readOnly,
|
||||||
UUID: b.UUID,
|
UUID: b.UUID,
|
||||||
Name: fmt.Sprintf("/dev/%s", b.Name),
|
Name: fmt.Sprintf("/dev/%s", b.Name),
|
||||||
SizeBytes: b.SizeBytes,
|
SizeBytes: b.SizeBytes,
|
||||||
Label: b.Label,
|
Label: b.Label,
|
||||||
MountPoint: mountpoint,
|
FilesystemLabel: b.FilesystemLabel,
|
||||||
Mounted: mountpoint != "",
|
MountPoint: mountpoint,
|
||||||
Found: true,
|
Mounted: mountpoint != "",
|
||||||
|
Found: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -129,7 +131,7 @@ func detectRuntimeState(r *Runtime) error {
|
|||||||
}
|
}
|
||||||
for _, d := range blockDevices.Disks {
|
for _, d := range blockDevices.Disks {
|
||||||
for _, part := range d.Partitions {
|
for _, part := range d.Partitions {
|
||||||
switch part.Label {
|
switch part.FilesystemLabel {
|
||||||
case "COS_PERSISTENT":
|
case "COS_PERSISTENT":
|
||||||
r.Persistent = detectPartition(part)
|
r.Persistent = detectPartition(part)
|
||||||
case "COS_RECOVERY":
|
case "COS_RECOVERY":
|
||||||
|
Reference in New Issue
Block a user