From: Chuck Lever Replace the hard-coded MSDOS_SUPER_MAGIC check in nfsd3_proc_pathconf() with a real check of the export's case behavior settings. Filesystems that implement ->fileattr_get can then report their case sensitivity behavior to NFSv3 clients. For filesystems without ->fileattr_get, the default POSIX behavior (case-sensitive, case-preserving) is reported to NFSv3 clients. Signed-off-by: Chuck Lever --- fs/nfsd/nfs3proc.c | 18 ++++++++++-------- fs/nfsd/vfs.c | 25 +++++++++++++++++++++++++ fs/nfsd/vfs.h | 2 ++ 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/fs/nfsd/nfs3proc.c b/fs/nfsd/nfs3proc.c index b6d03e1ef5f7..c8c76819cfbc 100644 --- a/fs/nfsd/nfs3proc.c +++ b/fs/nfsd/nfs3proc.c @@ -721,17 +721,19 @@ nfsd3_proc_pathconf(struct svc_rqst *rqstp) if (resp->status == nfs_ok) { struct super_block *sb = argp->fh.fh_dentry->d_sb; + bool case_insensitive, case_preserving; - /* Note that we don't care for remote fs's here */ - switch (sb->s_magic) { - case EXT2_SUPER_MAGIC: + if (sb->s_magic == EXT2_SUPER_MAGIC) { resp->p_link_max = EXT2_LINK_MAX; resp->p_name_max = EXT2_NAME_LEN; - break; - case MSDOS_SUPER_MAGIC: - resp->p_case_insensitive = 1; - resp->p_case_preserving = 0; - break; + } + + resp->status = nfsd_get_case_info(&argp->fh, + &case_insensitive, + &case_preserving); + if (resp->status == nfs_ok) { + resp->p_case_insensitive = case_insensitive; + resp->p_case_preserving = case_preserving; } } diff --git a/fs/nfsd/vfs.c b/fs/nfsd/vfs.c index 9cb20d4aeab1..157ddf405a5d 100644 --- a/fs/nfsd/vfs.c +++ b/fs/nfsd/vfs.c @@ -32,6 +32,7 @@ #include #include #include +#include #include "xdr3.h" @@ -2679,3 +2680,27 @@ nfsd_permission(struct svc_cred *cred, struct svc_export *exp, return err? nfserrno(err) : 0; } + +/** + * nfsd_get_case_info - get case sensitivity info for a file handle + * @fhp: file handle that has already been verified + * @case_insensitive: output, true if the filesystem is case-insensitive + * @case_preserving: output, true if the filesystem preserves case + * + * Returns nfs_ok on success, or an nfserr on failure. + */ +__be32 +nfsd_get_case_info(struct svc_fh *fhp, bool *case_insensitive, + bool *case_preserving) +{ + u32 case_info; + int err; + + err = vfs_get_case_info(fhp->fh_dentry, &case_info); + if (err) + return nfserrno(err); + + *case_insensitive = (case_info & FILEATTR_CASEFOLD_TYPE) != 0; + *case_preserving = (case_info & FILEATTR_CASE_PRESERVING) != 0; + return nfs_ok; +} diff --git a/fs/nfsd/vfs.h b/fs/nfsd/vfs.h index 0c0292611c6d..a80177744325 100644 --- a/fs/nfsd/vfs.h +++ b/fs/nfsd/vfs.h @@ -154,6 +154,8 @@ __be32 nfsd_readdir(struct svc_rqst *, struct svc_fh *, loff_t *, struct readdir_cd *, nfsd_filldir_t); __be32 nfsd_statfs(struct svc_rqst *, struct svc_fh *, struct kstatfs *, int access); +__be32 nfsd_get_case_info(struct svc_fh *fhp, bool *case_insensitive, + bool *case_preserving); __be32 nfsd_permission(struct svc_cred *cred, struct svc_export *exp, struct dentry *dentry, int acc); -- 2.52.0