gozfs

package module
v0.0.0-...-d9821e3 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2016 License: MIT Imports: 14 Imported by: 1

README

Pure Go Client for ZFS Stable API

GoDoc MIT Licensed

Requirements

You need a working ZFS setup with a few patches, in the following order.

  1. stable api https://github.com/zfsonlinux/zfs/pull/3907
  2. patch on top of stable api https://github.com/ClusterHQ/zfs/pull/13.patch

Generally you need root privileges to use anything zfs related.

Status

We have implemented most of the features we need. If any features are wanted please open an issue or (better yet) pull request. The beta TODO list is more or less:

  • stabilize zfs_receive
  • avoid zfs_cmd_t in its current form
  • implement usable public api akin to go-zfs
  • find a better name

Contributing

See the contributing guidelines

cgo

All the nv list handling is fully implemented in go. The only use of cgo is a wrapper that actually calls ioctl with the zfs_cmd_t, this may be changed in the future.

Documentation

Index

Constants

View Source
const (
	DatasetFilesystem = "filesystem"
	DatasetSnapshot   = "snapshot"
	DatasetVolume     = "volume"
)

ZFS Dataset Types

Variables

This section is empty.

Functions

func Exists

func Exists(name string) (bool, error)

Exists determines whether a dataset exists or not.

Types

type By

type By func(p1, p2 *Dataset) bool

By is the type of a "less" function that defines the ordering of its Dataset arguments.

func (By) Sort

func (by By) Sort(datasets []*Dataset)

Sort is a method on the function type, By, that sorts the argument slice according to the function.

type DMUObjsetStats

type DMUObjsetStats struct {
	CreationTxg  uint64 `nv:"dds_creation_txg"`
	GUID         uint64 `nv:"dds_guid"`
	Inconsistent bool   `nv:"dds_inconsistent"`
	IsSnapshot   bool   `nv:"dds_is_snapshot"`
	NumClones    uint64 `nv:"dds_num_clones"`
	Origin       string `nv:"dds_origin"`
	Type         string `nv:"dds_type"`
}

DMUObjsetStats represents zfs dataset information.

type Dataset

type Dataset struct {
	Name           string
	Properties     *DatasetProperties
	DMUObjsetStats *DMUObjsetStats
}

Dataset contains information and properties for a ZFS dataset.

func CreateFilesystem

func CreateFilesystem(name string, properties map[string]interface{}) (*Dataset, error)

CreateFilesystem creates a new filesystem.

func CreateVolume

func CreateVolume(name string, size uint64, properties map[string]interface{}) (*Dataset, error)

CreateVolume creates a new volume.

func Datasets

func Datasets(name string, dsTypes []string) ([]*Dataset, error)

Datasets retrieves a list of datasets of specified types. If types are not specified, all types will be returned.

func GetDataset

func GetDataset(name string) (*Dataset, error)

GetDataset retrieves a single dataset.

func ReceiveSnapshot

func ReceiveSnapshot(input io.Reader, name string) (*Dataset, error)

ReceiveSnapshot creates a snapshot from a zfs send stream. Currently a stub.

func (*Dataset) Children

func (d *Dataset) Children(depth uint64) ([]*Dataset, error)

Children returns a list of children of the dataset.

func (*Dataset) Clone

func (d *Dataset) Clone(name string, properties map[string]interface{}) (*Dataset, error)

Clone clones a snapshot and returns a clone dataset.

func (*Dataset) Destroy

func (d *Dataset) Destroy(opts *DestroyOptions) error

Destroy destroys a zfs dataset, optionally recursive for descendants and clones. Note that recursive destroys are not an atomic operation.

func (*Dataset) Diff

func (d *Dataset) Diff(name string)

Diff returns changes between a snapshot and the given dataset. Currently a stub.

func (*Dataset) Holds

func (d *Dataset) Holds() ([]string, error)

Holds returns a list of user holds on the dataset.

func (*Dataset) Mountpoint

func (d *Dataset) Mountpoint() string

Mountpoint returns the mountpoint of the dataset. It is based off of the dataset mountpoint property joined to the dataset name with the mountpointsource property trimmed from the name.

func (*Dataset) Pool

func (d *Dataset) Pool() string

Pool returns the zfs pool the dataset belongs to.

func (*Dataset) Rename

func (d *Dataset) Rename(newName string, recursive bool) (string, error)

Rename renames the dataset, returning the failed name on error.

func (*Dataset) Rollback

func (d *Dataset) Rollback(destroyMoreRecent bool) error

Rollback rolls back a dataset to a previous snapshot.

func (*Dataset) Send

func (d *Dataset) Send(output io.Writer) error

Send sends a stream of a snapshot to the writer.

func (*Dataset) SetProperty

func (d *Dataset) SetProperty(name string, value interface{}) error

SetProperty sets the value of a property of the dataset. Currently a stub.

func (*Dataset) Snapshot

func (d *Dataset) Snapshot(name string, recursive bool) error

Snapshot creates a new snapshot of the dataset.

func (*Dataset) Snapshots

func (d *Dataset) Snapshots() ([]*Dataset, error)

Snapshots returns a list of snapshots of the dataset.

type DatasetProperties

type DatasetProperties struct {
	Available             uint64
	CaseSensitivity       uint64
	CaseSensitivitySource string
	Clones                []string
	CompressRatio         uint64
	Compression           string // Empty value is replaced with "off"
	CompressionSource     string
	CreateTxg             uint64
	Creation              uint64
	DeferDestroy          uint64
	GUID                  uint64
	LogicalReferenced     uint64
	LogicalUsed           uint64
	Mountpoint            string
	MountpointSource      string
	Normalization         uint64
	NormalizationSource   string
	ObjsetID              uint64
	Origin                string
	PrevSnap              string
	PrevSnapSource        string
	Quota                 uint64
	QuotaSource           string
	RefCompressRatio      uint64
	RefQuota              uint64
	RefQuotaSource        string
	RefReservation        uint64
	RefReservationSource  string
	Referenced            uint64
	Reservation           uint64
	ReservationSource     string
	Type                  string // Int type mapped to string type
	UTF8Only              bool
	UTF8OnlySource        string
	Unique                uint64
	Used                  uint64
	UsedByChildren        uint64
	UsedByDataset         uint64
	UsedByRefReservation  uint64
	UsedBySnapshots       uint64
	UserAccounting        uint64
	UserDefined           map[string]string
	UserRefs              uint64
	Version               uint64
	VolBlockSize          uint64
	VolBlockSizeSource    string
	Volsize               uint64
	Written               uint64
}

DatasetProperties are properties of a ZFS dataset. Some properties may be modified from the values returned by zfs.

type DestroyOptions

type DestroyOptions struct {
	Recursive       bool
	RecursiveClones bool
	ForceUnmount    bool
	Defer           bool
}

DestroyOptions are used to determine the behavior when destroying a dataset.

Directories

Path Synopsis
cmd
nv

Jump to

Keyboard shortcuts

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