qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Riku Voipio <riku.voipio@iki.fi>
To: qemu-devel@nongnu.org
Cc: arnaud.patard@rtp-net.org
Subject: Re: [Qemu-devel] [PATCH] fix fcntl support in linux-user.
Date: Mon, 20 Apr 2009 16:22:06 +0300	[thread overview]
Message-ID: <20090420132206.GB10865@kos.to> (raw)
In-Reply-To: <87r5zofk3w.fsf@lechat.rtp-net.org>

On Sun, Apr 19, 2009 at 10:45:39PM +0200, Arnaud Patard wrote:
> 
> The current code in do_fcntl is passing the target command as a host
> command. This is introducing 2 problems:
> 
> - When building with "-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE", we
>   may end up passing commands like F_GETFL instead of F_GETFL64. This is
>   likely to return an error.
> 
> - The F_*64 constants doesn't always have the same value between host
>   and target.

This appears to be the case for some other fcntl constants as well. Howabout
implementing this as a target_to_host_fcntl_cmd() mapping function instead?

> Without this patch locking is not working (My test-case was pwck with arm as
> target and mips as host).

Could you also add the MIPS target definition for F_*64 so that mips on arm
would get fixed too?

> Signed-off-by: Arnaud Patard <arnaud.patard@rtp-net.org>
> ---

> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 2d51d6b..2d876c1 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -3126,7 +3141,7 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg)
>          fl.l_len = tswapl(target_fl->l_len);
>          fl.l_pid = tswapl(target_fl->l_pid);
>          unlock_user_struct(target_fl, arg, 0);
> -        ret = get_errno(fcntl(fd, cmd, &fl));
> +        ret = get_errno(fcntl(fd, F_GETLK, &fl));
>          if (ret == 0) {
>              if (!lock_user_struct(VERIFY_WRITE, target_fl, arg, 0))
>                  return -TARGET_EFAULT;
> @@ -3149,7 +3164,7 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg)
>          fl.l_len = tswapl(target_fl->l_len);
>          fl.l_pid = tswapl(target_fl->l_pid);
>          unlock_user_struct(target_fl, arg, 0);
> -        ret = get_errno(fcntl(fd, cmd, &fl));
> +        ret = get_errno(fcntl(fd, F_SETLK+(cmd-TARGET_F_SETLK), &fl));
>          break;
>  
>      case TARGET_F_GETLK64:
> @@ -3161,7 +3176,7 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg)
>          fl64.l_len = tswapl(target_fl64->l_len);
>          fl64.l_pid = tswap16(target_fl64->l_pid);
>          unlock_user_struct(target_fl64, arg, 0);
> -        ret = get_errno(fcntl(fd, cmd >> 1, &fl64));
> +        ret = get_errno(fcntl(fd, F_GETLK64, &fl64));
>          if (ret == 0) {
>              if (!lock_user_struct(VERIFY_WRITE, target_fl64, arg, 0))
>                  return -TARGET_EFAULT;
> @@ -3183,7 +3198,7 @@ static abi_long do_fcntl(int fd, int cmd, abi_ulong arg)
>          fl64.l_len = tswapl(target_fl64->l_len);
>          fl64.l_pid = tswap16(target_fl64->l_pid);
>          unlock_user_struct(target_fl64, arg, 0);
> -        ret = get_errno(fcntl(fd, cmd >> 1, &fl64));
> +        ret = get_errno(fcntl(fd, F_SETLK64+(cmd-TARGET_F_SETLK64), &fl64));
>          break;
>  
>      case F_GETFL:
> @@ -6022,7 +6039,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
>              ret = get_errno(fcntl(arg1, cmd, &fl));
>  	    break;
>          default:
> -            ret = do_fcntl(arg1, cmd, arg3);
> +            ret = do_fcntl(arg1, arg2, arg3);
>              break;
>          }
>  	break;

  reply	other threads:[~2009-04-20 13:22 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-19 20:45 [Qemu-devel] [PATCH] fix fcntl support in linux-user Arnaud Patard
2009-04-20 13:22 ` Riku Voipio [this message]
2009-04-21  8:21   ` Arnaud Patard
2009-04-21 12:51     ` Riku Voipio
2009-04-21 14:39       ` Jamie Lokier
2009-04-21 17:58         ` Riku Voipio
2009-04-22 10:04           ` Arnaud Patard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090420132206.GB10865@kos.to \
    --to=riku.voipio@iki.fi \
    --cc=arnaud.patard@rtp-net.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).