]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
fuse2fs: fix error return handling in op_truncate
authorDarrick J. Wong <djwong@kernel.org>
Wed, 21 May 2025 22:36:44 +0000 (15:36 -0700)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 23 May 2025 13:36:19 +0000 (09:36 -0400)
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 <djwong@kernel.org>
Link: https://lore.kernel.org/r/174786677675.1383760.13355151028679279614.stgit@frogsfrogsfrogs
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
misc/fuse2fs.c

index e33a0a8811d53ff9495f0333c1bb5fb1fce7751d..2a4e77c3f1e7deb57ccaf85f9b92f6de64dfaf35 100644 (file)
@@ -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);