From 28e34290ff0dc11e9c5d8b8a1e5992cd0cc941fb Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 21 Jan 2013 14:30:32 +0000 Subject: [PATCH] fuse: If guestfs_last_errno returns 0, don't return no error to FUSE layer. guestfs_last_errno (g) == 0 doesn't mean "no error". It means the errno was not captured. In this case we have to substitute some sort of errno, so choose EINVAL arbitrarily. --- src/fuse.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/fuse.c b/src/fuse.c index 6243addd0..6d3fe1e3a 100644 --- a/src/fuse.c +++ b/src/fuse.c @@ -72,7 +72,18 @@ gl_lock_define_initialized (static, mount_local_lock); g->localmountpoint, __func__, ## __VA_ARGS__); \ } -#define RETURN_ERRNO return -guestfs_last_errno (g) +#define RETURN_ERRNO \ + do { \ + int ret_errno = guestfs_last_errno (g); \ + \ + /* 0 doesn't mean "no error". It means the errno was not \ + * captured. Therefore we have to substitute an errno here. \ + */ \ + if (ret_errno == 0) \ + ret_errno = EINVAL; \ + \ + return -ret_errno; \ + } while (0) static struct guestfs_xattr_list * copy_xattr_list (const struct guestfs_xattr *first, size_t num)