mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] ntfs: wire up the fileattr API
@ 2026-09-01  9:15 Baolin Liu
  2026-09-01  9:15 ` [PATCH 1/2] ntfs: implement fileattr_get and fileattr_set Baolin Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Baolin Liu @ 2026-09-01  9:15 UTC (permalink / raw)
  To: linkinjeon, hyc.lee; +Cc: ntfs, linux-kernel, liubaolin12138, Baolin Liu

From: Baolin Liu <liubaolin@kylinos.cn>

This series implements fileattr_get and fileattr_set for ntfs so that
lsattr(1) and chattr(1) work on ntfs.

Patch 1 wires up the fileattr inode operations and implements support
for FS_IMMUTABLE_FL and FS_APPEND_FL. These flags map to inode->i_flags
(S_IMMUTABLE, S_APPEND), so the VFS enforces them. fileattr_get also
reports the compressed and encrypted state, which the driver already
exposes through STATX_ATTR_* in ntfs_getattr().

Patch 2 adds FS_NODUMP_FL support, which dump(8) and other backup tools
use to mark files to skip. The flag is stored in a new ntfs_inode field
and reported through both fileattr_get (for lsattr) and ntfs_getattr()
(as STATX_ATTR_NODUMP, for statx), so the two interfaces stay consistent.

All three accepted flags (immutable, append-only, nodump) are kept in
memory and do not survive a remount, matching ntfs3 behavior.

Tested in QEMU on an NTFS volume, both with chattr(1)/lsattr(1) and with
a test binary issuing the ioctls directly:
 - chattr +i/+a/+d each set the flag and lsattr reads it back
 - appending to a +i file fails with EPERM
 - statx(2) reports STATX_ATTR_NODUMP once nodump is set, and stops
   reporting it once cleared
 - FS_COMPR_FL is rejected with EOPNOTSUPP
 - lsattr reports 'c' on a compressed file
 - chattr -i/-a/-d clear the flags, and a flag set before unmounting is
   gone after dropping caches and mounting again

Baolin Liu (2):
  ntfs: implement fileattr_get and fileattr_set
  ntfs: support the nodump flag

 fs/ntfs/file.c  | 65 ++++++++++++++++++++++++++++++++++++++++++++++++-
 fs/ntfs/inode.c |  1 +
 fs/ntfs/inode.h |  1 +
 fs/ntfs/ntfs.h  |  4 +++
 4 files changed, 70 insertions(+), 1 deletion(-)

-- 
2.51.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/2] ntfs: implement fileattr_get and fileattr_set
  2026-09-01  9:15 [PATCH 0/2] ntfs: wire up the fileattr API Baolin Liu
@ 2026-09-01  9:15 ` Baolin Liu
  2026-09-02  1:22   ` Namjae Jeon
  2026-09-02  2:00   ` Hyunchul Lee
  2026-09-01  9:15 ` [PATCH 2/2] ntfs: support the nodump flag Baolin Liu
  2026-09-02  1:44 ` [PATCH 0/2] ntfs: wire up the fileattr API Namjae Jeon
  2 siblings, 2 replies; 11+ messages in thread
From: Baolin Liu @ 2026-09-01  9:15 UTC (permalink / raw)
  To: linkinjeon, hyc.lee; +Cc: ntfs, linux-kernel, liubaolin12138, Baolin Liu

From: Baolin Liu <liubaolin@kylinos.cn>

Wire up the fileattr inode operations so that lsattr(1) and chattr(1)
work on ntfs.

fileattr_get reports the compressed and encrypted state of the attribute
and the immutable and append-only flags, the same states ntfs_getattr()
already reports through STATX_ATTR_*.

fileattr_set accepts only FS_IMMUTABLE_FL and FS_APPEND_FL. Compression
and encryption are rejected because changing them would require
rewriting the attribute data. Both accepted flags go to inode->i_flags,
so the VFS enforces them.

Neither flag has an on-disk representation of its own, so a value set
through fileattr_set only lives for the lifetime of the mount. Note also
that S_IMMUTABLE is re-derived on every mount, from FILE_ATTR_SYSTEM when
mounted with sys_immutable and unconditionally for system files, so
clearing it on such a file does not survive a remount either.

Signed-off-by: Baolin Liu <liubaolin@kylinos.cn>
---
 fs/ntfs/file.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/ntfs/ntfs.h |  4 ++++
 2 files changed, 60 insertions(+)

diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index 1969e4f444f7..b7a0fb2d8229 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -15,6 +15,7 @@
 #include <linux/posix_acl_xattr.h>
 #include <linux/compat.h>
 #include <linux/falloc.h>
+#include <linux/fileattr.h>
 
 #include "lcnalloc.h"
 #include "ntfs.h"
@@ -135,6 +136,59 @@ static int ntfs_file_release(struct inode *vi, struct file *filp)
 	return 0;
 }
 
+/*
+ * 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;
+
+	fileattr_fill_flags(fa, flags);
+	return 0;
+}
+
+/*
+ * ntfs_fileattr_set - inode_operations::fileattr_set
+ * @idmap:	idmap of the mount @dentry was found from
+ * @dentry:	dentry to set the flags of
+ * @fa:		flags to set
+ */
+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;
+}
+
 /*
  * ntfs_file_fsync - sync a file to disk
  * @filp:	file to be synced
@@ -1215,6 +1269,8 @@ const struct file_operations ntfs_file_ops = {
 const struct inode_operations ntfs_file_inode_ops = {
 	.setattr	= ntfs_setattr,
 	.getattr	= ntfs_getattr,
+	.fileattr_get	= ntfs_fileattr_get,
+	.fileattr_set	= ntfs_fileattr_set,
 	.listxattr	= ntfs_listxattr,
 	.get_acl	= ntfs_get_acl,
 	.set_acl	= ntfs_set_acl,
diff --git a/fs/ntfs/ntfs.h b/fs/ntfs/ntfs.h
index 45f77848a9cf..6a8d5c1aeedc 100644
--- a/fs/ntfs/ntfs.h
+++ b/fs/ntfs/ntfs.h
@@ -183,6 +183,10 @@ extern const struct inode_operations ntfs_dir_inode_ops;
 extern const struct  file_operations ntfs_empty_file_ops;
 extern const struct inode_operations ntfs_empty_inode_ops;
 
+extern int ntfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa);
+extern int ntfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
+			     struct file_kattr *fa);
+
 extern const struct export_operations ntfs_export_ops;
 
 /*
-- 
2.51.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 2/2] ntfs: support the nodump flag
  2026-09-01  9:15 [PATCH 0/2] ntfs: wire up the fileattr API Baolin Liu
  2026-09-01  9:15 ` [PATCH 1/2] ntfs: implement fileattr_get and fileattr_set Baolin Liu
@ 2026-09-01  9:15 ` Baolin Liu
  2026-09-02  1:44 ` [PATCH 0/2] ntfs: wire up the fileattr API Namjae Jeon
  2 siblings, 0 replies; 11+ messages in thread
From: Baolin Liu @ 2026-09-01  9:15 UTC (permalink / raw)
  To: linkinjeon, hyc.lee; +Cc: ntfs, linux-kernel, liubaolin12138, Baolin Liu

From: Baolin Liu <liubaolin@kylinos.cn>

Add FS_NODUMP_FL to the flags fileattr_set accepts, so that chattr +d
works, and report it back from both fileattr_get and ntfs_getattr(), the
latter as STATX_ATTR_NODUMP.

The flag is advisory: it only tells backup tools such as dump(8) to skip
the file, so the driver merely has to remember it. NTFS has no on-disk
attribute for it, so it is kept in a new ntfs_inode field and lives for
the lifetime of the mount. ntfs3 does the same.

Signed-off-by: Baolin Liu <liubaolin@kylinos.cn>
---
 fs/ntfs/file.c  | 11 +++++++++--
 fs/ntfs/inode.c |  1 +
 fs/ntfs/inode.h |  1 +
 3 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index b7a0fb2d8229..2ff1d2c74343 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -155,6 +155,8 @@ int ntfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa)
 		flags |= FS_IMMUTABLE_FL;
 	if (vi->i_flags & S_APPEND)
 		flags |= FS_APPEND_FL;
+	if (ni->nodump)
+		flags |= FS_NODUMP_FL;
 
 	fileattr_fill_flags(fa, flags);
 	return 0;
@@ -174,7 +176,7 @@ int ntfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
 
 	if (fileattr_has_fsx(fa))
 		return -EOPNOTSUPP;
-	if (fa->flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL))
+	if (fa->flags & ~(FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL))
 		return -EOPNOTSUPP;
 
 	if (fa->flags & FS_IMMUTABLE_FL)
@@ -183,6 +185,7 @@ int ntfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
 		new_fl |= S_APPEND;
 
 	inode_set_flags(vi, new_fl, S_IMMUTABLE | S_APPEND);
+	NTFS_I(vi)->nodump = fa->flags & FS_NODUMP_FL;
 
 	inode_set_ctime_current(vi);
 	mark_inode_dirty(vi);
@@ -445,8 +448,12 @@ int ntfs_getattr(struct mnt_idmap *idmap, const struct path *path,
 	if (inode->i_flags & S_APPEND)
 		stat->attributes |= STATX_ATTR_APPEND;
 
+	if (ni->nodump)
+		stat->attributes |= STATX_ATTR_NODUMP;
+
 	stat->attributes_mask |= STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED |
-				 STATX_ATTR_IMMUTABLE | STATX_ATTR_APPEND;
+				 STATX_ATTR_IMMUTABLE | STATX_ATTR_APPEND |
+				 STATX_ATTR_NODUMP;
 
 	/*
 	 * If it's a compressed or encrypted file, NTFS currently
diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c
index 5aedc045f65a..5520df707162 100644
--- a/fs/ntfs/inode.c
+++ b/fs/ntfs/inode.c
@@ -492,6 +492,7 @@ void __ntfs_init_inode(struct super_block *sb, struct ntfs_inode *ni)
 	ni->reparse_tag = 0;
 	ni->reparse_flags = 0;
 	ni->target = NULL;
+	ni->nodump = 0;
 	ni->i_dealloc_clusters = 0;
 }
 
diff --git a/fs/ntfs/inode.h b/fs/ntfs/inode.h
index ff61bd402df0..bc24dcf0b49f 100644
--- a/fs/ntfs/inode.h
+++ b/fs/ntfs/inode.h
@@ -145,6 +145,7 @@ struct ntfs_inode {
 	__le32 reparse_tag;
 	__le32 reparse_flags;
 	char *target;
+	bool nodump;
 };
 
 /*
-- 
2.51.0


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] ntfs: implement fileattr_get and fileattr_set
  2026-09-01  9:15 ` [PATCH 1/2] ntfs: implement fileattr_get and fileattr_set Baolin Liu
@ 2026-09-02  1:22   ` Namjae Jeon
  2026-09-02  6:44     ` liubaolin
  2026-09-02  2:00   ` Hyunchul Lee
  1 sibling, 1 reply; 11+ messages in thread
From: Namjae Jeon @ 2026-09-02  1:22 UTC (permalink / raw)
  To: Baolin Liu; +Cc: hyc.lee, ntfs, linux-kernel, Baolin Liu

On Tue, Sep 1, 2026 at 6:15 PM Baolin Liu <liubaolin12138@163.com> wrote:
>
> From: Baolin Liu <liubaolin@kylinos.cn>
>
> Wire up the fileattr inode operations so that lsattr(1) and chattr(1)
> work on ntfs.
>
> fileattr_get reports the compressed and encrypted state of the attribute
> and the immutable and append-only flags, the same states ntfs_getattr()
> already reports through STATX_ATTR_*.
>
> fileattr_set accepts only FS_IMMUTABLE_FL and FS_APPEND_FL. Compression
> and encryption are rejected because changing them would require
> rewriting the attribute data. Both accepted flags go to inode->i_flags,
> so the VFS enforces them.
>
> Neither flag has an on-disk representation of its own, so a value set
> through fileattr_set only lives for the lifetime of the mount. Note also
> that S_IMMUTABLE is re-derived on every mount, from FILE_ATTR_SYSTEM when
> mounted with sys_immutable and unconditionally for system files, so
> clearing it on such a file does not survive a remount either.
NTFS forces S_IMMUTABLE on system metadata files such as $MFT, but
this patch allows userspace to clear that protection. The patch should
reject clearing immutable for these files and for files made immutable
by the sys_immutable mount option.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/2] ntfs: wire up the fileattr API
  2026-09-01  9:15 [PATCH 0/2] ntfs: wire up the fileattr API Baolin Liu
  2026-09-01  9:15 ` [PATCH 1/2] ntfs: implement fileattr_get and fileattr_set Baolin Liu
  2026-09-01  9:15 ` [PATCH 2/2] ntfs: support the nodump flag Baolin Liu
@ 2026-09-02  1:44 ` Namjae Jeon
  2026-09-02  7:26   ` liubaolin
  2026-09-08  8:31   ` liubaolin
  2 siblings, 2 replies; 11+ messages in thread
From: Namjae Jeon @ 2026-09-02  1:44 UTC (permalink / raw)
  To: Baolin Liu; +Cc: hyc.lee, ntfs, linux-kernel, Baolin Liu

On Tue, Sep 1, 2026 at 6:15 PM Baolin Liu <liubaolin12138@163.com> wrote:
>
> From: Baolin Liu <liubaolin@kylinos.cn>
>
> This series implements fileattr_get and fileattr_set for ntfs so that
> lsattr(1) and chattr(1) work on ntfs.
>
> Patch 1 wires up the fileattr inode operations and implements support
> for FS_IMMUTABLE_FL and FS_APPEND_FL. These flags map to inode->i_flags
> (S_IMMUTABLE, S_APPEND), so the VFS enforces them. fileattr_get also
> reports the compressed and encrypted state, which the driver already
> exposes through STATX_ATTR_* in ntfs_getattr().
>
> Patch 2 adds FS_NODUMP_FL support, which dump(8) and other backup tools
> use to mark files to skip. The flag is stored in a new ntfs_inode field
> and reported through both fileattr_get (for lsattr) and ntfs_getattr()
> (as STATX_ATTR_NODUMP, for statx), so the two interfaces stay consistent.
>
> All three accepted flags (immutable, append-only, nodump) are kept in
> memory and do not survive a remount, matching ntfs3 behavior.
This patch-set does not persist these flags on disk. So, the settings
survive only while the corresponding inode remains cached. inode
reclaim caused by memory pressure or drop_caches can discard them
before unmount. Could you find a way to persist immutable, append, and
nodump in metadata without causing compatibility issues?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] ntfs: implement fileattr_get and fileattr_set
  2026-09-01  9:15 ` [PATCH 1/2] ntfs: implement fileattr_get and fileattr_set Baolin Liu
  2026-09-02  1:22   ` Namjae Jeon
@ 2026-09-02  2:00   ` Hyunchul Lee
  2026-09-02  7:25     ` liubaolin
  1 sibling, 1 reply; 11+ messages in thread
From: Hyunchul Lee @ 2026-09-02  2:00 UTC (permalink / raw)
  To: Baolin Liu; +Cc: linkinjeon, ntfs, linux-kernel, Baolin Liu

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

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] ntfs: implement fileattr_get and fileattr_set
  2026-09-02  1:22   ` Namjae Jeon
@ 2026-09-02  6:44     ` liubaolin
  0 siblings, 0 replies; 11+ messages in thread
From: liubaolin @ 2026-09-02  6:44 UTC (permalink / raw)
  To: Namjae Jeon; +Cc: hyc.lee, ntfs, linux-kernel, Baolin Liu



在 2026/9/2 09:22, Namjae Jeon 写道:
> On Tue, Sep 1, 2026 at 6:15 PM Baolin Liu <liubaolin12138@163.com> wrote:
>>
>> From: Baolin Liu <liubaolin@kylinos.cn>
>>
>> Wire up the fileattr inode operations so that lsattr(1) and chattr(1)
>> work on ntfs.
>>
>> fileattr_get reports the compressed and encrypted state of the attribute
>> and the immutable and append-only flags, the same states ntfs_getattr()
>> already reports through STATX_ATTR_*.
>>
>> fileattr_set accepts only FS_IMMUTABLE_FL and FS_APPEND_FL. Compression
>> and encryption are rejected because changing them would require
>> rewriting the attribute data. Both accepted flags go to inode->i_flags,
>> so the VFS enforces them.
>>
>> Neither flag has an on-disk representation of its own, so a value set
>> through fileattr_set only lives for the lifetime of the mount. Note also
>> that S_IMMUTABLE is re-derived on every mount, from FILE_ATTR_SYSTEM when
>> mounted with sys_immutable and unconditionally for system files, so
>> clearing it on such a file does not survive a remount either.
> NTFS forces S_IMMUTABLE on system metadata files such as $MFT, but
> this patch allows userspace to clear that protection. The patch should
> reject clearing immutable for these files and for files made immutable
> by the sys_immutable mount option.

Hi Namjae,

   You are right, that is a hole. The driver forces S_IMMUTABLE on those
   files for a reason and userspace should not be able to clear it.

   I will add the check and send a v2.

   Thanks for the review.

Thanks,
Baolin


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/2] ntfs: implement fileattr_get and fileattr_set
  2026-09-02  2:00   ` Hyunchul Lee
@ 2026-09-02  7:25     ` liubaolin
  0 siblings, 0 replies; 11+ messages in thread
From: liubaolin @ 2026-09-02  7:25 UTC (permalink / raw)
  To: Hyunchul Lee; +Cc: linkinjeon, ntfs, linux-kernel, Baolin Liu



在 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


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/2] ntfs: wire up the fileattr API
  2026-09-02  1:44 ` [PATCH 0/2] ntfs: wire up the fileattr API Namjae Jeon
@ 2026-09-02  7:26   ` liubaolin
  2026-09-08  8:31   ` liubaolin
  1 sibling, 0 replies; 11+ messages in thread
From: liubaolin @ 2026-09-02  7:26 UTC (permalink / raw)
  To: Namjae Jeon; +Cc: hyc.lee, ntfs, linux-kernel, Baolin Liu



在 2026/9/2 09:44, Namjae Jeon 写道:
> On Tue, Sep 1, 2026 at 6:15 PM Baolin Liu <liubaolin12138@163.com> wrote:
>>
>> From: Baolin Liu <liubaolin@kylinos.cn>
>>
>> This series implements fileattr_get and fileattr_set for ntfs so that
>> lsattr(1) and chattr(1) work on ntfs.
>>
>> Patch 1 wires up the fileattr inode operations and implements support
>> for FS_IMMUTABLE_FL and FS_APPEND_FL. These flags map to inode->i_flags
>> (S_IMMUTABLE, S_APPEND), so the VFS enforces them. fileattr_get also
>> reports the compressed and encrypted state, which the driver already
>> exposes through STATX_ATTR_* in ntfs_getattr().
>>
>> Patch 2 adds FS_NODUMP_FL support, which dump(8) and other backup tools
>> use to mark files to skip. The flag is stored in a new ntfs_inode field
>> and reported through both fileattr_get (for lsattr) and ntfs_getattr()
>> (as STATX_ATTR_NODUMP, for statx), so the two interfaces stay consistent.
>>
>> All three accepted flags (immutable, append-only, nodump) are kept in
>> memory and do not survive a remount, matching ntfs3 behavior.
> This patch-set does not persist these flags on disk. So, the settings
> survive only while the corresponding inode remains cached. inode
> reclaim caused by memory pressure or drop_caches can discard them
> before unmount. Could you find a way to persist immutable, append, and
> nodump in metadata without causing compatibility issues?

Hi Namjae,

   You are right about inode reclaim, I had not considered that - not just
   a remount, memory pressure or drop_caches can silently drop these flags
   as well.

   I will look into how to persist them without breaking compatibility.


   Thanks for the review.

Thanks,
Baolin


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/2] ntfs: wire up the fileattr API
  2026-09-02  1:44 ` [PATCH 0/2] ntfs: wire up the fileattr API Namjae Jeon
  2026-09-02  7:26   ` liubaolin
@ 2026-09-08  8:31   ` liubaolin
  2026-09-09  4:48     ` Namjae Jeon
  1 sibling, 1 reply; 11+ messages in thread
From: liubaolin @ 2026-09-08  8:31 UTC (permalink / raw)
  To: Namjae Jeon, Hyunchul Lee; +Cc: ntfs, linux-kernel, Baolin Liu



在 2026/9/2 09:44, Namjae Jeon 写道:
> On Tue, Sep 1, 2026 at 6:15 PM Baolin Liu <liubaolin12138@163.com> wrote:
>>
>> From: Baolin Liu <liubaolin@kylinos.cn>
>>
>> This series implements fileattr_get and fileattr_set for ntfs so that
>> lsattr(1) and chattr(1) work on ntfs.
>>
>> Patch 1 wires up the fileattr inode operations and implements support
>> for FS_IMMUTABLE_FL and FS_APPEND_FL. These flags map to inode->i_flags
>> (S_IMMUTABLE, S_APPEND), so the VFS enforces them. fileattr_get also
>> reports the compressed and encrypted state, which the driver already
>> exposes through STATX_ATTR_* in ntfs_getattr().
>>
>> Patch 2 adds FS_NODUMP_FL support, which dump(8) and other backup tools
>> use to mark files to skip. The flag is stored in a new ntfs_inode field
>> and reported through both fileattr_get (for lsattr) and ntfs_getattr()
>> (as STATX_ATTR_NODUMP, for statx), so the two interfaces stay consistent.
>>
>> All three accepted flags (immutable, append-only, nodump) are kept in
>> memory and do not survive a remount, matching ntfs3 behavior.
> This patch-set does not persist these flags on disk. So, the settings
> survive only while the corresponding inode remains cached. inode
> reclaim caused by memory pressure or drop_caches can discard them
> before unmount. Could you find a way to persist immutable, append, and
> nodump in metadata without causing compatibility issues?

Hi Namjae,Hyunchul,

   Regarding the persistence concern, I propose storing the 
Linux-specific flags in one private EA entry in the file's existing NTFS 
$EA attribute:

     EA name:  $LXFLAGS
     EA value: a 32-bit little-endian bitmask

     bit 0: immutable
     bit 1: append-only
     bit 2: nodump

   The three flags are boolean states, so one bit is sufficient for each 
of them. Using one 32-bit value also leaves room for future expansion.

   This would add an EA entry named $LXFLAGS to the existing $EA 
attribute;it would not introduce a new NTFS attribute type. The driver 
already uses the standard $EA/$EA_INFORMATION mechanism for $LXUID, 
$LXGID, $LXMOD and $LXDEV, so this approach would reuse the existing 
on-disk mechanism.

   The inode loading path would restore the flags from $LXFLAGS, and 
fileattr_set() would update the entry. The entry would be removed when 
all three flags are cleared. This would allow the flags to survive inode 
reclaim, drop_caches, unmount/remount, and reboot.

   This approach would not require changes to mkntfs or to the NTFS 
filesystem format.

   Would this approach be acceptable? If so, I will implement it and 
submit a new revision as soon as possible.

Thanks,
Baolin.


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/2] ntfs: wire up the fileattr API
  2026-09-08  8:31   ` liubaolin
@ 2026-09-09  4:48     ` Namjae Jeon
  0 siblings, 0 replies; 11+ messages in thread
From: Namjae Jeon @ 2026-09-09  4:48 UTC (permalink / raw)
  To: liubaolin; +Cc: Hyunchul Lee, ntfs, linux-kernel, Baolin Liu

On Tue, Sep 8, 2026 at 5:31 PM liubaolin <liubaolin12138@163.com> wrote:
>
>
>
> 在 2026/9/2 09:44, Namjae Jeon 写道:
> > On Tue, Sep 1, 2026 at 6:15 PM Baolin Liu <liubaolin12138@163.com> wrote:
> >>
> >> From: Baolin Liu <liubaolin@kylinos.cn>
> >>
> >> This series implements fileattr_get and fileattr_set for ntfs so that
> >> lsattr(1) and chattr(1) work on ntfs.
> >>
> >> Patch 1 wires up the fileattr inode operations and implements support
> >> for FS_IMMUTABLE_FL and FS_APPEND_FL. These flags map to inode->i_flags
> >> (S_IMMUTABLE, S_APPEND), so the VFS enforces them. fileattr_get also
> >> reports the compressed and encrypted state, which the driver already
> >> exposes through STATX_ATTR_* in ntfs_getattr().
> >>
> >> Patch 2 adds FS_NODUMP_FL support, which dump(8) and other backup tools
> >> use to mark files to skip. The flag is stored in a new ntfs_inode field
> >> and reported through both fileattr_get (for lsattr) and ntfs_getattr()
> >> (as STATX_ATTR_NODUMP, for statx), so the two interfaces stay consistent.
> >>
> >> All three accepted flags (immutable, append-only, nodump) are kept in
> >> memory and do not survive a remount, matching ntfs3 behavior.
> > This patch-set does not persist these flags on disk. So, the settings
> > survive only while the corresponding inode remains cached. inode
> > reclaim caused by memory pressure or drop_caches can discard them
> > before unmount. Could you find a way to persist immutable, append, and
> > nodump in metadata without causing compatibility issues?
>
> Hi Namjae,Hyunchul,
>
>    Regarding the persistence concern, I propose storing the
> Linux-specific flags in one private EA entry in the file's existing NTFS
> $EA attribute:
>
>      EA name:  $LXFLAGS
>      EA value: a 32-bit little-endian bitmask
>
>      bit 0: immutable
>      bit 1: append-only
>      bit 2: nodump
>
>    The three flags are boolean states, so one bit is sufficient for each
> of them. Using one 32-bit value also leaves room for future expansion.
>
>    This would add an EA entry named $LXFLAGS to the existing $EA
> attribute;it would not introduce a new NTFS attribute type. The driver
> already uses the standard $EA/$EA_INFORMATION mechanism for $LXUID,
> $LXGID, $LXMOD and $LXDEV, so this approach would reuse the existing
> on-disk mechanism.
>
>    The inode loading path would restore the flags from $LXFLAGS, and
> fileattr_set() would update the entry. The entry would be removed when
> all three flags are cleared. This would allow the flags to survive inode
> reclaim, drop_caches, unmount/remount, and reboot.
>
>    This approach would not require changes to mkntfs or to the NTFS
> filesystem format.
>
>    Would this approach be acceptable? If so, I will implement it and
> submit a new revision as soon as possible.
Could you please check whether Windows CHKDSK or the Windows NTFS
modifies or deletes this EA? If neither modifies nor deletes it,
please implement the proposed approach.

Thanks.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2026-09-09  4:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-01  9:15 [PATCH 0/2] ntfs: wire up the fileattr API Baolin Liu
2026-09-01  9:15 ` [PATCH 1/2] ntfs: implement fileattr_get and fileattr_set Baolin Liu
2026-09-02  1:22   ` Namjae Jeon
2026-09-02  6:44     ` liubaolin
2026-09-02  2:00   ` Hyunchul Lee
2026-09-02  7:25     ` liubaolin
2026-09-01  9:15 ` [PATCH 2/2] ntfs: support the nodump flag Baolin Liu
2026-09-02  1:44 ` [PATCH 0/2] ntfs: wire up the fileattr API Namjae Jeon
2026-09-02  7:26   ` liubaolin
2026-09-08  8:31   ` liubaolin
2026-09-09  4:48     ` Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®