mirror of
https://github.com/kairos-io/kairos-sdk.git
synced 2025-08-10 03:27:15 +00:00
* ✨ Add state api This is related to https://github.com/kairos-io/kairos/issues/34. Starts to unify the API to retrieve the state in the sdk to have a common place to query system status information. * 🤖 Add test * Update go.mod * ⚙️ Fine-tune detection of partitions * 🤖 Add more fine-grained tests * 🎨 Add /dev/ to partition name * 🤖 Fixup tests * ⚙️ Remount accessors * ✨ Add state partition to cloud-init paths * 📝 Upper case Kairos in motd * 🎨 Add mounts sdk * 🎨 Set grub options via SDK * 🎨 Make it more idiomatic
35 lines
834 B
Go
35 lines
834 B
Go
package mounts
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/kairos-io/kairos/pkg/machine"
|
|
"github.com/kairos-io/kairos/sdk/state"
|
|
)
|
|
|
|
func PrepareWrite(partition state.PartitionState, mountpath string) error {
|
|
if partition.Mounted && partition.IsReadOnly {
|
|
if mountpath == partition.MountPoint {
|
|
return machine.Remount("rw", partition.MountPoint)
|
|
}
|
|
err := machine.Remount("rw", partition.MountPoint)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return machine.Mount(partition.Label, mountpath)
|
|
}
|
|
|
|
return machine.Mount(partition.Label, mountpath)
|
|
}
|
|
|
|
func Mount(partition state.PartitionState, mountpath string) error {
|
|
return machine.Mount(partition.Label, mountpath)
|
|
}
|
|
|
|
func Umount(partition state.PartitionState) error {
|
|
if !partition.Mounted {
|
|
return fmt.Errorf("partition not mounted")
|
|
}
|
|
return machine.Umount(partition.MountPoint)
|
|
}
|