From: Nikolaus Rath Date: Tue, 22 Aug 2017 15:05:26 +0000 (+0200) Subject: Document and unify error codes of fuse_lowlevel_notify_* X-Git-Tag: fuse-3.2.0~22 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=84499b2eefb0c8496b9eccb8b2c0f5928fb68ce6;p=qemu-gpiodev%2Flibfuse.git Document and unify error codes of fuse_lowlevel_notify_* --- diff --git a/ChangeLog.rst b/ChangeLog.rst index 396b2d6..a564d9b 100644 --- a/ChangeLog.rst +++ b/ChangeLog.rst @@ -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. diff --git a/include/fuse_lowlevel.h b/include/fuse_lowlevel.h index cd045f3..ebfc626 100644 --- a/include/fuse_lowlevel.h +++ b/include/fuse_lowlevel.h @@ -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 diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c index ff7de82..3d78d9e 100644 --- a/lib/fuse_lowlevel.c +++ b/lib/fuse_lowlevel.c @@ -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));