Commit 3cf08068 authored by Han-Wen Nienhuys's avatar Han-Wen Nienhuys

Provide InitIn.SupportsVersion and InitIn.SupportsNotify.

parent 0534f2ff
......@@ -441,6 +441,10 @@ func (ms *Server) write(req *request) Status {
// InodeNotify invalidates the information associated with the inode
// (ie. data cache, attributes, etc.)
func (ms *Server) InodeNotify(node uint64, off int64, length int64) Status {
if !ms.kernelSettings.SupportsNotify(NOTIFY_INVAL_INODE) {
return ENOSYS
}
entry := &NotifyInvalInodeOut{
Ino: node,
Off: off,
......@@ -512,6 +516,9 @@ func (ms *Server) DeleteNotify(parent uint64, child uint64, name string) Status
// within a directory changes. You should not hold any FUSE filesystem
// locks, as that can lead to deadlock.
func (ms *Server) EntryNotify(parent uint64, name string) Status {
if !ms.kernelSettings.SupportsNotify(NOTIFY_INVAL_ENTRY) {
return ENOSYS
}
req := request{
inHeader: &InHeader{
Opcode: _OP_NOTIFY_ENTRY,
......@@ -543,6 +550,26 @@ func (ms *Server) EntryNotify(parent uint64, name string) Status {
return result
}
// SupportsVersion returns true if the kernel supports the given
// protocol version or newer.
func (in *InitIn) SupportsVersion(maj, min uint32) bool {
return in.Major >= maj && in.Minor >= min
}
// SupportsNotify returns whether a certain notification type is
// supported. Pass any of the NOTIFY_INVAL_* types as argument.
func (in *InitIn) SupportsNotify(notifyType int) bool {
switch notifyType {
case NOTIFY_INVAL_ENTRY:
return in.SupportsVersion(7, 12)
case NOTIFY_INVAL_INODE:
return in.SupportsVersion(7, 12)
case NOTIFY_INVAL_DELETE:
return in.SupportsVersion(7, 18)
}
return false
}
var defaultBufferPool BufferPool
func init() {
......
......@@ -341,13 +341,14 @@ type NotifyInvalDeleteOut struct {
}
const (
NOTIFY_POLL = -1
NOTIFY_INVAL_INODE = -2
NOTIFY_INVAL_ENTRY = -3
NOTIFY_STORE = -4
NOTIFY_RETRIEVE = -5
// NOTIFY_POLL = -1
NOTIFY_INVAL_INODE = -2
NOTIFY_INVAL_ENTRY = -3
// NOTIFY_STORE = -4
// NOTIFY_RETRIEVE = -5
NOTIFY_INVAL_DELETE = -6
NOTIFY_CODE_MAX = -6
// NOTIFY_CODE_MAX = -6
)
type FlushIn struct {
......
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