Commit c44d05f4 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Reinstate debug info for paths and filehandles.

parent 62dac3a2
......@@ -153,10 +153,14 @@ type File interface {
Fsync(*FsyncIn) (code Status)
}
// Wrap a File return in this to set FUSE flags.
// Wrap a File return in this to set FUSE flags. Also used internally
// to store open file data.
type WithFlags struct {
File
// For debugging.
Description string
// Put FOPEN_* flags here.
FuseFlags uint32
......
......@@ -73,7 +73,7 @@ func TestCacheFs(t *testing.T) {
CheckSuccess(err)
if string(c) != "hello" {
t.Fatalf("expect 'hello' %q", string(c))
t.Fatalf("Page cache skipped: expect 'hello' %q", string(c))
}
code := pathfs.EntryNotify("", "file.txt")
......
......@@ -78,6 +78,9 @@ func (me *fileSystemMount) fileInfoToAttr(fi *os.FileInfo, out *AttrOut) {
func (me *FileSystemConnector) getOpenedFile(h uint64) *openedFile {
b := (*openedFile)(unsafe.Pointer(DecodeHandle(h)))
if me.Debug {
log.Printf("File %d = %s", h, b.WithFlags.Description)
}
return b
}
......@@ -112,10 +115,16 @@ func (me *fileSystemMount) registerFileHandle(node *Inode, dir rawDir, f File, f
OpenFlags: flags,
},
}
withFlags, ok := f.(*WithFlags)
if ok {
b.WithFlags.FuseFlags = withFlags.FuseFlags
b.WithFlags.File = withFlags.File
for {
withFlags, ok := f.(*WithFlags)
if !ok {
break
}
b.WithFlags.FuseFlags |= withFlags.FuseFlags
b.WithFlags.Description += withFlags.Description
f = withFlags.File
}
node.openFiles = append(node.openFiles, b)
......
......@@ -174,7 +174,8 @@ func (me *FileSystemConnector) Open(header *InHeader, input *OpenIn) (flags uint
func (me *FileSystemConnector) SetAttr(header *InHeader, input *SetAttrIn) (out *AttrOut, code Status) {
var f File
if input.Valid&FATTR_FH != 0 {
me.getOpenedFile(input.Fh)
opened := me.getOpenedFile(input.Fh)
f = opened.WithFlags.File
}
node := me.getInodeData(header.NodeId)
......
......@@ -164,7 +164,12 @@ func (me *pathInode) GetPath() (path string) {
if n != me.ifs.root {
return ".deleted"
}
return ReverseJoin(rev_components, "/")
p := ReverseJoin(rev_components, "/")
if me.ifs.Debug {
log.Printf("Inode %d = %q", me.Inode().nodeId, p)
}
return p
}
func (me *pathInode) AddChild(name string, child FsNode) {
......@@ -379,7 +384,14 @@ func (me *pathInode) createChild(name string) *pathInode {
}
func (me *pathInode) Open(flags uint32, context *Context) (file File, code Status) {
return me.fs.Open(me.GetPath(), flags, context)
file, code = me.fs.Open(me.GetPath(), flags, context)
if me.ifs.Debug {
file = &WithFlags{
File: file,
Description: me.GetPath(),
}
}
return
}
func (me *pathInode) Lookup(name string, context *Context) (fi *os.FileInfo, node FsNode, code Status) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment