From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1Lu7iD-0000zZ-Qo for qemu-devel@nongnu.org; Wed, 15 Apr 2009 12:11:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1Lu7iD-0000yk-2m for qemu-devel@nongnu.org; Wed, 15 Apr 2009 12:11:45 -0400 Received: from [199.232.76.173] (port=48806 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Lu7iC-0000yY-RD for qemu-devel@nongnu.org; Wed, 15 Apr 2009 12:11:44 -0400 Received: from savannah.gnu.org ([199.232.41.3]:50082 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1Lu7iC-0003M8-Fc for qemu-devel@nongnu.org; Wed, 15 Apr 2009 12:11:44 -0400 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Lu7iC-00075y-0t for qemu-devel@nongnu.org; Wed, 15 Apr 2009 16:11:44 +0000 Received: from aurel32 by cvs.savannah.gnu.org with local (Exim 4.69) (envelope-from ) id 1Lu7iB-00075u-OS for qemu-devel@nongnu.org; Wed, 15 Apr 2009 16:11:43 +0000 MIME-Version: 1.0 Errors-To: aurel32 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Aurelien Jarno Message-Id: Date: Wed, 15 Apr 2009 16:11:43 +0000 Subject: [Qemu-devel] [7114] linux-user: Added posix message queue syscalls except mq_notify Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Revision: 7114 http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=7114 Author: aurel32 Date: 2009-04-15 16:11:43 +0000 (Wed, 15 Apr 2009) Log Message: ----------- linux-user: Added posix message queue syscalls except mq_notify Signed-off-by: Lionel Landwerlin Signed-off-by: Kirill A. Shutemov Signed-off-by: Riku Voipio Signed-off-by: Aurelien Jarno Modified Paths: -------------- trunk/linux-user/strace.list trunk/linux-user/syscall.c trunk/linux-user/syscall_defs.h Modified: trunk/linux-user/strace.list =================================================================== --- trunk/linux-user/strace.list 2009-04-15 16:04:03 UTC (rev 7113) +++ trunk/linux-user/strace.list 2009-04-15 16:11:43 UTC (rev 7114) @@ -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 }, Modified: trunk/linux-user/syscall.c =================================================================== --- trunk/linux-user/syscall.c 2009-04-15 16:04:03 UTC (rev 7113) +++ trunk/linux-user/syscall.c 2009-04-15 16:11:43 UTC (rev 7114) @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -635,7 +636,44 @@ 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, abi_ulong rfd_addr, abi_ulong wfd_addr, @@ -6148,6 +6186,81 @@ 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); Modified: trunk/linux-user/syscall_defs.h =================================================================== --- trunk/linux-user/syscall_defs.h 2009-04-15 16:04:03 UTC (rev 7113) +++ trunk/linux-user/syscall_defs.h 2009-04-15 16:11:43 UTC (rev 7114) @@ -1998,6 +1998,13 @@ 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"