diff mbox series

[v2,036/108] linux-user: Split out symlink, symlinkat

Message ID 20180610030220.3777-37-richard.henderson@linaro.org
State New
Headers show
Series linux-user: Split do_syscall | expand

Commit Message

Richard Henderson June 10, 2018, 3:01 a.m. UTC
All targets define symlinkat; remove the ifdef.

Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 linux-user/syscall.c | 64 +++++++++++++++++++++++---------------------
 1 file changed, 34 insertions(+), 30 deletions(-)

-- 
2.17.1
diff mbox series

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 326323e377..39d8a70d7d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9331,6 +9331,36 @@  IMPL(stime)
 }
 #endif
 
+#ifdef TARGET_NR_symlink
+IMPL(symlink)
+{
+    char *p1 = lock_user_string(arg1);
+    char *p2 = lock_user_string(arg2);
+    abi_long ret = -TARGET_EFAULT;
+
+    if (p1 && p2) {
+        ret = get_errno(symlink(p1, p2));
+    }
+    unlock_user(p2, arg2, 0);
+    unlock_user(p1, arg1, 0);
+    return ret;
+}
+#endif
+
+IMPL(symlinkat)
+{
+    char *p1 = lock_user_string(arg1);
+    char *p2 = lock_user_string(arg3);
+    abi_long ret = -TARGET_EFAULT;
+
+    if (p1 && p2) {
+        ret = get_errno(symlinkat(p1, arg2, p2));
+    }
+    unlock_user(p2, arg3, 0);
+    unlock_user(p1, arg1, 0);
+    return ret;
+}
+
 IMPL(sync)
 {
     sync();
@@ -9561,36 +9591,6 @@  static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1,
     void *p;
 
     switch(num) {
-#ifdef TARGET_NR_symlink
-    case TARGET_NR_symlink:
-        {
-            void *p2;
-            p = lock_user_string(arg1);
-            p2 = lock_user_string(arg2);
-            if (!p || !p2)
-                ret = -TARGET_EFAULT;
-            else
-                ret = get_errno(symlink(p, p2));
-            unlock_user(p2, arg2, 0);
-            unlock_user(p, arg1, 0);
-        }
-        return ret;
-#endif
-#if defined(TARGET_NR_symlinkat)
-    case TARGET_NR_symlinkat:
-        {
-            void *p2;
-            p  = lock_user_string(arg1);
-            p2 = lock_user_string(arg3);
-            if (!p || !p2)
-                ret = -TARGET_EFAULT;
-            else
-                ret = get_errno(symlinkat(p, arg2, p2));
-            unlock_user(p2, arg3, 0);
-            unlock_user(p, arg1, 0);
-        }
-        return ret;
-#endif
 #ifdef TARGET_NR_readlink
     case TARGET_NR_readlink:
         {
@@ -12837,6 +12837,10 @@  static impl_fn *syscall_table(unsigned num)
 #ifdef TARGET_NR_stime
         SYSCALL(stime);
 #endif
+#ifdef TARGET_NR_symlink
+        SYSCALL(symlink);
+#endif
+        SYSCALL(symlinkat);
         SYSCALL(sync);
 #ifdef CONFIG_SYNCFS
         SYSCALL(syncfs);