diff mbox series

[v2,081/108] linux-user: Split out getresgid32, getresuid32, setresgid32, setresuid32

Message ID 20180610030220.3777-82-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
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 linux-user/syscall.c | 93 +++++++++++++++++++++++++++-----------------
 1 file changed, 57 insertions(+), 36 deletions(-)

-- 
2.17.1
diff mbox series

Patch

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 031033c0ea..af96cc95d3 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8674,6 +8674,22 @@  IMPL(getresgid)
 }
 #endif
 
+#ifdef TARGET_NR_getresgid32
+IMPL(getresgid32)
+{
+    gid_t rgid, egid, sgid;
+    abi_long ret = get_errno(getresgid(&rgid, &egid, &sgid));
+
+    if (!is_error(ret) &&
+        (put_user_u32(rgid, arg1) ||
+         put_user_u32(egid, arg2) ||
+         put_user_u32(sgid, arg3))) {
+        return -TARGET_EFAULT;
+    }
+    return ret;
+}
+#endif
+
 #ifdef TARGET_NR_getresuid
 IMPL(getresuid)
 {
@@ -8690,6 +8706,21 @@  IMPL(getresuid)
 }
 #endif
 
+#ifdef TARGET_NR_getresuid32
+IMPL(getresuid32)
+{
+    uid_t ruid, euid, suid;
+    abi_long ret = get_errno(getresuid(&ruid, &euid, &suid));
+
+    if (!is_error(ret) &&
+        (put_user_u32(ruid, arg1) ||
+         put_user_u32(euid, arg2) ||
+         put_user_u32(suid, arg3))) {
+        return -TARGET_EFAULT;
+    }
+    return ret;
+}
+#endif
 IMPL(getrlimit)
 {
     int resource = target_to_host_resource(arg1);
@@ -10906,6 +10937,13 @@  IMPL(setresgid)
 }
 #endif
 
+#ifdef TARGET_NR_setresgid32
+IMPL(setresgid32)
+{
+    return get_errno(sys_setresgid(arg1, arg2, arg3));
+}
+#endif
+
 #ifdef TARGET_NR_setresuid
 IMPL(setresuid)
 {
@@ -10914,6 +10952,13 @@  IMPL(setresuid)
 }
 #endif
 
+#ifdef TARGET_NR_setresuid32
+IMPL(setresuid32)
+{
+    return get_errno(sys_setresuid(arg1, arg2, arg3));
+}
+#endif
+
 IMPL(setreuid)
 {
     return get_errno(setreuid(low2highuid(arg1), low2highuid(arg2)));
@@ -11898,42 +11943,6 @@  static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1,
     void *p;
 
     switch(num) {
-#ifdef TARGET_NR_setresuid32
-    case TARGET_NR_setresuid32:
-        return get_errno(sys_setresuid(arg1, arg2, arg3));
-#endif
-#ifdef TARGET_NR_getresuid32
-    case TARGET_NR_getresuid32:
-        {
-            uid_t ruid, euid, suid;
-            ret = get_errno(getresuid(&ruid, &euid, &suid));
-            if (!is_error(ret)) {
-                if (put_user_u32(ruid, arg1)
-                    || put_user_u32(euid, arg2)
-                    || put_user_u32(suid, arg3))
-                    return -TARGET_EFAULT;
-            }
-        }
-        return ret;
-#endif
-#ifdef TARGET_NR_setresgid32
-    case TARGET_NR_setresgid32:
-        return get_errno(sys_setresgid(arg1, arg2, arg3));
-#endif
-#ifdef TARGET_NR_getresgid32
-    case TARGET_NR_getresgid32:
-        {
-            gid_t rgid, egid, sgid;
-            ret = get_errno(getresgid(&rgid, &egid, &sgid));
-            if (!is_error(ret)) {
-                if (put_user_u32(rgid, arg1)
-                    || put_user_u32(egid, arg2)
-                    || put_user_u32(sgid, arg3))
-                    return -TARGET_EFAULT;
-            }
-        }
-        return ret;
-#endif
 #ifdef TARGET_NR_chown32
     case TARGET_NR_chown32:
         if (!(p = lock_user_string(arg1)))
@@ -13235,8 +13244,14 @@  static impl_fn *syscall_table(unsigned num)
 #ifdef TARGET_NR_getresgid
         SYSCALL(getresgid);
 #endif
+#ifdef TARGET_NR_getresgid32
+        SYSCALL(getresgid32);
+#endif
 #ifdef TARGET_NR_getresuid
         SYSCALL(getresuid);
+#endif
+#ifdef TARGET_NR_getresuid32
+        SYSCALL(getresuid32);
 #endif
         SYSCALL(getrlimit);
         SYSCALL(getrusage);
@@ -13491,11 +13506,17 @@  static impl_fn *syscall_table(unsigned num)
 #ifdef TARGET_NR_setresgid
         SYSCALL(setresgid);
 #endif
+#ifdef TARGET_NR_setresgid32
+        SYSCALL(setresgid32);
+#endif
 #ifdef TARGET_NR_setregid32
         SYSCALL(setregid32);
 #endif
 #ifdef TARGET_NR_setresuid
         SYSCALL(setresuid);
+#endif
+#ifdef TARGET_NR_setresuid32
+        SYSCALL(setresuid32);
 #endif
         SYSCALL(setreuid);
 #ifdef TARGET_NR_setreuid32