Linux XFS filesystem development
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: djwong@kernel.org, miklos@szeredi.hu
Cc: joannelkoong@gmail.com, bernd@bsbernd.com,
	linux-xfs@vger.kernel.org, John@groves.net,
	linux-fsdevel@vger.kernel.org, neal@gompa.dev,
	joannelkoong@gmail.com
Subject: [PATCH 5/8] fuse: implement file attributes mask for statx
Date: Mon, 15 Sep 2025 17:25:19 -0700	[thread overview]
Message-ID: <175798150135.381990.13601554069647977877.stgit@frogsfrogsfrogs> (raw)
In-Reply-To: <175798149979.381990.14913079500562122255.stgit@frogsfrogsfrogs>

From: Darrick J. Wong <djwong@kernel.org>

Actually copy the attributes/attributes_mask from userspace.  Ignore
file attributes bits that the VFS sets (or doesn't set) on its own.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
Reviewed-by: Joanne Koong <joannelkoong@gmail.com>
---
 fs/fuse/fuse_i.h |   37 +++++++++++++++++++++++++++++++++++++
 fs/fuse/dir.c    |    4 ++++
 fs/fuse/inode.c  |    3 +++
 3 files changed, 44 insertions(+)


diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h
index e13e8270f4f58d..52776b77efc0e4 100644
--- a/fs/fuse/fuse_i.h
+++ b/fs/fuse/fuse_i.h
@@ -140,6 +140,10 @@ struct fuse_inode {
 	/** Version of last attribute change */
 	u64 attr_version;
 
+	/** statx file attributes */
+	u64 statx_attributes;
+	u64 statx_attributes_mask;
+
 	union {
 		/* read/write io cache (regular file only) */
 		struct {
@@ -1221,6 +1225,39 @@ void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
 				   u64 attr_valid, u32 cache_mask,
 				   u64 evict_ctr);
 
+/*
+ * These statx attribute flags are set by the VFS so mask them out of replies
+ * from the fuse server for local filesystems.  Nonlocal filesystems are
+ * responsible for enforcing and advertising these flags themselves.
+ */
+#define FUSE_STATX_LOCAL_VFS_ATTRIBUTES (STATX_ATTR_IMMUTABLE | \
+					 STATX_ATTR_APPEND)
+
+/*
+ * These statx attribute flags are set by the VFS so mask them out of replies
+ * from the fuse server.
+ */
+#define FUSE_STATX_VFS_ATTRIBUTES (STATX_ATTR_AUTOMOUNT | STATX_ATTR_DAX | \
+				   STATX_ATTR_MOUNT_ROOT)
+
+static inline u64 fuse_statx_attributes_mask(const struct fuse_conn *fc,
+					     const struct fuse_statx *sx)
+{
+	if (fc->local_fs)
+		return sx->attributes_mask & ~(FUSE_STATX_VFS_ATTRIBUTES |
+					       FUSE_STATX_LOCAL_VFS_ATTRIBUTES);
+	return sx->attributes_mask & ~FUSE_STATX_VFS_ATTRIBUTES;
+}
+
+static inline u64 fuse_statx_attributes(const struct fuse_conn *fc,
+					const struct fuse_statx *sx)
+{
+	if (fc->local_fs)
+		return sx->attributes & ~(FUSE_STATX_VFS_ATTRIBUTES |
+					  FUSE_STATX_LOCAL_VFS_ATTRIBUTES);
+	return sx->attributes & ~FUSE_STATX_VFS_ATTRIBUTES;
+}
+
 u32 fuse_get_cache_mask(struct inode *inode);
 
 /**
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c
index 5c569c3cb53f3d..a7f47e43692f1c 100644
--- a/fs/fuse/dir.c
+++ b/fs/fuse/dir.c
@@ -1278,6 +1278,8 @@ static int fuse_do_statx(struct mnt_idmap *idmap, struct inode *inode,
 		stat->result_mask = sx->mask & (STATX_BASIC_STATS | STATX_BTIME);
 		stat->btime.tv_sec = sx->btime.tv_sec;
 		stat->btime.tv_nsec = min_t(u32, sx->btime.tv_nsec, NSEC_PER_SEC - 1);
+		stat->attributes |= fuse_statx_attributes(fm->fc, sx);
+		stat->attributes_mask |= fuse_statx_attributes_mask(fm->fc, sx);
 		fuse_fillattr(idmap, inode, &attr, stat);
 		stat->result_mask |= STATX_TYPE;
 	}
@@ -1382,6 +1384,8 @@ static int fuse_update_get_attr(struct mnt_idmap *idmap, struct inode *inode,
 			stat->btime = fi->i_btime;
 			stat->result_mask |= STATX_BTIME;
 		}
+		stat->attributes = fi->statx_attributes;
+		stat->attributes_mask = fi->statx_attributes_mask;
 	}
 
 	return err;
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c
index c8dd0bcb7e6f9f..55db991bb6b8c1 100644
--- a/fs/fuse/inode.c
+++ b/fs/fuse/inode.c
@@ -287,6 +287,9 @@ void fuse_change_attributes_common(struct inode *inode, struct fuse_attr *attr,
 			fi->i_btime.tv_sec = sx->btime.tv_sec;
 			fi->i_btime.tv_nsec = sx->btime.tv_nsec;
 		}
+
+		fi->statx_attributes = fuse_statx_attributes(fc, sx);
+		fi->statx_attributes_mask = fuse_statx_attributes_mask(fc, sx);
 	}
 
 	if (attr->blksize)


  parent reply	other threads:[~2025-09-16  0:25 UTC|newest]

Thread overview: 126+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20250916000759.GA8080@frogsfrogsfrogs>
2025-09-16  0:18 ` [PATCHSET RFC v5 1/8] fuse: general bug fixes Darrick J. Wong
2025-09-16  0:24   ` [PATCH 1/8] fuse: fix livelock in synchronous file put from fuseblk workers Darrick J. Wong
2025-09-23 10:57     ` Miklos Szeredi
2025-09-16  0:24   ` [PATCH 2/8] fuse: flush pending fuse events before aborting the connection Darrick J. Wong
2025-09-23 11:11     ` Miklos Szeredi
2025-09-23 14:54       ` Darrick J. Wong
2025-09-23 18:56         ` Miklos Szeredi
2025-09-23 20:59           ` Darrick J. Wong
2025-09-23 22:34             ` Darrick J. Wong
2025-09-24 12:04               ` Miklos Szeredi
2025-09-24 17:50                 ` Darrick J. Wong
2025-09-24 18:19                   ` Miklos Szeredi
2025-09-24 20:54                     ` Darrick J. Wong
2025-09-30 10:29                       ` Miklos Szeredi
2025-09-30 17:56                         ` Darrick J. Wong
2025-09-16  0:24   ` [PATCH 3/8] fuse: capture the unique id of fuse commands being sent Darrick J. Wong
2025-09-23 10:58     ` Miklos Szeredi
2025-09-16  0:25   ` [PATCH 4/8] fuse: signal that a fuse filesystem should exhibit local fs behaviors Darrick J. Wong
2025-09-17 17:18     ` Joanne Koong
2025-09-18 16:52       ` Darrick J. Wong
2025-09-19  9:24         ` Miklos Szeredi
2025-09-19 17:50           ` Darrick J. Wong
2025-09-23 14:57             ` Miklos Szeredi
2025-09-23 20:51               ` Darrick J. Wong
2025-09-24 13:55                 ` Miklos Szeredi
2025-09-24 17:31                   ` Darrick J. Wong
2025-09-25 19:17                     ` Darrick J. Wong
2025-09-16  0:25   ` Darrick J. Wong [this message]
2025-09-16  0:25   ` [PATCH 6/8] fuse: update file mode when updating acls Darrick J. Wong
2025-09-16  0:25   ` [PATCH 7/8] fuse: propagate default and file acls on creation Darrick J. Wong
2025-09-16  6:41     ` Chen Linxuan
2025-09-16 14:48       ` Darrick J. Wong
2025-09-16  0:26   ` [PATCH 8/8] fuse: enable FUSE_SYNCFS for all fuseblk servers Darrick J. Wong
2025-09-23 10:58     ` Miklos Szeredi
2025-09-16  0:18 ` [PATCHSET RFC v5 2/8] iomap: cleanups ahead of adding fuse support Darrick J. Wong
2025-09-16  0:26   ` [PATCH 1/2] iomap: trace iomap_zero_iter zeroing activities Darrick J. Wong
2025-09-16 13:49     ` Christoph Hellwig
2025-09-16 14:49       ` Darrick J. Wong
2025-09-16  0:26   ` [PATCH 2/2] iomap: error out on file IO when there is no inline_data buffer Darrick J. Wong
2025-09-16 13:50     ` Christoph Hellwig
2025-09-16 14:50       ` Darrick J. Wong
2025-09-16  0:18 ` [PATCHSET RFC v5 3/8] fuse: cleanups ahead of adding fuse support Darrick J. Wong
2025-09-16  0:26   ` [PATCH 1/5] fuse: allow synchronous FUSE_INIT Darrick J. Wong
2025-09-17 17:22     ` Joanne Koong
2025-09-18 18:04       ` Darrick J. Wong
2025-09-16  0:27   ` [PATCH 2/5] fuse: move the backing file idr and code into a new source file Darrick J. Wong
2025-09-25 14:11     ` Miklos Szeredi
2025-09-16  0:27   ` [PATCH 3/5] fuse: move the passthrough-specific code back to passthrough.c Darrick J. Wong
2025-09-17  2:47     ` Amir Goldstein
2025-09-18 18:02       ` Darrick J. Wong
2025-09-19  7:34         ` Miklos Szeredi
2025-09-19  9:36           ` Amir Goldstein
2025-09-19 17:43           ` Darrick J. Wong
2025-09-16  0:27   ` [PATCH 4/5] fuse_trace: " Darrick J. Wong
2025-09-16  0:27   ` [PATCH 5/5] fuse: move CREATE_TRACE_POINTS to a separate file Darrick J. Wong
2025-09-25 14:25     ` Miklos Szeredi
2025-09-16  0:19 ` [PATCHSET RFC v5 4/8] fuse: allow servers to use iomap for better file IO performance Darrick J. Wong
2025-09-16  0:28   ` [PATCH 01/28] fuse: implement the basic iomap mechanisms Darrick J. Wong
2025-09-19 22:36     ` Joanne Koong
2025-09-23 20:32       ` Darrick J. Wong
2025-09-23 21:24         ` Joanne Koong
2025-09-23 22:10           ` Darrick J. Wong
2025-09-23 23:08             ` Darrick J. Wong
2025-09-16  0:28   ` [PATCH 02/28] fuse_trace: " Darrick J. Wong
2025-09-16  0:28   ` [PATCH 03/28] fuse: make debugging configurable at runtime Darrick J. Wong
2025-09-16  0:29   ` [PATCH 04/28] fuse: adapt FUSE_DEV_IOC_BACKING_{OPEN,CLOSE} to add new iomap devices Darrick J. Wong
2025-09-17  3:09     ` Amir Goldstein
2025-09-18 18:17       ` Darrick J. Wong
2025-09-18 18:42         ` Amir Goldstein
2025-09-18 19:03           ` Darrick J. Wong
2025-09-19  7:13           ` Miklos Szeredi
2025-09-19  9:54             ` Amir Goldstein
2025-09-19 17:42               ` Darrick J. Wong
2025-09-23  7:10                 ` Miklos Szeredi
2025-09-16  0:29   ` [PATCH 05/28] fuse_trace: " Darrick J. Wong
2025-09-16  0:29   ` [PATCH 06/28] fuse: flush events and send FUSE_SYNCFS and FUSE_DESTROY on unmount Darrick J. Wong
2025-09-16  0:29   ` [PATCH 07/28] fuse: create a per-inode flag for toggling iomap Darrick J. Wong
2025-09-16  0:30   ` [PATCH 08/28] fuse_trace: " Darrick J. Wong
2025-09-16  0:30   ` [PATCH 09/28] fuse: isolate the other regular file IO paths from iomap Darrick J. Wong
2025-09-16  0:30   ` [PATCH 10/28] fuse: implement basic iomap reporting such as FIEMAP and SEEK_{DATA,HOLE} Darrick J. Wong
2025-09-16  0:30   ` [PATCH 11/28] fuse_trace: " Darrick J. Wong
2025-09-16  0:31   ` [PATCH 12/28] fuse: implement direct IO with iomap Darrick J. Wong
2025-09-16  0:31   ` [PATCH 13/28] fuse_trace: " Darrick J. Wong
2025-09-16  0:31   ` [PATCH 14/28] fuse: implement buffered " Darrick J. Wong
2025-09-16  0:31   ` [PATCH 15/28] fuse_trace: " Darrick J. Wong
2025-09-16  0:32   ` [PATCH 16/28] fuse: implement large folios for iomap pagecache files Darrick J. Wong
2025-09-16  0:32   ` [PATCH 17/28] fuse: use an unrestricted backing device with iomap pagecache io Darrick J. Wong
2025-09-16  0:32   ` [PATCH 18/28] fuse: advertise support for iomap Darrick J. Wong
2025-09-16  0:32   ` [PATCH 19/28] fuse: query filesystem geometry when using iomap Darrick J. Wong
2025-09-16  0:33   ` [PATCH 20/28] fuse_trace: " Darrick J. Wong
2025-09-16  0:33   ` [PATCH 21/28] fuse: implement fadvise for iomap files Darrick J. Wong
2025-09-16  0:33   ` [PATCH 22/28] fuse: invalidate ranges of block devices being used for iomap Darrick J. Wong
2025-09-16  0:33   ` [PATCH 23/28] fuse_trace: " Darrick J. Wong
2025-09-16  0:34   ` [PATCH 24/28] fuse: implement inline data file IO via iomap Darrick J. Wong
2025-09-16  0:34   ` [PATCH 25/28] fuse_trace: " Darrick J. Wong
2025-09-16  0:34   ` [PATCH 26/28] fuse: allow more statx fields Darrick J. Wong
2025-09-16  0:35   ` [PATCH 27/28] fuse: support atomic writes with iomap Darrick J. Wong
2025-09-16  0:35   ` [PATCH 28/28] fuse: disable direct reclaim for any fuse server that uses iomap Darrick J. Wong
2025-09-16  0:19 ` [PATCHSET RFC v5 5/8] fuse: allow servers to specify root node id Darrick J. Wong
2025-09-16  0:35   ` [PATCH 1/3] fuse: make the root nodeid dynamic Darrick J. Wong
2025-09-16  0:35   ` [PATCH 2/3] fuse_trace: " Darrick J. Wong
2025-09-16  0:36   ` [PATCH 3/3] fuse: allow setting of root nodeid Darrick J. Wong
2025-09-16  0:19 ` [PATCHSET RFC v5 6/8] fuse: handle timestamps and ACLs correctly when iomap is enabled Darrick J. Wong
2025-09-16  0:36   ` [PATCH 1/9] fuse: enable caching of timestamps Darrick J. Wong
2025-09-16  0:36   ` [PATCH 2/9] fuse: force a ctime update after a fileattr_set call when in iomap mode Darrick J. Wong
2025-09-16  0:36   ` [PATCH 3/9] fuse: allow local filesystems to set some VFS iflags Darrick J. Wong
2025-09-16  0:37   ` [PATCH 4/9] fuse_trace: " Darrick J. Wong
2025-09-16  0:37   ` [PATCH 5/9] fuse: cache atime when in iomap mode Darrick J. Wong
2025-09-16  0:37   ` [PATCH 6/9] fuse: let the kernel handle KILL_SUID/KILL_SGID for iomap filesystems Darrick J. Wong
2025-09-16  0:37   ` [PATCH 7/9] fuse_trace: " Darrick J. Wong
2025-09-16  0:38   ` [PATCH 8/9] fuse: update ctime when updating acls on an iomap inode Darrick J. Wong
2025-09-16  0:38   ` [PATCH 9/9] fuse: always cache ACLs when using iomap Darrick J. Wong
2025-09-16  0:19 ` [PATCHSET RFC v5 7/8] fuse: cache iomap mappings for even better file IO performance Darrick J. Wong
2025-09-16  0:38   ` [PATCH 01/10] fuse: cache iomaps Darrick J. Wong
2025-09-16  0:38   ` [PATCH 02/10] fuse_trace: " Darrick J. Wong
2025-09-16  0:39   ` [PATCH 03/10] fuse: use the iomap cache for iomap_begin Darrick J. Wong
2025-09-16  0:39   ` [PATCH 04/10] fuse_trace: " Darrick J. Wong
2025-09-16  0:39   ` [PATCH 05/10] fuse: invalidate iomap cache after file updates Darrick J. Wong
2025-09-16  0:39   ` [PATCH 06/10] fuse_trace: " Darrick J. Wong
2025-09-16  0:40   ` [PATCH 07/10] fuse: enable iomap cache management Darrick J. Wong
2025-09-16  0:40   ` [PATCH 08/10] fuse_trace: " Darrick J. Wong
2025-09-16  0:40   ` [PATCH 09/10] fuse: overlay iomap inode info in struct fuse_inode Darrick J. Wong
2025-09-16  0:41   ` [PATCH 10/10] fuse: enable iomap Darrick J. Wong
2025-09-16  0:20 ` [PATCHSET RFC v5 8/8] fuse: run fuse servers as a contained service Darrick J. Wong
2025-09-16  0:41   ` [PATCH 1/2] fuse: allow privileged mount helpers to pre-approve iomap usage Darrick J. Wong
2025-09-16  0:41   ` [PATCH 2/2] fuse: set iomap backing device block size Darrick J. Wong

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=175798150135.381990.13601554069647977877.stgit@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=John@groves.net \
    --cc=bernd@bsbernd.com \
    --cc=joannelkoong@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --cc=neal@gompa.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