All of lore.kernel.org
 help / color / mirror / Atom feed
From: YAMAMOTO Takashi <yamamoto@midokura.com>
To: qemu-devel@nongnu.org
Cc: YAMAMOTO Takashi <yamamoto@midokura.com>,
	Laurent Vivier <laurent@vivier.eu>
Subject: [PATCH 5/5] linux-user: Implement pivot_root
Date: Mon, 24 May 2021 13:54:11 +0900	[thread overview]
Message-ID: <20210524045412.15152-6-yamamoto@midokura.com> (raw)
In-Reply-To: <20210524045412.15152-1-yamamoto@midokura.com>

Used by runc.

Signed-off-by: YAMAMOTO Takashi <yamamoto@midokura.com>
---
 linux-user/syscall.c | 23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 2947e79dc0..e739921e86 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -35,6 +35,7 @@
 #include <sys/prctl.h>
 #include <sys/resource.h>
 #include <sys/swap.h>
+#include <sys/syscall.h>
 #include <linux/capability.h>
 #include <sched.h>
 #include <sys/timex.h>
@@ -8254,6 +8255,11 @@ static int host_to_target_cpu_mask(const unsigned long *host_mask,
     return 0;
 }
 
+static int pivot_root(const char *new_root, const char *put_old)
+{
+    return syscall(SYS_pivot_root, new_root, put_old);
+}
+
 /* This is an internal helper for do_syscall so that it is easier
  * to have a single return point, so that actions, such as logging
  * of syscall results, can be performed.
@@ -13222,6 +13228,23 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
 #endif
 
+#if defined(TARGET_NR_pivot_root)
+    case TARGET_NR_pivot_root:
+        {
+            void *p2;
+            p = lock_user_string(arg1); /* new_root */
+            p2 = lock_user_string(arg2); /* put_old */
+            if (!p || !p2) {
+                ret = -TARGET_EFAULT;
+            } else {
+                ret = get_errno(pivot_root(p, p2));
+            }
+            unlock_user(p2, arg2, 0);
+            unlock_user(p, arg1, 0);
+        }
+        return ret;
+#endif
+
     default:
         qemu_log_mask(LOG_UNIMP, "Unsupported syscall: %d\n", num);
         return -TARGET_ENOSYS;
-- 
2.21.1 (Apple Git-122.3)



  parent reply	other threads:[~2021-05-24  4:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-24  4:54 [PATCH 0/5] linux-user changes to run docker YAMAMOTO Takashi
2021-05-24  4:54 ` [PATCH 1/5] linux-user: handle /proc/self/exe for execve YAMAMOTO Takashi
2021-05-24 10:50   ` Alex Bennée
2021-05-24 22:54     ` Takashi Yamamoto
2021-05-24  4:54 ` [PATCH 2/5] linux-uesr: make exec_path realpath YAMAMOTO Takashi
2021-05-24 10:55   ` Alex Bennée
2021-05-24 22:59     ` Takashi Yamamoto
2021-05-26  1:42       ` Takashi Yamamoto
2021-05-24  4:54 ` [PATCH 3/5] linux-user: Fix the execfd case of /proc/self/exe open YAMAMOTO Takashi
2021-05-24  4:54 ` [PATCH 4/5] linux-user: dup the execfd on start up YAMAMOTO Takashi
2021-05-24  4:54 ` YAMAMOTO Takashi [this message]
2021-05-25 20:21   ` [PATCH 5/5] linux-user: Implement pivot_root Laurent Vivier
2021-05-26  0:50     ` Takashi Yamamoto
2021-05-24 17:45 ` [PATCH 0/5] linux-user changes to run docker Alex Bennée
2021-05-24 23:22   ` Takashi Yamamoto
2021-05-27  1:44     ` Takashi Yamamoto
2021-05-27 13:08       ` Alex Bennée
2021-05-31  2:45         ` Takashi Yamamoto

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=20210524045412.15152-6-yamamoto@midokura.com \
    --to=yamamoto@midokura.com \
    --cc=laurent@vivier.eu \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.