Re: [PATCH 1/2] ntfs: implement fileattr_get and fileattr_set
From: liubaolin
Date: Wed Sep 02 2026 - 03:31:13 EST
在 2026/9/2 10:00, Hyunchul Lee 写道:
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.
Hi Hyunchul,
I will add FS_CASEFOLD_FL.
You are right about persistence. Namjae also pointed out that inode
reclaim can drop these flags before an unmount. I will look into storing
them on disk.
Thanks for the review.
Thanks,
Baolin