From patchwork Mon Jun 27 16:44:52 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 2332 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 64F5123F08 for ; Mon, 27 Jun 2011 16:44:58 +0000 (UTC) Received: from mail-qw0-f52.google.com (mail-qw0-f52.google.com [209.85.216.52]) by fiordland.canonical.com (Postfix) with ESMTP id 3552FA18229 for ; Mon, 27 Jun 2011 16:44:58 +0000 (UTC) Received: by qwb8 with SMTP id 8so3527018qwb.11 for ; Mon, 27 Jun 2011 09:44:57 -0700 (PDT) Received: by 10.224.196.1 with SMTP id ee1mr4757296qab.109.1309193097702; Mon, 27 Jun 2011 09:44:57 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.229.48.135 with SMTP id r7cs47237qcf; Mon, 27 Jun 2011 09:44:57 -0700 (PDT) Received: by 10.42.168.5 with SMTP id u5mr2608550icy.510.1309193096669; Mon, 27 Jun 2011 09:44:56 -0700 (PDT) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk [81.2.115.146]) by mx.google.com with ESMTPS id j5si15096041ibd.84.2011.06.27.09.44.55 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 27 Jun 2011 09:44:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1QbEvc-0006wB-47; Mon, 27 Jun 2011 17:44:52 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Riku Voipio Subject: [PATCH 2/2] linux-user: Implement prlimit64 syscall Date: Mon, 27 Jun 2011 17:44:52 +0100 Message-Id: <1309193092-26640-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: <1309193092-26640-1-git-send-email-peter.maydell@linaro.org> References: <1309193092-26640-1-git-send-email-peter.maydell@linaro.org> Implement the prlimit64 syscall. Signed-off-by: Peter Maydell --- linux-user/syscall.c | 43 +++++++++++++++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 5 +++++ 2 files changed, 48 insertions(+), 0 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5cb27c7..2ec1c2b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -550,6 +550,21 @@ _syscall5(int, sys_ppoll, struct pollfd *, fds, nfds_t, nfds, size_t, sigsetsize) #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); @@ -7840,6 +7855,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 04c268d..e2700eb 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -2280,3 +2280,8 @@ struct target_epoll_event { target_epoll_data_t data; }; #endif + +struct target_rlimit64 { + uint64_t rlim_cur; + uint64_t rlim_max; +};