mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Baolin Liu <liubaolin12138@163.com>
To: linkinjeon@kernel.org, hyc.lee@gmail.com
Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org,
	chenxiaosong@chenxiaosong.com, Baolin Liu <liubaolin@kylinos.cn>
Subject: [PATCH v4 10/10] ntfs: persist nodump in the $LINUXFLAGS EA
Date: Wed, 23 Sep 2026 14:02:46 +0800	[thread overview]
Message-ID: <20260923060246.2499192-11-liubaolin12138@163.com> (raw)
In-Reply-To: <20260923060246.2499192-1-liubaolin12138@163.com>

From: Baolin Liu <liubaolin@kylinos.cn>

Store nodump in bit 2 of LINUXFLAGS and allow it through fileattr_set.
Report the cached persistent bit through fileattr_get and
STATX_ATTR_NODUMP, including the statx supported-attribute mask. Reuse
the existing EA update and inode-load paths; nodump needs no additional
inode flag enforcement.

Document the complete immutable, append-only and nodump bitmask.

Signed-off-by: Baolin Liu <liubaolin@kylinos.cn>
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
---
 Documentation/filesystems/ntfs.rst | 34 +++++++++++++++++-------------
 fs/ntfs/ea.h                       |  3 ++-
 fs/ntfs/file.c                     | 11 ++++++++--
 3 files changed, 30 insertions(+), 18 deletions(-)

diff --git a/Documentation/filesystems/ntfs.rst b/Documentation/filesystems/ntfs.rst
index fb9c89b9b493..d305fd4314d2 100644
--- a/Documentation/filesystems/ntfs.rst
+++ b/Documentation/filesystems/ntfs.rst
@@ -38,21 +38,25 @@ The project is available at:
 Linux file attributes
 =====================
 
-The driver supports lsattr(1) and setting immutable and append-only with chattr(1).
-Immutable is stored in bit 0 and append-only in bit 1 of a private ``$LINUXFLAGS`` extended attribute
-within the standard NTFS ``$EA``/``$EA_INFORMATION`` attributes. Its value
-is a 32-bit little-endian bitmask. Unknown bits are preserved; the entry
-is removed when the entire value becomes zero. These settings survive
-inode eviction, unmount and reboot. Direct writes or removal through
-xattr interfaces are rejected; use chattr(1) instead.
-
-System metadata files and files protected by ``sys_immutable`` cannot
-have their immutable protection cleared. Protection derived solely from
-that policy is not stored in the EA. Compression, encryption
-and mount-wide case folding are reported but cannot be changed through
-chattr(1).
-
-Windows does not enforce the Linux immutable and append-only flags stored in this EA.
+The driver supports lsattr(1) and chattr(1). Immutable, append-only and
+nodump are stored in a private ``$LINUXFLAGS`` extended attribute within the
+standard NTFS ``$EA``/``$EA_INFORMATION`` attributes. Its value is a
+32-bit little-endian bitmask: bit 0 is immutable, bit 1 is append-only,
+and bit 2 is nodump. Unknown bits are preserved when updating the flags;
+the entry is removed when the entire value becomes zero. These settings
+survive inode eviction, unmount and reboot. Direct writes to this EA
+through setxattr(2) or removexattr(2) are rejected; use chattr(1) instead.
+
+System metadata files and files protected by the ``sys_immutable`` mount
+option cannot have their immutable protection cleared with chattr(1).
+Protection derived solely from the mount option is not stored in the EA.
+Case folding is reported according to the mount options and cannot be
+configured per file. Compression and encryption are reported but cannot
+be changed through chattr(1).
+
+These Linux flags are enforced by Linux. Storing them in an NTFS EA does
+not make Windows enforce immutable, append-only or nodump semantics.
+
 
 Supported mount options
 =======================
diff --git a/fs/ntfs/ea.h b/fs/ntfs/ea.h
index b988b39f5f00..8f144fa4f9bb 100644
--- a/fs/ntfs/ea.h
+++ b/fs/ntfs/ea.h
@@ -10,8 +10,9 @@
 /* $LINUXFLAGS stores these bits in a single little-endian 32-bit value. */
 #define NTFS_LINUXFLAGS_IMMUTABLE	BIT(0)
 #define NTFS_LINUXFLAGS_APPEND	BIT(1)
+#define NTFS_LINUXFLAGS_NODUMP	BIT(2)
 #define NTFS_LINUXFLAGS_MASK	(NTFS_LINUXFLAGS_IMMUTABLE | \
-				 NTFS_LINUXFLAGS_APPEND)
+				 NTFS_LINUXFLAGS_APPEND | NTFS_LINUXFLAGS_NODUMP)
 
 extern const struct xattr_handler *const ntfs_xattr_handlers[];
 
diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c
index cda8d02c130e..38309cbd98c2 100644
--- a/fs/ntfs/file.c
+++ b/fs/ntfs/file.c
@@ -159,6 +159,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->linuxflags & NTFS_LINUXFLAGS_NODUMP)
+		flags |= FS_NODUMP_FL;
 	if (!NVolCaseSensitive(ni->vol))
 		flags |= FS_CASEFOLD_FL;
 
@@ -190,7 +192,7 @@ int ntfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
 {
 	struct inode *vi = d_inode(dentry);
 	struct ntfs_inode *ni = NTFS_I(vi);
-	u32 allowed = FS_IMMUTABLE_FL | FS_APPEND_FL;
+	u32 allowed = FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL;
 	u32 readonly = 0;
 	u32 linuxflags = ni->linuxflags & ~NTFS_LINUXFLAGS_MASK;
 	unsigned int new_fl = 0;
@@ -233,6 +235,8 @@ int ntfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentry,
 		new_fl |= S_APPEND;
 		linuxflags |= NTFS_LINUXFLAGS_APPEND;
 	}
+	if (fa->flags & FS_NODUMP_FL)
+		linuxflags |= NTFS_LINUXFLAGS_NODUMP;
 
 	mutex_lock(&ni->mrec_lock);
 	err = ntfs_ea_set_linuxflags(vi, linuxflags);
@@ -507,9 +511,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->linuxflags & NTFS_LINUXFLAGS_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
-- 
2.51.0


  parent reply	other threads:[~2026-09-23  6:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-23  6:02 [PATCH v4 00/10] ntfs: persist Linux file attributes in an EA Baolin Liu
2026-09-23  6:02 ` [PATCH v4 01/10] ntfs: keep the EA presence flag after creating the first entry Baolin Liu
2026-09-23  6:02 ` [PATCH v4 02/10] ntfs: validate EA chains and link zero-terminated tails Baolin Liu
2026-09-23  6:02 ` [PATCH v4 03/10] ntfs: propagate EA write and truncate errors Baolin Liu
2026-09-23  6:02 ` [PATCH v4 04/10] ntfs: preserve EA attribute lookup errors Baolin Liu
2026-09-23  6:02 ` [PATCH v4 05/10] ntfs: distinguish empty EA values from removal Baolin Liu
2026-09-23  6:02 ` [PATCH v4 06/10] ntfs: restore EA attributes when an update fails Baolin Liu
2026-09-23  6:02 ` [PATCH v4 07/10] ntfs: add fileattr query support Baolin Liu
2026-09-23  6:02 ` [PATCH v4 08/10] ntfs: persist immutable in the $LINUXFLAGS EA Baolin Liu
2026-09-23  6:02 ` [PATCH v4 09/10] ntfs: persist append-only " Baolin Liu
2026-09-23  6:02 ` Baolin Liu [this message]
2026-10-12  3:16 ` [PATCH v4 00/10] ntfs: persist Linux file attributes in an EA liubaolin
2026-10-12  4:43   ` Hyunchul Lee
2026-10-12  5:06     ` Namjae Jeon
2026-10-12  8:15       ` liubaolin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260923060246.2499192-11-liubaolin12138@163.com \
    --to=liubaolin12138@163.com \
    --cc=chenxiaosong@chenxiaosong.com \
    --cc=hyc.lee@gmail.com \
    --cc=linkinjeon@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=liubaolin@kylinos.cn \
    --cc=ntfs@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®