From 5813427b1ddcd74c39f49563c12f1f4a6dba5cea Mon Sep 17 00:00:00 2001 From: ths Date: Sat, 31 Mar 2007 18:59:32 +0000 Subject: [PATCH] fcntl() remaining fix, by Stuart Anderson. git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2559 c046a42c-6fe2-441c-8c8c-71466251a162 --- linux-user/syscall.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f79b5e0..c3a172b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1793,6 +1793,13 @@ static long do_fcntl(int fd, int cmd, target_ulong arg) switch(cmd) { case TARGET_F_GETLK: + lock_user_struct(target_fl, arg, 1); + fl.l_type = tswap16(target_fl->l_type); + fl.l_whence = tswap16(target_fl->l_whence); + fl.l_start = tswapl(target_fl->l_start); + fl.l_len = tswapl(target_fl->l_len); + fl.l_pid = tswapl(target_fl->l_pid); + unlock_user_struct(target_fl, arg, 0); ret = fcntl(fd, cmd, &fl); if (ret == 0) { lock_user_struct(target_fl, arg, 0); @@ -1818,6 +1825,13 @@ static long do_fcntl(int fd, int cmd, target_ulong arg) break; case TARGET_F_GETLK64: + lock_user_struct(target_fl64, arg, 1); + fl64.l_type = tswap16(target_fl64->l_type) >> 1; + fl64.l_whence = tswap16(target_fl64->l_whence); + fl64.l_start = tswapl(target_fl64->l_start); + fl64.l_len = tswapl(target_fl64->l_len); + fl64.l_pid = tswap16(target_fl64->l_pid); + unlock_user_struct(target_fl64, arg, 0); ret = fcntl(fd, cmd >> 1, &fl64); if (ret == 0) { lock_user_struct(target_fl64, arg, 0); @@ -3896,6 +3910,26 @@ long do_syscall(void *cpu_env, int num, long arg1, long arg2, long arg3, switch(arg2) { case TARGET_F_GETLK64: +#ifdef TARGET_ARM + if (((CPUARMState *)cpu_env)->eabi) { + lock_user_struct(target_efl, arg3, 1); + fl.l_type = tswap16(target_efl->l_type); + fl.l_whence = tswap16(target_efl->l_whence); + fl.l_start = tswap64(target_efl->l_start); + fl.l_len = tswap64(target_efl->l_len); + fl.l_pid = tswapl(target_efl->l_pid); + unlock_user_struct(target_efl, arg3, 0); + } else +#endif + { + lock_user_struct(target_fl, arg3, 1); + fl.l_type = tswap16(target_fl->l_type); + fl.l_whence = tswap16(target_fl->l_whence); + fl.l_start = tswap64(target_fl->l_start); + fl.l_len = tswap64(target_fl->l_len); + fl.l_pid = tswapl(target_fl->l_pid); + unlock_user_struct(target_fl, arg3, 0); + } ret = get_errno(fcntl(arg1, cmd, &fl)); if (ret == 0) { #ifdef TARGET_ARM -- 2.7.4