From patchwork Wed Jul 13 14:48:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 104538 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id CE5B8B6F64 for ; Thu, 14 Jul 2011 01:19:25 +1000 (EST) Received: from localhost ([::1]:37791 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qh1Dc-0005zQ-MH for incoming@patchwork.ozlabs.org; Wed, 13 Jul 2011 11:19:20 -0400 Received: from eggs.gnu.org ([140.186.70.92]:43886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qh0kY-0006cP-HZ for qemu-devel@nongnu.org; Wed, 13 Jul 2011 10:49:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qh0kT-0007s8-4y for qemu-devel@nongnu.org; Wed, 13 Jul 2011 10:49:18 -0400 Received: from afflict.kos.to ([92.243.29.197]:47337) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qh0kS-0007s1-N4 for qemu-devel@nongnu.org; Wed, 13 Jul 2011 10:49:12 -0400 Received: from kos.to (a88-115-163-181.elisa-laajakaista.fi [88.115.163.181]) (using TLSv1 with cipher DHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id A80F126699; Wed, 13 Jul 2011 14:49:10 +0000 (UTC) Received: by kos.to (sSMTP sendmail emulation); Wed, 13 Jul 2011 17:49:10 +0300 From: riku.voipio@iki.fi To: qemu-devel@nongnu.org Date: Wed, 13 Jul 2011 17:48:45 +0300 Message-Id: <163a05a8398bc4b56c7498fa9901422a159168bf.1310568214.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 92.243.29.197 Cc: Peter Maydell Subject: [Qemu-devel] [PATCH 06/15] linux-user: Implement prlimit64 syscall X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Peter Maydell Implement the prlimit64 syscall. Slightly modified to apply upstream -Riku Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 43 +++++++++++++++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 4 ++++ 2 files changed, 47 insertions(+), 0 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index fed7a8f..e2f356b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -559,6 +559,21 @@ _syscall6(int, sys_pselect6, int, nfds, fd_set *, readfds, fd_set *, writefds, fd_set *, exceptfds, struct timespec *, timeout, void *, sig); #endif +#if defined(TARGET_NR_prlimit64) +#ifndef __NR_prlimit64 +# define __NR_prlimit64 -1 +#endif +#define __NR_sys_prlimit64 __NR_prlimit64 +/* The glibc rlimit structure may not be that used by the underlying syscall */ +struct host_rlimit64 { + uint64_t rlim_cur; + uint64_t rlim_max; +}; +_syscall4(int, sys_prlimit64, pid_t, pid, int, resource, + const struct host_rlimit64 *, new_limit, + struct host_rlimit64 *, old_limit) +#endif + extern int personality(int); extern int flock(int, int); extern int setfsuid(int); @@ -7990,6 +8005,34 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, } #endif #endif +#ifdef TARGET_NR_prlimit64 + case TARGET_NR_prlimit64: + { + /* args: pid, resource number, ptr to new rlimit, ptr to old rlimit */ + struct target_rlimit64 *target_rnew, *target_rold; + struct host_rlimit64 rnew, rold, *rnewp = 0; + if (arg3) { + if (!lock_user_struct(VERIFY_READ, target_rnew, arg3, 1)) { + goto efault; + } + rnew.rlim_cur = tswap64(target_rnew->rlim_cur); + rnew.rlim_max = tswap64(target_rnew->rlim_max); + unlock_user_struct(target_rnew, arg3, 0); + rnewp = &rnew; + } + + ret = get_errno(sys_prlimit64(arg1, arg2, rnewp, arg4 ? &rold : 0)); + if (!is_error(ret) && arg4) { + if (!lock_user_struct(VERIFY_WRITE, target_rold, arg4, 1)) { + goto efault; + } + target_rold->rlim_cur = tswap64(rold.rlim_cur); + target_rold->rlim_max = tswap64(rold.rlim_max); + unlock_user_struct(target_rold, arg4, 1); + } + break; + } +#endif default: unimplemented: gemu_log("qemu: Unsupported syscall: %d\n", num); diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 1b73451..1fdc84d 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2293,3 +2293,7 @@ struct target_epoll_event { target_epoll_data_t data; }; #endif +struct target_rlimit64 { + uint64_t rlim_cur; + uint64_t rlim_max; +};