syscall.c (64a563dd8dd6ca2661d96a2e4b69f0a5465cab94) syscall.c (5de154e82f4e507084f6c12b4ee300221ce078ce)
1/*
2 * Linux syscalls
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or

--- 6332 unchanged lines hidden (view full) ---

6341
6342 if (((flags & CLONE_THREAD_FLAGS) != CLONE_THREAD_FLAGS) ||
6343 (flags & CLONE_INVALID_THREAD_FLAGS)) {
6344 return -TARGET_EINVAL;
6345 }
6346
6347 ts = g_new0(TaskState, 1);
6348 init_task_state(ts);
1/*
2 * Linux syscalls
3 *
4 * Copyright (c) 2003 Fabrice Bellard
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or

--- 6332 unchanged lines hidden (view full) ---

6341
6342 if (((flags & CLONE_THREAD_FLAGS) != CLONE_THREAD_FLAGS) ||
6343 (flags & CLONE_INVALID_THREAD_FLAGS)) {
6344 return -TARGET_EINVAL;
6345 }
6346
6347 ts = g_new0(TaskState, 1);
6348 init_task_state(ts);
6349
6350 /* Grab a mutex so that thread setup appears atomic. */
6351 pthread_mutex_lock(&clone_lock);
6352
6353 /* we create a new CPU instance. */
6354 new_env = cpu_copy(env);
6355 /* Init regs that differ from the parent. */
6356 cpu_clone_regs(new_env, newsp);
6357 new_cpu = ENV_GET_CPU(new_env);
6358 new_cpu->opaque = ts;
6359 ts->bprm = parent_ts->bprm;
6360 ts->info = parent_ts->info;
6361 ts->signal_mask = parent_ts->signal_mask;
6362
6363 if (flags & CLONE_CHILD_CLEARTID) {
6364 ts->child_tidptr = child_tidptr;
6365 }
6366
6367 if (flags & CLONE_SETTLS) {
6368 cpu_set_tls (new_env, newtls);
6369 }
6370
6349 /* we create a new CPU instance. */
6350 new_env = cpu_copy(env);
6351 /* Init regs that differ from the parent. */
6352 cpu_clone_regs(new_env, newsp);
6353 new_cpu = ENV_GET_CPU(new_env);
6354 new_cpu->opaque = ts;
6355 ts->bprm = parent_ts->bprm;
6356 ts->info = parent_ts->info;
6357 ts->signal_mask = parent_ts->signal_mask;
6358
6359 if (flags & CLONE_CHILD_CLEARTID) {
6360 ts->child_tidptr = child_tidptr;
6361 }
6362
6363 if (flags & CLONE_SETTLS) {
6364 cpu_set_tls (new_env, newtls);
6365 }
6366
6367 /* Grab a mutex so that thread setup appears atomic. */
6368 pthread_mutex_lock(&clone_lock);
6369
6371 memset(&info, 0, sizeof(info));
6372 pthread_mutex_init(&info.mutex, NULL);
6373 pthread_mutex_lock(&info.mutex);
6374 pthread_cond_init(&info.cond, NULL);
6375 info.env = new_env;
6376 if (flags & CLONE_CHILD_SETTID) {
6377 info.child_tidptr = child_tidptr;
6378 }

--- 2316 unchanged lines hidden (view full) ---

8695 struct target_sigaction act, oact, *pact;
8696 if (arg2) {
8697 if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
8698 goto efault;
8699 act._sa_handler = old_act->_sa_handler;
8700 target_siginitset(&act.sa_mask, old_act->sa_mask);
8701 act.sa_flags = old_act->sa_flags;
8702 act.sa_restorer = old_act->sa_restorer;
6370 memset(&info, 0, sizeof(info));
6371 pthread_mutex_init(&info.mutex, NULL);
6372 pthread_mutex_lock(&info.mutex);
6373 pthread_cond_init(&info.cond, NULL);
6374 info.env = new_env;
6375 if (flags & CLONE_CHILD_SETTID) {
6376 info.child_tidptr = child_tidptr;
6377 }

--- 2316 unchanged lines hidden (view full) ---

8694 struct target_sigaction act, oact, *pact;
8695 if (arg2) {
8696 if (!lock_user_struct(VERIFY_READ, old_act, arg2, 1))
8697 goto efault;
8698 act._sa_handler = old_act->_sa_handler;
8699 target_siginitset(&act.sa_mask, old_act->sa_mask);
8700 act.sa_flags = old_act->sa_flags;
8701 act.sa_restorer = old_act->sa_restorer;
8702#ifdef TARGET_ARCH_HAS_KA_RESTORER
8703 act.ka_restorer = 0;
8704#endif
8703 unlock_user_struct(old_act, arg2, 0);
8704 pact = &act;
8705 } else {
8706 pact = NULL;
8707 }
8708 ret = get_errno(do_sigaction(arg1, pact, &oact));
8709 if (!is_error(ret) && arg3) {
8710 if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))

--- 58 unchanged lines hidden (view full) ---

8769 if (sigsetsize != sizeof(target_sigset_t)) {
8770 ret = -TARGET_EINVAL;
8771 break;
8772 }
8773 if (arg2) {
8774 if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) {
8775 goto efault;
8776 }
8705 unlock_user_struct(old_act, arg2, 0);
8706 pact = &act;
8707 } else {
8708 pact = NULL;
8709 }
8710 ret = get_errno(do_sigaction(arg1, pact, &oact));
8711 if (!is_error(ret) && arg3) {
8712 if (!lock_user_struct(VERIFY_WRITE, old_act, arg3, 0))

--- 58 unchanged lines hidden (view full) ---

8771 if (sigsetsize != sizeof(target_sigset_t)) {
8772 ret = -TARGET_EINVAL;
8773 break;
8774 }
8775 if (arg2) {
8776 if (!lock_user_struct(VERIFY_READ, act, arg2, 1)) {
8777 goto efault;
8778 }
8777#ifdef TARGET_SPARC
8778 act->sa_restorer = restorer;
8779#ifdef TARGET_ARCH_HAS_KA_RESTORER
8780 act->ka_restorer = restorer;
8779#endif
8780 } else {
8781 act = NULL;
8782 }
8783 if (arg3) {
8784 if (!lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) {
8785 ret = -TARGET_EFAULT;
8786 goto rt_sigaction_fail;

--- 2717 unchanged lines hidden (view full) ---

11504 ret = -host_to_target_errno(ret);
11505 break;
11506#endif
11507
11508#if TARGET_ABI_BITS == 32
11509
11510#ifdef TARGET_NR_fadvise64_64
11511 case TARGET_NR_fadvise64_64:
8781#endif
8782 } else {
8783 act = NULL;
8784 }
8785 if (arg3) {
8786 if (!lock_user_struct(VERIFY_WRITE, oact, arg3, 0)) {
8787 ret = -TARGET_EFAULT;
8788 goto rt_sigaction_fail;

--- 2717 unchanged lines hidden (view full) ---

11506 ret = -host_to_target_errno(ret);
11507 break;
11508#endif
11509
11510#if TARGET_ABI_BITS == 32
11511
11512#ifdef TARGET_NR_fadvise64_64
11513 case TARGET_NR_fadvise64_64:
11512#if defined(TARGET_PPC) || defined(TARGET_XTENSA)
11514#if defined(TARGET_PPC)
11513 /* 6 args: fd, advice, offset (high, low), len (high, low) */
11514 ret = arg2;
11515 arg2 = arg3;
11516 arg3 = arg4;
11517 arg4 = arg5;
11518 arg5 = arg6;
11519 arg6 = ret;
11520#else

--- 352 unchanged lines hidden (view full) ---

11873 goto unimplemented_nowarn;
11874#endif
11875#endif
11876#ifdef TARGET_NR_getdomainname
11877 case TARGET_NR_getdomainname:
11878 goto unimplemented_nowarn;
11879#endif
11880
11515 /* 6 args: fd, advice, offset (high, low), len (high, low) */
11516 ret = arg2;
11517 arg2 = arg3;
11518 arg3 = arg4;
11519 arg4 = arg5;
11520 arg5 = arg6;
11521 arg6 = ret;
11522#else

--- 352 unchanged lines hidden (view full) ---

11875 goto unimplemented_nowarn;
11876#endif
11877#endif
11878#ifdef TARGET_NR_getdomainname
11879 case TARGET_NR_getdomainname:
11880 goto unimplemented_nowarn;
11881#endif
11882
11881#ifdef TARGET_NR_clock_settime
11882 case TARGET_NR_clock_settime:
11883 {
11884 struct timespec ts;
11885
11886 ret = target_to_host_timespec(&ts, arg2);
11887 if (!is_error(ret)) {
11888 ret = get_errno(clock_settime(arg1, &ts));
11889 }
11890 break;
11891 }
11892#endif
11893#ifdef TARGET_NR_clock_gettime
11894 case TARGET_NR_clock_gettime:
11895 {
11896 struct timespec ts;
11897 ret = get_errno(clock_gettime(arg1, &ts));
11898 if (!is_error(ret)) {
11883#ifdef TARGET_NR_clock_gettime
11884 case TARGET_NR_clock_gettime:
11885 {
11886 struct timespec ts;
11887 ret = get_errno(clock_gettime(arg1, &ts));
11888 if (!is_error(ret)) {
11899 ret = host_to_target_timespec(arg2, &ts);
11889 host_to_target_timespec(arg2, &ts);
11900 }
11901 break;
11902 }
11903#endif
11904#ifdef TARGET_NR_clock_getres
11905 case TARGET_NR_clock_getres:
11906 {
11907 struct timespec ts;

--- 191 unchanged lines hidden (view full) ---

12099 /* Not implemented for now... */
12100/* case TARGET_NR_mq_notify: */
12101/* break; */
12102
12103 case TARGET_NR_mq_getsetattr:
12104 {
12105 struct mq_attr posix_mq_attr_in, posix_mq_attr_out;
12106 ret = 0;
11890 }
11891 break;
11892 }
11893#endif
11894#ifdef TARGET_NR_clock_getres
11895 case TARGET_NR_clock_getres:
11896 {
11897 struct timespec ts;

--- 191 unchanged lines hidden (view full) ---

12089 /* Not implemented for now... */
12090/* case TARGET_NR_mq_notify: */
12091/* break; */
12092
12093 case TARGET_NR_mq_getsetattr:
12094 {
12095 struct mq_attr posix_mq_attr_in, posix_mq_attr_out;
12096 ret = 0;
12097 if (arg3 != 0) {
12098 ret = mq_getattr(arg1, &posix_mq_attr_out);
12099 copy_to_user_mq_attr(arg3, &posix_mq_attr_out);
12100 }
12107 if (arg2 != 0) {
12108 copy_from_user_mq_attr(&posix_mq_attr_in, arg2);
12101 if (arg2 != 0) {
12102 copy_from_user_mq_attr(&posix_mq_attr_in, arg2);
12109 ret = get_errno(mq_setattr(arg1, &posix_mq_attr_in,
12110 &posix_mq_attr_out));
12111 } else if (arg3 != 0) {
12112 ret = get_errno(mq_getattr(arg1, &posix_mq_attr_out));
12103 ret |= mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr_out);
12113 }
12104 }
12114 if (ret == 0 && arg3 != 0) {
12115 copy_to_user_mq_attr(arg3, &posix_mq_attr_out);
12116 }
12105
12117 }
12118 break;
12119#endif
12120
12121#ifdef CONFIG_SPLICE
12122#ifdef TARGET_NR_tee
12123 case TARGET_NR_tee:
12124 {

--- 533 unchanged lines hidden ---
12106 }
12107 break;
12108#endif
12109
12110#ifdef CONFIG_SPLICE
12111#ifdef TARGET_NR_tee
12112 case TARGET_NR_tee:
12113 {

--- 533 unchanged lines hidden ---