From: Darrick J. Wong Date: Wed, 21 May 2025 22:36:44 +0000 (-0700) Subject: fuse2fs: fix error return handling in op_truncate X-Git-Tag: v1.47.3-rc1~57 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=18c01ba6cfd542e7c966de685d4a225d81b95c57;p=thirdparty%2Fe2fsprogs.git fuse2fs: fix error return handling in op_truncate Fix a couple of bugs with the errcode/ret handling in op_truncate. First, we need to return ESTALE for a zero inumber because there is no inode zero in an ext* filesystem. Second, we need to return negative errno for failures to libfuse, not raw errcode_t. Cc: linux-ext4@vger.kernel.org # v1.43 Fixes: 81cbf1ef4f5dab ("misc: add fuse2fs, a FUSE server for e2fsprogs") Signed-off-by: Darrick J. Wong Link: https://lore.kernel.org/r/174786677675.1383760.13355151028679279614.stgit@frogsfrogsfrogs Signed-off-by: Theodore Ts'o --- diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index e33a0a88..2a4e77c3 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -1976,10 +1976,14 @@ static int op_truncate(const char *path, off_t len fs = ff->fs; pthread_mutex_lock(&ff->bfl); err = ext2fs_namei(fs, EXT2_ROOT_INO, EXT2_ROOT_INO, path, &ino); - if (err || ino == 0) { + if (err) { ret = translate_error(fs, 0, err); goto out; } + if (!ino) { + ret = -ESTALE; + goto out; + } dbg_printf(ff, "%s: ino=%d len=%jd\n", __func__, ino, (intmax_t) len); ret = check_inum_access(fs, ino, W_OK);