Add PollOp
parent
ac7ca2c754
commit
54ad710d24
|
@ -688,6 +688,22 @@ func convertInMessage(
|
|||
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:
|
||||
o = &unknownOp{
|
||||
OpCode: inMsg.Header().Opcode,
|
||||
|
@ -944,6 +960,10 @@ func (c *Connection) kernelResponseForOp(
|
|||
out.TimeGran = 1
|
||||
out.MaxPages = o.MaxPages
|
||||
|
||||
case *fuseops.PollOp:
|
||||
out := (*fusekernel.PollOut)(m.Grow(int(unsafe.Sizeof(fusekernel.PollOut{}))))
|
||||
out.Revents = uint32(o.Revents)
|
||||
|
||||
default:
|
||||
panic(fmt.Sprintf("Unexpected op: %#v", op))
|
||||
}
|
||||
|
|
|
@ -965,3 +965,28 @@ type FallocateOp struct {
|
|||
Mode uint32
|
||||
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
|
||||
SetXattr(context.Context, *fuseops.SetXattrOp) 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
|
||||
// decremented to zero, and clean up any resources associated with the file
|
||||
|
@ -236,6 +237,9 @@ func (s *fileSystemServer) handleOp(
|
|||
|
||||
case *fuseops.FallocateOp:
|
||||
err = s.fs.Fallocate(ctx, typed)
|
||||
|
||||
case *fuseops.PollOp:
|
||||
err = s.fs.Poll(ctx, typed)
|
||||
}
|
||||
|
||||
c.Reply(ctx, err)
|
||||
|
|
|
@ -204,5 +204,11 @@ func (fs *NotImplementedFileSystem) Fallocate(
|
|||
return fuse.ENOSYS
|
||||
}
|
||||
|
||||
func (fs *NotImplementedFileSystem) Poll(
|
||||
ctx context.Context,
|
||||
op *fuseops.PollOp) error {
|
||||
return fuse.ENOSYS
|
||||
}
|
||||
|
||||
func (fs *NotImplementedFileSystem) Destroy() {
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue