diff --git a/database.go b/database.go index b611b62..2bfe744 100644 --- a/database.go +++ b/database.go @@ -32,11 +32,12 @@ import ( "path/filepath" "regexp" "strconv" - "sync/atomic" "time" ) -var inodeCnt uint64 +// +// database +// type database struct { base string @@ -175,7 +176,3 @@ func (this *database) parseVerName(name string) (time.Time, error) { return time.Unix(timestamp, 0), nil } - -func allocInode() uint64 { - return atomic.AddUint64(&inodeCnt, 1) -} diff --git a/dir.go b/dir.go index da074ee..291a4b6 100644 --- a/dir.go +++ b/dir.go @@ -30,6 +30,10 @@ import ( "path" ) +// +// versionedDir +// + type versionedDir struct { dirs map[string]*versionedDir files map[string]*versionedFile diff --git a/file.go b/file.go index 0aa4e5d..82bc3eb 100644 --- a/file.go +++ b/file.go @@ -30,6 +30,10 @@ import ( "os" ) +// +// versionedFile +// + type versionedFile struct { node *versionedNode inode uint64 diff --git a/meta.go b/meta.go index e1808b1..76a0fcb 100644 --- a/meta.go +++ b/meta.go @@ -29,6 +29,10 @@ import ( "strings" ) +// +// versionMetadata +// + type versionMetadata struct { Deleted []string `json:"deleted"` path string diff --git a/node.go b/node.go index 26ff9d6..557cd35 100644 --- a/node.go +++ b/node.go @@ -24,12 +24,15 @@ package main import ( "bazil.org/fuse" - "fmt" "os" "syscall" "time" ) +// +// versionedNode +// + type versionedNode struct { path string info os.FileInfo @@ -110,6 +113,14 @@ func (this *versionedNode) rebasedPath() string { return this.ver.rebasePath(this.path) } +func (this *versionedNode) rebasedTermPath() string { + if this.ver.terminus == nil { + return this.rebasedPath() + } + + return this.ver.terminus.rebasePath(this.path) +} + func (this *versionedNode) owner() (gid, uid uint32) { stat := this.info.Sys().(*syscall.Stat_t) @@ -138,7 +149,3 @@ func (this *versionedNode) attr(attr *fuse.Attr) { attr.Gid, attr.Uid = this.owner() attr.Rdev = uint32(stat.Rdev) } - -func (this *versionedNode) String() string { - return fmt.Sprintf("%s (%s)", this.path, this.rebasedPath()) -} diff --git a/util.go b/util.go new file mode 100644 index 0000000..87e7ea6 --- /dev/null +++ b/util.go @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2015 Alex Yatskov + * Author: Alex Yatskov + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +package main + +import "sync/atomic" + +// +// utilities +// + +var inodeCnt uint64 + +func allocInode() uint64 { + return atomic.AddUint64(&inodeCnt, 1) +} diff --git a/version.go b/version.go index a754e4a..8504e3d 100644 --- a/version.go +++ b/version.go @@ -32,6 +32,10 @@ import ( "time" ) +// +// version +// + type version struct { base string parent *version @@ -141,10 +145,6 @@ func (this *version) rebasePath(paths ...string) string { return filepath.Join(combined...) } -func (this *version) Root() (fs.Node, error) { - return this.root, nil -} - func (this *version) dump(root *versionedDir, depth int) { indent := strings.Repeat("\t", depth) for name, dir := range root.dirs { @@ -159,3 +159,7 @@ func (this *version) dump(root *versionedDir, depth int) { func (this *version) dumpRoot() { this.dump(this.root, 0) } + +func (this *version) Root() (fs.Node, error) { + return this.root, nil +} diff --git a/vfs b/vfs new file mode 100755 index 0000000..ae225e3 Binary files /dev/null and b/vfs differ