diff mbox series

[v7,64/74] linux-user: Split out gethostname, sethostname

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

Commit Message

Richard Henderson May 19, 2019, 8:37 p.m. UTC
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 linux-user/syscall-defs.h     |  4 ++++
 linux-user/syscall-proc.inc.c | 28 ++++++++++++++++++++++++++++
 linux-user/syscall.c          | 19 -------------------
 linux-user/strace.list        |  6 ------
 4 files changed, 32 insertions(+), 25 deletions(-)

-- 
2.17.1
diff mbox series

Patch

diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h
index 77d750f66f..3ba697fd53 100644
--- a/linux-user/syscall-defs.h
+++ b/linux-user/syscall-defs.h
@@ -59,6 +59,9 @@  SYSCALL_DEF(futimesat, ARG_ATDIRFD, ARG_STR, ARG_PTR);
 #ifdef TARGET_NR_fork
 SYSCALL_DEF(fork);
 #endif
+#ifdef TARGET_NR_gethostname
+SYSCALL_DEF(gethostname, ARG_PTR, ARG_DEC);
+#endif
 SYSCALL_DEF(getpgid, ARG_DEC);
 #ifdef TARGET_NR_getpgrp
 SYSCALL_DEF(getpgrp);
@@ -207,6 +210,7 @@  SYSCALL_DEF(semctl, ARG_DEC, ARG_DEC, ARG_DEC, ARG_HEX);
 #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semget)
 SYSCALL_DEF(semget, ARG_DEC, ARG_DEC, ARG_HEX);
 #endif
+SYSCALL_DEF(sethostname, ARG_STR);
 SYSCALL_DEF(setpgid, ARG_DEC, ARG_DEC);
 SYSCALL_DEF(setsid);
 #if !defined(SYSCALL_TABLE) || defined(TARGET_NR_semop)
diff --git a/linux-user/syscall-proc.inc.c b/linux-user/syscall-proc.inc.c
index 567df54581..b1a801fb62 100644
--- a/linux-user/syscall-proc.inc.c
+++ b/linux-user/syscall-proc.inc.c
@@ -438,6 +438,21 @@  SYSCALL_IMPL(fork)
 }
 #endif
 
+#ifdef TARGET_NR_gethostname
+SYSCALL_IMPL(gethostname)
+{
+    char *name = lock_user(VERIFY_WRITE, arg1, arg2, 0);
+    abi_long ret;
+    
+    if (!name) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(gethostname(name, arg2));
+    unlock_user(name, arg1, arg2);
+    return ret;
+}
+#endif
+
 SYSCALL_IMPL(getpgid)
 {
     return get_errno(getpgid(arg1));
@@ -485,6 +500,19 @@  SYSCALL_IMPL(nice)
 }
 #endif
 
+SYSCALL_IMPL(sethostname)
+{
+    void *p = lock_user_string(arg1);
+    abi_long ret;
+
+    if (!p) {
+        return -TARGET_EFAULT;
+    }
+    ret = get_errno(sethostname(p, arg2));
+    unlock_user(p, arg1, 0);
+    return ret;
+}
+
 SYSCALL_IMPL(setpgid)
 {
     return get_errno(setpgid(arg1, arg2));
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b8b18ac1de..6dd4196647 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4240,12 +4240,6 @@  static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
     void *p;
 
     switch(num) {
-    case TARGET_NR_sethostname:
-        if (!(p = lock_user_string(arg1)))
-            return -TARGET_EFAULT;
-        ret = get_errno(sethostname(p, arg2));
-        unlock_user(p, arg1, 0);
-        return ret;
 #ifdef TARGET_NR_setrlimit
     case TARGET_NR_setrlimit:
         {
@@ -7078,19 +7072,6 @@  static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1,
         return ret;
     }
 #endif
-#ifdef TARGET_NR_gethostname
-    case TARGET_NR_gethostname:
-    {
-        char *name = lock_user(VERIFY_WRITE, arg1, arg2, 0);
-        if (name) {
-            ret = get_errno(gethostname(name, arg2));
-            unlock_user(name, arg1, arg2);
-        } else {
-            ret = -TARGET_EFAULT;
-        }
-        return ret;
-    }
-#endif
 #ifdef TARGET_NR_atomic_cmpxchg_32
     case TARGET_NR_atomic_cmpxchg_32:
     {
diff --git a/linux-user/strace.list b/linux-user/strace.list
index b1c2f7851e..361ceec853 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -244,9 +244,6 @@ 
 #ifdef TARGET_NR_getgroups32
 { TARGET_NR_getgroups32, "getgroups32" , NULL, NULL, NULL },
 #endif
-#ifdef TARGET_NR_gethostname
-{ TARGET_NR_gethostname, "gethostname" , NULL, NULL, NULL },
-#endif
 #ifdef TARGET_NR_getitimer
 { TARGET_NR_getitimer, "getitimer" , NULL, NULL, NULL },
 #endif
@@ -1025,9 +1022,6 @@ 
 #ifdef TARGET_NR_sethae
 { TARGET_NR_sethae, "sethae" , NULL, NULL, NULL },
 #endif
-#ifdef TARGET_NR_sethostname
-{ TARGET_NR_sethostname, "sethostname" , NULL, NULL, NULL },
-#endif
 #ifdef TARGET_NR_setitimer
 { TARGET_NR_setitimer, "setitimer" , NULL, NULL, NULL },
 #endif