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,
	liubaolin12138@163.com, Baolin Liu <liubaolin@kylinos.cn>
Subject: [PATCH 2/2] ntfs: support the nodump flag
Date: Tue,  1 Sep 2026 17:15:18 +0800	[thread overview]
Message-ID: <20260901091519.2885376-3-liubaolin12138@163.com> (raw)
In-Reply-To: <20260901091519.2885376-1-liubaolin12138@163.com>

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


  parent reply	other threads:[~2026-09-01  9:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 ` Baolin Liu [this message]
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

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=20260901091519.2885376-3-liubaolin12138@163.com \
    --to=liubaolin12138@163.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®