[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 02/10] linux-user: redirect openat calls
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PATCH 02/10] linux-user: redirect openat calls |
Date: |
Tue, 12 Aug 2014 16:42:12 +0300 |
From: Riku Voipio <address@hidden>
While Mikhail fixed /proc/self/maps, it was noticed openat calls are
not redirected currently. Some archs don't have open at all, so
openat needs to be redirected.
Fix this by consolidating open/openat code to do_openat - open
is implemented using openat(AT_FDCWD, ... ), which according
to open(2) man page is identical.
Since all targets now have openat, remove the ifdef around sys_openat
and openat: case in do_syscall.
Cc: Mikhail Ilin <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/syscall.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c8c2b4c..dd77673 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -294,7 +294,6 @@ static int sys_getcwd1(char *buf, size_t size)
return strlen(buf)+1;
}
-#ifdef TARGET_NR_openat
static int sys_openat(int dirfd, const char *pathname, int flags, mode_t mode)
{
/*
@@ -306,7 +305,6 @@ static int sys_openat(int dirfd, const char *pathname, int
flags, mode_t mode)
}
return (openat(dirfd, pathname, flags));
}
-#endif
#ifdef TARGET_NR_utimensat
#ifdef CONFIG_UTIMENSAT
@@ -5274,7 +5272,7 @@ static int open_net_route(void *cpu_env, int fd)
}
#endif
-static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode)
+static int do_openat(void *cpu_env, int dirfd, const char *pathname, int
flags, mode_t mode)
{
struct fake_open {
const char *filename;
@@ -5295,7 +5293,7 @@ static int do_open(void *cpu_env, const char *pathname,
int flags, mode_t mode)
if (is_proc_myself(pathname, "exe")) {
int execfd = qemu_getauxval(AT_EXECFD);
- return execfd ? execfd : get_errno(open(exec_path, flags, mode));
+ return execfd ? execfd : get_errno(sys_openat(dirfd, exec_path, flags,
mode));
}
for (fake_open = fakes; fake_open->filename; fake_open++) {
@@ -5329,7 +5327,7 @@ static int do_open(void *cpu_env, const char *pathname,
int flags, mode_t mode)
return fd;
}
- return get_errno(open(path(pathname), flags, mode));
+ return get_errno(sys_openat(dirfd, path(pathname), flags, mode));
}
/* do_syscall() should always have a single exit point at the end so
@@ -5404,22 +5402,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
arg1,
case TARGET_NR_open:
if (!(p = lock_user_string(arg1)))
goto efault;
- ret = get_errno(do_open(cpu_env, p,
- target_to_host_bitmask(arg2, fcntl_flags_tbl),
- arg3));
+ ret = get_errno(do_openat(cpu_env, AT_FDCWD, p,
+ target_to_host_bitmask(arg2,
fcntl_flags_tbl),
+ arg3));
unlock_user(p, arg1, 0);
break;
-#if defined(TARGET_NR_openat) && defined(__NR_openat)
case TARGET_NR_openat:
if (!(p = lock_user_string(arg2)))
goto efault;
- ret = get_errno(sys_openat(arg1,
- path(p),
- target_to_host_bitmask(arg3,
fcntl_flags_tbl),
- arg4));
+ ret = get_errno(do_openat(cpu_env, arg1, p,
+ target_to_host_bitmask(arg3,
fcntl_flags_tbl),
+ arg4));
unlock_user(p, arg2, 0);
break;
-#endif
case TARGET_NR_close:
ret = get_errno(close(arg1));
break;
--
2.0.1
- [Qemu-devel] [PATCH 00/10] linux-user update, riku . voipio, 2014/08/12
- [Qemu-devel] [PATCH 01/10] linux-user: /proc/self/maps content, riku . voipio, 2014/08/12
- [Qemu-devel] [PATCH 06/10] linux-user: fix readlink handling with magic exe symlink, riku . voipio, 2014/08/12
- [Qemu-devel] [PATCH 09/10] linux-user: support {name_to, open_by}_handle_at syscalls, riku . voipio, 2014/08/12
- [Qemu-devel] [PATCH 10/10] linux-user: add setns and unshare, riku . voipio, 2014/08/12
- [Qemu-devel] [PATCH 03/10] linux-user: make binfmt flag O require P, riku . voipio, 2014/08/12
- [Qemu-devel] [PATCH 05/10] linux-user: Fix conversion of sigevent argument to timer_create, riku . voipio, 2014/08/12
- [Qemu-devel] [PATCH 08/10] linux-user: support ioprio_{get, set} syscalls, riku . voipio, 2014/08/12
- [Qemu-devel] [PATCH 07/10] linux-user: support timerfd_{create, gettime, settime} syscalls, riku . voipio, 2014/08/12
- [Qemu-devel] [PATCH 04/10] linux-user: Fix syscall instruction usermode emulation on X86_64, riku . voipio, 2014/08/12
- [Qemu-devel] [PATCH 02/10] linux-user: redirect openat calls,
riku . voipio <=