Document and unify error codes of fuse_lowlevel_notify_*
authorNikolaus Rath <Nikolaus@rath.org>
Tue, 22 Aug 2017 15:05:26 +0000 (17:05 +0200)
committerNikolaus Rath <Nikolaus@rath.org>
Tue, 22 Aug 2017 15:05:26 +0000 (17:05 +0200)
ChangeLog.rst
include/fuse_lowlevel.h
lib/fuse_lowlevel.c

index 396b2d6909ab5739c53e0fb636b1b7885cddfa79..a564d9bd76be8febfbffdd5e923720f4cc632de5 100644 (file)
@@ -1,6 +1,12 @@
 Unreleased Changes
 ==================
 
+* Improved documentation of `fuse_lowlevel_notify_*` functions.
+
+* `fuse_lowlevel_notify_inval_inode()` and
+  `fuse_lowlevel_notify_inval_entry()` now return -ENOSYS instead of
+  an undefined error if the function is not supported by the kernel.
+  
 * Documented the special meaning of the *zero* offset for the
   fuse_fill_dir_t function.
   
index cd045f32f58d3eaa63655c7ed855174d5a8ed3ee..ebfc626d2b4da4df254cca8ddb06e8c2743207ec 100644 (file)
@@ -1525,7 +1525,11 @@ int fuse_reply_poll(fuse_req_t req, unsigned revents);
 int fuse_lowlevel_notify_poll(struct fuse_pollhandle *ph);
 
 /**
- * Notify to invalidate cache for an inode
+ * Notify to invalidate cache for an inode.
+ *
+ * Added in FUSE protocol version 7.12. If the kernel does not support
+ * this (or a newer) version, the function will return -ENOSYS and do
+ * nothing.
  *
  * @param se the session object
  * @param ino the inode number
@@ -1541,9 +1545,13 @@ int fuse_lowlevel_notify_inval_inode(struct fuse_session *se, fuse_ino_t ino,
  * Notify to invalidate parent attributes and the dentry matching
  * parent/name
  *
- * To avoid a deadlock don't call this function from a filesystem operation and
- * don't call it with a lock held that can also be held by a filesystem
- * operation.
+ * To avoid a deadlock don't call this function from a filesystem
+ * operation and don't call it with a lock held that can also be held
+ * by a filesystem operation.
+ *
+ * Added in FUSE protocol version 7.12. If the kernel does not support
+ * this (or a newer) version, the function will return -ENOSYS and do
+ * nothing.
  *
  * @param se the session object
  * @param parent inode number
@@ -1555,18 +1563,21 @@ int fuse_lowlevel_notify_inval_entry(struct fuse_session *se, fuse_ino_t parent,
                                     const char *name, size_t namelen);
 
 /**
- * As of kernel 4.8, this function behaves like
- * fuse_lowlevel_notify_inval_entry() with the following additional
- * effect:
+ * This function behaves like fuse_lowlevel_notify_inval_entry() with
+ * the following additional effect (at least as of Linux kernel 4.8):
  *
  * If the provided *child* inode matches the inode that is currently
  * associated with the cached dentry, and if there are any inotify
  * watches registered for the dentry, then the watchers are informed
  * that the dentry has been deleted.
  *
- * To avoid a deadlock don't call this function from a filesystem operation and
- * don't call it with a lock held that can also be held by a filesystem
- * operation.
+ * To avoid a deadlock don't call this function from a filesystem
+ * operation and don't call it with a lock held that can also be held
+ * by a filesystem operation.
+ *
+ * Added in FUSE protocol version 7.18. If the kernel does not support
+ * this (or a newer) version, the function will return -ENOSYS and do
+ * nothing.
  *
  * @param se the session object
  * @param parent inode number
@@ -1593,6 +1604,10 @@ int fuse_lowlevel_notify_delete(struct fuse_session *se,
  * If this function returns an error, then the store wasn't fully
  * completed, but it may have been partially completed.
  *
+ * Added in FUSE protocol version 7.15. If the kernel does not support
+ * this (or a newer) version, the function will return -ENOSYS and do
+ * nothing.
+ *
  * @param se the session object
  * @param ino the inode number
  * @param offset the starting offset into the file to store to
@@ -1611,8 +1626,8 @@ int fuse_lowlevel_notify_store(struct fuse_session *se, fuse_ino_t ino,
  * the returned data.
  *
  * Only present pages are returned in the retrieve reply.  Retrieving
- * stops when it finds a non-present page and only data prior to that is
- * returned.
+ * stops when it finds a non-present page and only data prior to that
+ * is returned.
  *
  * If this function returns an error, then the retrieve will not be
  * completed and no reply will be sent.
@@ -1621,6 +1636,10 @@ int fuse_lowlevel_notify_store(struct fuse_session *se, fuse_ino_t ino,
  * buffer.  For dirty pages the write() method will be called
  * regardless of having been retrieved previously.
  *
+ * Added in FUSE protocol version 7.15. If the kernel does not support
+ * this (or a newer) version, the function will return -ENOSYS and do
+ * nothing.
+ *
  * @param se the session object
  * @param ino the inode number
  * @param size the number of bytes to retrieve
index ff7de82c2dabc73f34a30b22edd9b2e3f585b1d0..3d78d9ec7ec033281bdea451c8d76cd8464d0ea1 100644 (file)
@@ -2123,6 +2123,9 @@ int fuse_lowlevel_notify_inval_inode(struct fuse_session *se, fuse_ino_t ino,
        if (!se)
                return -EINVAL;
 
+       if (se->conn.proto_major < 6 || se->conn.proto_minor < 12)
+               return -ENOSYS;
+       
        outarg.ino = ino;
        outarg.off = off;
        outarg.len = len;
@@ -2141,6 +2144,9 @@ int fuse_lowlevel_notify_inval_entry(struct fuse_session *se, fuse_ino_t parent,
 
        if (!se)
                return -EINVAL;
+       
+       if (se->conn.proto_major < 6 || se->conn.proto_minor < 12)
+               return -ENOSYS;
 
        outarg.parent = parent;
        outarg.namelen = namelen;
@@ -2164,7 +2170,7 @@ int fuse_lowlevel_notify_delete(struct fuse_session *se,
        if (!se)
                return -EINVAL;
 
-       if (se->conn.proto_minor < 18)
+       if (se->conn.proto_major < 6 || se->conn.proto_minor < 18)
                return -ENOSYS;
 
        outarg.parent = parent;
@@ -2193,7 +2199,7 @@ int fuse_lowlevel_notify_store(struct fuse_session *se, fuse_ino_t ino,
        if (!se)
                return -EINVAL;
 
-       if (se->conn.proto_minor < 15)
+       if (se->conn.proto_major < 6 || se->conn.proto_minor < 15)
                return -ENOSYS;
 
        out.unique = 0;
@@ -2271,7 +2277,7 @@ int fuse_lowlevel_notify_retrieve(struct fuse_session *se, fuse_ino_t ino,
        if (!se)
                return -EINVAL;
 
-       if (se->conn.proto_minor < 15)
+       if (se->conn.proto_major < 6 || se->conn.proto_minor < 15)
                return -ENOSYS;
 
        rreq = malloc(sizeof(*rreq));