qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] linux-user: Add support for pivot_root syscall


From: David Leonard
Subject: [PATCH] linux-user: Add support for pivot_root syscall
Date: Mon, 12 Oct 2020 17:14:16 +1000 (AEST)
User-agent: Alpine 2.22 (DEB 394 2020-01-19)


Tested on Ubuntu 20.04 x86_64 against arm-linux-gnueabi toolchain.

Signed-off-by: David Leonard <David.Leonard@digi.com>
---
 linux-user/syscall.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 897d20c076..8143c8c280 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -345,6 +345,10 @@ _syscall5(int, kcmp, pid_t, pid1, pid_t, pid2, int, type,
           unsigned long, idx1, unsigned long, idx2)
 #endif

+#if defined(TARGET_NR_pivot_root) && defined(__NR_pivot_root)
+_syscall2(int, pivot_root, const char *, new_root, const char *, put_old)
+#endif
+
 /*
  * It is assumed that struct statx is architecture independent.
  */
@@ -8834,6 +8838,22 @@ static abi_long do_syscall1(void *cpu_env, int num, 
abi_long arg1,
         ret = get_errno(umount2(p, arg2));
         unlock_user(p, arg1, 0);
         return ret;
+#endif
+#if defined(TARGET_NR_pivot_root) && defined(__NR_pivot_root)
+    case TARGET_NR_pivot_root:
+        {
+            void *p2;
+            p  = lock_user_string(arg1);
+            p2 = lock_user_string(arg2);
+            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
     case TARGET_NR_ioctl:
         return do_ioctl(arg1, arg2, arg3);
--
2.25.1




reply via email to

[Prev in Thread] Current Thread [Next in Thread]