btrfs

package
v0.8.3 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2015 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Desc = iota
	Asc  = iota
)

Constants used for passing to log

Variables

View Source
var (
	ErrComplete  = errors.New("pfs: complete")
	ErrCancelled = errors.New("pfs: cancelled")
)

Functions

func Append added in v0.8.1

func Append(name string, r io.Reader) (int64, error)

Append reads data out of reader and appends it to the file. If the file doesn't exist it creates it.

func Before added in v0.8.1

func Before(name1, name2 string) (bool, error)

return true if name1 was last modified before name2

func Branch

func Branch(repo, commit, branch string) error

func CheckExists added in v0.8.1

func CheckExists(name string, t *testing.T)

CheckExists checks that a file is present

func CheckFile added in v0.8.1

func CheckFile(name, content string, t *testing.T)

CheckFile checks if a file on disk contains a given string.

func CheckNoExists added in v0.8.1

func CheckNoExists(name string, t *testing.T)

CheckNoExists checks that no file is present.

func Commit

func Commit(repo, commit, branch string) error

Commit creates a new commit for a branch.

func Commits

func Commits(repo, from string, order int, cont func(CommitInfo) error) error

Commits is a wrapper around `Log` which parses the output in to a convenient struct

func CopyFile added in v0.7.1

func CopyFile(name string, r io.Reader) (int64, error)

func Create

func Create(name string) (*os.File, error)

func CreateAll

func CreateAll(name string) (*os.File, error)

func CreateFromReader

func CreateFromReader(name string, r io.Reader) (int64, error)

func DanglingCommit added in v0.8.1

func DanglingCommit(repo, commit, branch string) error

DanglingCommit creates a commit but resets the branch to point to its current parent

func Ensure

func Ensure(repo string) error

Ensure is like Init but won't error if the repo is already present. It will error if the repo is not present and we fail to make it.

func FileExists

func FileExists(name string) (bool, error)

func FilePath

func FilePath(name string) string

func FindNew

func FindNew(repo, from, to string) ([]string, error)

FindNew returns an array of filenames that were created or modified between `from` and `to`

func GetFrom added in v0.7.1

func GetFrom(repo string) (string, error)

GetFrom returns the commit that this repo should pass to Pull to get itself up to date.

func GetMeta added in v0.7.1

func GetMeta(name, key string) string

GetMeta gets metadata from a commit.

func Glob added in v0.8.1

func Glob(pattern string) ([]string, error)

func Hold

func Hold(repo, commit string) (string, error)

Hold creates a temporary snapshot of a commit that no one else knows about. It's your responsibility to release the snapshot with Release

func HostPath added in v0.8.1

func HostPath(name string) string

func Init

func Init(repo string) error

Init initializes an empty repo.

func IsReadOnly added in v0.7.1

func IsReadOnly(volume string) (bool, error)

func LazyWalk

func LazyWalk(name string, f func(string) error) error
func Link(oldname, newname string) error

func Log

func Log(repo, from string, order int, cont func(io.Reader) error) error

Log returns all of the commits the repo which have generation >= from.

func Lstat added in v0.7.1

func Lstat(name string) (os.FileInfo, error)

func Mkdir

func Mkdir(name string) error

func MkdirAll

func MkdirAll(name string) error

TODO(rw,jd): check into atomicity/race conditions with multiple callers

func NewIn added in v0.8.1

func NewIn(repo, commit string) ([]string, error)

func Open

func Open(name string) (*os.File, error)

func OpenFd added in v0.7.1

func OpenFd(name string, mode int, perm uint32) (int, error)

func OpenFile

func OpenFile(name string, flag int, perm os.FileMode) (*os.File, error)

func PathCommit added in v0.8.1

func PathCommit(name string) string

PathCommit extracts the commit from a path

func PathFile added in v0.8.1

func PathFile(name string) string

PathFile extracts the file from a path

func PathRepo added in v0.8.1

func PathRepo(name string) string

PathRepo extracts the repo from a path

func Pull

func Pull(repo, from string, cb Pusher) error

func RandSeq

func RandSeq(n int) string

Generates a random sequence of letters. Useful for making filesystems that won't interfere with each other. This should be factored out to another file.

func ReadDir

func ReadDir(name string) ([]os.FileInfo, error)

func ReadFile added in v0.7.1

func ReadFile(name string) ([]byte, error)
func Readlink(name string) (string, error)

func Recv

func Recv(repo string, data io.Reader) error

func Release

func Release(name string)

Release releases commit snapshots held by Hold.

func Remove

func Remove(name string) error

func RemoveAll added in v0.7.1

func RemoveAll(name string) error

func Rename

func Rename(oldname, newname string) error

func Send

func Send(repo, commit string, cont func(io.Reader) error) error

func SetMeta added in v0.7.1

func SetMeta(branch, key, value string) error

SetMeta sets metadata for a branch.

func SetReadOnly

func SetReadOnly(volume string) error

func Snapshot

func Snapshot(volume string, dest string, readonly bool) error

func Stat added in v0.7.1

func Stat(name string) (os.FileInfo, error)

func SubvolumeCreate

func SubvolumeCreate(name string) error

func SubvolumeDelete

func SubvolumeDelete(name string) error

func SubvolumeDeleteAll added in v0.7.1

func SubvolumeDeleteAll(name string) error
func Symlink(oldname, newname string) error

func Sync

func Sync() error

func TrimFilePath

func TrimFilePath(name string) string

func UnsetReadOnly

func UnsetReadOnly(volume string) error

func WaitAnyFile added in v0.8.3

func WaitAnyFile(files ...string) (string, error)

WaitAnyFile returns as soon as ANY of the files exists. It returns an error if waiting for ANY of the files errors.

func WaitFile added in v0.8.3

func WaitFile(name string, cancel chan struct{}) error

func WriteFile

func WriteFile(name string, data []byte) error

Types

type CommitInfo

type CommitInfo struct {
	Path string
	// contains filtered or unexported fields
}

type LocalReplica added in v0.7.1

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

A LocalReplica implements the Replica interface and replicates the commits to a local repo. It expects `repo` to already exist

func NewLocalReplica added in v0.7.1

func NewLocalReplica(repo string) *LocalReplica

func (LocalReplica) Pull added in v0.7.1

func (r LocalReplica) Pull(from string, cb Pusher) error

func (LocalReplica) Push added in v0.7.1

func (r LocalReplica) Push(diff io.Reader) error

type Puller added in v0.7.1

type Puller interface {
	// Pull pulls data from a replica and applies it to the target,
	// `from` is used to pickup where you left-off, passing `from=""` will start from the beginning
	// Pull returns the value that should be passed next as `from`
	Pull(from string, target Pusher) error
}

type Pusher added in v0.7.1

type Pusher interface {
	Push(diff io.Reader) error
}

type Replica added in v0.7.1

type Replica interface {
	Pusher
	Puller
}

type S3Replica added in v0.7.1

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

func NewS3Replica added in v0.7.1

func NewS3Replica(uri string) *S3Replica

func (*S3Replica) Pull added in v0.7.1

func (r *S3Replica) Pull(from string, target Pusher) error

func (*S3Replica) Push added in v0.7.1

func (r *S3Replica) Push(diff io.Reader) error

Jump to

Keyboard shortcuts

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