Re: [PATCH 1/2] ntfs: implement fileattr_get and fileattr_set

From: Hyunchul Lee

Date: Tue Sep 01 2026 - 22:00:34 EST


Hi Baolin,

> +/*
> + * ntfs_fileattr_get - inode_operations::fileattr_get
> + * @dentry: dentry to report the flags of
> + * @fa: filled in with the flags of @dentry
> + */
> +int ntfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
> +{
> + struct inode *vi = d_inode(dentry);
> + struct ntfs_inode *ni = NTFS_I(vi);
> + u32 flags = 0;
> +
> + if (NInoCompressed(ni) || NInoWofCompressed(ni))
> + flags |= FS_COMPR_FL;
> + if (NInoEncrypted(ni))
> + flags |= FS_ENCRYPT_FL;
> + if (vi->i_flags & S_IMMUTABLE)
> + flags |= FS_IMMUTABLE_FL;
> + if (vi->i_flags & S_APPEND)
> + flags |= FS_APPEND_FL;

It would be better to set FS_CASEFOLD_FL as well.

> +int ntfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
> + struct file_kattr *fa)
> +{
> + struct inode *vi = d_inode(dentry);
> + unsigned int new_fl = 0;
> +
> + if (fileattr_has_fsx(fa))
> + return -EOPNOTSUPP;
> + if (fa->flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL))
> + return -EOPNOTSUPP;

> +
> + if (fa->flags & FS_IMMUTABLE_FL)
> + new_fl |= S_IMMUTABLE;
> + if (fa->flags & FS_APPEND_FL)
> + new_fl |= S_APPEND;
> +
> + inode_set_flags(vi, new_fl, S_IMMUTABLE | S_APPEND);
> +
> + inode_set_ctime_current(vi);
> + mark_inode_dirty(vi);
> + return 0;
> +}

Currently, these flags are not written to disk.
I think that we should store them to disk or
reject them.

--
Thanks,
Hyunchul