From nobody Sat Sep 26 13:18:35 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68CF7473C96 for ; Tue, 1 Sep 2026 09:15:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.3 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788254156; cv=none; b=NXlMVEI5IBdHbjmM+sPLlXITHkCU/xwJ+T4e4y+vOPbt2G2Y5z1VxZRRcdbI6Kb+sV1nIPIxPQVtVxKbWaQpSHGpmleUhO5OaclYPjpDpA8dNmwLLb9j+CltDv8hE8cKiEEJ0x7daLKb4+pGOHnDF0ZAZGSo/ejKLRSp24QFzJg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788254156; c=relaxed/simple; bh=e+TnL+Hjy0zOw8pk2BwP+QadpoM/zU7FgWPSM7/hgec=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ABaqdayEBa/+ws28i2JrwOaNzfEVKUErxHf9Hh+uqswSvX0PKEgaOCSZBk2coOgJ8oqV+hTdXVYkkHrvx3lh9C3Ns5/oJqu7PuiT8FV2mmwMzGNxUCe/nGciMdBh9qQp/n3rlN13IUkdIW+7N7VTuVjfLSSMz0ccDjheb3+thNg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=ZB7FHVbY; arc=none smtp.client-ip=220.197.31.3 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="ZB7FHVbY" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=D2 QWu7eHZZMS4ZOhJkjuAzZd0y97wwL2svj4oicLWM0=; b=ZB7FHVbYGfNR8TlGBs flKuFryg29AXBITQAKfiWRMynmh/KawQYX3FPkFOHKboTuY+WvRWjPSJcMIR7SXm OU5HD5PCmMVr3j8imaisYaV3kc3ppXEGaaS4mcYTC77OSE21MW3HrOrWKksxA8j+ LCC1qkJpAkpevh81NLxIJaRPE= Received: from liubaolin-ThinkPad-E15-Gen-2 (unknown []) by gzga-smtp-mtada-g1-3 (Coremail) with SMTP id _____wDXmJ6pl5ZqstwpQw--.142S3; Tue, 01 Sep 2026 17:15:29 +0800 (CST) From: Baolin Liu To: linkinjeon@kernel.org, hyc.lee@gmail.com Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org, liubaolin12138@163.com, Baolin Liu Subject: [PATCH 1/2] ntfs: implement fileattr_get and fileattr_set Date: Tue, 1 Sep 2026 17:15:17 +0800 Message-ID: <20260901091519.2885376-2-liubaolin12138@163.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260901091519.2885376-1-liubaolin12138@163.com> References: <20260901091519.2885376-1-liubaolin12138@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wDXmJ6pl5ZqstwpQw--.142S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxXF1Utw4UJw4DuFWkKw43GFg_yoWrXFy8pa n3JFyrGw4fWry2g39akFWUu3WF9w1xXr4UZry7W34IyFnrtryxKryfKF1rCF1rtrZ5CrnF gF1UtrWUCF13Zw7anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pRY9aDUUUUU= X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbCwhFSHWqWl7FiZQAA3B Content-Type: text/plain; charset="utf-8" From: Baolin Liu 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 --- 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 #include #include +#include =20 #include "lcnalloc.h" #include "ntfs.h" @@ -135,6 +136,59 @@ static int ntfs_file_release(struct inode *vi, struct = file *filp) return 0; } =20 +/* + * 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 =3D d_inode(dentry); + struct ntfs_inode *ni =3D NTFS_I(vi); + u32 flags =3D 0; + + if (NInoCompressed(ni) || NInoWofCompressed(ni)) + flags |=3D FS_COMPR_FL; + if (NInoEncrypted(ni)) + flags |=3D FS_ENCRYPT_FL; + if (vi->i_flags & S_IMMUTABLE) + flags |=3D FS_IMMUTABLE_FL; + if (vi->i_flags & S_APPEND) + flags |=3D 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 =3D d_inode(dentry); + unsigned int new_fl =3D 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 |=3D S_IMMUTABLE; + if (fa->flags & FS_APPEND_FL) + new_fl |=3D 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 =3D { const struct inode_operations ntfs_file_inode_ops =3D { .setattr =3D ntfs_setattr, .getattr =3D ntfs_getattr, + .fileattr_get =3D ntfs_fileattr_get, + .fileattr_set =3D ntfs_fileattr_set, .listxattr =3D ntfs_listxattr, .get_acl =3D ntfs_get_acl, .set_acl =3D 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_op= s; extern const struct file_operations ntfs_empty_file_ops; extern const struct inode_operations ntfs_empty_inode_ops; =20 +extern int ntfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa); +extern int ntfs_fileattr_set(struct mnt_idmap *idmap, struct dentry *dentr= y, + struct file_kattr *fa); + extern const struct export_operations ntfs_export_ops; =20 /* --=20 2.51.0 From nobody Sat Sep 26 13:18:35 2026 Received: from m16.mail.163.com (m16.mail.163.com [220.197.31.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 00AF0477E22 for ; Tue, 1 Sep 2026 09:15:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=220.197.31.2 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788254156; cv=none; b=RiRqBN+QB8KVdqEekgb8xCfXqeDOKW/eDndCUTM3VM0FiutkHxyDFXfE0yYQKhTTC/IM6jbVPNiTVv9vVqiBpv7VaoZTsfLP4LqJAOCACPJR+NkKPpyXvbfK09wmH8gmvPwkWYalt9w1cH+p27PzcTE9a8nz8eEicaMzn1B2GLQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1788254156; c=relaxed/simple; bh=QYFtU56wHUIHz9DqB9/4PCaSfSoLvAsDwkg+srcbm7k=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KySe6wJlt076NCeA0aG4tUTshRjmlR2CY/rmBfWxN2NwrKOK1jviSkOpQiIz9hK02yiSP+TiM4gyoIfQuNL15t6cllyPGky/f3+I27qvHzpWXKHr9kZn8Mcc5E/JcxXPzMzKK89YzRU4T8eCRERAZwkLMNbIY2AzJ0MB8F5G86Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com; spf=pass smtp.mailfrom=163.com; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b=nhgXXPI9; arc=none smtp.client-ip=220.197.31.2 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=163.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=163.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=163.com header.i=@163.com header.b="nhgXXPI9" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:To:Subject:Date:Message-ID:MIME-Version; bh=VX 5Cuk3BS+hb9L7FUjA0yrHAyqJD41h0HN4osJ2eN5s=; b=nhgXXPI9Ks84rYMzio CEgTm/Xg/Bkr+jQDNcyN3z9Vnd1bFnp/gf/LBJeedEO75EqspnFyyTLmCr/GpEiN 5pYJ/Z4SwjNGvUBINdpXuvYPP37zq9YzQ1pHXxClQsA+I4JvfqFzJ2OkUDSiD2zS CvQEhSj0zcSYNwcuSiROTgMK0= Received: from liubaolin-ThinkPad-E15-Gen-2 (unknown []) by gzga-smtp-mtada-g1-3 (Coremail) with SMTP id _____wDXmJ6pl5ZqstwpQw--.142S4; Tue, 01 Sep 2026 17:15:31 +0800 (CST) From: Baolin Liu To: linkinjeon@kernel.org, hyc.lee@gmail.com Cc: ntfs@lists.linux.dev, linux-kernel@vger.kernel.org, liubaolin12138@163.com, Baolin Liu Subject: [PATCH 2/2] ntfs: support the nodump flag Date: Tue, 1 Sep 2026 17:15:18 +0800 Message-ID: <20260901091519.2885376-3-liubaolin12138@163.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260901091519.2885376-1-liubaolin12138@163.com> References: <20260901091519.2885376-1-liubaolin12138@163.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: _____wDXmJ6pl5ZqstwpQw--.142S4 X-Coremail-Antispam: 1Uf129KBjvJXoWxWw1ktF43WF43GFyfAr1UKFg_yoW5Wr4kpF Z3JFyfGa18Wry2grZ29r4jg3W0yanrGrWUurW5Aw1Iy3ZxJr1aqFySk3W0grnYqrWku342 qFyUt3yUAFW2937anT9S1TB71UUUUU7qnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0zR8hL8UUUUU= X-CM-SenderInfo: xolxutxrol0iasrtmqqrwthudrp/xtbCwRRTHmqWl7RmCAAA3p Content-Type: text/plain; charset="utf-8" From: Baolin Liu 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 --- 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 fil= e_kattr *fa) flags |=3D FS_IMMUTABLE_FL; if (vi->i_flags & S_APPEND) flags |=3D FS_APPEND_FL; + if (ni->nodump) + flags |=3D FS_NODUMP_FL; =20 fileattr_fill_flags(fa, flags); return 0; @@ -174,7 +176,7 @@ int ntfs_fileattr_set(struct mnt_idmap *idmap, struct d= entry *dentry, =20 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; =20 if (fa->flags & FS_IMMUTABLE_FL) @@ -183,6 +185,7 @@ int ntfs_fileattr_set(struct mnt_idmap *idmap, struct d= entry *dentry, new_fl |=3D S_APPEND; =20 inode_set_flags(vi, new_fl, S_IMMUTABLE | S_APPEND); + NTFS_I(vi)->nodump =3D fa->flags & FS_NODUMP_FL; =20 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 |=3D STATX_ATTR_APPEND; =20 + if (ni->nodump) + stat->attributes |=3D STATX_ATTR_NODUMP; + stat->attributes_mask |=3D STATX_ATTR_COMPRESSED | STATX_ATTR_ENCRYPTED | - STATX_ATTR_IMMUTABLE | STATX_ATTR_APPEND; + STATX_ATTR_IMMUTABLE | STATX_ATTR_APPEND | + STATX_ATTR_NODUMP; =20 /* * 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 n= tfs_inode *ni) ni->reparse_tag =3D 0; ni->reparse_flags =3D 0; ni->target =3D NULL; + ni->nodump =3D 0; ni->i_dealloc_clusters =3D 0; } =20 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; }; =20 /* --=20 2.51.0