[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/5] linux-user: move read to own function
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PATCH 2/5] linux-user: move read to own function |
Date: |
Fri, 12 Oct 2012 21:24:39 +0300 |
From: Riku Voipio <address@hidden>
In preparations for for refactoring the main switch/case out
Signed-off-by: Riku Voipio <address@hidden>
---
linux-user/syscall.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 0b077e7..497cae5 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5131,6 +5131,21 @@ static void do_exit(void *cpu_env, abi_long arg1)
_exit(arg1);
}
+static abi_long do_read(abi_long arg1, abi_long arg2, abi_long arg3)
+{
+ abi_long ret;
+ void *p;
+ if (arg3 == 0)
+ ret = 0;
+ else {
+ if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
+ return -EFAULT;
+ ret = read(arg1, p, arg3);
+ unlock_user(p, arg2, ret);
+ }
+ return ret;
+}
+
/* do_syscall() should always have a single exit point at the end so
that actions, such as logging of syscall results, can be performed.
All errnos that do_syscall() returns must be -TARGET_<errcode>. */
@@ -5155,14 +5170,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long
arg1,
do_exit(cpu_env, arg1);
break;
case TARGET_NR_read:
- if (arg3 == 0)
- ret = 0;
- else {
- if (!(p = lock_user(VERIFY_WRITE, arg2, arg3, 0)))
- goto efault;
- ret = get_errno(read(arg1, p, arg3));
- unlock_user(p, arg2, ret);
- }
+ ret = get_errno(do_read(arg1, arg2, arg3));
break;
case TARGET_NR_write:
if (!(p = lock_user(VERIFY_READ, arg2, arg3, 1)))
--
1.7.9.5
- [Qemu-devel] [RFC] [PATCH 0/5] linux-user: refactor do_syscall(), riku . voipio, 2012/10/12
- [Qemu-devel] [PATCH 4/5] linux-user: complete do_open function isolation, riku . voipio, 2012/10/12
- [Qemu-devel] [PATCH 5/5] linux-user: do_openat wrapper added, riku . voipio, 2012/10/12
- [Qemu-devel] [PATCH 1/5] linux-user: move exit to own function, riku . voipio, 2012/10/12
- [Qemu-devel] [PATCH 2/5] linux-user: move read to own function,
riku . voipio <=
- [Qemu-devel] [PATCH 3/5] linux-user: move write to own function, riku . voipio, 2012/10/12
- Re: [Qemu-devel] [RFC] [PATCH 0/5] linux-user: refactor do_syscall(), Richard Henderson, 2012/10/12
- Re: [Qemu-devel] [RFC] [PATCH 0/5] linux-user: refactor do_syscall(), Blue Swirl, 2012/10/13