Documentation ¶
Overview ¶
Package partition manipulate snappy disk partitions
Index ¶
- Variables
- func BootloaderDir() string
- func MigrateToDynamicGrub() error
- type Interface
- type MountOption
- type Partition
- func (p *Partition) BootloaderDir() string
- func (p *Partition) IsNextBootOther() bool
- func (p *Partition) MarkBootSuccessful() (err error)
- func (p *Partition) RunWithOther(option MountOption, f func(otherRoot string) (err error)) (err error)
- func (p *Partition) SyncBootloaderFiles(bootAssets map[string]string) (err error)
- func (p *Partition) ToggleNextBoot() (err error)
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBootloader is returned if the bootloader can not be determined ErrBootloader = errors.New("Unable to determine bootloader") // ErrPartitionDetection is returned if the partition type can not // be detected ErrPartitionDetection = errors.New("Failed to detect system type") // ErrNoDualPartition is returned if you try to use a dual // partition feature on a single partition ErrNoDualPartition = errors.New("No dual partition") )
var ( // ErrNoHardwareYaml is returned when no hardware yaml is found in // the update, this means that there is nothing to process with regards // to device parts. ErrNoHardwareYaml = errors.New("no hardware.yaml") )
Functions ¶
func BootloaderDir ¶
func BootloaderDir() string
BootloaderDir returns the full path to the (mounted and writable) bootloader-specific boot directory.
func MigrateToDynamicGrub ¶
func MigrateToDynamicGrub() error
MigrateToDynamicGrub rearranges things to work with the old, dynamic grub setup. Needed for when you rollback over the switch to static grub.
Types ¶
type Interface ¶
type Interface interface { ToggleNextBoot() error MarkBootSuccessful() error // FIXME: could we make SyncBootloaderFiles part of ToogleBootloader // to expose even less implementation details? SyncBootloaderFiles(bootAssets map[string]string) error IsNextBootOther() bool // run the function f with the otherRoot mounted RunWithOther(rw MountOption, f func(otherRoot string) (err error)) (err error) }
Interface provides the interface to interact with a partition
type MountOption ¶
type MountOption int
MountOption represents how the partition should be mounted, currently RO (read-only) and RW (read-write) are supported
const ( // RO mounts the partition read-only RO MountOption = iota // RW mounts the partition read-only RW )
type Partition ¶
type Partition struct {
// contains filtered or unexported fields
}
Partition is the type to interact with the partition
func (*Partition) BootloaderDir ¶
BootloaderDir returns the full path to the (mounted and writable) bootloader-specific boot directory.
func (*Partition) IsNextBootOther ¶
IsNextBootOther return true if the next boot will use the other rootfs partition.
func (*Partition) MarkBootSuccessful ¶
MarkBootSuccessful marks the boot as successful
func (*Partition) RunWithOther ¶
func (p *Partition) RunWithOther(option MountOption, f func(otherRoot string) (err error)) (err error)
RunWithOther mount the other rootfs partition, execute the specified function and unmount "other" before returning. If "other" is mounted read-write, /proc, /sys and /dev will also be bind-mounted at the time the specified function is called.
func (*Partition) SyncBootloaderFiles ¶
SyncBootloaderFiles syncs the bootloader files
We need this code solve the following scenario: 1. start with: /boot/a/k1, /boot/b/k1 2. upgrade with new kernel k2: /boot/a/k1, /boot/b/k2 3. reboot into b, running with /boot/b/k2 4. new update without a changed kernel, system-a updated 6. reboot to system-a with /boot/a/k1 (WRONG!) But it should be system-a with /boot/a/k2 it was just not part of the s-i delta as we already got it. So as step (5) above we do the SyncBootloaderFiles that copies /boot/b/k2 -> /boot/a/ (and that is ok because we know /boot/b/k2 works)
func (*Partition) ToggleNextBoot ¶
ToggleNextBoot toggles the roofs that should be used on the next boot