qemu-devel.nongnu.org archive mirror
 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 v3 3/6] linux-user: Add strace support for printing argument of syscalls used for extended attributes
Date: Mon, 15 Jun 2020 13:52:38 +0200	[thread overview]
Message-ID: <31cda0bd-0c42-bf99-0256-007688059c4d@vivier.eu> (raw)
In-Reply-To: <20200611155109.3648-4-filip.bozuta@syrmia.com>

Le 11/06/2020 à 17:51, Filip Bozuta a écrit :
> From: Filip Bozuta <Filip.Bozuta@syrmia.com>
> 
> This patch implements strace argument printing functionality for following syscalls:
> 
>     *getxattr, lgetxattr, fgetxattr - retrieve an extended attribute value
> 
>         ssize_t getxattr(const char *path, const char *name, void *value, size_t size)
>         ssize_t lgetxattr(const char *path, const char *name, void *value, size_t size)
>         ssize_t fgetxattr(int fd, const char *name, void *value, size_t size)
>         man page: https://www.man7.org/linux/man-pages/man2/getxattr.2.html
> 
>     *listxattr, llistxattr, flistxattr - list extended attribute names
> 
>         ssize_t listxattr(const char *path, char *list, size_t size)
>         ssize_t llistxattr(const char *path, char *list, size_t size)
>         ssize_t flistxattr(int fd, char *list, size_t size)
>         man page: https://www.man7.org/linux/man-pages/man2/listxattr.2.html
> 
>     *removexattr, lremovexattr, fremovexattr - remove an extended attribute
> 
>          int removexattr(const char *path, const char *name)
>          int lremovexattr(const char *path, const char *name)
>          int fremovexattr(int fd, const char *name)
>          man page: https://www.man7.org/linux/man-pages/man2/removexattr.2.html

Compared to v2, fremovexattr, removexattr and lremovexattr are missing.

> 
> Implementation notes:
> 
>     All of the syscalls have strings as argument types and thus a separate
>     printing function was stated in file "strace.list" for every one of them.
>     All of these printing functions were defined in "strace.c" using existing
>     printing functions for appropriate argument types:
>        "print_string()" - for (const char*) type
>        "print_pointer()" - for (char*) and (void *) type
>        "print_raw_param()" for (int) and (size_t) type
>     Syscalls "getxattr()" and "lgetxattr()" have the same number and type of
>     arguments and thus their print functions ("print_getxattr", "print_lgetxattr")
>     share a same definition. The same statement applies to syscalls "listxattr()"
>     and "llistxattr()".
>     Function "print_syscall_ret_listxattr()" was added to print the returned list
>     of extended attributes for syscalls "print_listxattr(), print_llistxattr() and
>     print_flistxattr()".
> 
> Signed-off-by: Filip Bozuta <Filip.Bozuta@syrmia.com>
> ---
>  linux-user/strace.c    | 95 ++++++++++++++++++++++++++++++++++++++++++
>  linux-user/strace.list | 15 ++++---
>  2 files changed, 104 insertions(+), 6 deletions(-)
> 
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 4f85606c19..a7c3ea8df3 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -834,6 +834,41 @@ print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret,
>  }
>  #endif
>  
> +#if defined(TARGET_NR_listxattr) || defined(TARGET_NR_llistxattr) \
> + || defined(TARGGET_NR_flistxattr)
> +static void
> +print_syscall_ret_listxattr(const struct syscallname *name, abi_long ret,
> +                            abi_long arg0, abi_long arg1, abi_long arg2,
> +                            abi_long arg3, abi_long arg4, abi_long arg5)
> +{
> +    const char *errstr = NULL;
> +
> +    SYSCALL_RET_ERR(ret, errstr);
> +
> +    if (ret >= 0) {
> +        qemu_log(TARGET_ABI_FMT_ld, ret);
> +        qemu_log(" (list = ");
> +        if (arg1 != 0) {
> +            abi_long attr = arg1;
> +            while (target_strlen(attr) != 0) {

You can't rely on target_strlen(), you should rely on the value returned
by the ioctl() (ret) that is defined as the length of the returned data.

Thanks,
Laurent


  reply	other threads:[~2020-06-15 11:53 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-11 15:51 [PATCH v3 0/6] Add strace support for printing arguments of selected syscalls Filip Bozuta
2020-06-11 15:51 ` [PATCH v3 1/6] linux-user: Extend strace support to enable argument printing after syscall execution Filip Bozuta
2020-06-15 11:44   ` Laurent Vivier
2020-06-11 15:51 ` [PATCH v3 2/6] linux-user: Add strace support for a group of syscalls Filip Bozuta
2020-06-11 15:51 ` [PATCH v3 3/6] linux-user: Add strace support for printing argument of syscalls used for extended attributes Filip Bozuta
2020-06-15 11:52   ` Laurent Vivier [this message]
2020-06-11 15:51 ` [PATCH v3 4/6] linux-user: Add strace support for printing arguments of lseek() Filip Bozuta
2020-06-11 15:51 ` [PATCH v3 5/6] linux-user: Add strace support for printing arguments of chown()/lchown() Filip Bozuta
2020-06-11 15:51 ` [PATCH v3 6/6] linux-user: Add strace support for printing arguments of fallocate() Filip Bozuta
2020-06-15 11:58   ` Laurent Vivier
2020-06-15 12:42     ` Filip Bozuta
2020-06-11 19:58 ` [PATCH v3 0/6] Add strace support for printing arguments of selected syscalls no-reply

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=31cda0bd-0c42-bf99-0256-007688059c4d@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 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).