diff mbox series

[07/16] fuse2fs: report nanoseconds resolution through getattr

Message ID 174553065051.1160461.5080284869849276746.stgit@frogsfrogsfrogs
State New
Headers show
Series [01/16] fuse2fs: refuse unsupported features | expand

Commit Message

Darrick J. Wong April 24, 2025, 9:42 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Report the nanonseconds component of timestamps via getattr, and tell
fuse that we actually support nanosecond granularity.

Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
 misc/fuse2fs.c |    6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c
index d56d51207d1f25..bf4e592e7d2782 100644
--- a/misc/fuse2fs.c
+++ b/misc/fuse2fs.c
@@ -586,6 +586,9 @@  static void *op_init(struct fuse_conn_info *conn
 	dbg_printf(ff, "%s: dev=%s\n", __func__, fs->device_name);
 #ifdef FUSE_CAP_IOCTL_DIR
 	conn->want |= FUSE_CAP_IOCTL_DIR;
+#endif
+#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0)
+	conn->time_gran = 1;
 #endif
 	if (fs->flags & EXT2_FLAG_RW) {
 		fs->super->s_mnt_count++;
@@ -635,10 +638,13 @@  static int stat_inode(ext2_filsys fs, ext2_ino_t ino, struct stat *statbuf)
 						(struct ext2_inode *)&inode);
 	EXT4_INODE_GET_XTIME(i_atime, &tv, &inode);
 	statbuf->st_atime = tv.tv_sec;
+	statbuf->st_atim.tv_nsec = tv.tv_nsec;
 	EXT4_INODE_GET_XTIME(i_mtime, &tv, &inode);
 	statbuf->st_mtime = tv.tv_sec;
+	statbuf->st_mtim.tv_nsec = tv.tv_nsec;
 	EXT4_INODE_GET_XTIME(i_ctime, &tv, &inode);
 	statbuf->st_ctime = tv.tv_sec;
+	statbuf->st_ctim.tv_nsec = tv.tv_nsec;
 	if (LINUX_S_ISCHR(inode.i_mode) ||
 	    LINUX_S_ISBLK(inode.i_mode)) {
 		if (inode.i_block[0])