Whamcloud - gitweb
fuse2fs: simplify reading and writing inodes
authorDarrick J. Wong <djwong@kernel.org>
Wed, 21 May 2025 22:43:01 +0000 (15:43 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 23 May 2025 13:41:20 +0000 (09:41 -0400)
Wrap the inode read and write methods in a wrapper so that we don't have
to maintain all these silly casts and sizeof operators.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786678229.1384866.9795826246954895736.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/fuse2fs.c

index e8417d1..f2d613d 100644 (file)
@@ -315,6 +315,21 @@ do {                                                                              \
                (timespec)->tv_nsec = 0;                                       \
 } while (0)
 
+static inline errcode_t fuse2fs_read_inode(ext2_filsys fs, ext2_ino_t ino,
+                                          struct ext2_inode_large *inode)
+{
+       memset(inode, 0, sizeof(*inode));
+       return ext2fs_read_inode_full(fs, ino, EXT2_INODE(inode),
+                                     sizeof(*inode));
+}
+
+static inline errcode_t fuse2fs_write_inode(ext2_filsys fs, ext2_ino_t ino,
+                                           struct ext2_inode_large *inode)
+{
+       return ext2fs_write_inode_full(fs, ino, EXT2_INODE(inode),
+                                      sizeof(*inode));
+}
+
 static void get_now(struct timespec *now)
 {
 #ifdef CLOCK_REALTIME