On Tue 20-01-26 09:24:24, Chuck Lever wrote:
> From: Chuck Lever <[email protected]>
> 
> Enable upper layers such as NFSD to retrieve case sensitivity
> information from file systems by adding FS_XFLAG_CASEFOLD and
> FS_XFLAG_CASENONPRESERVING flags.
> 
> Filesystems report case-insensitive or case-nonpreserving behavior
> by setting these flags directly in fa->fsx_xflags. The default
> (flags unset) indicates POSIX semantics: case-sensitive and
> case-preserving. These flags are read-only; userspace cannot set
> them via ioctl.
> 
> Relocate struct file_kattr initialization from fileattr_fill_xflags()
> and fileattr_fill_flags() to vfs_fileattr_get() and the ioctl/syscall
> call sites. This allows filesystem ->fileattr_get() callbacks to set
> flags directly in fa->fsx_xflags before invoking the fill functions,
> which previously would have zeroed those values. Callers that bypass
> vfs_fileattr_get() must now zero-initialize the struct themselves.
> 
> Case sensitivity information is exported to userspace via the
> fa_xflags field in the FS_IOC_FSGETXATTR ioctl and file_getattr()
> system call.
> 
> Signed-off-by: Chuck Lever <[email protected]>
> ---
>  fs/file_attr.c           | 14 ++++++--------
>  fs/xfs/xfs_ioctl.c       |  2 +-
>  include/linux/fileattr.h |  3 ++-
>  include/uapi/linux/fs.h  |  2 ++
>  4 files changed, 11 insertions(+), 10 deletions(-)
> 
> diff --git a/fs/file_attr.c b/fs/file_attr.c
> index 13cdb31a3e94..2700200c5b9c 100644
> --- a/fs/file_attr.c
> +++ b/fs/file_attr.c
> @@ -15,12 +15,10 @@
>   * @fa:              fileattr pointer
>   * @xflags:  FS_XFLAG_* flags
>   *
> - * Set ->fsx_xflags, ->fsx_valid and ->flags (translated xflags).  All
> - * other fields are zeroed.
> + * Set ->fsx_xflags, ->fsx_valid and ->flags (translated xflags).
>   */
>  void fileattr_fill_xflags(struct file_kattr *fa, u32 xflags)
>  {
> -     memset(fa, 0, sizeof(*fa));
>       fa->fsx_valid = true;
>       fa->fsx_xflags = xflags;
>       if (fa->fsx_xflags & FS_XFLAG_IMMUTABLE)
> @@ -46,11 +44,9 @@ EXPORT_SYMBOL(fileattr_fill_xflags);
>   * @flags:   FS_*_FL flags
>   *
>   * Set ->flags, ->flags_valid and ->fsx_xflags (translated flags).
> - * All other fields are zeroed.
>   */
>  void fileattr_fill_flags(struct file_kattr *fa, u32 flags)
>  {
> -     memset(fa, 0, sizeof(*fa));
>       fa->flags_valid = true;
>       fa->flags = flags;
>       if (fa->flags & FS_SYNC_FL)
> @@ -84,6 +80,8 @@ int vfs_fileattr_get(struct dentry *dentry, struct 
> file_kattr *fa)
>       struct inode *inode = d_inode(dentry);
>       int error;
>  
> +     memset(fa, 0, sizeof(*fa));
> +

Umm, but ioctl_getflags() sets fa->flags_valid as a hint for
->fileattr_get() handler and this will now zero-out that hint. So I agree
that zeroing fa in fileattr_fill_{,x}flags() is a bit unexpected and moving
it is desirable but it needs a bit more careful surgery.

                                                                Honza
-- 
Jan Kara <[email protected]>
SUSE Labs, CR


_______________________________________________
Linux-f2fs-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

Reply via email to