@@ -7908,6 +7908,22 @@ IMPL(close)
return get_errno(close(arg1));
}
+#ifdef TARGET_NR_creat
+IMPL(creat)
+{
+ char *p = lock_user_string(arg1);
+ abi_long ret;
+
+ if (!p) {
+ return -TARGET_EFAULT;
+ }
+ ret = get_errno(creat(p, arg2));
+ fd_trans_unregister(ret);
+ unlock_user(p, arg1, 0);
+ return ret;
+}
+#endif
+
IMPL(execve)
{
abi_ulong *guest_ptrs;
@@ -8055,6 +8071,13 @@ IMPL(exit)
g_assert_not_reached();
}
+#ifdef TARGET_NR_fork
+IMPL(fork)
+{
+ return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0));
+}
+#endif
+
#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
IMPL(name_to_handle_at)
{
@@ -8216,6 +8239,40 @@ IMPL(read)
return ret;
}
+#ifdef TARGET_NR_waitid
+IMPL(waitid)
+{
+ siginfo_t info;
+ abi_long ret;
+
+ info.si_pid = 0;
+ ret = get_errno(safe_waitid(arg1, arg2, &info, arg4, NULL));
+ if (!is_error(ret) && arg3 && info.si_pid != 0) {
+ target_siginfo_t *p
+ = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0);
+ if (!p) {
+ return -TARGET_EFAULT;
+ }
+ host_to_target_siginfo(p, &info);
+ unlock_user(p, arg3, sizeof(target_siginfo_t));
+ }
+ return ret;
+}
+#endif
+
+#ifdef TARGET_NR_waitpid
+IMPL(waitpid)
+{
+ int status;
+ abi_long ret = get_errno(safe_wait4(arg1, &status, arg3, 0));
+ if (!is_error(ret) && arg2 && ret &&
+ put_user_s32(host_to_target_waitstatus(status), arg2)) {
+ return -TARGET_EFAULT;
+ }
+ return ret;
+}
+#endif
+
IMPL(write)
{
abi_long ret;
@@ -8258,45 +8315,6 @@ IMPL(everything_else)
char *fn;
switch(num) {
-#ifdef TARGET_NR_fork
- case TARGET_NR_fork:
- return get_errno(do_fork(cpu_env, TARGET_SIGCHLD, 0, 0, 0, 0));
-#endif
-#ifdef TARGET_NR_waitpid
- case TARGET_NR_waitpid:
- {
- int status;
- ret = get_errno(safe_wait4(arg1, &status, arg3, 0));
- if (!is_error(ret) && arg2 && ret
- && put_user_s32(host_to_target_waitstatus(status), arg2))
- return -TARGET_EFAULT;
- }
- return ret;
-#endif
-#ifdef TARGET_NR_waitid
- case TARGET_NR_waitid:
- {
- siginfo_t info;
- info.si_pid = 0;
- ret = get_errno(safe_waitid(arg1, arg2, &info, arg4, NULL));
- if (!is_error(ret) && arg3 && info.si_pid != 0) {
- if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_siginfo_t), 0)))
- return -TARGET_EFAULT;
- host_to_target_siginfo(p, &info);
- unlock_user(p, arg3, sizeof(target_siginfo_t));
- }
- }
- return ret;
-#endif
-#ifdef TARGET_NR_creat /* not on alpha */
- case TARGET_NR_creat:
- if (!(p = lock_user_string(arg1)))
- return -TARGET_EFAULT;
- ret = get_errno(creat(p, arg2));
- fd_trans_unregister(ret);
- unlock_user(p, arg1, 0);
- return ret;
-#endif
#ifdef TARGET_NR_link
case TARGET_NR_link:
{
@@ -12932,8 +12950,14 @@ IMPL(everything_else)
static impl_fn * const syscall_table[] = {
[TARGET_NR_brk] = impl_brk,
[TARGET_NR_close] = impl_close,
+#ifdef TARGET_NR_creat
+ [TARGET_NR_creat] = impl_creat,
+#endif
[TARGET_NR_execve] = impl_execve,
[TARGET_NR_exit] = impl_exit,
+#ifdef TARGET_NR_fork
+ [TARGET_NR_fork] = impl_fork,
+#endif
#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
[TARGET_NR_name_to_handle_at] = impl_name_to_handle_at,
#endif
@@ -12945,6 +12969,12 @@ static impl_fn * const syscall_table[] = {
[TARGET_NR_open_by_handle_at] = impl_open_by_handle_at,
#endif
[TARGET_NR_read] = impl_read,
+#ifdef TARGET_NR_waitid
+ [TARGET_NR_waitid] = impl_waitid,
+#endif
+#ifdef TARGET_NR_waitpid
+ [TARGET_NR_waitpid] = impl_waitpid,
+#endif
[TARGET_NR_write] = impl_write,
};
Signed-off-by: Richard Henderson <richard.henderson@linaro.org> --- linux-user/syscall.c | 108 +++++++++++++++++++++++++++---------------- 1 file changed, 69 insertions(+), 39 deletions(-) -- 2.17.0