aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHereThereBeDragons <HereThereBeDragons@users.noreply.github.com>2023-06-30 14:57:06 +0200
committerGitHub <noreply@github.com>2023-06-30 13:57:06 +0100
commit51bc827df873d9ff4069b83796cd32fcb6bd659e (patch)
tree157b5c7d6d300f6006d10d7c1676a8a0300ce524 /lib
parent756726800683b22b9c4eb75bf56bcf30cb50cca1 (diff)
downloadlibfuse-51bc827df873d9ff4069b83796cd32fcb6bd659e.tar.gz
Make expire only function fail if no kernel support (#789)
Diffstat (limited to 'lib')
-rw-r--r--lib/fuse_lowlevel.c41
1 files changed, 36 insertions, 5 deletions
diff --git a/lib/fuse_lowlevel.c b/lib/fuse_lowlevel.c
index 1ce6083..4b9ee89 100644
--- a/lib/fuse_lowlevel.c
+++ b/lib/fuse_lowlevel.c
@@ -2305,9 +2305,28 @@ int fuse_lowlevel_notify_inval_inode(struct fuse_session *se, fuse_ino_t ino,
return send_notify_iov(se, FUSE_NOTIFY_INVAL_INODE, iov, 2);
}
-int fuse_lowlevel_notify_expire_entry(struct fuse_session *se, fuse_ino_t parent,
- const char *name, size_t namelen,
- enum fuse_expire_flags flags)
+/**
+ * Notify parent attributes and the dentry matching parent/name
+ *
+ * Underlying base function for fuse_lowlevel_notify_inval_entry() and
+ * fuse_lowlevel_notify_expire_entry().
+ *
+ * @warning
+ * Only checks if fuse_lowlevel_notify_inval_entry() is supported by
+ * the kernel. All other flags will fall back to
+ * fuse_lowlevel_notify_inval_entry() if not supported!
+ * DO THE PROPER CHECKS IN THE DERIVED FUNCTION!
+ *
+ * @param se the session object
+ * @param parent inode number
+ * @param name file name
+ * @param namelen strlen() of file name
+ * @param flags flags to control if the entry should be expired or invalidated
+ * @return zero for success, -errno for failure
+*/
+static int fuse_lowlevel_notify_entry(struct fuse_session *se, fuse_ino_t parent,
+ const char *name, size_t namelen,
+ enum fuse_notify_entry_flags flags)
{
struct fuse_notify_inval_entry_out outarg;
struct iovec iov[3];
@@ -2333,9 +2352,21 @@ int fuse_lowlevel_notify_expire_entry(struct fuse_session *se, fuse_ino_t parent
}
int fuse_lowlevel_notify_inval_entry(struct fuse_session *se, fuse_ino_t parent,
- const char *name, size_t namelen)
+ const char *name, size_t namelen)
+{
+ return fuse_lowlevel_notify_entry(se, parent, name, namelen, FUSE_LL_INVALIDATE);
+}
+
+int fuse_lowlevel_notify_expire_entry(struct fuse_session *se, fuse_ino_t parent,
+ const char *name, size_t namelen)
{
- return fuse_lowlevel_notify_expire_entry(se, parent, name, namelen, 0);
+ if (!se)
+ return -EINVAL;
+
+ if (!(se->conn.capable & FUSE_CAP_EXPIRE_ONLY))
+ return -ENOSYS;
+
+ return fuse_lowlevel_notify_entry(se, parent, name, namelen, FUSE_LL_EXPIRE_ONLY);
}