Documentation ¶
Index ¶
- Constants
- Variables
- func Create(p *CreateParam) error
- func IsError(err error, code int) bool
- func IsNotMounted(err error) bool
- func SetLogFile(file string) error
- func SetLogLevel(v int)
- func SetVerboseLevel(v int)
- func UUID() (string, error)
- func UmountByDevice(dev string) error
- type CreateFlags
- type CreateParam
- type Err
- type FSInfoData
- type ImageInfoData
- type ImageMode
- type MountParam
- type Ploop
- func (d Ploop) Close()
- func (d Ploop) DeleteSnapshot(uuid string) error
- func (d Ploop) ImageInfo() (ImageInfoData, error)
- func (d Ploop) IsMounted() (bool, error)
- func (d Ploop) Mount(p *MountParam) (string, error)
- func (d Ploop) Replace(p *ReplaceParam) error
- func (d Ploop) Resize(size uint64, offline bool) error
- func (d Ploop) Snapshot() (string, error)
- func (d Ploop) SwitchSnapshot(uuid string) error
- func (d Ploop) SwitchSnapshotExtended(uuid string, flags SwitchFlag) (string, error)
- func (d Ploop) TopDeltaFile() (string, error)
- func (d Ploop) Umount() error
- type ReplaceFlag
- type ReplaceParam
- type SwitchFlag
Constants ¶
const ( NoConsole = C.PLOOP_LOG_NOCONSOLE NoStdout = C.PLOOP_LOG_NOSTDOUT Timestamps = C.PLOOP_LOG_TIMESTAMPS )
Possible SetVerboseLevel arguments
const ( E_CREAT E_DEVICE E_DEVIOC E_OPEN E_MALLOC E_READ E_WRITE E_RESERVED_8 E_SYSFS E_RESERVED_10 E_PLOOPFMT E_SYS E_PROTOCOL E_LOOP E_FSTAT E_FSYNC E_EBUSY E_FLOCK E_FTRUNCATE E_FALLOCATE E_MOUNT E_UMOUNT E_LOCK E_MKFS E_RESERVED_25 E_RESIZE_FS E_MKDIR E_RENAME E_ABORT E_RELOC E_RESERVED_31 E_RESERVED_32 E_CHANGE_GPT E_RESERVED_34 E_UNLINK E_MKNOD E_PLOOPINUSE E_PARAM E_DISKDESCR E_DEV_NOT_MOUNTED E_FSCK E_RESERVED_42 E_NOSNAP )
SYSEXIT_* errors
Variables ¶
var ErrCodes = []string{ E_CREAT: "E_CREAT", E_DEVICE: "E_DEVICE", E_DEVIOC: "E_DEVIOC", E_OPEN: "E_OPEN", E_MALLOC: "E_MALLOC", E_READ: "E_READ", E_WRITE: "E_WRITE", E_RESERVED_8: "E_RESERVED", E_SYSFS: "E_SYSFS", E_RESERVED_10: "E_RESERVED", E_PLOOPFMT: "E_PLOOPFMT", E_SYS: "E_SYS", E_PROTOCOL: "E_PROTOCOL", E_LOOP: "E_LOOP", E_FSTAT: "E_FSTAT", E_FSYNC: "E_FSYNC", E_EBUSY: "E_EBUSY", E_FLOCK: "E_FLOCK", E_FTRUNCATE: "E_FTRUNCATE", E_FALLOCATE: "E_FALLOCATE", E_MOUNT: "E_MOUNT", E_UMOUNT: "E_UMOUNT", E_LOCK: "E_LOCK", E_MKFS: "E_MKFS", E_RESERVED_25: "E_RESERVED", E_RESIZE_FS: "E_RESIZE_FS", E_MKDIR: "E_MKDIR", E_RENAME: "E_RENAME", E_ABORT: "E_ABORT", E_RELOC: "E_RELOC", E_RESERVED_31: "E_RESERVED", E_RESERVED_32: "E_RESERVED", E_CHANGE_GPT: "E_CHANGE_GPT", E_RESERVED_34: "E_RESERVED", E_UNLINK: "E_UNLINK", E_MKNOD: "E_MKNOD", E_PLOOPINUSE: "E_PLOOPINUSE", E_PARAM: "E_PARAM", E_DISKDESCR: "E_DISKDESCR", E_DEV_NOT_MOUNTED: "E_DEV_NOT_MOUNTED", E_FSCK: "E_FSCK", E_RESERVED_42: "E_RESERVED", E_NOSNAP: "E_NOSNAP", }
ErrCodes is a map of ploop numerical error codes to their short names
Functions ¶
func Create ¶
func Create(p *CreateParam) error
Create creates a ploop image and its DiskDescriptor.xml
func IsNotMounted ¶
IsNotMounted returns true if an error is ploop "device is not mounted"
func SetLogFile ¶
SetLogFile enables logging to a file and sets log file name
func SetLogLevel ¶
func SetLogLevel(v int)
SetLogLevel sets a level of verbosity when logging to a file
func SetVerboseLevel ¶
func SetVerboseLevel(v int)
SetVerboseLevel sets a level of verbosity when logging to stdout/stderr
func UmountByDevice ¶
UmountByDevice unmounts the ploop filesystem and dismantles the device. Unlike Umount(), this is a lower-level function meaning it can be less safe and should generally not be used.
Types ¶
type CreateFlags ¶
type CreateFlags uint
CreateFlags is a type for CreateParam.Flags
const (
NoLazy CreateFlags = C.PLOOP_CREATE_NOLAZY
)
Possible values for CreateFlags
type CreateParam ¶
type CreateParam struct { Size uint64 // image size, in kilobytes (FS size is about 10% smaller) Mode ImageMode // image mode File string // path to and a file name for base delta image CLog uint // cluster block size log (6 to 15, default 11) Flags CreateFlags // flags }
CreateParam is a set of parameters for a newly created ploop
type FSInfoData ¶
type FSInfoData struct { BlockSize uint64 Blocks uint64 BlocksFree uint64 Inodes uint64 InodesFree uint64 }
FSInfoData holds information about ploop inner file system
func FSInfo ¶
func FSInfo(file string) (FSInfoData, error)
FSInfo gets info of ploop's inner file system
type ImageInfoData ¶
ImageInfoData holds information about ploop image
type ImageMode ¶
type ImageMode int
ImageMode is a type for CreateParam.Mode field
const ( Expanded ImageMode = C.PLOOP_EXPANDED_MODE Preallocated ImageMode = C.PLOOP_EXPANDED_PREALLOCATED_MODE Raw ImageMode = C.PLOOP_RAW_MODE )
Possible values for ImageMode
func ParseImageMode ¶
ParseImageMode converts a string to ImageMode value
type MountParam ¶
type MountParam struct { UUID string // snapshot uuid (empty for top delta) Target string // mount point (empty if no mount is needed) Flags int // bit mount flags such as MS_NOATIME Data string // auxiliary mount options Readonly bool // mount read-only Fsck bool // do fsck before mounting inner FS Quota bool // enable quota for inner FS }
MountParam is a set of parameters to pass to Mount()
type Ploop ¶
type Ploop struct {
// contains filtered or unexported fields
}
Ploop is a type containing DiskDescriptor.xml opened by the library
func (Ploop) Close ¶
func (d Ploop) Close()
Close closes a ploop disk descriptor when it is no longer needed
func (Ploop) DeleteSnapshot ¶
DeleteSnapshot deletes a snapshot (merging it down if necessary)
func (Ploop) ImageInfo ¶
func (d Ploop) ImageInfo() (ImageInfoData, error)
ImageInfo gets information about a ploop image
func (Ploop) Mount ¶
func (d Ploop) Mount(p *MountParam) (string, error)
Mount creates a ploop device and (optionally) mounts it
func (Ploop) Replace ¶
func (d Ploop) Replace(p *ReplaceParam) error
Replace replaces a ploop image to a different (but identical) one
func (Ploop) SwitchSnapshot ¶
SwitchSnapshot switches to a specified snapshot, creates a new empty delta on top of it, and makes it a top one (i.e. the one new data will be written to). Old top delta (i.e. data modified since the last snapshot) is lost.
func (Ploop) SwitchSnapshotExtended ¶
func (d Ploop) SwitchSnapshotExtended(uuid string, flags SwitchFlag) (string, error)
SwitchSnapshotExtended is same as SwitchSnapshot but with additional flags modifying its behavior. Please see individual flags description. Returns uuid of what was the old top delta if SkipDestroy flag is set.
func (Ploop) TopDeltaFile ¶
TopDeltaFile returns file name of top delta
type ReplaceFlag ¶
type ReplaceFlag int
ReplaceFlag is a type for ReplaceParam.Flags field
const ( // KeepName renames the new file to old file name after replace; // note that if this option is used the old file is removed. KeepName ReplaceFlag = C.PLOOP_REPLACE_KEEP_NAME )
Possible values for ReplaceParam.Flags field
type ReplaceParam ¶
type ReplaceParam struct { File string // new image file name // Image to be replaced is specified by either // uuid, current file name, or level, // in the above order of preference. UUID string CurFile string Level int Flags ReplaceFlag }
ReplaceParam is a set of parameters to Replace()
type SwitchFlag ¶
type SwitchFlag uint
SwitchFlag is a type for SwitchSnapshotExtended.Flags
const ( // SkipDestroy flag, if set, modifies the behavior of // SwitchSnapshotExtended to not delete the old top delta, but // make it a snapshot and return its uuid. Without this flag, // old top delta (i.e. data modified since the last snapshot) // is lost. SkipDestroy SwitchFlag = C.PLOOP_SNAP_SKIP_TOPDELTA_DESTROY // SkipCreate flag, if set, modifies the behavior of // SwitchSnapshotExtended to not create a new top delta, // but rather transform the specified snapshot itself to be // the new top delta), so all new changes will be written // right to it. Snapshot UUID is lost in this case. SkipCreate SwitchFlag = C.PLOOP_SNAP_SKIP_TOPDELTA_CREATE )