partition

package
v0.0.0-...-0579a83 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 29, 2015 License: GPL-3.0 Imports: 19 Imported by: 0

Documentation

Overview

Package partition manipulate snappy disk partitions

Index

Constants

This section is empty.

Variables

View Source
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")
)
View Source
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 New

func New() *Partition

New creates a new partition type

func (*Partition) BootloaderDir

func (p *Partition) BootloaderDir() string

BootloaderDir returns the full path to the (mounted and writable) bootloader-specific boot directory.

func (*Partition) IsNextBootOther

func (p *Partition) IsNextBootOther() bool

IsNextBootOther return true if the next boot will use the other rootfs partition.

func (*Partition) MarkBootSuccessful

func (p *Partition) MarkBootSuccessful() (err error)

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

func (p *Partition) SyncBootloaderFiles(bootAssets map[string]string) (err error)

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

func (p *Partition) ToggleNextBoot() (err error)

ToggleNextBoot toggles the roofs that should be used on the next boot

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL