zfs

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: MIT Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const MaxDatasetNameLen = 256 - 1
View Source
const (
	// For a placeholder filesystem to be a placeholder, the property source must be local,
	// i.e. not inherited.
	PlaceholderPropertyName string = "zrepl:placeholder"
)
View Source
const RecvStderrBufSiz = 1 << 15

Variables

View Source
var (
	AllVersionTypes = VersionTypeSet{
		Bookmark: true,
		Snapshot: true,
	}
	Bookmarks = VersionTypeSet{
		Bookmark: true,
	}
	Snapshots = VersionTypeSet{
		Snapshot: true,
	}
)
View Source
var ErrBookmarkCloningNotSupported = fmt.Errorf("bookmark cloning feature is not yet supported by ZFS")
View Source
var ErrEncryptedSendNotSupported = fmt.Errorf("raw sends which are required for encrypted zfs send are not supported")
View Source
var ResumeTokenCorruptError = errors.New("resume token is corrupt")
View Source
var ResumeTokenDecodingNotSupported = errors.New("zfs binary does not allow decoding resume token or zrepl cannot scrape zfs output")
View Source
var ResumeTokenParsingError = errors.New("zrepl cannot parse resume token values")
View Source
var ZFS_BINARY string = "zfs"

Functions

func ComponentNamecheck added in v0.3.0

func ComponentNamecheck(datasetPathComponent string) error

From module/zcommon/zfs_namecheck.c

Snapshot names must be made up of alphanumeric characters plus the following characters:

[-_.: ]

func EncryptionCLISupported added in v0.3.0

func EncryptionCLISupported(ctx context.Context) (bool, error)

func FilesystemVersionEqualIdentity added in v0.3.0

func FilesystemVersionEqualIdentity(a, b FilesystemVersion) bool

Only takes into account those attributes of FilesystemVersion that are immutable over time in ZFS.

func PrometheusRegister

func PrometheusRegister(registry prometheus.Registerer) error

func ResumeRecvSupported added in v0.3.0

func ResumeRecvSupported(ctx context.Context, fs *DatasetPath) (bool, error)

fs == nil only checks for CLI support

func ResumeSendSupported added in v0.3.0

func ResumeSendSupported(ctx context.Context) (bool, error)

func ValidHoldTag added in v0.3.0

func ValidHoldTag(tag string) error

returned err != nil is guaranteed to represent invalid hold tag

func ZFSCreatePlaceholderFilesystem

func ZFSCreatePlaceholderFilesystem(ctx context.Context, fs *DatasetPath, parent *DatasetPath, encryption FilesystemPlaceholderCreateEncryptionValue) (err error)

func ZFSDestroy

func ZFSDestroy(ctx context.Context, arg string) (err error)

func ZFSDestroyFilesystemVersion

func ZFSDestroyFilesystemVersion(ctx context.Context, filesystem *DatasetPath, version *FilesystemVersion) (err error)

func ZFSDestroyFilesystemVersions added in v0.2.0

func ZFSDestroyFilesystemVersions(ctx context.Context, reqs []*DestroySnapOp)

func ZFSDestroyIdempotent added in v0.3.0

func ZFSDestroyIdempotent(ctx context.Context, path string) error

func ZFSGetEncryptionEnabled added in v0.3.0

func ZFSGetEncryptionEnabled(ctx context.Context, fs string) (enabled bool, err error)

returns false, nil if encryption is not supported

func ZFSGetGUID added in v0.3.0

func ZFSGetGUID(ctx context.Context, fs string, version string) (g uint64, err error)

The returned error includes requested filesystem and version as quoted strings in its error message

func ZFSGetReceiveResumeTokenOrEmptyStringIfNotSupported added in v0.3.0

func ZFSGetReceiveResumeTokenOrEmptyStringIfNotSupported(ctx context.Context, fs *DatasetPath) (string, error)

if string is empty and err == nil, the feature is not supported

func ZFSHold added in v0.3.0

func ZFSHold(ctx context.Context, fs string, v FilesystemVersion, tag string) error

Idemptotent: does not return an error if the tag already exists

func ZFSHolds added in v0.3.0

func ZFSHolds(ctx context.Context, fs, snap string) ([]string, error)

func ZFSList

func ZFSList(ctx context.Context, properties []string, zfsArgs ...string) (res [][]string, err error)

func ZFSListChan

func ZFSListChan(ctx context.Context, out chan ZFSListResult, properties []string, notExistHint *DatasetPath, zfsArgs ...string)

ZFSListChan executes `zfs list` and sends the results to the `out` channel. The `out` channel is always closed by ZFSListChan: If an error occurs, it is closed after sending a result with the Err field set. If no error occurs, it is just closed. If the operation is cancelled via context, the channel is just closed.

If notExistHint is not nil and zfs exits with an error, the stderr is attempted to be interpreted as a *DatasetDoesNotExist error.

However, if callers do not drain `out` or cancel via `ctx`, the process will leak either running because IO is pending or as a zombie.

func ZFSListPlaceholderFilesystemsWithAdditionalProps added in v0.5.0

func ZFSListPlaceholderFilesystemsWithAdditionalProps(ctx context.Context, root string, additionalProps []string) (map[string]*ZFSProperties, error)

func ZFSRecv

func ZFSRecv(ctx context.Context, fs string, v *ZFSSendArgVersion, stream io.ReadCloser, opts RecvOptions) (err error)

func ZFSRecvClearResumeToken

func ZFSRecvClearResumeToken(ctx context.Context, fs string) (err error)

always returns *ClearResumeTokenError

func ZFSRelease added in v0.3.0

func ZFSRelease(ctx context.Context, tag string, snaps ...string) error

Idempotent: if the hold doesn't exist, this is not an error

func ZFSRollback

func ZFSRollback(ctx context.Context, fs *DatasetPath, snapshot FilesystemVersion, rollbackArgs ...string) (err error)

func ZFSSendArgsSkipValidation added in v0.6.0

func ZFSSendArgsSkipValidation(ctx context.Context) context.Context

func ZFSSet

func ZFSSet(ctx context.Context, fs *DatasetPath, props map[string]string) error

func ZFSSetPlaceholder

func ZFSSetPlaceholder(ctx context.Context, p *DatasetPath, isPlaceholder bool) error

func ZFSSnapshot

func ZFSSnapshot(ctx context.Context, fs *DatasetPath, name string, recursive bool) (err error)

Types

type BookmarkExists added in v0.3.0

type BookmarkExists struct {
	// contains filtered or unexported fields
}

func (*BookmarkExists) Error added in v0.3.0

func (e *BookmarkExists) Error() string

type ClearResumeTokenError

type ClearResumeTokenError struct {
	ZFSOutput []byte
	CmdError  error
}

func (ClearResumeTokenError) Error

func (e ClearResumeTokenError) Error() string

type DatasetDoesNotExist

type DatasetDoesNotExist struct {
	Path string
}

func (*DatasetDoesNotExist) Error

func (d *DatasetDoesNotExist) Error() string

type DatasetFilter

type DatasetFilter interface {
	Filter(p *DatasetPath) (pass bool, err error)
	// The caller owns the returned set.
	// Implementations should return a copy.
	UserSpecifiedDatasets() UserSpecifiedDatasetsSet
}

func NoFilter

func NoFilter() DatasetFilter

Returns a DatasetFilter that does not filter (passes all paths)

type DatasetPath

type DatasetPath struct {
	// contains filtered or unexported fields
}

func NewDatasetPath

func NewDatasetPath(s string) (p *DatasetPath, err error)

func ZFSListMapping

func ZFSListMapping(ctx context.Context, filter DatasetFilter) (datasets []*DatasetPath, err error)

func (*DatasetPath) Copy

func (p *DatasetPath) Copy() (c *DatasetPath)

func (*DatasetPath) Empty

func (p *DatasetPath) Empty() bool

func (DatasetPath) Equal

func (p DatasetPath) Equal(q *DatasetPath) bool

func (*DatasetPath) Extend

func (p *DatasetPath) Extend(extend *DatasetPath)

func (*DatasetPath) HasPrefix

func (p *DatasetPath) HasPrefix(prefix *DatasetPath) bool

func (*DatasetPath) Length

func (p *DatasetPath) Length() int

func (*DatasetPath) MarshalJSON

func (p *DatasetPath) MarshalJSON() ([]byte, error)

func (*DatasetPath) Pool added in v0.3.0

func (p *DatasetPath) Pool() (string, error)

func (*DatasetPath) ToString

func (p *DatasetPath) ToString() string

func (*DatasetPath) TrimNPrefixComps

func (p *DatasetPath) TrimNPrefixComps(n int)

func (*DatasetPath) TrimPrefix

func (p *DatasetPath) TrimPrefix(prefix *DatasetPath)

func (*DatasetPath) UnmarshalJSON

func (p *DatasetPath) UnmarshalJSON(b []byte) error

type DatasetPathForest

type DatasetPathForest struct {
	// contains filtered or unexported fields
}

func NewDatasetPathForest

func NewDatasetPathForest() *DatasetPathForest

func (*DatasetPathForest) Add

func (f *DatasetPathForest) Add(p *DatasetPath)

func (*DatasetPathForest) WalkTopDown

func (f *DatasetPathForest) WalkTopDown(visitor DatasetPathsVisitor)

Traverse a list of DatasetPaths top down, i.e. given a set of datasets with same path prefix, those with shorter prefix are traversed first. If there are gaps, i.e. the intermediary component a/b between a and a/b/c, those gaps are still visited but the FilledIn property of the visit is set to true.

type DatasetPathVisit

type DatasetPathVisit struct {
	Path *DatasetPath
	// If true, the dataset referenced by Path was not in the list of datasets to traverse
	FilledIn bool
	Parent   *DatasetPathVisit
}

type DatasetPathsVisitor

type DatasetPathsVisitor func(v *DatasetPathVisit) (visitChildTree bool)

type DestroySnapOp added in v0.2.0

type DestroySnapOp struct {
	Filesystem string
	Name       string
	ErrOut     *error
}

func (*DestroySnapOp) String added in v0.2.0

func (o *DestroySnapOp) String() string

type DestroySnapshotsError added in v0.2.0

type DestroySnapshotsError struct {
	RawLines      []string
	Filesystem    string
	Undestroyable []string // snapshot name only (filesystem@ stripped)
	Reason        []string
}

func (*DestroySnapshotsError) Error added in v0.2.0

func (e *DestroySnapshotsError) Error() string

type DrySendInfo

type DrySendInfo struct {
	Type         DrySendType
	Filesystem   string // parsed from To field
	From, To     string // direct copy from ZFS output
	SizeEstimate uint64 // 0 if size estimate is not possible
}

func ZFSSendDry

func ZFSSendDry(ctx context.Context, sendArgs ZFSSendArgsValidated) (_ *DrySendInfo, err error)

to may be "", in which case a full ZFS send is done May return BookmarkSizeEstimationNotSupported as err if from is a bookmark.

type DrySendType

type DrySendType string
const (
	DrySendTypeFull        DrySendType = "full"
	DrySendTypeIncremental DrySendType = "incremental"
)

func DrySendTypeFromString

func DrySendTypeFromString(s string) (DrySendType, error)

type EntityType added in v0.3.0

type EntityType string
const (
	EntityTypeFilesystem EntityType = "filesystem"
	EntityTypeVolume     EntityType = "volume"
	EntityTypeSnapshot   EntityType = "snapshot"
	EntityTypeBookmark   EntityType = "bookmark"
)

func (EntityType) MustValidate added in v0.3.0

func (e EntityType) MustValidate()

func (EntityType) String added in v0.3.0

func (e EntityType) String() string

func (EntityType) Validate added in v0.3.0

func (e EntityType) Validate() error

type ErrRecvResumeNotSupported added in v0.3.0

type ErrRecvResumeNotSupported struct {
	FS       string
	CheckErr error
}

func (*ErrRecvResumeNotSupported) Error added in v0.3.0

func (e *ErrRecvResumeNotSupported) Error() string

type FilesystemPlaceholderCreateEncryptionValue added in v0.5.0

type FilesystemPlaceholderCreateEncryptionValue int
const (
	FilesystemPlaceholderCreateEncryptionInherit FilesystemPlaceholderCreateEncryptionValue = 1 << iota
	FilesystemPlaceholderCreateEncryptionOff
)

func FilesystemPlaceholderCreateEncryptionValueString added in v0.5.0

func FilesystemPlaceholderCreateEncryptionValueString(s string) (FilesystemPlaceholderCreateEncryptionValue, error)

FilesystemPlaceholderCreateEncryptionValueString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func FilesystemPlaceholderCreateEncryptionValueValues added in v0.5.0

func FilesystemPlaceholderCreateEncryptionValueValues() []FilesystemPlaceholderCreateEncryptionValue

FilesystemPlaceholderCreateEncryptionValueValues returns all values of the enum

func (FilesystemPlaceholderCreateEncryptionValue) IsAFilesystemPlaceholderCreateEncryptionValue added in v0.5.0

func (i FilesystemPlaceholderCreateEncryptionValue) IsAFilesystemPlaceholderCreateEncryptionValue() bool

IsAFilesystemPlaceholderCreateEncryptionValue returns "true" if the value is listed in the enum definition. "false" otherwise

func (FilesystemPlaceholderCreateEncryptionValue) String added in v0.5.0

type FilesystemPlaceholderState

type FilesystemPlaceholderState struct {
	FS                    string
	FSExists              bool
	IsPlaceholder         bool
	RawLocalPropertyValue string
}

func ZFSGetFilesystemPlaceholderState

func ZFSGetFilesystemPlaceholderState(ctx context.Context, p *DatasetPath) (state *FilesystemPlaceholderState, err error)

ZFSGetFilesystemPlaceholderState is the authoritative way to determine whether a filesystem is a placeholder. Note that the property source must be `local` for the returned value to be valid.

For nonexistent FS, err == nil and state.FSExists == false

type FilesystemVersion

type FilesystemVersion struct {
	Type VersionType

	// Display name. Should not be used for identification, only for user output
	Name string

	// GUID as exported by ZFS. Uniquely identifies a snapshot across pools
	Guid uint64

	// The TXG in which the snapshot was created. For bookmarks,
	// this is the GUID of the snapshot it was initially tied to.
	CreateTXG uint64

	// The time the dataset was created
	Creation time.Time

	// userrefs field (snapshots only)
	UserRefs OptionUint64
}

The data in a FilesystemVersion is guaranteed to stem from a ZFS CLI invocation.

func ParseFilesystemVersion added in v0.3.0

func ParseFilesystemVersion(args ParseFilesystemVersionArgs) (v FilesystemVersion, err error)

func ZFSBookmark

func ZFSBookmark(ctx context.Context, fs string, v FilesystemVersion, bookmark string) (bm FilesystemVersion, err error)

idempotently create bookmark of the given version v

if `v` is a bookmark, returns ErrBookmarkCloningNotSupported unless a bookmark with the name `bookmark` exists and has the same idenitty (zfs.FilesystemVersionEqualIdentity)

v must be validated by the caller

func ZFSGetFilesystemVersion added in v0.3.0

func ZFSGetFilesystemVersion(ctx context.Context, ds string) (v FilesystemVersion, _ error)

func ZFSListFilesystemVersions

func ZFSListFilesystemVersions(ctx context.Context, fs *DatasetPath, options ListFilesystemVersionsOptions) (res []FilesystemVersion, err error)

returned versions are sorted by createtxg FIXME drop sort by createtxg requirement

func (FilesystemVersion) FullPath added in v0.3.0

func (v FilesystemVersion) FullPath(fs string) string

func (FilesystemVersion) GetCreateTXG added in v0.3.0

func (v FilesystemVersion) GetCreateTXG() uint64

func (FilesystemVersion) GetGUID added in v0.3.0

func (v FilesystemVersion) GetGUID() uint64

func (FilesystemVersion) GetGuid added in v0.3.0

func (v FilesystemVersion) GetGuid() uint64

func (FilesystemVersion) GetName added in v0.3.0

func (v FilesystemVersion) GetName() string

func (FilesystemVersion) IsBookmark added in v0.3.0

func (v FilesystemVersion) IsBookmark() bool

func (FilesystemVersion) IsSnapshot added in v0.3.0

func (v FilesystemVersion) IsSnapshot() bool

func (FilesystemVersion) RelName added in v0.3.0

func (v FilesystemVersion) RelName() string

func (FilesystemVersion) String

func (v FilesystemVersion) String() string

func (FilesystemVersion) ToAbsPath

func (v FilesystemVersion) ToAbsPath(p *DatasetPath) string

func (FilesystemVersion) ToSendArgVersion added in v0.3.0

func (v FilesystemVersion) ToSendArgVersion() ZFSSendArgVersion

type GetMountpointOutput added in v0.3.0

type GetMountpointOutput struct {
	Mounted    bool
	Mountpoint string
}

func ZFSGetMountpoint added in v0.3.0

func ZFSGetMountpoint(ctx context.Context, fs string) (*GetMountpointOutput, error)

type ListFilesystemVersionsOptions added in v0.3.0

type ListFilesystemVersionsOptions struct {
	// the prefix of the version name, without the delimiter char
	// empty means any prefix matches
	ShortnamePrefix string

	// which types should be returned
	// nil or len(0) means any prefix matches
	Types VersionTypeSet
}

type MigrateHashBasedPlaceholderReport

type MigrateHashBasedPlaceholderReport struct {
	OriginalState     FilesystemPlaceholderState
	NeedsModification bool
}

func ZFSMigrateHashBasedPlaceholderToCurrent

func ZFSMigrateHashBasedPlaceholderToCurrent(ctx context.Context, fs *DatasetPath, dryRun bool) (*MigrateHashBasedPlaceholderReport, error)

fs must exist, will panic otherwise

type OptionUint64 added in v0.3.0

type OptionUint64 struct {
	Value uint64
	Valid bool
}

type ParseFilesystemVersionArgs added in v0.3.0

type ParseFilesystemVersionArgs struct {
	// contains filtered or unexported fields
}

type PathValidationError added in v0.3.0

type PathValidationError struct {
	// contains filtered or unexported fields
}

func EntityNamecheck added in v0.3.0

func EntityNamecheck(path string, t EntityType) (err *PathValidationError)

combines

lib/libzfs/libzfs_dataset.c: zfs_validate_name
module/zcommon/zfs_namecheck.c: entity_namecheck

The '%' character is not allowed because it's reserved for zfs-internal use

func (*PathValidationError) Error added in v0.3.0

func (e *PathValidationError) Error() string

func (*PathValidationError) Path added in v0.3.0

func (e *PathValidationError) Path() string

type PropertySource added in v0.4.0

type PropertySource uint32
const (
	SourceLocal PropertySource = 1 << iota
	SourceDefault
	SourceInherited
	SourceNone
	SourceTemporary
	SourceReceived

	SourceAny PropertySource = ^PropertySource(0)
)

func PropertySourceString added in v0.4.0

func PropertySourceString(s string) (PropertySource, error)

PropertySourceString retrieves an enum value from the enum constants string name. Throws an error if the param is not part of the enum.

func PropertySourceValues added in v0.4.0

func PropertySourceValues() []PropertySource

PropertySourceValues returns all values of the enum

func (PropertySource) IsAPropertySource added in v0.4.0

func (i PropertySource) IsAPropertySource() bool

IsAPropertySource returns "true" if the value is listed in the enum definition. "false" otherwise

func (PropertySource) String added in v0.4.0

func (i PropertySource) String() string

type PropertyValue added in v0.4.0

type PropertyValue struct {
	Value  string
	Source PropertySource
}

type RecvCannotReadFromStreamErr added in v0.3.0

type RecvCannotReadFromStreamErr struct {
	Msg string
}

func (*RecvCannotReadFromStreamErr) Error added in v0.3.0

type RecvDestroyOrOverwriteEncryptedErr added in v0.3.0

type RecvDestroyOrOverwriteEncryptedErr struct {
	Msg string
}

func (*RecvDestroyOrOverwriteEncryptedErr) Error added in v0.3.0

type RecvFailedWithResumeTokenErr added in v0.3.0

type RecvFailedWithResumeTokenErr struct {
	Msg               string
	ResumeTokenRaw    string
	ResumeTokenParsed *ResumeToken
}

func (*RecvFailedWithResumeTokenErr) Error added in v0.3.0

type RecvOptions

type RecvOptions struct {
	// Rollback to the oldest snapshot, destroy it, then perform `recv -F`.
	// Note that this doesn't change property values, i.e. an existing local property value will be kept.
	RollbackAndForceRecv bool
	// Set -s flag used for resumable send & recv
	SavePartialRecvState bool

	InheritProperties  []zfsprop.Property
	OverrideProperties map[zfsprop.Property]string
}

type ResumeToken

type ResumeToken struct {
	HasFromGUID, HasToGUID        bool
	FromGUID, ToGUID              uint64
	ToName                        string
	HasCompressOK, CompressOK     bool
	HasRawOk, RawOK               bool
	HasLargeBlockOK, LargeBlockOK bool
	HasEmbedOk, EmbedOK           bool
	HasSavedOk, SavedOk           bool
}

NOTE: Update ZFSSendARgs.Validate when changing fields (potentially SECURITY SENSITIVE)

func ParseResumeToken

func ParseResumeToken(ctx context.Context, token string) (*ResumeToken, error)

Abuse 'zfs send' to decode the resume token

FIXME: implement nvlist unpacking in Go and read through libzfs_sendrecv.c

func (*ResumeToken) ToNameSplit added in v0.3.0

func (t *ResumeToken) ToNameSplit() (fs *DatasetPath, snapName string, err error)

type SendStream added in v0.3.0

type SendStream struct {
	// contains filtered or unexported fields
}

func ZFSSend

func ZFSSend(ctx context.Context, sendArgs ZFSSendArgsValidated) (*SendStream, error)

if token != "", then send -t token is used otherwise send [-i from] to is used (if from is "" a full ZFS send is done)

Returns ErrEncryptedSendNotSupported if encrypted send is requested but not supported by CLI

func (*SendStream) Close added in v0.3.0

func (s *SendStream) Close() error

func (*SendStream) Read added in v0.3.0

func (s *SendStream) Read(p []byte) (n int, _ error)

func (*SendStream) TestOnly_ExitErr added in v0.5.0

func (s *SendStream) TestOnly_ExitErr() *ZFSError

func (*SendStream) TestOnly_ReplaceStdoutReader added in v0.5.0

func (s *SendStream) TestOnly_ReplaceStdoutReader(f io.ReadCloser) (prev io.ReadCloser)

type UserSpecifiedDatasetsSet added in v0.6.1

type UserSpecifiedDatasetsSet map[string]bool

A set of dataset names that the user specified in the configuration file.

type VersionType

type VersionType string
const (
	Bookmark VersionType = "bookmark"
	Snapshot VersionType = "snapshot"
)

func DecomposeVersionString

func DecomposeVersionString(v string) (fs string, versionType VersionType, name string, err error)

func (VersionType) DelimiterChar

func (t VersionType) DelimiterChar() string

func (VersionType) String

func (t VersionType) String() string

type VersionTypeSet added in v0.3.0

type VersionTypeSet map[VersionType]bool

func (VersionTypeSet) String added in v0.3.0

func (s VersionTypeSet) String() string

type ZFSError

type ZFSError struct {
	Stderr  []byte
	WaitErr error
}

func (*ZFSError) Error

func (e *ZFSError) Error() string

type ZFSListMappingPropertiesResult

type ZFSListMappingPropertiesResult struct {
	Path *DatasetPath
	// Guaranteed to have the same length as properties in the originating call
	Fields []string
}

func ZFSListMappingProperties

func ZFSListMappingProperties(ctx context.Context, filter DatasetFilter, properties []string) (datasets []ZFSListMappingPropertiesResult, err error)

properties must not contain 'name'

type ZFSListResult

type ZFSListResult struct {
	Fields []string
	Err    error
}

type ZFSProperties

type ZFSProperties struct {
	// contains filtered or unexported fields
}

func NewZFSProperties

func NewZFSProperties() *ZFSProperties

func ZFSGet

func ZFSGet(ctx context.Context, fs *DatasetPath, props []string) (*ZFSProperties, error)

func ZFSGetRawAnySource added in v0.2.0

func ZFSGetRawAnySource(ctx context.Context, path string, props []string) (*ZFSProperties, error)

func (*ZFSProperties) Get

func (p *ZFSProperties) Get(key string) string

func (*ZFSProperties) GetDetails added in v0.4.0

func (p *ZFSProperties) GetDetails(key string) PropertyValue

type ZFSSendArgVersion added in v0.3.0

type ZFSSendArgVersion struct {
	RelName string
	GUID    uint64
}

NOTE: When updating this struct, make sure to update funcs Validate ValidateCorrespondsToResumeToken

func (ZFSSendArgVersion) FullPath added in v0.3.0

func (v ZFSSendArgVersion) FullPath(fs string) string

func (ZFSSendArgVersion) GetGuid added in v0.3.0

func (v ZFSSendArgVersion) GetGuid() uint64

func (ZFSSendArgVersion) IsSnapshot added in v0.3.0

func (v ZFSSendArgVersion) IsSnapshot() bool

func (ZFSSendArgVersion) MustBeBookmark added in v0.3.0

func (v ZFSSendArgVersion) MustBeBookmark()

func (ZFSSendArgVersion) ToSendArgVersion added in v0.3.0

func (v ZFSSendArgVersion) ToSendArgVersion() ZFSSendArgVersion

func (ZFSSendArgVersion) ValidateExists added in v0.3.0

func (a ZFSSendArgVersion) ValidateExists(ctx context.Context, fs string) error

func (ZFSSendArgVersion) ValidateExistsAndGetVersion added in v0.3.0

func (a ZFSSendArgVersion) ValidateExistsAndGetVersion(ctx context.Context, fs string) (v FilesystemVersion, _ error)

fs must be not empty

func (ZFSSendArgVersion) ValidateInMemory added in v0.3.0

func (v ZFSSendArgVersion) ValidateInMemory(fs string) error

type ZFSSendArgsResumeTokenMismatchError added in v0.3.0

type ZFSSendArgsResumeTokenMismatchError struct {
	What ZFSSendArgsResumeTokenMismatchErrorCode
	Err  error
}

func (*ZFSSendArgsResumeTokenMismatchError) Error added in v0.3.0

type ZFSSendArgsResumeTokenMismatchErrorCode added in v0.3.0

type ZFSSendArgsResumeTokenMismatchErrorCode int
const (
	ZFSSendArgsResumeTokenMismatchGeneric          ZFSSendArgsResumeTokenMismatchErrorCode = 1 + iota
	ZFSSendArgsResumeTokenMismatchEncryptionNotSet                                         // encryption not set in token but required by send args
	ZFSSendArgsResumeTokenMismatchEncryptionSet                                            // encryption not set in token but not required by send args
	ZFSSendArgsResumeTokenMismatchFilesystem
)

The format is ZFSSendArgsResumeTokenMismatch+WhatIsWrongInToken

type ZFSSendArgsUnvalidated added in v0.3.0

type ZFSSendArgsUnvalidated struct {
	FS       string
	From, To *ZFSSendArgVersion // From may be nil
	ZFSSendFlags
}

When updating this struct, check Validate and ValidateCorrespondsToResumeToken (POTENTIALLY SECURITY SENSITIVE)

func (ZFSSendArgsUnvalidated) Validate added in v0.3.0

- Recursively call Validate on each field. - Make sure that if ResumeToken != "", it reflects the same operation as the other parameters would.

This function is not pure because GUIDs are checked against the local host's datasets.

type ZFSSendArgsValidated added in v0.3.0

type ZFSSendArgsValidated struct {
	ZFSSendArgsUnvalidated
	FromVersion *FilesystemVersion
	ToVersion   FilesystemVersion
}

type ZFSSendArgsValidationError added in v0.3.0

type ZFSSendArgsValidationError struct {
	Args ZFSSendArgsUnvalidated
	What ZFSSendArgsValidationErrorCode
	Msg  error
}

func (ZFSSendArgsValidationError) Error added in v0.3.0

type ZFSSendArgsValidationErrorCode added in v0.3.0

type ZFSSendArgsValidationErrorCode int
const (
	ZFSSendArgsGenericValidationError ZFSSendArgsValidationErrorCode = 1 + iota
	ZFSSendArgsEncryptedSendRequestedButFSUnencrypted
	ZFSSendArgsFSEncryptionCheckFail
	ZFSSendArgsResumeTokenMismatch
)

type ZFSSendFlags added in v0.4.0

type ZFSSendFlags struct {
	Encrypted        *nodefault.Bool
	Properties       bool
	BackupProperties bool
	Raw              bool
	LargeBlocks      bool
	Compressed       bool
	EmbeddedData     bool
	Saved            bool

	// Preferred if not empty
	ResumeToken string // if not nil, must match what is specified in From, To (covered by ValidateCorrespondsToResumeToken)
}

func (ZFSSendFlags) Validate added in v0.4.0

func (f ZFSSendFlags) Validate() error

Directories

Path Synopsis
Package zfscmd provides a wrapper around packate os/exec.
Package zfscmd provides a wrapper around packate os/exec.

Jump to

Keyboard shortcuts

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