Add PollOp
parent
062810a628
commit
0f0f6e3670
|
@ -607,6 +607,22 @@ func convertInMessage(
|
||||||
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case fusekernel.OpPoll:
|
||||||
|
type input fusekernel.PollIn
|
||||||
|
in := (*input)(inMsg.Consume(unsafe.Sizeof(input{})))
|
||||||
|
if in == nil {
|
||||||
|
return nil, errors.New("Corrupt OpPoll")
|
||||||
|
}
|
||||||
|
|
||||||
|
o = &fuseops.PollOp{
|
||||||
|
Inode: fuseops.InodeID(inMsg.Header().Nodeid),
|
||||||
|
Handle: fuseops.HandleID(in.Fh),
|
||||||
|
Kh: in.Kh,
|
||||||
|
Flags: fusekernel.PollFlags(in.Flags),
|
||||||
|
Events: fusekernel.PollEvents(in.Events),
|
||||||
|
OpContext: fuseops.OpContext{Pid: inMsg.Header().Pid},
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
o = &unknownOp{
|
o = &unknownOp{
|
||||||
OpCode: inMsg.Header().Opcode,
|
OpCode: inMsg.Header().Opcode,
|
||||||
|
@ -863,6 +879,10 @@ func (c *Connection) kernelResponseForOp(
|
||||||
out.TimeGran = 1
|
out.TimeGran = 1
|
||||||
out.MaxPages = o.MaxPages
|
out.MaxPages = o.MaxPages
|
||||||
|
|
||||||
|
case *fuseops.PollOp:
|
||||||
|
out := (*fusekernel.PollOut)(m.Grow(int(unsafe.Sizeof(fusekernel.PollOut{}))))
|
||||||
|
out.Revents = uint32(o.Revents)
|
||||||
|
|
||||||
default:
|
default:
|
||||||
panic(fmt.Sprintf("Unexpected op: %#v", op))
|
panic(fmt.Sprintf("Unexpected op: %#v", op))
|
||||||
}
|
}
|
||||||
|
|
|
@ -976,3 +976,28 @@ type FallocateOp struct {
|
||||||
Mode uint32
|
Mode uint32
|
||||||
OpContext OpContext
|
OpContext OpContext
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Request notifications when the file system user calls poll/select or
|
||||||
|
// similar operations on a file.
|
||||||
|
type PollOp struct {
|
||||||
|
// The inode and handle the user wants to poll
|
||||||
|
Inode InodeID
|
||||||
|
Handle HandleID
|
||||||
|
|
||||||
|
// Kh is the "kernel handle". The reason behind it is that it's allocated
|
||||||
|
// by the kernel on file allocation and guaranteed to be unique as opposed
|
||||||
|
// to regular file handles (HandleID) generated by the userland server
|
||||||
|
// (by us). Kh has to be used in NotifyPollWakeupOut replies.
|
||||||
|
Kh uint64
|
||||||
|
|
||||||
|
// Poll flags
|
||||||
|
Flags fusekernel.PollFlags
|
||||||
|
|
||||||
|
// Requested events
|
||||||
|
Events fusekernel.PollEvents
|
||||||
|
|
||||||
|
// Set by the file system: the actual events that have happened
|
||||||
|
// since the last poll
|
||||||
|
Revents fusekernel.PollEvents
|
||||||
|
OpContext OpContext
|
||||||
|
}
|
||||||
|
|
|
@ -63,6 +63,7 @@ type FileSystem interface {
|
||||||
ListXattr(context.Context, *fuseops.ListXattrOp) error
|
ListXattr(context.Context, *fuseops.ListXattrOp) error
|
||||||
SetXattr(context.Context, *fuseops.SetXattrOp) error
|
SetXattr(context.Context, *fuseops.SetXattrOp) error
|
||||||
Fallocate(context.Context, *fuseops.FallocateOp) error
|
Fallocate(context.Context, *fuseops.FallocateOp) error
|
||||||
|
Poll(context.Context, *fuseops.PollOp) error
|
||||||
|
|
||||||
// Regard all inodes (including the root inode) as having their lookup counts
|
// Regard all inodes (including the root inode) as having their lookup counts
|
||||||
// decremented to zero, and clean up any resources associated with the file
|
// decremented to zero, and clean up any resources associated with the file
|
||||||
|
@ -236,6 +237,9 @@ func (s *fileSystemServer) handleOp(
|
||||||
|
|
||||||
case *fuseops.FallocateOp:
|
case *fuseops.FallocateOp:
|
||||||
err = s.fs.Fallocate(ctx, typed)
|
err = s.fs.Fallocate(ctx, typed)
|
||||||
|
|
||||||
|
case *fuseops.PollOp:
|
||||||
|
err = s.fs.Poll(ctx, typed)
|
||||||
}
|
}
|
||||||
|
|
||||||
c.Reply(ctx, err)
|
c.Reply(ctx, err)
|
||||||
|
|
|
@ -204,5 +204,11 @@ func (fs *NotImplementedFileSystem) Fallocate(
|
||||||
return fuse.ENOSYS
|
return fuse.ENOSYS
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (fs *NotImplementedFileSystem) Poll(
|
||||||
|
ctx context.Context,
|
||||||
|
op *fuseops.PollOp) error {
|
||||||
|
return fuse.ENOSYS
|
||||||
|
}
|
||||||
|
|
||||||
func (fs *NotImplementedFileSystem) Destroy() {
|
func (fs *NotImplementedFileSystem) Destroy() {
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue