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=1795974666; b=2NOyn8+Dmd8ArJnOTp49uc+XEiuutJ65AFLBhq4MVGrzP0ZrDsggMVTkmffyPQU6FGGJ 03RpaKqi6N4oT7iqIfp+FEM1AMAzUR0lRf0O74b7wDPE1QB2eaNDLdU2+5i5NB27Lkb7R Cd4nTkLtNPLk568pQBzfTanVnQR9S8hT+n3LKUYimKktAiSlZS788W8fF/EJAGhVZe3eE VH5NRYq8MxepgiykB7HavqSYZCMdlfnd1fFh3gk93oiw1bP6Nc5i87JqWWCBgIlg5ZO6/ BNP+mM+t0XwbPPQkXAQaYpiwRkEDriJRnl9618OODaGarE8h39JqAixEg2KIBE95pAA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795974666; 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=hVI60jamhvZjUMJmWAMUhn/B29YCmSfDuSxNbenqA/q8+0QbxcJzt3Gdnhl9Fvd5m2+N /sluYPHancNmBx/kc+41WTQGA/LFYJZ028i52cf3GvKa/i+q1bqnJMGKbeXXQWFR8ym7u kix2IkOJLO55PutDI7D1AMoOdLXjDaDIP/KRwRsUKd+sQjjsuHAn+ZFH4vG3r1TWbpzLU RhwwDGYspCBCFh1LO+x02mmPCoqUitp4e0BLyhLFipT8WytlNVGRtmXmdJFYuBX6rcE0h Avn/AS6SwZIEs/VSUF8BlJPAhyX+T3vRNxgBUD4d7NKP4Lpchcz3pxAOgvY1qiYj7gQ== 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 C5F25606A329 for ; Sun, 29 Nov 2026 17:51:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C5F25606A329 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-4a2153c8525so78182465e9.3 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=nkskbnESSAp8QA31yj8g58+bGU7QRL2LIMNWiqyi37ORPEUTdwDtm2fvPVA5ikT5gH xsxyLXXYC+CA0k579PhBzcC5mPtNhNoon/A+XyKtUrGngmhqPxahuIobrb/JYPnCaDBt oV0SScehYfLuTtA9hmbv3oU0t1ZbmvEu03LLqmtnh03WnK07n0pYzhB3bLoIBd7RSl4t rFPIMvLJHm5h6edtlqk9/oa7kyUeKn7jDg7uhAQNtWYEt4qSDKKfhtR1WcLDGMGprUN5 Fpcl+wBcQKzowXgpi0M7OqIhFitcRSVTEQ/qreMr5D7qaopsi/U3Ns8TwILFJGiwS+ZM u/rQ== X-Forwarded-Encrypted: i=1; AL+hErF7dvm6cCoiTpHCggqd1CCAtDiJ+wXibQELYqnzAgWs4bsJojj4rKGP7+vGynOFJ4eZSUQ/MNfjr50=@vger.kernel.org X-Gm-Message-State: APuU4Z8yl8Rpx9NqaDte3lysk6EcO+uOUbEr5msoalJfR/bsDdKHAZF2 iILpXTF/AKOLEC2J/Ka4PhaVXKuAfBA7oLa1xG8DpfYaQM9E3zS4MKAj X-Gm-Gg: AZFdTZfX9eBOhxC5CMUj+YZmqCcts74fcmRTO7RzVkOymNapSGXA16CdsJapgAlnDBJ 5tSp5H7EM/a/uzUse+uyVzdKUCAlaPoUi9E5bTttPyKweJjQBhX0o61faGINAEwlqDYj9MhFnAa dgUKEDq1S/XNzYzAFrSbbYIqztvIKlsKEAz1fwiMkgbNn+5WKPsA3RaqUdHYfflZP26Vovfb6jU 96DBH833Q3HkWLUicEKTIaZ9R1ssvj7Ekkc45pZ75OtV/OKgMJIBAZMQ0jz+Je64AmhCuUlsNeh C+OwTVubiA14s9F/oJdmS0WM2poRZyCxF4AwAI6ejukuW0KCJ6qK+HztNF07cH7NUgFpLAqMHU5 KJQVRNO/T4GMk3rjgD2ZK7msxp2UQfs9z3PcNnzNyB0dxSMKytZcJKL1iS0GV6/CM/oC5RewDfU Y6CqzFLZmSm5Pxe9wLNnw19K5pr50rsW+jQfNg36gJcRRe05cfkobpzZ1VcMSO4V7cn11nz1W64 2jVjgWcfIefKjGjAHHXPK3tz1bhRMSPiqbHntKAMXW7OasMmZo9KtENbo7Jgidf0XQQ/YXekXe6 w8jBjlFzIdItRYEaUVYL5ohHjBP0s0tC99/PilKyBumNFDM= 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-api@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--