Message ID | 20240911144502.115260-7-andrealmeid@igalia.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | tmpfs: Add case-insensitive support for tmpfs | expand |
André Almeida <andrealmeid@igalia.com> writes: > Export generic_ci_ dentry functions so they can be used by > case-insensitive filesystems that need something more custom than the > default one set by `struct generic_ci_dentry_ops`. > > Signed-off-by: André Almeida <andrealmeid@igalia.com> > --- > Changes from v3: > - New patch > --- > fs/libfs.c | 8 +++++--- > include/linux/fs.h | 3 +++ > 2 files changed, 8 insertions(+), 3 deletions(-) > > diff --git a/fs/libfs.c b/fs/libfs.c > index 838524314b1b..c09254ecdcdd 100644 > --- a/fs/libfs.c > +++ b/fs/libfs.c > @@ -1783,8 +1783,8 @@ bool is_empty_dir_inode(struct inode *inode) > * > * Return: 0 if names match, 1 if mismatch, or -ERRNO > */ > -static int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, > - const char *str, const struct qstr *name) > +int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, > + const char *str, const struct qstr *name) > { > const struct dentry *parent; > const struct inode *dir; > @@ -1827,6 +1827,7 @@ static int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, > > return utf8_strncasecmp(dentry->d_sb->s_encoding, name, &qstr); > } > +EXPORT_SYMBOL(generic_ci_d_compare); > > /** > * generic_ci_d_hash - generic d_hash implementation for casefolding filesystems > @@ -1835,7 +1836,7 @@ static int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, > * > * Return: 0 if hash was successful or unchanged, and -EINVAL on error > */ > -static int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str) > +int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str) > { > const struct inode *dir = READ_ONCE(dentry->d_inode); > struct super_block *sb = dentry->d_sb; > @@ -1850,6 +1851,7 @@ static int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str) > return -EINVAL; > return 0; > } > +EXPORT_SYMBOL(generic_ci_d_hash); > > static const struct dentry_operations generic_ci_dentry_ops = { > .d_hash = generic_ci_d_hash, > diff --git a/include/linux/fs.h b/include/linux/fs.h > index 937142950dfe..4cd86d36c03d 100644 > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -3386,6 +3386,9 @@ extern int generic_ci_match(const struct inode *parent, > const struct qstr *folded_name, > const u8 *de_name, u32 de_name_len); > bool generic_ci_validate_strict_name(struct inode *dir, struct qstr *name); > +int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str); > +int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, > + const char *str, const struct qstr *name); guard these with: #if IS_ENABLED(CONFIG_UNICODE) #endif > > static inline bool sb_has_encoding(const struct super_block *sb) > {
diff --git a/fs/libfs.c b/fs/libfs.c index 838524314b1b..c09254ecdcdd 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1783,8 +1783,8 @@ bool is_empty_dir_inode(struct inode *inode) * * Return: 0 if names match, 1 if mismatch, or -ERRNO */ -static int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, - const char *str, const struct qstr *name) +int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, + const char *str, const struct qstr *name) { const struct dentry *parent; const struct inode *dir; @@ -1827,6 +1827,7 @@ static int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, return utf8_strncasecmp(dentry->d_sb->s_encoding, name, &qstr); } +EXPORT_SYMBOL(generic_ci_d_compare); /** * generic_ci_d_hash - generic d_hash implementation for casefolding filesystems @@ -1835,7 +1836,7 @@ static int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, * * Return: 0 if hash was successful or unchanged, and -EINVAL on error */ -static int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str) +int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str) { const struct inode *dir = READ_ONCE(dentry->d_inode); struct super_block *sb = dentry->d_sb; @@ -1850,6 +1851,7 @@ static int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str) return -EINVAL; return 0; } +EXPORT_SYMBOL(generic_ci_d_hash); static const struct dentry_operations generic_ci_dentry_ops = { .d_hash = generic_ci_d_hash, diff --git a/include/linux/fs.h b/include/linux/fs.h index 937142950dfe..4cd86d36c03d 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3386,6 +3386,9 @@ extern int generic_ci_match(const struct inode *parent, const struct qstr *folded_name, const u8 *de_name, u32 de_name_len); bool generic_ci_validate_strict_name(struct inode *dir, struct qstr *name); +int generic_ci_d_hash(const struct dentry *dentry, struct qstr *str); +int generic_ci_d_compare(const struct dentry *dentry, unsigned int len, + const char *str, const struct qstr *name); static inline bool sb_has_encoding(const struct super_block *sb) {
Export generic_ci_ dentry functions so they can be used by case-insensitive filesystems that need something more custom than the default one set by `struct generic_ci_dentry_ops`. Signed-off-by: André Almeida <andrealmeid@igalia.com> --- Changes from v3: - New patch --- fs/libfs.c | 8 +++++--- include/linux/fs.h | 3 +++ 2 files changed, 8 insertions(+), 3 deletions(-)