2022-10-23 18:22:32 +00:00
|
|
|
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
|
|
|
|
}
|
2023-03-09 16:18:37 +00:00
|
|
|
return machine.Mount(partition.FilesystemLabel, mountpath)
|
2022-10-23 18:22:32 +00:00
|
|
|
}
|
|
|
|
|
2023-03-09 16:18:37 +00:00
|
|
|
return machine.Mount(partition.FilesystemLabel, mountpath)
|
2022-10-23 18:22:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func Mount(partition state.PartitionState, mountpath string) error {
|
2023-03-09 16:18:37 +00:00
|
|
|
return machine.Mount(partition.FilesystemLabel, mountpath)
|
2022-10-23 18:22:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func Umount(partition state.PartitionState) error {
|
|
|
|
if !partition.Mounted {
|
|
|
|
return fmt.Errorf("partition not mounted")
|
|
|
|
}
|
|
|
|
return machine.Umount(partition.MountPoint)
|
|
|
|
}
|