From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:45978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOoJr-0008Uv-Px for qemu-devel@nongnu.org; Thu, 18 Oct 2012 07:31:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TOoJj-0005WE-Ax for qemu-devel@nongnu.org; Thu, 18 Oct 2012 07:31:19 -0400 Received: from afflict.kos.to ([92.243.29.197]:57405) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TOoJj-0005Vn-4A for qemu-devel@nongnu.org; Thu, 18 Oct 2012 07:31:11 -0400 From: riku.voipio@linaro.org Date: Thu, 18 Oct 2012 14:31:03 +0300 Message-Id: <885c1d10b803fc37e6656e733ba916c702b6f515.1350559608.git.riku.voipio@linaro.org> In-Reply-To: References: Subject: [Qemu-devel] [PATCH 07/11] linux-user: If loading fails, print error as string, not number List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell From: Peter Maydell If the attempt to load the guest executable fails, print the error message as a string, not a number. This requires us to fix a couple of places in loader_exec() where we were returning -1 instead of a valid negative errno. The change allows us to drop the "Unknown binary format" message because the strerror-enhanced message is now a more self-explanatory "Error while loading $guest-binary: Exec format error". Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/linuxload.c | 8 ++++---- linux-user/main.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/linux-user/linuxload.c b/linux-user/linuxload.c index b47025f..381ab89 100644 --- a/linux-user/linuxload.c +++ b/linux-user/linuxload.c @@ -140,8 +140,9 @@ int loader_exec(const char * filename, char ** argv, char ** envp, bprm->p = TARGET_PAGE_SIZE*MAX_ARG_PAGES-sizeof(unsigned int); memset(bprm->page, 0, sizeof(bprm->page)); retval = open(filename, O_RDONLY); - if (retval < 0) - return retval; + if (retval < 0) { + return -errno; + } bprm->fd = retval; bprm->filename = (char *)filename; bprm->argc = count(argv); @@ -165,8 +166,7 @@ int loader_exec(const char * filename, char ** argv, char ** envp, retval = load_flt_binary(bprm,regs,infop); #endif } else { - fprintf(stderr, "Unknown binary format\n"); - return -1; + return -ENOEXEC; } } diff --git a/linux-user/main.c b/linux-user/main.c index 9f3476b..bcaadb6 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3569,7 +3569,7 @@ int main(int argc, char **argv, char **envp) ret = loader_exec(filename, target_argv, target_environ, regs, info, &bprm); if (ret != 0) { - printf("Error %d while loading %s\n", ret, filename); + printf("Error while loading %s: %s\n", filename, strerror(-ret)); _exit(1); } -- 1.7.9.5