From: Darrick J. Wong Date: Wed, 21 May 2025 22:43:01 +0000 (-0700) Subject: fuse2fs: simplify reading and writing inodes X-Git-Tag: v1.47.3-rc1~39 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7607e348ab22fcf1381bb0b832c922a5fbe6337e;p=thirdparty%2Fe2fsprogs.git fuse2fs: simplify reading and writing inodes 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 Link: https://lore.kernel.org/r/174786678229.1384866.9795826246954895736.stgit@frogsfrogsfrogs Signed-off-by: Theodore Ts'o --- diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index e8417d19..f2d613d8 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -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