[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 02/38] linux-user: Consistently return host errnos
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PULL v2 02/38] linux-user: Consistently return host errnos from do_openat() |
Date: |
Fri, 27 May 2016 15:59:53 +0300 |
From: Peter Maydell <address@hidden>
The function do_openat() is not consistent about whether it is
returning a host errno or a guest errno in case of failure.
Standardise on returning -1 with errno set (ie caller has
to call get_errno()).
Signed-off-by: Peter Maydell <address@hidden>
Reported-by: Timothy Edward Baldwin <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
Reviewed-by: Laurent Vivier <address@hidden>
---
linux-user/syscall.c | 14 ++++++++++----
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 5246f36..f4c2e19 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5559,7 +5559,9 @@ static int open_self_cmdline(void *cpu_env, int fd)
nb_read = read(fd_orig, buf, sizeof(buf));
if (nb_read < 0) {
+ int e = errno;
fd_orig = close(fd_orig);
+ errno = e;
return -1;
} else if (nb_read == 0) {
break;
@@ -5579,7 +5581,9 @@ static int open_self_cmdline(void *cpu_env, int fd)
if (word_skipped) {
if (write(fd, cp_buf, nb_read) != nb_read) {
+ int e = errno;
close(fd_orig);
+ errno = e;
return -1;
}
}
@@ -5599,7 +5603,7 @@ static int open_self_maps(void *cpu_env, int fd)
fp = fopen("/proc/self/maps", "r");
if (fp == NULL) {
- return -EACCES;
+ return -1;
}
while ((read = getline(&line, &len, fp)) != -1) {
@@ -5743,7 +5747,7 @@ static int open_net_route(void *cpu_env, int fd)
fp = fopen("/proc/net/route", "r");
if (fp == NULL) {
- return -EACCES;
+ return -1;
}
/* read header */
@@ -5793,7 +5797,7 @@ static int do_openat(void *cpu_env, int dirfd, const char
*pathname, int flags,
if (is_proc_myself(pathname, "exe")) {
int execfd = qemu_getauxval(AT_EXECFD);
- return execfd ? execfd : get_errno(sys_openat(dirfd, exec_path, flags,
mode));
+ return execfd ? execfd : sys_openat(dirfd, exec_path, flags, mode);
}
for (fake_open = fakes; fake_open->filename; fake_open++) {
@@ -5819,7 +5823,9 @@ static int do_openat(void *cpu_env, int dirfd, const char
*pathname, int flags,
unlink(filename);
if ((r = fake_open->fill(cpu_env, fd))) {
+ int e = errno;
close(fd);
+ errno = e;
return r;
}
lseek(fd, 0, SEEK_SET);
@@ -5827,7 +5833,7 @@ static int do_openat(void *cpu_env, int dirfd, const char
*pathname, int flags,
return fd;
}
- return get_errno(sys_openat(dirfd, path(pathname), flags, mode));
+ return sys_openat(dirfd, path(pathname), flags, mode);
}
#define TIMER_MAGIC 0x0caf0000
--
2.1.4
- [Qemu-devel] [PULL v2 00/38] linux-user pull request, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 04/38] linux-user: Define TARGET_ERESTART* errno values, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 01/38] linux-user: Check array bounds in errno conversion, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 06/38] linux-user: Support for restarting system calls for x86 targets, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 09/38] linux-user: Support for restarting system calls for PPC targets, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 08/38] linux-user: Support for restarting system calls for MIPS targets, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 02/38] linux-user: Consistently return host errnos from do_openat(),
riku . voipio <=
- [Qemu-devel] [PULL v2 07/38] linux-user: Support for restarting system calls for ARM targets, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 03/38] linux-user: Reindent signal handling, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 05/38] linux-user: Renumber TARGET_QEMU_ESIGRETURN, make it not arch-specific, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 10/38] linux-user: Support for restarting system calls for SPARC targets, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 16/38] linux-user: Support for restarting system calls for S390 targets, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 11/38] linux-user: Support for restarting system calls for SH4 targets, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 14/38] linux-user: Support for restarting system calls for OpenRISC targets, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 13/38] linux-user: Support for restarting system calls for UniCore32 targets, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 15/38] linux-user: Support for restarting system calls for M68K targets, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 12/38] linux-user: Support for restarting system calls for Alpha targets, riku . voipio, 2016/05/27