zfs

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2024 License: MIT Imports: 27 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"
)

Variables

View Source
var (
	ResumeTokenCorruptError         = errors.New("resume token is corrupt")
	ResumeTokenDecodingNotSupported = errors.New("zfs binary does not allow decoding resume token or zrepl cannot scrape zfs output")
	ResumeTokenParsingError         = errors.New("zrepl cannot parse resume token values")
)
View Source
var (
	AllVersionTypes = VersionTypeSet{
		Bookmark: true,
		Snapshot: true,
	}
	Bookmarks = VersionTypeSet{
		Bookmark: true,
	}
	Snapshots = VersionTypeSet{
		Snapshot: true,
	}
)
View Source
var ErrBookmarkCloningNotSupported = errors.New("bookmark cloning feature is not yet supported by ZFS")
View Source
var ZfsBin string = "zfs"

Functions

func ComponentNamecheck

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 FilesystemVersionEqualIdentity

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 ValidHoldTag

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,
) error

func ZFSDestroy

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

func ZFSDestroyFilesystemVersion

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

func ZFSDestroyFilesystemVersions

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

func ZFSDestroyIdempotent

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

func ZFSGetEncryptionEnabled

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

returns false, nil if encryption is not supported

func ZFSGetGUID

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

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

func ZFSGetRecursive

func ZFSGetRecursive(ctx context.Context, path string, depth int,
	dstypes []string, props []string, allowedSources PropertySource,
) (map[string]*ZFSProperties, error)

func ZFSHold

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

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

func ZFSList

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

func ZFSListIter

func ZFSListIter(ctx context.Context, properties []string,
	notExistHint *DatasetPath, zfsArgs ...string,
) iter.Seq[ZFSListResult]

ZFSListIter executes `zfs list` and returns an iterator with the results.

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

func ZFSRecv

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

func ZFSRecvClearResumeToken

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

always returns *ClearResumeTokenError

func ZFSRelease

func ZFSRelease(ctx context.Context, tag string, snap 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,
) error

func ZFSSendArgsSkipValidation

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,
) error

Types

type BookmarkExists

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

func (*BookmarkExists) Error

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 {
	Empty() bool
	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,
) ([]*DatasetPath, 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

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

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

func (*DestroySnapOp) String

func (o *DestroySnapOp) String() string

type DestroySnapshotsError

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

func (*DestroySnapshotsError) Error

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, 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

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

func (EntityType) MustValidate

func (e EntityType) MustValidate()

func (EntityType) String

func (e EntityType) String() string

func (EntityType) Validate

func (e EntityType) Validate() error

type FilesystemPlaceholderCreateEncryptionValue

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

func FilesystemPlaceholderCreateEncryptionValueString

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

func FilesystemPlaceholderCreateEncryptionValueValues() []FilesystemPlaceholderCreateEncryptionValue

FilesystemPlaceholderCreateEncryptionValueValues returns all values of the enum

func (FilesystemPlaceholderCreateEncryptionValue) IsAFilesystemPlaceholderCreateEncryptionValue

func (i FilesystemPlaceholderCreateEncryptionValue) IsAFilesystemPlaceholderCreateEncryptionValue() bool

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

func (FilesystemPlaceholderCreateEncryptionValue) String

type FilesystemPlaceholderState

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

func NewPlaceholderState added in v0.9.2

func NewPlaceholderState(p *DatasetPath, props *ZFSProperties,
) *FilesystemPlaceholderState

func ZFSGetFilesystemPlaceholderState

func ZFSGetFilesystemPlaceholderState(ctx context.Context, p *DatasetPath,
) (*FilesystemPlaceholderState, 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

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

func ZFSBookmark

func ZFSBookmark(ctx context.Context, fs string, v FilesystemVersion,
	bookmark string,
) (FilesystemVersion, 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

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

func ZFSListFilesystemVersions

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

ZFSListFilesystemVersions returns versions are sorted by createtxg.

FIXME drop sort by createtxg requirement

func (FilesystemVersion) FullPath

func (v FilesystemVersion) FullPath(fs string) string

func (FilesystemVersion) GetCreateTXG

func (v FilesystemVersion) GetCreateTXG() uint64

func (FilesystemVersion) GetGUID

func (v FilesystemVersion) GetGUID() uint64

func (FilesystemVersion) GetGuid

func (v FilesystemVersion) GetGuid() uint64

func (FilesystemVersion) GetName

func (v FilesystemVersion) GetName() string

func (FilesystemVersion) IsBookmark

func (v FilesystemVersion) IsBookmark() bool

func (FilesystemVersion) IsSnapshot

func (v FilesystemVersion) IsSnapshot() bool

func (FilesystemVersion) RelName

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

func (v FilesystemVersion) ToSendArgVersion() ZFSSendArgVersion

type GetMountpointOutput

type GetMountpointOutput struct {
	Mounted    bool
	Mountpoint string
}

func ZFSGetMountpoint

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

type ListFilesystemVersionsOptions

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

type OptionUint64 struct {
	Value uint64
	Valid bool
}

type ParseFilesystemVersionArgs

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

func (ParseFilesystemVersionArgs) Parse

func (ParseFilesystemVersionArgs) WithCreateTxg

func (ParseFilesystemVersionArgs) WithCreation

func (ParseFilesystemVersionArgs) WithFullName

func (ParseFilesystemVersionArgs) WithGuid

func (ParseFilesystemVersionArgs) WithUserRefs

type PathValidationError

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

func EntityNamecheck

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

func (e *PathValidationError) Error() string

func (*PathValidationError) Path

func (e *PathValidationError) Path() string

type PropertySource

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

	SourceAny PropertySource = ^PropertySource(0)
)

func PropertySourceString

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

func PropertySourceValues() []PropertySource

PropertySourceValues returns all values of the enum

func (PropertySource) IsAPropertySource

func (i PropertySource) IsAPropertySource() bool

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

func (PropertySource) String

func (i PropertySource) String() string

type PropertyValue

type PropertyValue struct {
	Value  string
	Source PropertySource
}

func NewPropertyValue

func NewPropertyValue(v string, src PropertySource) PropertyValue

type RecvCannotReadFromStreamErr

type RecvCannotReadFromStreamErr struct {
	Msg string
}

func (*RecvCannotReadFromStreamErr) Error

type RecvDestroyOrOverwriteEncryptedErr

type RecvDestroyOrOverwriteEncryptedErr struct {
	Msg string
}

func (*RecvDestroyOrOverwriteEncryptedErr) Error

type RecvFailedWithResumeTokenErr

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

func (*RecvFailedWithResumeTokenErr) Error

func (self *RecvFailedWithResumeTokenErr) Error() string

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

Example resume tokens:

From a non-incremental send

1-bf31b879a-b8-789c636064000310a500c4ec50360710e72765a5269740f80cd8e4d3d28a534b18e00024cf86249f5459925acc802a8facbf243fbd3433858161f5ddb9ab1ae7c7466a20c97382e5f312735319180af2f3730cf58166953824c2cc0200cde81651

From an incremental send

1-c49b979a2-e0-789c636064000310a501c49c50360710a715e5e7a69766a63040c1eabb735735ce8f8d5400b2d991d4e52765a5269740f82080219f96569c5ac2000720793624f9a4ca92d46206547964fd25f91057f09e37babb88c9bf5503499e132c9f97989bcac050909f9f63a80f34abc421096616007c881d4c

Resulting output of zfs send -nvt <token>

resume token contents: nvlist version: 0

fromguid = 0x595d9f81aa9dddab
object = 0x1
offset = 0x0
bytes = 0x0
toguid = 0x854f02a2dd32cf0d
toname = pool1/test@b

cannot resume send: 'pool1/test@b' used in the initial send no longer exists

func (*ResumeToken) ToNameSplit

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

type SendStream

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

func NewSendStream

func NewSendStream(cmd *zfscmd.Cmd, r io.ReadCloser, stderrBuf *bytes.Buffer,
	cancel context.CancelFunc,
) *SendStream

func ZFSSend

func ZFSSend(
	ctx context.Context, sendArgs ZFSSendArgsValidated, pipeCmds ...[]string,
) (*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

func (s *SendStream) Close() error

func (*SendStream) Read

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

func (*SendStream) TestOnly_ExitErr

func (s *SendStream) TestOnly_ExitErr() *ZFSError

func (*SendStream) TestOnly_ReplaceStdoutReader

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

type UserSpecifiedDatasetsSet

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

type VersionTypeSet map[VersionType]bool

func (VersionTypeSet) String

func (s VersionTypeSet) String() string

type ZFSError

type ZFSError struct {
	Stderr  []byte
	WaitErr error
}

func NewZfsError

func NewZfsError(err error, stderr []byte) *ZFSError

func (*ZFSError) Error

func (self *ZFSError) Error() string

func (*ZFSError) Unwrap

func (self *ZFSError) Unwrap() error

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,
) ([]ZFSListMappingPropertiesResult, 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(fs string, order int) *ZFSProperties

func ZFSGet

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

func ZFSGetRawAnySource

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

func (*ZFSProperties) Add

func (p *ZFSProperties) Add(propName string, propValue PropertyValue) bool

func (*ZFSProperties) DatasetPath added in v0.9.2

func (p *ZFSProperties) DatasetPath() (*DatasetPath, error)

func (*ZFSProperties) Fs added in v0.9.2

func (p *ZFSProperties) Fs() string

func (*ZFSProperties) Get

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

func (*ZFSProperties) GetDetails

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

func (*ZFSProperties) Order added in v0.9.2

func (p *ZFSProperties) Order() int

func (*ZFSProperties) Valid

func (p *ZFSProperties) Valid(props []string) bool

type ZFSSendArgVersion

type ZFSSendArgVersion struct {
	RelName string
	GUID    uint64
}

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

func (ZFSSendArgVersion) FullPath

func (v ZFSSendArgVersion) FullPath(fs string) string

func (ZFSSendArgVersion) GetGuid

func (v ZFSSendArgVersion) GetGuid() uint64

func (ZFSSendArgVersion) IsSnapshot

func (v ZFSSendArgVersion) IsSnapshot() bool

func (ZFSSendArgVersion) MustBeBookmark

func (v ZFSSendArgVersion) MustBeBookmark()

func (ZFSSendArgVersion) ToSendArgVersion

func (v ZFSSendArgVersion) ToSendArgVersion() ZFSSendArgVersion

func (ZFSSendArgVersion) ValidateExists

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

func (ZFSSendArgVersion) ValidateExistsAndGetVersion

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

fs must be not empty

func (ZFSSendArgVersion) ValidateInMemory

func (v ZFSSendArgVersion) ValidateInMemory(fs string) error

type ZFSSendArgsResumeTokenMismatchError

type ZFSSendArgsResumeTokenMismatchError struct {
	What ZFSSendArgsResumeTokenMismatchErrorCode
	Err  error
}

func (*ZFSSendArgsResumeTokenMismatchError) Error

type ZFSSendArgsResumeTokenMismatchErrorCode

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

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

- 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

type ZFSSendArgsValidated struct {
	ZFSSendArgsUnvalidated
	FromVersion *FilesystemVersion
	ToVersion   FilesystemVersion
}

type ZFSSendArgsValidationError

type ZFSSendArgsValidationError struct {
	Args ZFSSendArgsUnvalidated
	What ZFSSendArgsValidationErrorCode
	Msg  error
}

func (ZFSSendArgsValidationError) Error

type ZFSSendArgsValidationErrorCode

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

type ZFSSendFlags

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

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