summaryrefslogtreecommitdiffstats
path: root/linux-user/syscall.c
diff options
context:
space:
mode:
authorTimothy E Baldwin2016-05-12 19:47:48 +0200
committerRiku Voipio2016-05-27 13:50:38 +0200
commitc10a07387b77b94d8f7233f3b5bb559211d4e49a (patch)
tree3e0e38e00c326c57282ac2c620d84ae6acd68fcf /linux-user/syscall.c
parentlinux-user: Use safe_syscall for read and write system calls (diff)
downloadqemu-c10a07387b77b94d8f7233f3b5bb559211d4e49a.tar.gz
qemu-c10a07387b77b94d8f7233f3b5bb559211d4e49a.tar.xz
qemu-c10a07387b77b94d8f7233f3b5bb559211d4e49a.zip
linux-user: Use safe_syscall for open and openat system calls
Restart open() and openat() if signals occur before, or during with SA_RESTART. Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk> Message-id: 1441497448-32489-17-git-send-email-T.E.Baldwin99@members.leeds.ac.uk [PMM: Adjusted to follow new -1-and-set-errno safe_syscall convention] Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
Diffstat (limited to 'linux-user/syscall.c')
-rw-r--r--linux-user/syscall.c18
1 files changed, 4 insertions, 14 deletions
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index bee13607be..0037ee7dd7 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