Documentation ¶
Index ¶
- Variables
- func CreateSnapshot(source string, path string, recursive bool, read_only bool) error
- func CreateSnapshotFd(fd uintptr, path string, recursive bool, read_only bool) error
- func CreateSnapshotFd2(fd uintptr, parent_fd uintptr, name string, recursive bool, read_only bool) error
- func CreateSnapshotWithQgroup(source string, path string, recursive bool, read_only bool, ...) error
- func CreateSnapshotWithQgroupFd(fd uintptr, path string, recursive bool, read_only bool, ...) error
- func CreateSnapshotWithQgroupFd2(fd uintptr, parent_fd uintptr, name string, recursive bool, read_only bool, ...) error
- func CreateSubvolume(path string) error
- func CreateSubvolumeFd(parent_fd uintptr, name string) error
- func CreateSubvolumeWithQgroup(path string, qgroup_inherit *QgroupInherit) error
- func CreateSubvolumeWithQgroupFd(parent_fd uintptr, name string, qgroup_inherit *QgroupInherit) error
- func DeleteSubvolume(path string, recursive bool) error
- func DeleteSubvolumeByIdFd(parent_fd uintptr, subvolid uint64) error
- func DeleteSubvolumeFd(parent_fd uintptr, name string, recursive bool) error
- func DeletedSubvolumes(path string) ([]uint64, error)
- func DeletedSubvolumesFd(fd uintptr) ([]uint64, error)
- func GetCError(err error) uint32
- func GetDefaultSubvolume(path string) (uint64, error)
- func GetDefaultSubvolumeFd(fd uintptr) (uint64, error)
- func GetSubvolumeReadOnly(path string) (bool, error)
- func GetSubvolumeReadOnlyFd(fd uintptr) (bool, error)
- func IsSubvolume(path string) (bool, error)
- func IsSubvolumeFd(fd uintptr) (bool, error)
- func SetDefaultSubvolume(path string, id uint64) error
- func SetDefaultSubvolumeFd(fd uintptr, id uint64) error
- func SetSubvolumeReadOnly(path string, read_only bool) error
- func SetSubvolumeReadOnlyFd(fd uintptr, read_only bool) error
- func StartSync(path string) (uint64, error)
- func StratSyncFd(fd uintptr) (uint64, error)
- func SubvolumeId(path string) (uint64, error)
- func SubvolumeIdFd(fd uintptr) (uint64, error)
- func SubvolumePath(path string, id uint64) (string, error)
- func SubvolumePathFd(fd uintptr, id uint64) (string, error)
- func Sync(path string) error
- func SyncFd(fd uintptr) error
- func WaitSync(path string, transid uint64) error
- func WaitSyncFd(fd uintptr, transid uint64) error
- type QgroupInherit
- type SubvolumeInfo
- type SubvolumeInfoIterator
- type SubvolumeInfoIteratorResult
- type SubvolumeIterator
- type SubvolumeIteratorResult
Constants ¶
This section is empty.
Variables ¶
var ( ErrStopIteration = errors.New("stop iteration") ErrNoMemory = errors.New("cannot allocate memory") ErrInvalidArgument = errors.New("invalid argument") ErrNotBtrfs = errors.New("not a Btrfs filesystem") ErrNotSubvolume = errors.New("not a Btrfs subvolume") ErrSubvolumeNotFound = errors.New("subvolume not found") ErrOpenFailed = errors.New("could not open") ErrRmdirFailed = errors.New("could not rmdir") ErrUnlinkFailed = errors.New("could not unlink") ErrStatFailed = errors.New("could not stat") ErrStatfsFailed = errors.New("could not statfs") ErrSearchFailed = errors.New("could not search B-tree") ErrInoLookupFailed = errors.New("could not lookup inode") ErrSubvolGetflagsFailed = errors.New("could not get subvolume flags") ErrSubvolSetflagsFailed = errors.New("could not set subvolume flags") ErrSubvolCreateFailed = errors.New("could not create subvolume") ErrSnapCreateFailed = errors.New("could not create snapshot") ErrSnapDestroyFailed = errors.New("could not destroy subvolume/snapshot") ErrDefaultSubvolFailed = errors.New("could not set default subvolume") ErrSyncFailed = errors.New("could not sync filesystem") ErrStartSyncFailed = errors.New("could not start filesystem sync") ErrWaitSyncFailed = errors.New("could not wait for filesystem sync") ErrGetSubvolInfoFailed = errors.New("could not get subvolume information with BTRFS_IOC_GET_SUBVOL_INFO") ErrGetSubvolRootrefFailed = errors.New("could not get rootref information with BTRFS_IOC_GET_SUBVOL_ROOTREF") ErrInoLookupUserFailed = errors.New("could not resolve subvolume path with BTRFS_IOC_INO_LOOKUP_USER") ErrFsInfoFailed = errors.New("could not get filesystem information") )
Functions ¶
func CreateSnapshot ¶
CreateSnapshot creates a new snapshot from a source subvolume path. If source is not a subvolume the subvolume containing source will be snapshotted
func CreateSnapshotFd ¶
See CreateSnapshot
func CreateSnapshotFd2 ¶
func CreateSnapshotFd2(fd uintptr, parent_fd uintptr, name string, recursive bool, read_only bool) error
CreateSnapshotFd2 creates a new snapshot form a source subvolume file descriptor, a target parent file descriptor and name.
func CreateSnapshotWithQgroup ¶
func CreateSnapshotWithQgroup(source string, path string, recursive bool, read_only bool, qgroup_inherit *QgroupInherit) error
CreateSnapshotWithQgroup creates a new snapshot from a source subvolume path with Qgroups to inherit from.
func CreateSnapshotWithQgroupFd ¶
func CreateSnapshotWithQgroupFd(fd uintptr, path string, recursive bool, read_only bool, qgroup_inherit *QgroupInherit) error
See CreateSnapshotWithQgroup.
func CreateSnapshotWithQgroupFd2 ¶
func CreateSnapshotWithQgroupFd2(fd uintptr, parent_fd uintptr, name string, recursive bool, read_only bool, qgroup_inherit *QgroupInherit) error
CreateSnapshotWithQgroupFd2 creates a new snapshot form a source subvolume file descriptor, a target parent file descriptor and name, with Qgroups to inherit from.
func CreateSubvolume ¶
CreateSubvolume creates a new subvolume under a given path.
func CreateSubvolumeFd ¶
func CreateSubvolumeWithQgroup ¶
func CreateSubvolumeWithQgroup(path string, qgroup_inherit *QgroupInherit) error
CreateSubvolumeWithQgroup creates a new subvolume under a given path, with Qgroups to inherit from.
func CreateSubvolumeWithQgroupFd ¶
func CreateSubvolumeWithQgroupFd(parent_fd uintptr, name string, qgroup_inherit *QgroupInherit) error
CreateSubvolumeWithQgroupFd creates a new subvolume given its parent file descriptor, a name and Qgroups to inherit from.
func DeleteSubvolume ¶
DeleteSubvolume deletes a subvolume or snapshot. If recursive is set subvolumes beneath the given subvolume will be deleted befor attempting to delete the given subvolume. Unless the filesystem is mounted with 'user_subvol_rm_allow', appropriate privileges are required (CAP_SYS_ADMIN).
func DeleteSubvolumeByIdFd ¶
DeleteSubvolumeByIdFd deletes a subvolume or snapshot by its parent file descriptor and id. See DeleteSubvolume
func DeleteSubvolumeFd ¶
DeleteSubvolumeFd deletes a subvolume or snapshot by its parent file descriptor and name. See DeleteSubvolume.
func DeletedSubvolumes ¶
DeletedSubvolumes returns a list of subvolume IDs which have been deleted but not yet cleaned up.
func DeletedSubvolumesFd ¶
See DeletedSubvolumesFd.
func GetDefaultSubvolume ¶
GetDefaultSubvolume returns the default subvolume ID for a filesystem.
func GetDefaultSubvolumeFd ¶
See GetDefaultSubvolume.
func GetSubvolumeReadOnly ¶
GetSubvolumeReadOnly returns whether a subvolume is read-only.
func GetSubvolumeReadOnlyFd ¶
See GetSubvolumeReadOnly.
func IsSubvolume ¶
IsSubvolume returns whether a given path is a Btrfs subvolume.
func SetDefaultSubvolume ¶
SetDefaultSubvolume sets the default subvolume for a filesystem. The given path may be any path in the Btrfs filesystem; it dose not have to refer to a subvolume unless id is zero. If the given ID is zero, the subvolume ID of the subvolume containing path is used.
func SetDefaultSubvolumeFd ¶
See SetDefaultSubvolume.
func SetSubvolumeReadOnly ¶
SetSubvolumeReadOnly sets whether a subvolume is read-only.
func SetSubvolumeReadOnlyFd ¶
See SetSubvolumeReadOnly.
func SubvolumeId ¶
SubvolumeId returns the ID of the subvolume containing a given path.
func SubvolumePath ¶
SubvolumePath returns the path of the subvolume with a given ID.
func SubvolumePathFd ¶
See SubvolumePath.
Types ¶
type QgroupInherit ¶
type QgroupInherit struct {
// contains filtered or unexported fields
}
QgroupInherit is the qgroup inheritance specifier for SubvolumeCreate or SubvolumeSnapshot.
func CreateQgroupInherit ¶
func CreateQgroupInherit() (*QgroupInherit, error)
CreateQgroupInherit creates a qgroup inheritance specifier. The returnd QgroupInherit struct must be freed with Destroy().
func (QgroupInherit) AddGroup ¶
func (q QgroupInherit) AddGroup(groupid uint64) error
AddGroup adds an inheritance from a qgroup with the given ID to a qgroup inheritance specifier.
func (QgroupInherit) Destroy ¶
func (q QgroupInherit) Destroy()
Destroy destroyes the qgroup inheritance specifier.
func (QgroupInherit) GetGroups ¶
func (q QgroupInherit) GetGroups() []uint64
GetGroups returs the qgroup IDs contained in a qgroup inheritance specifier.
type SubvolumeInfo ¶
type SubvolumeInfo struct { Id uint64 ParentId uint64 DirId uint64 Flags uint64 UUID string ParentUUID string ReceivedUUID string Generation uint64 Ctransid uint64 Otransid uint64 Stransid uint64 Rtransid uint64 Ctime time.Time Otime time.Time Stime time.Time Rtime time.Time }
SubvolumeInfo is a representation of a Btrfs subvolume or snapshot.
func GetSubvolumeInfo ¶
func GetSubvolumeInfo(path string, id uint64) (*SubvolumeInfo, error)
GetSubvolumeInfo returns information about a subvolume with a given ID or path. The given path may be any path in the Btrfs filesystem; it dose not have to refer to a subvolume unless id is zero. If the given ID is zero, the subvolume ID of the subvolume containing path is used.
func GetSubvolumeInfoFd ¶
func GetSubvolumeInfoFd(fd uintptr, id uint64) (*SubvolumeInfo, error)
See GetSubvolumeInfo.
type SubvolumeInfoIterator ¶ added in v0.1.3
type SubvolumeInfoIterator struct {
// contains filtered or unexported fields
}
func CreateSubvolumeInfoIterator ¶ added in v0.1.3
func CreateSubvolumeInfoIterator(path string, top uint64, post_order bool) (*SubvolumeInfoIterator, error)
Identical to CreateSubvolumeIterator but GetNext() returns a SubvolumeInfo insted of a subvolume Id. The returnd SubvolumeInfoIterator struct must be freed with Destroy().
func CreateSubvolumeInfoIteratorFd ¶ added in v0.1.3
func CreateSubvolumeInfoIteratorFd(fd uintptr, top uint64, post_order bool) (*SubvolumeInfoIterator, error)
See CreateSubvolumeInfoIterator.
func (*SubvolumeInfoIterator) Destroy ¶ added in v0.1.3
func (it *SubvolumeInfoIterator) Destroy()
Destroy destroyes the SubvolumeInfoIterator.
func (*SubvolumeInfoIterator) Fd ¶ added in v0.1.3
func (it *SubvolumeInfoIterator) Fd() uintptr
Fd returns the file descriptor referencing the SubvolumeInfoIterator
func (*SubvolumeInfoIterator) GetNext ¶ added in v0.1.3
func (it *SubvolumeInfoIterator) GetNext() (*SubvolumeInfoIteratorResult, error)
GetNext gets the Path and SubvolumeInfo of the next subvolume from a SubvolumeInfoIterator.
func (*SubvolumeInfoIterator) HasNext ¶ added in v0.1.3
func (it *SubvolumeInfoIterator) HasNext() bool
HasNext returns true if the SubvolumeInfoIterator has a next value.
type SubvolumeInfoIteratorResult ¶ added in v0.1.3
type SubvolumeInfoIteratorResult struct { Path string Info *SubvolumeInfo }
type SubvolumeIterator ¶
type SubvolumeIterator struct {
// contains filtered or unexported fields
}
func CreateSubvolumeIterator ¶
func CreateSubvolumeIterator(path string, top uint64, post_order bool) (*SubvolumeIterator, error)
CreateSubvolumeIterator creates an iterator over subvolumes in a Btrfs filesystem. Lists all subvolumes beneath (but not including) the subvolume with the ID top. The given path may be any path in the Btrfs filesystem; it dose not have to refer to a subvolume unless top is zero. If the as top given ID is zero, the subvolume ID of the subvolume containing path is used. By default subvolumes are listed pre-order e.g., foo will be yielded befor foo/bar. This behavior can be reversed by setting post_order. The returnd SubvolumeIterator struct must be freed with Destroy().
func CreateSubvolumeIteratorFd ¶
func CreateSubvolumeIteratorFd(fd uintptr, top uint64, post_order bool) (*SubvolumeIterator, error)
See CreateSubvolumeIterator.
func (*SubvolumeIterator) Destroy ¶
func (it *SubvolumeIterator) Destroy()
Destroy destroyes the SubvolumeIterator.
func (*SubvolumeIterator) Fd ¶
func (it *SubvolumeIterator) Fd() uintptr
Fd returns the file descriptor referencing the SubvolumeIterator
func (*SubvolumeIterator) GetNext ¶ added in v0.1.3
func (it *SubvolumeIterator) GetNext() (*SubvolumeIteratorResult, error)
GetNext gets the Path and Id of the next subvolume from a SubvolumeIterator.
func (*SubvolumeIterator) HasNext ¶ added in v0.1.3
func (it *SubvolumeIterator) HasNext() bool
HasNext returns true if the SubvolumeIterator has a next value.