On 17 November 2010 12:30, Jamie Lentin <j...@lentin.co.uk> wrote:
> In setsockopt, the socket level options are translated to the hosts'
> architecture before the real syscall is called, e.g.
> TARGET_SO_TYPE -> SO_TYPE. This patch does the same with getsockopt.

I agree that this is necessary (at least for MIPS; I think all
the other architectures happen to have the same values for the
constants so the bug doesn't cause problems.

> diff -uprN a/linux-user/syscall.c b/linux-user/syscall.c
> --- a/linux-user/syscall.c      2010-05-04 16:27:48.000000000 +0100
> +++ b/linux-user/syscall.c      2010-07-29 21:47:12.000000000 +0100
> @@ -1383,6 +1383,57 @@ static abi_long do_getsockopt(int sockfd
>        case TARGET_SO_PEERNAME:
>            /* These don't just return a single integer */
>            goto unimplemented;
> +            /* Options with 'int' argument.  */
> +        case TARGET_SO_DEBUG:
> +            optname = SO_DEBUG;
> +            goto int_case;

[etc]

Wouldn't it be better to have a helper function for the conversion
rather than duplicating this set of cases in getsockopt() and
setsockopt() ?  (cf target_to_host_fcntl_cmd).

-- PMM

Reply via email to