Commit 875784b3 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

fuse: implement LOOKUP for pollhack.

Some versions of FUSE need this; fixes pathfs owner tests.
parent c5c77f10
...@@ -129,22 +129,6 @@ func doOpen(server *Server, req *request) { ...@@ -129,22 +129,6 @@ func doOpen(server *Server, req *request) {
func doCreate(server *Server, req *request) { func doCreate(server *Server, req *request) {
out := (*CreateOut)(req.outData) out := (*CreateOut)(req.outData)
if req.filenames[0] == pollHackName && req.inHeader.NodeId == FUSE_ROOT_ID {
out.EntryOut = EntryOut{
NodeId: pollHackInode,
Attr: Attr{
Ino: pollHackInode,
Mode: S_IFREG | 0644,
Nlink: 1,
},
}
out.OpenOut = OpenOut{
Fh: pollHackInode,
}
req.status = OK
return
}
status := server.fileSystem.Create((*CreateIn)(req.inData), req.filenames[0], out) status := server.fileSystem.Create((*CreateIn)(req.inData), req.filenames[0], out)
req.status = status req.status = status
} }
...@@ -262,9 +246,6 @@ func doGetAttr(server *Server, req *request) { ...@@ -262,9 +246,6 @@ func doGetAttr(server *Server, req *request) {
// doForget - forget one NodeId // doForget - forget one NodeId
func doForget(server *Server, req *request) { func doForget(server *Server, req *request) {
if req.inHeader.NodeId == pollHackInode {
return
}
if !server.opts.RememberInodes { if !server.opts.RememberInodes {
server.fileSystem.Forget(req.inHeader.NodeId, (*ForgetIn)(req.inData).Nlookup) server.fileSystem.Forget(req.inHeader.NodeId, (*ForgetIn)(req.inData).Nlookup)
} }
......
...@@ -37,6 +37,7 @@ func (fs *ownerFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse ...@@ -37,6 +37,7 @@ func (fs *ownerFs) GetAttr(name string, context *fuse.Context) (*fuse.Attr, fuse
func setupOwnerTest(t *testing.T, opts *nodefs.Options) (workdir string, cleanup func()) { func setupOwnerTest(t *testing.T, opts *nodefs.Options) (workdir string, cleanup func()) {
wd := testutil.TempDir() wd := testutil.TempDir()
opts.Debug = testutil.VerboseTest()
fs := &ownerFs{NewDefaultFileSystem()} fs := &ownerFs{NewDefaultFileSystem()}
nfs := NewPathNodeFs(fs, nil) nfs := NewPathNodeFs(fs, nil)
state, _, err := nodefs.MountRoot(wd, nfs.Root(), opts) state, _, err := nodefs.MountRoot(wd, nfs.Root(), opts)
...@@ -45,7 +46,7 @@ func setupOwnerTest(t *testing.T, opts *nodefs.Options) (workdir string, cleanup ...@@ -45,7 +46,7 @@ func setupOwnerTest(t *testing.T, opts *nodefs.Options) (workdir string, cleanup
} }
go state.Serve() go state.Serve()
if err := state.WaitMount(); err != nil { if err := state.WaitMount(); err != nil {
t.Fatal("WaitMount", err) t.Fatalf("WaitMount: %v", err)
} }
return wd, func() { return wd, func() {
state.Unmount() state.Unmount()
......
...@@ -7,3 +7,28 @@ package fuse ...@@ -7,3 +7,28 @@ package fuse
// can say ENOSYS and prevent further _OP_POLL requests. // can say ENOSYS and prevent further _OP_POLL requests.
const pollHackName = ".go-fuse-epoll-hack" const pollHackName = ".go-fuse-epoll-hack"
const pollHackInode = ^uint64(0) const pollHackInode = ^uint64(0)
func doPollHackLookup(ms *Server, req *request) {
switch req.inHeader.Opcode {
case _OP_CREATE:
out := (*CreateOut)(req.outData)
out.EntryOut = EntryOut{
NodeId: pollHackInode,
Attr: Attr{
Ino: pollHackInode,
Mode: S_IFREG | 0644,
Nlink: 1,
},
}
out.OpenOut = OpenOut{
Fh: pollHackInode,
}
req.status = OK
case _OP_LOOKUP:
out := (*EntryOut)(req.outData)
*out = EntryOut{}
req.status = ENOENT
default:
req.status = EIO
}
}
...@@ -389,18 +389,19 @@ func (ms *Server) handleRequest(req *request) Status { ...@@ -389,18 +389,19 @@ func (ms *Server) handleRequest(req *request) Status {
log.Println(req.InputDebug()) log.Println(req.InputDebug())
} }
if req.inHeader.Opcode == _OP_POLL { if req.inHeader.NodeId == pollHackInode {
req.status = ENOSYS
} else if req.inHeader.NodeId == pollHackInode {
// We want to avoid switching off features through our // We want to avoid switching off features through our
// poll hack, so don't use ENOSYS // poll hack, so don't use ENOSYS
req.status = EIO req.status = EIO
if req.inHeader.Opcode == _OP_POLL {
req.status = ENOSYS
}
} else if req.inHeader.NodeId == FUSE_ROOT_ID && len(req.filenames) > 0 && req.filenames[0] == pollHackName {
doPollHackLookup(ms, req)
} else if req.status.Ok() && req.handler.Func == nil { } else if req.status.Ok() && req.handler.Func == nil {
log.Printf("Unimplemented opcode %v", operationName(req.inHeader.Opcode)) log.Printf("Unimplemented opcode %v", operationName(req.inHeader.Opcode))
req.status = ENOSYS req.status = ENOSYS
} } else if req.status.Ok() {
if req.status.Ok() {
req.handler.Func(ms, req) req.handler.Func(ms, req)
} }
......
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