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>
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);