All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: Filip Bozuta <Filip.Bozuta@syrmia.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH 2/2] linux-user: Add support for 'utimensat_time64()' and 'semtimedop_time64()'
Date: Mon, 24 Aug 2020 19:20:41 +0200	[thread overview]
Message-ID: <09ef09fe-dd22-4b54-95a9-52f300b8eb4a@vivier.eu> (raw)
In-Reply-To: <20200812135703.39404-3-Filip.Bozuta@syrmia.com>

Le 12/08/2020 à 15:57, Filip Bozuta a écrit :
> This patch introduces functionality for following time64 syscalls:
> 
> *utimensat_time64()
> 
>     int utimensat(int dirfd, const char *pathname,
>                   const struct timespec times[2], int flags);
>     -- change file timestamps with nanosecond precision --
>     man page: https://man7.org/linux/man-pages/man2/utimensat.2.html
> 
> *semtimedop_time64()
> 
>     int semtimedop(int semid, struct sembuf *sops, size_t nsops,
>                    const struct timespec *timeout);
>     -- System V semaphore operations --
>     man page: https://www.man7.org/linux/man-pages/man2/semtimedop.2.html
> 
> Implementation notes:
> 
>    Syscall 'utimensat_time64()' is implemented in similar way as its
>    regular variants only difference being that time64 converting function
>    is used to convert values of 'struct timespec' between host and target
>    ('target_to_host_timespec64()').
> 
>    For syscall 'semtimedop_time64()' and additional argument is added
>    in function 'do_semtimedop()' through which the aproppriate 'struct timespec'
>    converting function is called (0 for regular target_to_host_timespec()
>    and anything else for target_to_host_timespec64()). For 'do_ipc()' an
>    check was added as that additional argument: 'TARGET_ABI_BITS == 64'.
> 
> Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
> ---
>  linux-user/syscall.c | 55 ++++++++++++++++++++++++++++++++++++--------
>  1 file changed, 46 insertions(+), 9 deletions(-)
> 
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 8f63a46f58..44a13c5ec2 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -1253,7 +1253,8 @@ static inline abi_long target_to_host_timespec(struct timespec *host_ts,
>  #endif
>  
>  #if defined(TARGET_NR_clock_settime64) || defined(TARGET_NR_futex_time64) || \
> -    defined(TARGET_NR_pselect6_time64) || defined(TARGET_NR_ppoll_time64)
> +    defined(TARGET_NR_pselect6_time64) || defined(TARGET_NR_ppoll_time64) || \
> +    defined(TARGET_NR_utimensat_time64) || defined(TARGET_NR_semtimedop_time64)
>  static inline abi_long target_to_host_timespec64(struct timespec *host_ts,
>                                                   abi_ulong target_addr)
>  {
> @@ -3886,7 +3887,7 @@ static inline abi_long target_to_host_sembuf(struct sembuf *host_sembuf,
>  }
>  
>  #if defined(TARGET_NR_ipc) || defined(TARGET_NR_semop) || \
> -    defined(TARGET_NR_semtimedop)
> +    defined(TARGET_NR_semtimedop) || defined(TARGET_NR_semtimedop_time64)
>  
>  /*
>   * This macro is required to handle the s390 variants, which passes the
> @@ -3903,7 +3904,7 @@ static inline abi_long target_to_host_sembuf(struct sembuf *host_sembuf,
>  static inline abi_long do_semtimedop(int semid,
>                                       abi_long ptr,
>                                       unsigned nsops,
> -                                     abi_long timeout)
> +                                     abi_long timeout, int time64)

"bool time64" would be cleaner

>  {
>      struct sembuf sops[nsops];
>      struct timespec ts, *pts = NULL;
> @@ -3911,7 +3912,10 @@ static inline abi_long do_semtimedop(int semid,
>  
>      if (timeout) {
>          pts = &ts;
> -        if (target_to_host_timespec(pts, timeout)) {
> +        if (!time64 && target_to_host_timespec(pts, timeout)) {
> +            return -TARGET_EFAULT;
> +        }
> +        if (time64 && target_to_host_timespec64(pts, timeout)) {
>              return -TARGET_EFAULT;
>          }

why not:

    if (time64) {
        if (target_to_host_timespec64(pts, timeout)) {
            return -TARGET_EFAULT;
        }
    } else {
        if (target_to_host_timespec(pts, timeout)) {
              return -TARGET_EFAULT;
        }
    }

I think it's clearer.

With that fixed:

Reviewed-by: Laurent Vivier <laurent@vivier.eu>


      reply	other threads:[~2020-08-24 17:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-12 13:57 [PATCH 0/2] linux-user: Adding support for a group of 4 time64 syscalls Filip Bozuta
2020-08-12 13:57 ` [PATCH 1/2] linux-user: Add support for 'ppoll_time64()' and 'pselect6_time64()' Filip Bozuta
2020-08-24 17:12   ` Laurent Vivier
2020-08-12 13:57 ` [PATCH 2/2] linux-user: Add support for 'utimensat_time64()' and 'semtimedop_time64()' Filip Bozuta
2020-08-24 17:20   ` Laurent Vivier [this message]

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=09ef09fe-dd22-4b54-95a9-52f300b8eb4a@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=Filip.Bozuta@syrmia.com \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.