btrfs

package
v0.8.5 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 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

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

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 Changed

func Changed(name string, mtime time.Time) (bool, error)

After returns true if `mtime` is after the filesystem time for `name`

func CheckExists

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

CheckExists checks that a file is present

func CheckFile

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

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

func CheckNoExists

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

CheckNoExists checks that no file is present.

func Chtimes

func Chtimes(name string, atime, mtime time.Time) error

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

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

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

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

func GetMeta(name, key string) string

GetMeta gets metadata from a commit.

func Glob

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

func HostPath(name string) string

func Init

func Init(repo string) error

Init initializes an empty repo.

func IsReadOnly

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

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

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

func Open

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

func OpenFd

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

func PathCommit(name string) string

PathCommit extracts the commit from a path

func PathFile

func PathFile(name string) string

PathFile extracts the file from a path

func PathRepo

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

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

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

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

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

func SubvolumeCreate

func SubvolumeCreate(name string) error

func SubvolumeDelete

func SubvolumeDelete(name string) error

func SubvolumeDeleteAll

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

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

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

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

func NewLocalReplica(repo string) *LocalReplica

func (LocalReplica) Pull

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

func (LocalReplica) Push

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

type Puller

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

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

type Replica

type Replica interface {
	Pusher
	Puller
}

type S3Replica

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

func NewS3Replica

func NewS3Replica(uri string) *S3Replica

func (*S3Replica) Pull

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

func (*S3Replica) Push

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