diff mbox series

[v3,5/9] libfs: Create the helper struct generic_ci_always_del_dentry_ops

Message ID 20240905190252.461639-6-andrealmeid@igalia.com (mailing list archive)
State New
Headers show
Series tmpfs: Add case-insensitive support for tmpfs | expand

Commit Message

André Almeida Sept. 5, 2024, 7:02 p.m. UTC
Create a helper to assign dentry_operations with the generic case
insensitive functions plus setting .d_delete as always_delete_dentry.
This is useful to in-memory casefold filesystems like tmpfs.

Signed-off-by: André Almeida <andrealmeid@igalia.com>
---
v3: New patch
---
 fs/libfs.c         | 15 +++++++++++++++
 include/linux/fs.h |  1 +
 2 files changed, 16 insertions(+)
diff mbox series

Patch

diff --git a/fs/libfs.c b/fs/libfs.c
index 99fb36b48708..58b39640b686 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -1855,6 +1855,21 @@  static const struct dentry_operations generic_ci_dentry_ops = {
 #endif
 };
 
+/*
+ * Same as generic_ci_dentry_ops, but also set d_delete. Useful for in-memory
+ * casefold filesystems.
+ */
+const struct dentry_operations generic_ci_always_del_dentry_ops = {
+	.d_hash = generic_ci_d_hash,
+	.d_compare = generic_ci_d_compare,
+#ifdef CONFIG_FS_ENCRYPTION
+	.d_revalidate = fscrypt_d_revalidate,
+#endif
+	.d_delete = always_delete_dentry,
+};
+EXPORT_SYMBOL(generic_ci_always_del_dentry_ops);
+
+
 /**
  * generic_ci_match() - Match a name (case-insensitively) with a dirent.
  * This is a filesystem helper for comparison with directory entries.
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 937142950dfe..254a1dcf987b 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3337,6 +3337,7 @@  extern int always_delete_dentry(const struct dentry *);
 extern struct inode *alloc_anon_inode(struct super_block *);
 extern int simple_nosetlease(struct file *, int, struct file_lease **, void **);
 extern const struct dentry_operations simple_dentry_operations;
+extern const struct dentry_operations generic_ci_always_del_dentry_ops;
 
 extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags);
 extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *);