Better debugging messages
This commit is contained in:
parent
8c374b672a
commit
148d9879d5
11
dir.go
11
dir.go
@ -26,6 +26,7 @@ import (
|
|||||||
"bazil.org/fuse"
|
"bazil.org/fuse"
|
||||||
"bazil.org/fuse/fs"
|
"bazil.org/fuse/fs"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type versionedDir struct {
|
type versionedDir struct {
|
||||||
@ -44,27 +45,31 @@ func newVersionedDir(node *versionedNode, inode uint64) *versionedDir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this versionedDir) Attr(attr *fuse.Attr) {
|
func (this versionedDir) Attr(attr *fuse.Attr) {
|
||||||
|
log.Printf("versionedDir::Attr: %s", this.node)
|
||||||
|
|
||||||
attr.Mode = this.node.info.Mode()
|
attr.Mode = this.node.info.Mode()
|
||||||
attr.Inode = this.inode
|
attr.Inode = this.inode
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this versionedDir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
func (this versionedDir) ReadDirAll(ctx context.Context) ([]fuse.Dirent, error) {
|
||||||
var entries []fuse.Dirent
|
log.Printf("versionedDir::ReadDirAll: %s", this.node)
|
||||||
|
|
||||||
|
var entries []fuse.Dirent
|
||||||
for name, dir := range this.dirs {
|
for name, dir := range this.dirs {
|
||||||
entry := fuse.Dirent{Inode: dir.inode, Name: name, Type: fuse.DT_File}
|
entry := fuse.Dirent{Inode: dir.inode, Name: name, Type: fuse.DT_File}
|
||||||
entries = append(entries, entry)
|
entries = append(entries, entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
for name, file := range this.files {
|
for name, file := range this.files {
|
||||||
entry := fuse.Dirent{Inode: file.inode, Name: name, Type: fuse.DT_Dir}
|
entry := fuse.Dirent{Inode: file.inode, Name: name, Type: fuse.DT_Dir}
|
||||||
entries = append(entries, entry)
|
entries = append(entries, entry)
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil, nil
|
return entries, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this versionedDir) Lookup(ctx context.Context, name string) (fs.Node, error) {
|
func (this versionedDir) Lookup(ctx context.Context, name string) (fs.Node, error) {
|
||||||
|
log.Printf("versionedDir::Lookup: %s", this.node)
|
||||||
|
|
||||||
if dir, ok := this.dirs[name]; ok {
|
if dir, ok := this.dirs[name]; ok {
|
||||||
return dir, nil
|
return dir, nil
|
||||||
}
|
}
|
||||||
|
5
file.go
5
file.go
@ -26,6 +26,7 @@ import (
|
|||||||
"bazil.org/fuse"
|
"bazil.org/fuse"
|
||||||
"golang.org/x/net/context"
|
"golang.org/x/net/context"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type versionedFile struct {
|
type versionedFile struct {
|
||||||
@ -38,12 +39,16 @@ func newVersionedFile(node *versionedNode, inode uint64) *versionedFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (this versionedFile) Attr(attr *fuse.Attr) {
|
func (this versionedFile) Attr(attr *fuse.Attr) {
|
||||||
|
log.Printf("versionedFile::Attr: %s", this.node)
|
||||||
|
|
||||||
attr.Mode = this.node.info.Mode()
|
attr.Mode = this.node.info.Mode()
|
||||||
attr.Inode = this.inode
|
attr.Inode = this.inode
|
||||||
attr.Size = uint64(this.node.info.Size())
|
attr.Size = uint64(this.node.info.Size())
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this versionedFile) ReadAll(ctx context.Context) ([]byte, error) {
|
func (this versionedFile) ReadAll(ctx context.Context) ([]byte, error) {
|
||||||
|
log.Printf("versionedFile::ReadAll: %s", this.node)
|
||||||
|
|
||||||
bytes, err := ioutil.ReadFile(this.node.rebasedPath())
|
bytes, err := ioutil.ReadFile(this.node.rebasedPath())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -0,0 +1 @@
|
|||||||
|
Hello world
|
@ -0,0 +1 @@
|
|||||||
|
Blahblahblah
|
9
node.go
9
node.go
@ -22,7 +22,10 @@
|
|||||||
|
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "os"
|
import (
|
||||||
|
"fmt"
|
||||||
|
"os"
|
||||||
|
)
|
||||||
|
|
||||||
type versionedNode struct {
|
type versionedNode struct {
|
||||||
path string
|
path string
|
||||||
@ -35,3 +38,7 @@ type versionedNodeMap map[string]*versionedNode
|
|||||||
func (this *versionedNode) rebasedPath() string {
|
func (this *versionedNode) rebasedPath() string {
|
||||||
return this.ver.rebasePath(this.path)
|
return this.ver.rebasePath(this.path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *versionedNode) String() string {
|
||||||
|
return fmt.Sprintf("%s (%s)", this.path, this.rebasedPath())
|
||||||
|
}
|
||||||
|
6
vfs.go
6
vfs.go
@ -36,10 +36,10 @@ func main() {
|
|||||||
|
|
||||||
c, err := fuse.Mount(
|
c, err := fuse.Mount(
|
||||||
"mp",
|
"mp",
|
||||||
fuse.FSName("helloworld"),
|
fuse.FSName("vfs"),
|
||||||
fuse.Subtype("hellofs"),
|
fuse.Subtype("vfs"),
|
||||||
fuse.LocalVolume(),
|
fuse.LocalVolume(),
|
||||||
fuse.VolumeName("Hello world!"),
|
fuse.VolumeName("vfs"),
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
|
Loading…
Reference in New Issue
Block a user