[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL v2 24/38] linux-user: Use safe_syscall for open and o
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PULL v2 24/38] linux-user: Use safe_syscall for open and openat system calls |
Date: |
Fri, 27 May 2016 16:00:15 +0300 |
From: Timothy E Baldwin <address@hidden>
Restart open() and openat() if signals occur before,
or during with SA_RESTART.
Signed-off-by: Timothy Edward Baldwin <address@hidden>
Message-id: address@hidden
[PMM: Adjusted to follow new -1-and-set-errno safe_syscall convention]
Signed-off-by: Peter Maydell <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/syscall.c | 18 ++++--------------
1 file changed, 4 insertions(+), 14 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index bee1360..0037ee7 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -359,18 +359,6 @@ static int sys_getcwd1(char *buf, size_t size)
return strlen(buf)+1;
}
-static int sys_openat(int dirfd, const char *pathname, int flags, mode_t mode)
-{
- /*
- * open(2) has extra parameter 'mode' when called with
- * flag O_CREAT.
- */
- if ((flags & O_CREAT) != 0) {
- return (openat(dirfd, pathname, flags, mode));
- }
- return (openat(dirfd, pathname, flags));
-}
-
#ifdef TARGET_NR_utimensat
#ifdef CONFIG_UTIMENSAT
static int sys_utimensat(int dirfd, const char *pathname,
@@ -709,6 +697,8 @@ static type safe_##name(type1 arg1, type2 arg2, type3 arg3,
type4 arg4, \
safe_syscall3(ssize_t, read, int, fd, void *, buff, size_t, count)
safe_syscall3(ssize_t, write, int, fd, const void *, buff, size_t, count)
+safe_syscall4(int, openat, int, dirfd, const char *, pathname, \
+ int, flags, mode_t, mode)
static inline int host_to_target_sock_type(int host_type)
{
@@ -5851,7 +5841,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 : sys_openat(dirfd, exec_path, flags, mode);
+ return execfd ? execfd : safe_openat(dirfd, exec_path, flags, mode);
}
for (fake_open = fakes; fake_open->filename; fake_open++) {
@@ -5887,7 +5877,7 @@ static int do_openat(void *cpu_env, int dirfd, const char
*pathname, int flags,
return fd;
}
- return sys_openat(dirfd, path(pathname), flags, mode);
+ return safe_openat(dirfd, path(pathname), flags, mode);
}
#define TIMER_MAGIC 0x0caf0000
--
2.1.4
- [Qemu-devel] [PULL v2 13/38] linux-user: Support for restarting system calls for UniCore32 targets, (continued)
- [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
- [Qemu-devel] [PULL v2 17/38] linux-user: Support for restarting system calls for CRIS targets, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 18/38] linux-user: Support for restarting system calls for tilegx targets, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 23/38] linux-user: Use safe_syscall for read and write system calls, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 20/38] linux-user: Support for restarting system calls for Microblaze targets, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 21/38] linux-user: Add debug code to exercise restarting system calls, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 19/38] linux-user: Set r14 on exit from microblaze syscall, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 22/38] linux-user: Provide safe_syscall for fixing races between signals and syscalls, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 24/38] linux-user: Use safe_syscall for open and openat system calls,
riku . voipio <=
- [Qemu-devel] [PULL v2 25/38] linux-user: Use safe_syscall for wait system calls, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 29/38] linux-user: Handle negative values in timespec conversion, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 26/38] linux-user: Use safe_syscall for execve syscall, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 27/38] linux-user: Use safe_syscall for pselect, select syscalls, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 28/38] linux-user: Use safe_syscall for futex syscall, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 31/38] linux-user: Use g_try_malloc() in do_msgrcv(), riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 33/38] linux-user: Use direct syscalls for setuid(), etc, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 34/38] linux-user: arm: Remove ARM_cpsr and similar #defines, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 30/38] linux-user: Handle msgrcv error case correctly, riku . voipio, 2016/05/27
- [Qemu-devel] [PULL v2 32/38] linux-user: x86_64: Don't use 16-bit UIDs, riku . voipio, 2016/05/27