qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: riku.voipio@iki.fi
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>
Subject: [Qemu-devel] [PATCH 6/7] linux-user: Implement prlimit64 syscall
Date: Mon, 11 Jul 2011 17:11:01 +0300	[thread overview]
Message-ID: <163a05a8398bc4b56c7498fa9901422a159168bf.1310392747.git.riku.voipio@linaro.org> (raw)
In-Reply-To: <cover.1310392747.git.riku.voipio@linaro.org>

From: Peter Maydell <peter.maydell@linaro.org>

Implement the prlimit64 syscall.

Slightly modified to apply upstream -Riku

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 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;
+};
-- 
1.7.4.1

  parent reply	other threads:[~2011-07-11 14:11 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-11 14:10 [Qemu-devel] [PATCH 0/7] pending linux-user patches riku.voipio
2011-07-11 14:10 ` [Qemu-devel] [PATCH 1/7] arm-semi: Provide access to CLI arguments passed through the "-append" option riku.voipio
2011-07-11 14:10 ` [Qemu-devel] [PATCH 2/7] linux-user: Add support for KD...LED ioctls riku.voipio
2011-07-11 14:10 ` [Qemu-devel] [PATCH 3/7] linux-user: Add support for more VT ioctls riku.voipio
2011-07-11 14:10 ` [Qemu-devel] [PATCH 4/7] linux-user: Add support for even more FB ioctls riku.voipio
2011-07-11 14:11 ` [Qemu-devel] [PATCH 5/7] linux-user: Add syscall numbers from kernel 2.6.39.2 riku.voipio
2011-07-11 15:12   ` cedric.vincent
2011-07-11 14:11 ` riku.voipio [this message]
2011-07-11 14:11 ` [Qemu-devel] [PATCH 7/7] linux-user/syscall.c: Enforce pselect6 sigset size restrictions riku.voipio

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=163a05a8398bc4b56c7498fa9901422a159168bf.1310392747.git.riku.voipio@linaro.org \
    --to=riku.voipio@iki.fi \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).