From: Aurelien Jarno <aurelien@aurel32.net>
To: Riku Voipio <riku.voipio@iki.fi>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 05/10] Added posix message queue syscalls except mq_notify
Date: Wed, 15 Apr 2009 18:13:19 +0200 [thread overview]
Message-ID: <20090415161319.GC26206@hall.aurel32.net> (raw)
In-Reply-To: <8c2ee400c6638bd31f60f585f79c5fc4d044456c.1238963514.git.riku.voipio@iki.fi>
On Sun, Apr 05, 2009 at 11:59:21PM +0300, riku.voipio@iki.fi wrote:
> From: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
>
> From: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
>
> Added Added posix message queue syscalls and their strace
> prints.
>
> From: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
>
> Signed-off-by: Lionel Landwerlin <lionel.landwerlin@openwide.fr>
> Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>
> Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
> ---
> linux-user/strace.list | 12 ++--
> linux-user/syscall.c | 113 +++++++++++++++++++++++++++++++++++++++++++++
> linux-user/syscall_defs.h | 7 +++
> 3 files changed, 126 insertions(+), 6 deletions(-)
Thanks, applied.
> diff --git a/linux-user/strace.list b/linux-user/strace.list
> index 09a801f..3f688db 100644
> --- a/linux-user/strace.list
> +++ b/linux-user/strace.list
> @@ -524,22 +524,22 @@
> { TARGET_NR_mpx, "mpx" , NULL, NULL, NULL },
> #endif
> #ifdef TARGET_NR_mq_getsetattr
> -{ TARGET_NR_mq_getsetattr, "mq_getsetattr" , NULL, NULL, NULL },
> +{ TARGET_NR_mq_getsetattr, "mq_getsetattr" , "%s(%d,%p,%p)", NULL, NULL },
> #endif
> #ifdef TARGET_NR_mq_notify
> -{ TARGET_NR_mq_notify, "mq_notify" , NULL, NULL, NULL },
> +{ TARGET_NR_mq_notify, "mq_notify" , "%s(%d,%p)", NULL, NULL },
> #endif
> #ifdef TARGET_NR_mq_open
> -{ TARGET_NR_mq_open, "mq_open" , NULL, NULL, NULL },
> +{ TARGET_NR_mq_open, "mq_open" , "%s(\"/%s\",%#x,%#o,%p)", NULL, NULL },
> #endif
> #ifdef TARGET_NR_mq_timedreceive
> -{ TARGET_NR_mq_timedreceive, "mq_timedreceive" , NULL, NULL, NULL },
> +{ TARGET_NR_mq_timedreceive, "mq_timedreceive" , "%s(%d,%p,%d,%u,%p)", NULL, NULL },
> #endif
> #ifdef TARGET_NR_mq_timedsend
> -{ TARGET_NR_mq_timedsend, "mq_timedsend" , NULL, NULL, NULL },
> +{ TARGET_NR_mq_timedsend, "mq_timedsend" , "%s(%d,%p,%d,%u,%p)", NULL, NULL },
> #endif
> #ifdef TARGET_NR_mq_unlink
> -{ TARGET_NR_mq_unlink, "mq_unlink" , NULL, NULL, NULL },
> +{ TARGET_NR_mq_unlink, "mq_unlink" , "%s(%s)", NULL, NULL },
> #endif
> #ifdef TARGET_NR_mremap
> { TARGET_NR_mremap, "mremap" , NULL, NULL, NULL },
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 88ed46c..30bb617 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -29,6 +29,7 @@
> #include <fcntl.h>
> #include <time.h>
> #include <limits.h>
> +#include <mqueue.h>
> #include <sys/types.h>
> #include <sys/ipc.h>
> #include <sys/msg.h>
> @@ -635,6 +636,43 @@ static inline abi_long copy_to_user_timeval(abi_ulong target_tv_addr,
> return 0;
> }
>
> +static inline abi_long copy_from_user_mq_attr(struct mq_attr *attr,
> + abi_ulong target_mq_attr_addr)
> +{
> + struct target_mq_attr *target_mq_attr;
> +
> + if (!lock_user_struct(VERIFY_READ, target_mq_attr,
> + target_mq_attr_addr, 1))
> + return -TARGET_EFAULT;
> +
> + __get_user(attr->mq_flags, &target_mq_attr->mq_flags);
> + __get_user(attr->mq_maxmsg, &target_mq_attr->mq_maxmsg);
> + __get_user(attr->mq_msgsize, &target_mq_attr->mq_msgsize);
> + __get_user(attr->mq_curmsgs, &target_mq_attr->mq_curmsgs);
> +
> + unlock_user_struct(target_mq_attr, target_mq_attr_addr, 0);
> +
> + return 0;
> +}
> +
> +static inline abi_long copy_to_user_mq_attr(abi_ulong target_mq_attr_addr,
> + const struct mq_attr *attr)
> +{
> + struct target_mq_attr *target_mq_attr;
> +
> + if (!lock_user_struct(VERIFY_WRITE, target_mq_attr,
> + target_mq_attr_addr, 0))
> + return -TARGET_EFAULT;
> +
> + __put_user(attr->mq_flags, &target_mq_attr->mq_flags);
> + __put_user(attr->mq_maxmsg, &target_mq_attr->mq_maxmsg);
> + __put_user(attr->mq_msgsize, &target_mq_attr->mq_msgsize);
> + __put_user(attr->mq_curmsgs, &target_mq_attr->mq_curmsgs);
> +
> + unlock_user_struct(target_mq_attr, target_mq_attr_addr, 1);
> +
> + return 0;
> +}
>
> /* do_select() must return target values and target errnos. */
> static abi_long do_select(int n,
> @@ -6439,6 +6477,81 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
> break;
> #endif
>
> +#ifdef TARGET_NR_mq_open
> + case TARGET_NR_mq_open:
> + {
> + struct mq_attr posix_mq_attr;
> +
> + p = lock_user_string(arg1 - 1);
> + if (arg4 != 0)
> + copy_from_user_mq_attr (&posix_mq_attr, arg4);
> + ret = get_errno(mq_open(p, arg2, arg3, &posix_mq_attr));
> + unlock_user (p, arg1, 0);
> + break;
> + }
> +
> + case TARGET_NR_mq_unlink:
> + p = lock_user_string(arg1 - 1);
> + ret = get_errno(mq_unlink(p));
> + unlock_user (p, arg1, 0);
> + break;
> +
> + case TARGET_NR_mq_timedsend:
> + {
> + struct timespec ts;
> +
> + p = lock_user (VERIFY_READ, arg2, arg3, 1);
> + if (arg5 != 0) {
> + target_to_host_timespec(&ts, arg5);
> + ret = get_errno(mq_timedsend(arg1, p, arg3, arg4, &ts));
> + host_to_target_timespec(arg5, &ts);
> + }
> + else
> + ret = get_errno(mq_send(arg1, p, arg3, arg4));
> + unlock_user (p, arg2, arg3);
> + break;
> + }
> +
> + case TARGET_NR_mq_timedreceive:
> + {
> + struct timespec ts;
> + unsigned int prio;
> +
> + p = lock_user (VERIFY_READ, arg2, arg3, 1);
> + if (arg5 != 0) {
> + target_to_host_timespec(&ts, arg5);
> + ret = get_errno(mq_timedreceive(arg1, p, arg3, &prio, &ts));
> + host_to_target_timespec(arg5, &ts);
> + }
> + else
> + ret = get_errno(mq_receive(arg1, p, arg3, &prio));
> + unlock_user (p, arg2, arg3);
> + if (arg4 != 0)
> + put_user_u32(prio, arg4);
> + break;
> + }
> +
> + /* Not implemented for now... */
> +/* case TARGET_NR_mq_notify: */
> +/* break; */
> +
> + case TARGET_NR_mq_getsetattr:
> + {
> + struct mq_attr posix_mq_attr_in, posix_mq_attr_out;
> + ret = 0;
> + if (arg3 != 0) {
> + ret = mq_getattr(arg1, &posix_mq_attr_out);
> + copy_to_user_mq_attr(arg3, &posix_mq_attr_out);
> + }
> + if (arg2 != 0) {
> + copy_from_user_mq_attr(&posix_mq_attr_in, arg2);
> + ret |= mq_setattr(arg1, &posix_mq_attr_in, &posix_mq_attr_out);
> + }
> +
> + break;
> + }
> +#endif
> +
> default:
> unimplemented:
> gemu_log("qemu: Unsupported syscall: %d\n", num);
> diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
> index 7db7a8c..a373690 100644
> --- a/linux-user/syscall_defs.h
> +++ b/linux-user/syscall_defs.h
> @@ -1998,6 +1998,13 @@ struct linux_dirent64 {
> char d_name[256];
> };
>
> +struct target_mq_attr {
> + abi_long mq_flags;
> + abi_long mq_maxmsg;
> + abi_long mq_msgsize;
> + abi_long mq_curmsgs;
> +};
> +
> #include "socket.h"
>
> #include "errno_defs.h"
> --
> 1.6.2.1
>
>
>
>
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
next prev parent reply other threads:[~2009-04-15 16:13 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-04-05 20:59 [Qemu-devel] [PATCH 00/10] misc userland patches [v2] riku.voipio
2009-04-05 20:59 ` [Qemu-devel] [PATCH 01/10] Fix fstatat64()/newfstatat() syscall implementation riku.voipio
2009-04-05 20:59 ` [Qemu-devel] [PATCH 02/10] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets riku.voipio
2009-04-05 20:59 ` [Qemu-devel] [PATCH 03/10] Implement shm* syscalls and fix 64/32bit errors riku.voipio
2009-04-15 16:21 ` [Qemu-devel] [PATCH 02/10] Rewrite mmap_find_vma() to work fine on 64-bit hosts with 32-bit targets Aurelien Jarno
2009-04-05 20:59 ` [Qemu-devel] [PATCH 04/10] fix IPCOP_sem* and implement sem* riku.voipio
2009-04-06 9:06 ` Arnaud Patard
2009-04-06 15:17 ` Riku Voipio
2009-04-06 16:22 ` Arnaud Patard
2009-04-15 15:28 ` Aurelien Jarno
2009-04-16 14:23 ` Riku Voipio
2009-04-18 16:16 ` Aurelien Jarno
2009-04-05 20:59 ` [Qemu-devel] [PATCH 05/10] Added posix message queue syscalls except mq_notify riku.voipio
2009-04-15 16:13 ` Aurelien Jarno [this message]
2009-04-05 20:59 ` [Qemu-devel] [PATCH 06/10] Add support for passing contents of argv0 riku.voipio
2009-04-15 16:13 ` Aurelien Jarno
2009-04-05 20:59 ` [Qemu-devel] [PATCH 07/10] linux-user: unix sockets - fix running dbus riku.voipio
2009-04-15 16:14 ` Aurelien Jarno
2009-04-05 20:59 ` [Qemu-devel] [PATCH 08/10] linux-user: removed unnecessary MAX_SOCK_ADDR checks for socket syscalls riku.voipio
2009-04-15 16:14 ` Aurelien Jarno
2009-04-05 20:59 ` [Qemu-devel] [PATCH 09/10] Prefer glibc over direct syscalls riku.voipio
2009-04-15 16:14 ` Aurelien Jarno
2009-04-05 20:59 ` [Qemu-devel] [PATCH 10/10] linux-user: Proper exit code for uncaught signals riku.voipio
2009-04-15 16:19 ` Aurelien Jarno
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=20090415161319.GC26206@hall.aurel32.net \
--to=aurelien@aurel32.net \
--cc=qemu-devel@nongnu.org \
--cc=riku.voipio@iki.fi \
/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.