From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.53 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795974667; b=tybF1WfqOSdJB9bKHRH90+MoD1vstqXNEK+v8vRhD/i9NKzi1hrGPMy0+IdTUPJTG82T d2UWO6LZL5I6BLTvdCvVBAlxvI5N77nAC/XWvKnClxbYzK5YJDu+BDX3r9atO9xLUJLSV O0XYIY8lJd6riseYp6uLRPVT8Ul6SbLHtgDY1B+TfO01W/MkcOu3W9yjUI1ptMwR25ILO 4e1RGW9Rhkr83jMlUUdQ0TetLfiWeC55+CzolTpK77XJHEkXbGpin+Jd6mH9E/3UxuTC8 TDEY50YUiIciWO3U4Ui7RmYytEk+sMZbjoo/Itl+rssqrR90z7Levdeiyg0/MRxushg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795974667; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: Mime-Version:Content-Type:Date:Message-Id:To:Cc:Subject:From:X-Mailer: References:In-Reply-To; bh=kXiZZ2BWQOxE5mOg3T7wpLgHwdRXqprSVJtm60mimNU=; b=V6cxotALuFRIjzC5+WkL19slDmTFXpdx9OW0Lj2j5r30/8reGj15DDppyD4RAiULOW9S ZOH8CYY1B4hlwT/X9wwqYbnrscG9jp8k24pgesZU1f5OwCs5cUa1LHOQaOR+VBeYuiWtY V/B7jD7p5Jzu6YoQKOxeP4syXgdNFDwwwwng2TYe7Tjg2h/D2wIeeekmdupG37d0J67Py zEsx9/w/hN5MK1MU1HXpmztTozXP/DrJYP6m+j+djs7D7ckqKagdcrJfa2bbxMd4Td2Tg z61e2dKgVgW1wdERSI3Y54X282eW8YU+8TR4oMYzOA7LJhhDY1CqtcuK+lSk2Xq0uCA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=azZA3X5i; arc=none smtp.remote-ip=209.85.128.53 Received: from mail-wm1-f53.google.com (mail-wm1-f53.google.com [209.85.128.53]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5ED9606A327 for ; Sun, 29 Nov 2026 17:51:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C5ED9606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=azZA3X5i Received: by mail-wm1-f53.google.com with SMTP id 5b1f17b1804b1-4b79502c27aso96866075e9.1 for ; Sun, 29 Nov 2026 09:51:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1795974664; x=1796579464; darn=vger.kernel.org; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-type:mime-version:from:to:cc:subject:date:message-id :reply-to:content-type; bh=kXiZZ2BWQOxE5mOg3T7wpLgHwdRXqprSVJtm60mimNU=; b=azZA3X5iqezBnH3ATN3xRm8YF8Zu/HX/xzaSQc8oYW+ulTQHX8TfN7ft7HUaDzIRgs qzMHn60JoMx+Qx6wGOQqelAYK40VHv7B6fg1XwBWVTUjfC6uRBT2AisnCJlCPT3OwXZZ TCOmPFaxVAc5UIVzbFQA86dVa5ITx+awTK02iY0Bal9+qPT/KzGPne1oQMI7B7V9zC73 4ZShsur0EB0sBjrWez2+hE6/rgIOkX5Ycuuq9EEvt3Za3T+mnhyf555KKoOeUOqyP5gr A7HRsxL44KKi5cGJ5f5/TY0t6OoVx3I1kMWiiSue9j4IbY346MtJMLIB3FqtvkqwV6I6 nyLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1795974664; x=1796579464; h=in-reply-to:references:from:subject:cc:to:message-id:date :content-type:mime-version:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to:content-type; bh=kXiZZ2BWQOxE5mOg3T7wpLgHwdRXqprSVJtm60mimNU=; b=DFs3JqaBlNDBc6/18TQ/lEW+bIbB77p1q7Z4ZNTvYWkkWoRXebjKjRAdBEKsTOvaNP Qww2lua3RIZgX4GNdN1elJvlFzKh2X4/1CTp0BHtklHasWPT1SJCTyyTiAQx5LyekSJ3 Mv86tvX4P1dlgKoGFgT0RQIsU7zbbhkv64z+/HARos/F4yr48fPZxVT2FareRc+EPzHT lgLuYFnRs4MtXHLXwooqohJdigUcchR+HaMaG5FJJmoSE6REZ/G9M6awh1BoqHMvTTQQ xpYVeSIFpYOMGn7yfew9poHTRd+9sUPePhDfDanR/JYjuOL9GDsTVKQCryxrVcdblnku AaIQ== X-Forwarded-Encrypted: i=1; AL+hErFCrFO7Axg8vVXxOkb4rkDDN0Bv8uv+7KE+P/FiAbC1EgsW45s9T/uHky61TCmQOL/5tuj0zhqh5CM=@vger.kernel.org X-Gm-Message-State: APuU4Z/H29eNZFSTXmQgfwJCXp2ha4M6fJR/CfE88eMNoqkIi+l4YQ3K N1FXlbOTV6b3gGveoN9ZYnWRod8eZn7Zt9hrvS2zjX1DhzDwTNB+aB7D X-Gm-Gg: AZFdTZds/ZsXKGxYDibZTJC3PFjxvIIBKuzA5YlBP/hwJ9+AVXig9+9Ouv3TqJZEuwh qbKrNkMIsw9yLtNTQM1/4ZPQ5jbvWtm94+yA4C8tcVkANZz8VZv3HqRCwr37m5ACliAspFoXEKj t4AgNebu+0LqUY87xVXZ2H7NrVxo0ReCBavmHnQ8/wFw1TvWTq7IVUZ/nz0dtEAKfLQvyHap97l 0TZ7BoKgwBw8k7vdiGlChaD0tT9TLjXx7qs5W3wE6MYWUvPk5dI3T01K0w9DOO/82YAbfMpsIIh spOevve1rmmy7Ssx9VFEnpP9Zx+LAeg3Tss2JlH7Nr501Qz65aBUaTBBy2xhh5qYB7p0udtflss YjTV37DvcYC0aF5E1Q0uOpCKnWVmcno+RSa8mwn3JRhfhv/yNS7phMkAgIQ8t0vxrWwIhyZdf4W V+jxtYYGJN434p5+lkv6dNT+x5+G9wOKJA5qDJmg1Xm9cKdcsu7BNpRM0RMv4HuN2fFdprVNbmI /HKRzw98QV5W/78zHROR9H9Rex3ku8pV8Qz9te+0xUPCrTnSiJJt8I49+5CmtaOXAXyNf+m3F/+ 9PlVGaPKer1JSSJKCWkG6NsdJZn/O4MHFhO4+7cQEbD9c7M= X-Received: by 2002:a05:600c:19d0:b0:4bb:c483:ecaf with SMTP id 5b1f17b1804b1-4bbc483edc0mr19780405e9.4.1795974663700; Sun, 29 Nov 2026 09:51:03 -0800 (PST) Received: from localhost ([2001:b07:5d26:7a6a:365a:60ff:fe0d:cfc6]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb884b39b6sm802715165e9.12.2026.11.29.09.51.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 29 Nov 2026 09:51:02 -0800 (PST) X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list Mime-Version: 1.0 Content-Type: multipart/signed; boundary=e0f8f2e31d36f29e158bf10b50941a527eafb721d7580dcd3e4a4ac0f0d0; micalg=pgp-sha512; protocol="application/pgp-signature" Date: Sun, 29 Nov 2026 18:51:00 +0100 Message-Id: To: "Amir Goldstein" , "koraynilay" Cc: "Namjae Jeon" , "Hyunchul Lee" , "Jonathan Corbet" , "Eric Biggers" , "Theodore Y . Ts'o" , "Jaegeuk Kim" , "Alexander Viro" , "Christian Brauner" , "Shuah Khan" , "Randy Dunlap" , "Chuck Lever" , "Jeff Layton" , "Jan Kara" , "Alexander Aring" , "Darrick J . Wong" , "Andrey Albershteyn" , "Miklos Szeredi" , =?utf-8?q?Pali_Roh=C3=A1r?= , "Lauri Gates" , "Christoph Hellwig" , "Dave Chinner" , , , , , , , , , Subject: Re: [PATCH v3 4/5] ntfs: switch to the new xflags fileattr API From: "koraynilay" X-Mailer: aerc 0.22.0-0-gc2f86b7abde3 References: <20261129024233.2361718-1-koray.fra@gmail.com> <20261129024233.2361718-5-koray.fra@gmail.com> In-Reply-To: --e0f8f2e31d36f29e158bf10b50941a527eafb721d7580dcd3e4a4ac0f0d0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 On Sun Nov 29, 2026 at 10:12 AM CET, Amir Goldstein wrote: > On Sun, Nov 29, 2026 at 3:43=E2=80=AFAM koraynilay = wrote: >> >> Switch ntfs_fileattr_[gs]et() from the legacy FS_*_FL flags to the >> modern xflags (FS_XFLAG_*) fileattr API with masks. >> >> Assisted-by: Gemini:3.8-flash-high antigravity-cli-1.5.11 > > You know you are not required to add this tag anymore. Some vfs > maintainers would prefer that rather than specifying the model and > version of LLM to describe the how/what you used LLM in cover letter > or notes, which you already partly did. > > I know how much extensive personal effort you put into this patch set > and for me this work is a great example of human+LLM synergy, but new > reviewers don't know that if the scope of "Assisted-by" is not spelled ou= t. > > So my recommendation is to drop it and add a small section in the cover l= etter > about the essential role of LLM in auditing all the filesystems and all t= he > possible UAPI compatibility issues with legacy UAPI and internal vfs api. Ok yeah that makes sense, I'll do like I actually wanted to do for the docs patch (but didn't do), remove the Assisted-by and explain briefly how I used it in either the cover letter or in the --- comments. > Otherwise, this is a very clean patch and very nice reference example of > how to convert a filesystem to the new masks api. Thanks. > Some minor comments below > >> Signed-off-by: koraynilay >> --- >> fs/ntfs/file.c | 109 ++++++++++++++++++++++++++----------------------- >> 1 file changed, 58 insertions(+), 51 deletions(-) >> >> diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c >> index 50be49f4c913..34acf9333c41 100644 >> --- a/fs/ntfs/file.c >> +++ b/fs/ntfs/file.c >> @@ -155,31 +155,38 @@ int ntfs_file_release(struct inode *vi, struct fil= e *filp) >> * @dentry: dentry to report the flags of >> * @fa: filled in with the flags of @dentry >> */ >> +#define NTFS_RO_XFLAGS (FS_XFLAG_COMPR | FS_XFLAG_ENCRYPT | \ >> + FS_XFLAG_CASEFOLD) >> +#define NTFS_RW_XFLAGS (FS_XFLAG_IMMUTABLE | FS_XFLAG_APPEND | \ >> + FS_XFLAG_NOATIME | FS_XFLAG_NODUMP) >> 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; >> + u32 xflags =3D 0; >> >> if (NVolShutdown(ni->vol)) >> return -EIO; >> >> if (NInoCompressed(ni) || NInoWofCompressed(ni)) >> - flags |=3D FS_COMPR_FL; >> + xflags |=3D FS_XFLAG_COMPR; >> if (NInoEncrypted(ni)) >> - flags |=3D FS_ENCRYPT_FL; >> + xflags |=3D FS_XFLAG_ENCRYPT; >> if (vi->i_flags & S_IMMUTABLE) >> - flags |=3D FS_IMMUTABLE_FL; >> + xflags |=3D FS_XFLAG_IMMUTABLE; >> if (vi->i_flags & S_APPEND) >> - flags |=3D FS_APPEND_FL; >> + xflags |=3D FS_XFLAG_APPEND; >> if (vi->i_flags & S_NOATIME) >> - flags |=3D FS_NOATIME_FL; >> + xflags |=3D FS_XFLAG_NOATIME; >> if (ni->linuxflags & NTFS_LINUXFLAGS_NODUMP) >> - flags |=3D FS_NODUMP_FL; >> + xflags |=3D FS_XFLAG_NODUMP; >> if (!NVolCaseSensitive(ni->vol)) >> - flags |=3D FS_CASEFOLD_FL; >> + xflags |=3D FS_XFLAG_CASEFOLD; >> >> - fileattr_fill_flags(fa, flags); >> + fileattr_fill_xflags(fa, xflags); >> + fa->fsx_xflags_ro_mask =3D NTFS_RO_XFLAGS; >> + fa->fsx_xflags_rw_mask =3D NTFS_RW_XFLAGS; >> + fa->has_masks =3D true; >> return 0; >> } >> >> @@ -207,11 +214,9 @@ int ntfs_fileattr_set(const struct mnt_idmap *idmap= , struct dentry *dentry, >> { >> struct inode *vi =3D d_inode(dentry); >> struct ntfs_inode *ni =3D NTFS_I(vi); >> - u32 allowed =3D FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL | >> - FS_NOATIME_FL; >> - u32 readonly =3D 0; >> - u32 linuxflags =3D ni->linuxflags & ~NTFS_LINUXFLAGS_MASK; >> - unsigned int new_fl =3D 0; >> + u32 linuxflags =3D ni->linuxflags; >> + u32 rw_user_mask =3D fa->fsx_xflags_rw_mask; >> + unsigned int new_fl =3D 0, mask_fl =3D 0; >> bool forced_immutable; >> int err; >> >> @@ -219,44 +224,46 @@ int ntfs_fileattr_set(const struct mnt_idmap *idma= p, struct dentry *dentry, >> if (err) >> return err; >> >> - if (fileattr_has_fsx(fa)) >> - return -EOPNOTSUPP; > > Something about this feels wrong, meaning that the filesystem should > protect itself > from getting called with the wrong fileattr and not fully rely on vfs > to do that. > > This over trust is probably part of the problems you see with overlayfs > and also creates problems with ksmbd over ntfs. > > We discussed at some point a replacement for this helper - I am > not sure what exactly it should be called or exactly doing and maybe > it even needs to WARN_ON_ONCE() if an internal caller passes > unexpected fa format, because this function now expects a certain fa form= at. Hmm, I'll think about the best way to go about that, if returning with -EINVAL or WARN_ON_ONCE() or both. Actually, inode_set_flags already does something like this: void inode_set_flags(struct inode *inode, unsigned int flags, unsigned int mask) { WARN_ON_ONCE(flags & ~mask); set_mask_bits(&inode->i_flags, mask, flags); } >> - >> - /* chattr passes the unchanged read-only flags back to us too. *= / >> - if (NInoCompressed(ni) || NInoWofCompressed(ni)) >> - readonly |=3D FS_COMPR_FL; >> - if (NInoEncrypted(ni)) >> - readonly |=3D FS_ENCRYPT_FL; >> - if ((fa->flags ^ readonly) & (FS_COMPR_FL | FS_ENCRYPT_FL)) >> - return -EOPNOTSUPP; >> - allowed |=3D readonly; >> - >> - /* Case folding is a read-only, mount-wide property. */ >> - if (!NVolCaseSensitive(ni->vol)) >> - allowed |=3D FS_CASEFOLD_FL; >> - if (fa->flags & ~allowed) >> - return -EOPNOTSUPP; > > It is very surprising to see this hunk removed when reviewing the series > backwards ;) > > A commit should explain itself without relying on the reviewer keeping > context from previous patches, so the commit message needs to > explain why those protections were removed. Ah, yeah, I'll add it to the commit message. > >> - >> - forced_immutable =3D ntfs_is_forced_immutable(vi); >> - if (!(fa->flags & FS_IMMUTABLE_FL) && forced_immutable) >> - return -EPERM; >> - >> - if (fa->flags & FS_IMMUTABLE_FL) { >> - new_fl |=3D S_IMMUTABLE; >> - /* Do not persist an immutable bit derived from the moun= t. */ >> - if (!forced_immutable || >> - (ni->linuxflags & NTFS_LINUXFLAGS_IMMUTABLE)) >> - linuxflags |=3D NTFS_LINUXFLAGS_IMMUTABLE; >> + if (rw_user_mask & FS_XFLAG_IMMUTABLE) { >> + forced_immutable =3D ntfs_is_forced_immutable(vi); >> + if (!(fa->fsx_xflags & FS_XFLAG_IMMUTABLE) && forced_imm= utable) >> + return -EPERM; >> + >> + mask_fl |=3D S_IMMUTABLE; >> + if (fa->fsx_xflags & FS_XFLAG_IMMUTABLE) { >> + new_fl |=3D S_IMMUTABLE; >> + /* Do not persist an immutable bit derived from = the mount. */ >> + if (!forced_immutable || >> + (ni->linuxflags & NTFS_LINUXFLAGS_IMMUTABLE)= ) >> + linuxflags |=3D NTFS_LINUXFLAGS_IMMUTABL= E; >> + } else { >> + if (ni->linuxflags & NTFS_LINUXFLAGS_IMMUTABLE) >> + linuxflags &=3D ~NTFS_LINUXFLAGS_IMMUTAB= LE; >> + } >> } >> - if (fa->flags & FS_APPEND_FL) { >> - new_fl |=3D S_APPEND; >> - linuxflags |=3D NTFS_LINUXFLAGS_APPEND; >> + if (rw_user_mask & FS_XFLAG_APPEND) { >> + mask_fl |=3D S_APPEND; >> + if (fa->fsx_xflags & FS_XFLAG_APPEND) { >> + new_fl |=3D S_APPEND; >> + linuxflags |=3D NTFS_LINUXFLAGS_APPEND; >> + } else { >> + linuxflags &=3D ~NTFS_LINUXFLAGS_APPEND; >> + } >> + } >> + if (rw_user_mask & FS_XFLAG_NODUMP) { >> + if (fa->fsx_xflags & FS_XFLAG_NODUMP) >> + linuxflags |=3D NTFS_LINUXFLAGS_NODUMP; >> + else >> + linuxflags &=3D ~NTFS_LINUXFLAGS_NODUMP; >> } >> - if (fa->flags & FS_NODUMP_FL) >> - linuxflags |=3D NTFS_LINUXFLAGS_NODUMP; >> - if (fa->flags & FS_NOATIME_FL) { >> - new_fl |=3D S_NOATIME; >> - linuxflags |=3D NTFS_LINUXFLAGS_NOATIME; >> + if (rw_user_mask & FS_XFLAG_NOATIME) { >> + mask_fl |=3D S_NOATIME; >> + if (fa->fsx_xflags & FS_XFLAG_NOATIME) { >> + new_fl |=3D S_NOATIME; >> + linuxflags |=3D NTFS_LINUXFLAGS_NOATIME; >> + } else { >> + linuxflags &=3D ~NTFS_LINUXFLAGS_NOATIME; >> + } >> } > > > It's a bummer that email review has so much diffstat for what is essentia= lly Yeah and that's why I love the --word-diff and --ignore-all-spaces options. > indentation. Sometimes we need to accept that but I have a proposal > If you like it, maybe the diffstat will become even smaller. > > if (rw_user_mask & FS_XFLAG_IMMUTABLE) { > mask_fl |=3D S_IMMUTABLE; > linuxflags_mask |=3D NTFS_LINUXFLAGS_IMMUTABLE; > } > if (fa->fsx_xflags & FS_XFLAG_IMMUTABLE) { > > [ no change here and no else ] > > ... > err =3D ntfs_ea_set_linuxflags(vi, linuxflags & ~linuxflags_mask)= ; > > consistent with inode_set_flags(vi, new_fl, mask_fl); > > Whether fa->fsx_xflags check should be logically in the nested scope > is a matter of taste. I personally like better the smaller patch which > is easier to review, but it is not a must. > > Using linuxflags_mask instead of the else is definitely better IMO, > because it makes S_ flags and LINUXFLAGS handling consistent. > > WDYT? I tried it and with a preparatory patch that only switches ntfs to use xflags it looks very clean [1]. While I logically prefer to have them in if blocks, the new approach also makes sense because it's now 1:1 with new_fl (since set_mask_bits called by inode_set_flags does the exact same ((old & ~mask) | new). Thanks, koraynilay > Thanks, > Amir. [1]: commit ccda307355008ba86354128d934f7ab97be62a96 Author: koraynilay Date: Sun Nov 22 00:17:29 2026 +0100 ntfs: support the fileattr API masks in ntfs_fileattr_get/set() =20 Add support for the new fileattr API with masks in ntfs_fileattr_get() and ntfs_fileattr_set(). =20 This also allows us to remove checks for unsupported xflags, since VFS will take care of that by using the rw and ro masks returned in ntfs_fileattr_get(). =20 Signed-off-by: koraynilay --- fs/ntfs/file.c | 73 +++++++++++++++++++++++++++++++-----------------------= ---- 1 file changed, 39 insertions(+), 34 deletions(-) diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index ca088e7d636b..0a45359f3a2a 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c @@ -155,6 +155,10 @@ int ntfs_file_release(struct inode *vi, struct file *f= ilp) * @dentry: dentry to report the flags of * @fa: filled in with the flags of @dentry */ +#define NTFS_RO_XFLAGS (FS_XFLAG_COMPR | FS_XFLAG_ENCRYPT | \ + FS_XFLAG_CASEFOLD) +#define NTFS_RW_XFLAGS (FS_XFLAG_IMMUTABLE | FS_XFLAG_APPEND | \ + FS_XFLAG_NOATIME | FS_XFLAG_NODUMP) int ntfs_fileattr_get(struct dentry *dentry, struct file_kattr *fa) { struct inode *vi =3D d_inode(dentry); @@ -179,7 +183,9 @@ int ntfs_fileattr_get(struct dentry *dentry, struct fil= e_kattr *fa) if (!NVolCaseSensitive(ni->vol)) xflags |=3D FS_XFLAG_CASEFOLD; =20 - fileattr_fill_xflags(fa, xflags); + fa->fsx_xflags_ro_mask =3D NTFS_RO_XFLAGS; + fa->fsx_xflags_rw_mask =3D NTFS_RW_XFLAGS; + fa->has_masks =3D true; return 0; } =20 @@ -207,65 +213,64 @@ int ntfs_fileattr_set(const struct mnt_idmap *idmap, = struct dentry *dentry, { struct inode *vi =3D d_inode(dentry); struct ntfs_inode *ni =3D NTFS_I(vi); - u32 allowed =3D FS_XFLAG_IMMUTABLE | FS_XFLAG_APPEND | FS_XFLAG_NODUMP | - FS_XFLAG_NOATIME; - u32 readonly =3D 0; - u32 linuxflags =3D ni->linuxflags & ~NTFS_LINUXFLAGS_MASK; - unsigned int new_fl =3D 0; - bool forced_immutable; + u32 linuxflags =3D ni->linuxflags; + u32 rw_user_mask =3D fa->fsx_xflags_rw_mask; + unsigned int new_fl =3D 0, mask_fl =3D 0; + unsigned int new_linuxflags =3D 0, mask_linuxflags =3D 0; + bool forced_immutable =3D false; int err; =20 err =3D ntfs_emergency_state(ni->vol); if (err) return err; =20 - if (fa->fsx_extsize || fa->fsx_cowextsize || fa->fsx_projid) - return -EOPNOTSUPP; - - /* chattr passes the unchanged read-only flags back to us too. */ - if (NInoCompressed(ni) || NInoWofCompressed(ni)) - readonly |=3D FS_XFLAG_COMPR; - if (NInoEncrypted(ni)) - readonly |=3D FS_XFLAG_ENCRYPT; - if ((fa->fsx_xflags ^ readonly) & (FS_XFLAG_COMPR | FS_XFLAG_ENCRYPT)) - return -EOPNOTSUPP; - allowed |=3D readonly; - - /* Case folding is a read-only, mount-wide property. */ - if (!NVolCaseSensitive(ni->vol)) - allowed |=3D FS_XFLAG_CASEFOLD; - if (fa->fsx_xflags & ~allowed) - return -EOPNOTSUPP; - - forced_immutable =3D ntfs_is_forced_immutable(vi); - if (!(fa->fsx_xflags & FS_XFLAG_IMMUTABLE) && forced_immutable) - return -EPERM; + if (rw_user_mask & FS_XFLAG_IMMUTABLE) { + forced_immutable =3D ntfs_is_forced_immutable(vi); + if (!(fa->fsx_xflags & FS_XFLAG_IMMUTABLE) && forced_immutable) + return -EPERM; =20 + mask_fl |=3D S_IMMUTABLE; + mask_linuxflags |=3D NTFS_LINUXFLAGS_IMMUTABLE; + } if (fa->fsx_xflags & FS_XFLAG_IMMUTABLE) { new_fl |=3D S_IMMUTABLE; /* Do not persist an immutable bit derived from the mount. */ if (!forced_immutable || (ni->linuxflags & NTFS_LINUXFLAGS_IMMUTABLE)) - linuxflags |=3D NTFS_LINUXFLAGS_IMMUTABLE; + new_linuxflags |=3D NTFS_LINUXFLAGS_IMMUTABLE; + } + + if (rw_user_mask & FS_XFLAG_APPEND) { + mask_fl |=3D S_APPEND; + mask_linuxflags |=3D NTFS_LINUXFLAGS_APPEND; } if (fa->fsx_xflags & FS_XFLAG_APPEND) { new_fl |=3D S_APPEND; - linuxflags |=3D NTFS_LINUXFLAGS_APPEND; + new_linuxflags |=3D NTFS_LINUXFLAGS_APPEND; } + + if (rw_user_mask & FS_XFLAG_NODUMP) + mask_linuxflags |=3D NTFS_LINUXFLAGS_NODUMP; if (fa->fsx_xflags & FS_XFLAG_NODUMP) - linuxflags |=3D NTFS_LINUXFLAGS_NODUMP; + new_linuxflags |=3D NTFS_LINUXFLAGS_NODUMP; + + if (rw_user_mask & FS_XFLAG_NOATIME) { + mask_fl |=3D S_NOATIME; + mask_linuxflags |=3D NTFS_LINUXFLAGS_NOATIME; + } if (fa->fsx_xflags & FS_XFLAG_NOATIME) { new_fl |=3D S_NOATIME; - linuxflags |=3D NTFS_LINUXFLAGS_NOATIME; + new_linuxflags |=3D NTFS_LINUXFLAGS_NOATIME; } =20 mutex_lock(&ni->mrec_lock); - err =3D ntfs_ea_set_linuxflags(vi, linuxflags); + new_linuxflags |=3D linuxflags & ~mask_linuxflags; + err =3D ntfs_ea_set_linuxflags(vi, new_linuxflags); mutex_unlock(&ni->mrec_lock); if (err) return err; =20 - inode_set_flags(vi, new_fl, S_IMMUTABLE | S_APPEND | S_NOATIME); + inode_set_flags(vi, new_fl, mask_fl); inode_set_ctime_current(vi); mark_inode_dirty(vi); return 0; commit 347c2201ae065d608e9aee9bac2e93f9b9418156 Author: koraynilay Date: Sun Nov 29 18:10:31 2026 +0100 ntfs: switch from flags to xflags in ntfs_fileattr_get/set() =20 Switch ntfs_fileattr_get() and ntfs_fileattr_set() to use FS_XFLAG_* xflags instead of FS_*_FL flags. =20 Signed-off-by: koraynilay --- fs/ntfs/file.c | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/fs/ntfs/file.c b/fs/ntfs/file.c index 50be49f4c913..ca088e7d636b 100644 --- a/fs/ntfs/file.c +++ b/fs/ntfs/file.c @@ -159,27 +159,27 @@ int ntfs_fileattr_get(struct dentry *dentry, struct f= ile_kattr *fa) { struct inode *vi =3D d_inode(dentry); struct ntfs_inode *ni =3D NTFS_I(vi); - u32 flags =3D 0; + u32 xflags =3D 0; =20 if (NVolShutdown(ni->vol)) return -EIO; =20 if (NInoCompressed(ni) || NInoWofCompressed(ni)) - flags |=3D FS_COMPR_FL; + xflags |=3D FS_XFLAG_COMPR; if (NInoEncrypted(ni)) - flags |=3D FS_ENCRYPT_FL; + xflags |=3D FS_XFLAG_ENCRYPT; if (vi->i_flags & S_IMMUTABLE) - flags |=3D FS_IMMUTABLE_FL; + xflags |=3D FS_XFLAG_IMMUTABLE; if (vi->i_flags & S_APPEND) - flags |=3D FS_APPEND_FL; + xflags |=3D FS_XFLAG_APPEND; if (vi->i_flags & S_NOATIME) - flags |=3D FS_NOATIME_FL; + xflags |=3D FS_XFLAG_NOATIME; if (ni->linuxflags & NTFS_LINUXFLAGS_NODUMP) - flags |=3D FS_NODUMP_FL; + xflags |=3D FS_XFLAG_NODUMP; if (!NVolCaseSensitive(ni->vol)) - flags |=3D FS_CASEFOLD_FL; + xflags |=3D FS_XFLAG_CASEFOLD; =20 - fileattr_fill_flags(fa, flags); + fileattr_fill_xflags(fa, xflags); return 0; } =20 @@ -207,8 +207,8 @@ int ntfs_fileattr_set(const struct mnt_idmap *idmap, st= ruct dentry *dentry, { struct inode *vi =3D d_inode(dentry); struct ntfs_inode *ni =3D NTFS_I(vi); - u32 allowed =3D FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL | - FS_NOATIME_FL; + u32 allowed =3D FS_XFLAG_IMMUTABLE | FS_XFLAG_APPEND | FS_XFLAG_NODUMP | + FS_XFLAG_NOATIME; u32 readonly =3D 0; u32 linuxflags =3D ni->linuxflags & ~NTFS_LINUXFLAGS_MASK; unsigned int new_fl =3D 0; @@ -219,42 +219,42 @@ int ntfs_fileattr_set(const struct mnt_idmap *idmap, = struct dentry *dentry, if (err) return err; =20 - if (fileattr_has_fsx(fa)) + if (fa->fsx_extsize || fa->fsx_cowextsize || fa->fsx_projid) return -EOPNOTSUPP; =20 /* chattr passes the unchanged read-only flags back to us too. */ if (NInoCompressed(ni) || NInoWofCompressed(ni)) - readonly |=3D FS_COMPR_FL; + readonly |=3D FS_XFLAG_COMPR; if (NInoEncrypted(ni)) - readonly |=3D FS_ENCRYPT_FL; - if ((fa->flags ^ readonly) & (FS_COMPR_FL | FS_ENCRYPT_FL)) + readonly |=3D FS_XFLAG_ENCRYPT; + if ((fa->fsx_xflags ^ readonly) & (FS_XFLAG_COMPR | FS_XFLAG_ENCRYPT)) return -EOPNOTSUPP; allowed |=3D readonly; =20 /* Case folding is a read-only, mount-wide property. */ if (!NVolCaseSensitive(ni->vol)) - allowed |=3D FS_CASEFOLD_FL; - if (fa->flags & ~allowed) + allowed |=3D FS_XFLAG_CASEFOLD; + if (fa->fsx_xflags & ~allowed) return -EOPNOTSUPP; =20 forced_immutable =3D ntfs_is_forced_immutable(vi); - if (!(fa->flags & FS_IMMUTABLE_FL) && forced_immutable) + if (!(fa->fsx_xflags & FS_XFLAG_IMMUTABLE) && forced_immutable) return -EPERM; =20 - if (fa->flags & FS_IMMUTABLE_FL) { + if (fa->fsx_xflags & FS_XFLAG_IMMUTABLE) { new_fl |=3D S_IMMUTABLE; /* Do not persist an immutable bit derived from the mount. */ if (!forced_immutable || (ni->linuxflags & NTFS_LINUXFLAGS_IMMUTABLE)) linuxflags |=3D NTFS_LINUXFLAGS_IMMUTABLE; } - if (fa->flags & FS_APPEND_FL) { + if (fa->fsx_xflags & FS_XFLAG_APPEND) { new_fl |=3D S_APPEND; linuxflags |=3D NTFS_LINUXFLAGS_APPEND; } - if (fa->flags & FS_NODUMP_FL) + if (fa->fsx_xflags & FS_XFLAG_NODUMP) linuxflags |=3D NTFS_LINUXFLAGS_NODUMP; - if (fa->flags & FS_NOATIME_FL) { + if (fa->fsx_xflags & FS_XFLAG_NOATIME) { new_fl |=3D S_NOATIME; linuxflags |=3D NTFS_LINUXFLAGS_NOATIME; } --e0f8f2e31d36f29e158bf10b50941a527eafb721d7580dcd3e4a4ac0f0d0 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQSgVimKafU5DQMcjcDmj22qf5IGXAUCawxmBAAKCRDmj22qf5IG XLtdAQDV6Pg4ZG9F1QVueHlS5B9MxHQUerOSVW/28dRe8LzFTQEA/78gVRqc0IVA KHoHc10YNqkniwzWBv8O24l2lkH7Ogc= =gpmp -----END PGP SIGNATURE----- --e0f8f2e31d36f29e158bf10b50941a527eafb721d7580dcd3e4a4ac0f0d0--