Commit d13ebc4a authored by Jakob Unterwurzacher's avatar Jakob Unterwurzacher Committed by Han-Wen Nienhuys

fuse: implement GETATTR for pollHack

When the default_permissions option is passed to the kernel,
it issues a extra GETATTR on the .go-fuse-epoll-hack node.

Rejecting that with EIO makes `syscall.Creat` in `pollHack` fail,
ultimately erroring out during mount.

$ loopback -allow-other -debug b a
16:06:39.576856 rx 2: INIT i0 {7.31 Ra 0x20000 NO_OPEN_SUPPORT,PARALLEL_DIROPS,ABORT_ERROR,EXPLICIT_INVAL_DATA,SPLICE_WRITE,READDIRPLUS,ASYNC_DIO,DONT_MASK,NO_OPENDIR_SUPPORT,AUTO_INVAL_DATA,READDIRPLUS_AUTO,POSIX_ACL,HANDLE_KILLPRIV,MAX_PAGES,ATOMIC_O_TRUNC,EXPORT_SUPPORT,SPLICE_MOVE,BIG_WRITES,SPLICE_READ,FLOCK_LOCKS,IOCTL_DIR,WRITEBACK_CACHE,ASYNC_READ,POSIX_LOCKS,CACHE_SYMLINKS}
16:06:39.576999 tx 2:     OK, {7.28 Ra 0x20000 AUTO_INVAL_DATA,BIG_WRITES,ASYNC_READ,NO_OPEN_SUPPORT,PARALLEL_DIROPS,READDIRPLUS 0/0 Wr 0x10000 Tg 0x0}
16:06:39.578670 rx 4: GETATTR i1 {Fh 0}
16:06:39.578717 rx 6: GETATTR i1 {Fh 0}
16:06:39.578735 tx 4:     OK, {tA=1s {M040755 SZ=40 L=2 1026:1026 B0*4096 i0:1 A 1577370827.990394 M 1577370827.990394 C 1577370827.990394}}
16:06:39.578765 tx 6:     OK, {tA=1s {M040755 SZ=40 L=2 1026:1026 B0*4096 i0:1 A 1577370827.990394 M 1577370827.990394 C 1577370827.990394}}
16:06:39.579028 rx 8: LOOKUP i1 [".go-fuse-epoll-hack"] 20b
16:06:39.579053 tx 8:     2=no such file or directory, {i0 g0 tE=0s tA=0s {M00 SZ=0 L=0 0:0 B0*0 i0:0 A 0.000000 M 0.000000 C 0.000000}}
16:06:39.579087 rx 10: CREATE i1 {0100100 [WRONLY,TRUNC,CREAT,0x8000] (022)} [".go-fuse-epoll-hack"] 20b
16:06:39.579113 tx 10:     OK, {i18446744073709551615 g0 {M0100644 SZ=0 L=1 0:0 B0*0 i0:18446744073709551615 A 0.000000 M 0.000000 C 0.000000} &{18446744073709551615 0 0}}
16:06:39.579199 rx 14: GETATTR i1 {Fh 0}
16:06:39.579205 rx 12: GETATTR i18446744073709551615 {Fh 0}
16:06:39.579216 tx 14:     OK, {tA=1s {M040755 SZ=40 L=2 1026:1026 B0*4096 i0:1 A 1577370827.990394 M 1577370827.990394 C 1577370827.990394}}
16:06:39.579237 rx 16: LOOKUP i1 [".go-fuse-epoll-hack"] 20b
16:06:39.579242 tx 12:     5=input/output error, {tA=0s {M00 SZ=0 L=0 0:0 B0*0 i0:0 A 0.000000 M 0.000000 C 0.000000}}
16:06:39.579247 tx 16:     2=no such file or directory, {i0 g0 tE=0s tA=0s {M00 SZ=0 L=0 0:0 B0*0 i0:0 A 0.000000 M 0.000000 C 0.000000}}
16:06:39.579270 Mount fail: input/output error
16:06:39.579271 rx 20: LOOKUP i1 [".Trash"] 7b

Change-Id: I20024baf2e8f386b637abbd236b188bfdfa8579f
parent 493adfb7
......@@ -9,16 +9,17 @@ const pollHackName = ".go-fuse-epoll-hack"
const pollHackInode = ^uint64(0)
func doPollHackLookup(ms *Server, req *request) {
attr := Attr{
Ino: pollHackInode,
Mode: S_IFREG | 0644,
Nlink: 1,
}
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,
},
Attr: attr,
}
out.OpenOut = OpenOut{
Fh: pollHackInode,
......@@ -28,7 +29,15 @@ func doPollHackLookup(ms *Server, req *request) {
out := (*EntryOut)(req.outData())
*out = EntryOut{}
req.status = ENOENT
case _OP_GETATTR:
out := (*AttrOut)(req.outData())
out.Attr = attr
req.status = OK
case _OP_POLL:
req.status = ENOSYS
default:
req.status = EIO
// We want to avoid switching off features through our
// poll hack, so don't use ENOSYS
req.status = ERANGE
}
}
......@@ -458,14 +458,8 @@ func (ms *Server) handleRequest(req *request) Status {
log.Println(req.InputDebug())
}
if req.inHeader.NodeId == pollHackInode {
// We want to avoid switching off features through our
// poll hack, so don't use ENOSYS
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 {
if req.inHeader.NodeId == pollHackInode ||
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 {
log.Printf("Unimplemented opcode %v", operationName(req.inHeader.Opcode))
......
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