1999-02-19 03:21:36 +03:00
/*
* Copyright ( c ) 1993 Ulrich Pegelow < pegelow @ moorea . uni - muenster . de >
* Copyright ( c ) 1993 Branko Lankester < branko @ hacktic . nl >
* Copyright ( c ) 1993 , 1994 , 1995 , 1996 Rick Sladkey < jrs @ world . std . com >
1999-12-23 17:20:14 +03:00
* Copyright ( c ) 1996 - 1999 Wichert Akkerman < wichert @ cistron . nl >
1999-02-19 03:21:36 +03:00
* All rights reserved .
*
* Redistribution and use in source and binary forms , with or without
* modification , are permitted provided that the following conditions
* are met :
* 1. Redistributions of source code must retain the above copyright
* notice , this list of conditions and the following disclaimer .
* 2. Redistributions in binary form must reproduce the above copyright
* notice , this list of conditions and the following disclaimer in the
* documentation and / or other materials provided with the distribution .
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission .
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ` ` AS IS ' ' AND ANY EXPRESS OR
* IMPLIED WARRANTIES , INCLUDING , BUT NOT LIMITED TO , THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED .
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT , INDIRECT ,
* INCIDENTAL , SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT
* NOT LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE ,
* DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
*/
# include "defs.h"
2012-03-16 15:02:22 +04:00
# ifdef HAVE_MQUEUE_H
# include <mqueue.h>
# endif
2004-04-17 01:48:40 +04:00
# include <fcntl.h>
1999-02-19 03:21:36 +03:00
# include <sys/ipc.h>
# include <sys/sem.h>
# include <sys/msg.h>
# include <sys/shm.h>
# ifndef MSG_STAT
# define MSG_STAT 11
# endif
# ifndef MSG_INFO
# define MSG_INFO 12
# endif
# ifndef SHM_STAT
# define SHM_STAT 13
# endif
# ifndef SHM_INFO
# define SHM_INFO 14
# endif
# ifndef SEM_STAT
# define SEM_STAT 18
# endif
# ifndef SEM_INFO
# define SEM_INFO 19
# endif
2012-02-25 05:38:52 +04:00
# if !defined IPC_64
2003-01-14 12:46:17 +03:00
# define IPC_64 0x100
# endif
2004-04-17 01:48:40 +04:00
extern void printsigevent ( struct tcb * tcp , long arg ) ;
2004-09-04 07:39:20 +04:00
static const struct xlat msgctl_flags [ ] = {
2014-02-05 05:33:50 +04:00
XLAT ( IPC_RMID ) ,
XLAT ( IPC_SET ) ,
XLAT ( IPC_STAT ) ,
XLAT ( IPC_INFO ) ,
XLAT ( MSG_STAT ) ,
XLAT ( MSG_INFO ) ,
2014-02-05 06:20:51 +04:00
XLAT_END
1999-02-19 03:21:36 +03:00
} ;
2004-09-04 07:39:20 +04:00
static const struct xlat semctl_flags [ ] = {
2014-02-05 05:33:50 +04:00
XLAT ( IPC_RMID ) ,
XLAT ( IPC_SET ) ,
XLAT ( IPC_STAT ) ,
XLAT ( IPC_INFO ) ,
XLAT ( SEM_STAT ) ,
XLAT ( SEM_INFO ) ,
XLAT ( GETPID ) ,
XLAT ( GETVAL ) ,
XLAT ( GETALL ) ,
XLAT ( GETNCNT ) ,
XLAT ( GETZCNT ) ,
XLAT ( SETVAL ) ,
XLAT ( SETALL ) ,
2014-02-05 06:20:51 +04:00
XLAT_END
1999-02-19 03:21:36 +03:00
} ;
2004-09-04 07:39:20 +04:00
static const struct xlat shmctl_flags [ ] = {
2014-02-05 05:33:50 +04:00
XLAT ( IPC_RMID ) ,
XLAT ( IPC_SET ) ,
XLAT ( IPC_STAT ) ,
XLAT ( IPC_INFO ) ,
XLAT ( SHM_STAT ) ,
XLAT ( SHM_INFO ) ,
2003-01-14 12:46:17 +03:00
# ifdef SHM_LOCK
2014-02-05 05:33:50 +04:00
XLAT ( SHM_LOCK ) ,
2000-09-02 01:03:06 +04:00
# endif
2003-01-14 12:46:17 +03:00
# ifdef SHM_UNLOCK
2014-02-05 05:33:50 +04:00
XLAT ( SHM_UNLOCK ) ,
2003-01-14 12:46:17 +03:00
# endif
2014-02-05 06:20:51 +04:00
XLAT_END
1999-02-19 03:21:36 +03:00
} ;
2004-09-04 07:39:20 +04:00
static const struct xlat resource_flags [ ] = {
2014-02-05 05:33:50 +04:00
XLAT ( IPC_CREAT ) ,
XLAT ( IPC_EXCL ) ,
XLAT ( IPC_NOWAIT ) ,
2014-02-05 06:20:51 +04:00
XLAT_END
2005-05-09 11:40:33 +04:00
} ;
static const struct xlat shm_resource_flags [ ] = {
2014-02-05 05:33:50 +04:00
XLAT ( IPC_CREAT ) ,
XLAT ( IPC_EXCL ) ,
2003-07-17 13:03:04 +04:00
# ifdef SHM_HUGETLB
2014-02-05 05:33:50 +04:00
XLAT ( SHM_HUGETLB ) ,
2003-07-17 13:03:04 +04:00
# endif
2014-02-05 06:20:51 +04:00
XLAT_END
1999-02-19 03:21:36 +03:00
} ;
2004-09-04 07:39:20 +04:00
static const struct xlat shm_flags [ ] = {
2014-02-05 05:33:50 +04:00
XLAT ( SHM_REMAP ) ,
XLAT ( SHM_RDONLY ) ,
XLAT ( SHM_RND ) ,
2014-02-05 06:20:51 +04:00
XLAT_END
1999-02-19 03:21:36 +03:00
} ;
2014-04-26 03:39:20 +04:00
static const struct xlat ipc_msg_flags [ ] = {
2014-02-05 05:33:50 +04:00
XLAT ( MSG_NOERROR ) ,
XLAT ( MSG_EXCEPT ) ,
XLAT ( IPC_NOWAIT ) ,
2014-02-05 06:20:51 +04:00
XLAT_END
1999-02-19 03:21:36 +03:00
} ;
2009-10-08 00:25:10 +04:00
static const struct xlat semop_flags [ ] = {
2014-02-05 05:33:50 +04:00
XLAT ( SEM_UNDO ) ,
XLAT ( IPC_NOWAIT ) ,
2014-02-05 06:20:51 +04:00
XLAT_END
2009-10-08 00:25:10 +04:00
} ;
2011-05-30 16:00:14 +04:00
int sys_msgget ( struct tcb * tcp )
1999-02-19 03:21:36 +03:00
{
if ( entering ( tcp ) ) {
if ( tcp - > u_arg [ 0 ] )
2013-02-23 23:07:44 +04:00
tprintf ( " %#lx, " , tcp - > u_arg [ 0 ] ) ;
1999-02-19 03:21:36 +03:00
else
2013-02-23 23:07:44 +04:00
tprints ( " IPC_PRIVATE, " ) ;
2005-05-31 Dmitry V. Levin <ldv@altlinux.org>
* util.c (printxval): Change third argument from "char *" to
"const char *".
(printflags): Add third argument, "const char *", with similar
meaning to the third argument of printxval().
* defs.h (printxval): Change third argument from "char *" to
"const char *".
(printflags): Add third argument.
* bjm.c (sys_query_module) [LINUX]: Pass third argument to
printflags().
* desc.c (sys_fcntl): Likewise.
(sys_flock) [LOCK_SH]: Likewise.
(print_epoll_event) [HAVE_SYS_EPOLL_H]: Likewise.
* file.c (sys_open): Likewise.
(solaris_open) [LINUXSPARC]: Likewise.
(sys_access): Likewise.
(sys_chflags, sys_fchflags) [FREEBSD]: Likewise.
(realprintstat) [HAVE_LONG_LONG_OFF_T &&
HAVE_STRUCT_STAT_ST_FLAGS]: Likewise.
(printstat64) [HAVE_STAT64 &&
HAVE_STRUCT_STAT_ST_FLAGS]: Likewise.
(sys_setxattr, sys_fsetxattr): Likewise.
* ipc.c (sys_msgget, sys_msgsnd, sys_msgrcv, sys_semget,
sys_shmget, sys_shmat) [LINUX || SUNOS4 || FREEBSD]: Likewise.
(sys_mq_open) [LINUX]: Likewise.
(printmqattr) [HAVE_MQUEUE_H]: Likewise.
* mem.c (print_mmap) [!HAVE_LONG_LONG_OFF_T]: Likewise.
(sys_mmap64) [_LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T]: Likewise.
(sys_mprotect): Likewise.
(sys_mremap, sys_madvise, sys_mlockall) [LINUX]: Likewise.
(sys_msync) [MS_ASYNC]: Likewise.
(sys_mctl) [MC_SYNC]: Likewise.
(sys_remap_file_pages, sys_mbind, sys_get_mempolicy) [LINUX]:
Likewise.
* net.c (printmsghdr) [HAVE_STRUCT_MSGHDR_MSG_CONTROL]: Likewise.
(sys_send, sys_sendto): Likewise.
(sys_sendmsg) [HAVE_SENDMSG]: Likewise.
(sys_recv, sys_recvfrom): Likewise.
(sys_recvmsg) [HAVE_SENDMSG]: Likewise.
(printicmpfilter) [ICMP_FILTER]: Likewise.
* proc.c (proc_ioctl) [SVR4 && !HAVE_MP_PROCFS || FREEBSD]: Likewise.
* process.c (sys_clone) [LINUX]: Likewise.
(printwaitn): Likewise.
(sys_waitid) [SVR4 || LINUX]: Likewise.
* signal.c (sys_sigvec) [SUNOS4 || FREEBSD]: Likewise.
(sys_sigaction): Likewise.
(printcontext) [SVR4]: Likewise.
(print_stack_t) [LINUX) || FREEBSD]: Likewise.
(sys_rt_sigaction) [LINUX]: Likewise.
* sock.c (sock_ioctl) [LINUX]: Likewise.
* stream.c (sys_putmsg, sys_getmsg): Likewise.
(sys_putpmsg) [SYS_putpmsg]: Likewise.
(sys_getpmsg) [SYS_getpmsg]: Likewise.
(sys_poll): Likewise.
(print_transport_message) [TI_BIND]: Likewise.
(stream_ioctl): Likewise.
* system.c (sys_mount, sys_reboot): Likewise.
(sys_cacheflush) [LINUX && M68K]: Likewise.
(sys_capget, sys_capset) [SYS_capget]: Likewise.
* term.c (term_ioctl) [TIOCMGET]: Likewise.
* time.c (sys_clock_nanosleep, sys_timer_settime) [LINUX]:
Likewise.
Fixes RH#159310.
2005-06-01 23:02:36 +04:00
if ( printflags ( resource_flags , tcp - > u_arg [ 1 ] & ~ 0777 , NULL ) ! = 0 )
2011-09-01 12:00:28 +04:00
tprints ( " | " ) ;
2003-07-17 13:03:04 +04:00
tprintf ( " %#lo " , tcp - > u_arg [ 1 ] & 0777 ) ;
1999-02-19 03:21:36 +03:00
}
return 0 ;
}
2003-01-14 12:46:17 +03:00
# ifdef IPC_64
# define PRINTCTL(flagset, arg, dflt) \
2011-09-01 12:00:28 +04:00
if ( ( arg ) & IPC_64 ) tprints ( " IPC_64| " ) ; \
2003-01-14 12:46:17 +03:00
printxval ( ( flagset ) , ( arg ) & ~ IPC_64 , dflt )
# else
# define PRINTCTL printxval
# endif
2005-12-02 06:57:07 +03:00
static int
2011-05-30 16:00:14 +04:00
indirect_ipccall ( struct tcb * tcp )
2005-12-02 06:57:07 +03:00
{
# ifdef X86_64
Add x32 support to strace
X32 support is added to Linux kernel 3.4. In a nutshell, x32 is x86-64 with
32bit pointers. At system call level, x32 is also identical to x86-64,
as shown by many changes like "defined(X86_64) || defined(X32)". The
main differerence bewteen x32 and x86-64 is off_t in x32 is long long
instead of long.
This patch adds x32 support to strace. Tested on Linux/x32.
* configure.ac: Support X32.
* defs.h: Set SUPPORTED_PERSONALITIES to 3 for X86_64,
Set PERSONALITY2_WORDSIZE to 4 for X86_64.
Add tcb::ext_arg for X32.
* file.c (stat): New for X32.
(sys_lseek): Use 64-bit version for X32.
(printstat64): Check current_personality != 1 for X86_64.
* ipc.c (indirect_ipccall): Check current_personality == 1
for X86_64.
* mem.c (sys_mmap64): Also use tcp->u_arg for X32. Print NULL
for zero address. Call printllval for offset for X32.
* pathtrace.c (pathtrace_match): Don't check sys_old_mmap for
X32.
* process.c (ARG_FLAGS): Defined for X32.
(ARG_STACK): Likewise.
(ARG_PTID): Likewise.
(change_syscall): Handle X32.
(struct_user_offsets): Support X32.
(sys_arch_prctl): Likewise.
* signal.c: Include <asm/sigcontext.h> for X32.
(SA_RESTORER): Also define for X32.
* syscall.c (update_personality): Support X32 for X86_64.
(is_restart_error): Likewise.
(syscall_fixup_on_sysenter): Likewise.
(get_syscall_args): Likewise.
(get_syscall_result): Likewise.
(get_error): Likewise.
(__X32_SYSCALL_BIT): Define if not defined.
(__X32_SYSCALL_MASK): Likewise.
(get_scno): Check DS register value for X32. Use
__X32_SYSCALL_MASK on X32 system calls.
* util.c (printllval): Use ext_arg for X32.
(printcall): Support X32.
(change_syscall): Likewise.
(arg0_offset): Likewise.
(arg1_offset): Likewise.
* Makefile.am (EXTRA_DIST): Add linux/x32/errnoent.h,
linux/x32/ioctlent.h.in, linux/x32/signalent.h,
linux/x32/syscallent.h, linux/x86_64/errnoent2.h,
linux/x86_64/ioctlent2.h, linux/x86_64/signalent2.h and
linux/x86_64/syscallent2.h.
* linux/x32/errnoent.h: New.
* linux/x32/ioctlent.h.in: Likewise.
* linux/x32/signalent.h: Likewise.
* linux/x32/syscallent.h: Likewise.
* linux/x86_64/errnoent2.h: Likewise.
* linux/x86_64/ioctlent2.h: Likewise.
* linux/x86_64/signalent2.h: Likewise.
* linux/x86_64/syscallent2.h: Likewise.
Signed-off-by: H.J. Lu <hongjiu.lu@intel.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
2012-04-16 15:00:01 +04:00
return current_personality = = 1 ;
2005-12-02 06:57:07 +03:00
# endif
2005-12-02 07:18:55 +03:00
# if defined IA64
return tcp - > scno < 1024 ; /* ia32 emulation syscalls are low */
2005-12-02 06:57:07 +03:00
# endif
2012-10-24 20:58:16 +04:00
# if defined(ALPHA) || defined(MIPS) || defined(HPPA) || defined(__ARM_EABI__) || defined(AARCH64)
2005-12-02 06:57:07 +03:00
return 0 ;
2012-03-16 01:19:36 +04:00
# endif
return 1 ;
2005-12-02 06:57:07 +03:00
}
2011-05-30 16:00:14 +04:00
int sys_msgctl ( struct tcb * tcp )
1999-02-19 03:21:36 +03:00
{
if ( entering ( tcp ) ) {
2003-01-14 12:46:17 +03:00
tprintf ( " %lu, " , tcp - > u_arg [ 0 ] ) ;
PRINTCTL ( msgctl_flags , tcp - > u_arg [ 1 ] , " MSG_??? " ) ;
2005-12-02 06:57:07 +03:00
tprintf ( " , %#lx " , tcp - > u_arg [ indirect_ipccall ( tcp ) ? 3 : 2 ] ) ;
1999-02-19 03:21:36 +03:00
}
return 0 ;
}
2009-10-09 03:33:15 +04:00
static void
2010-04-01 02:22:01 +04:00
tprint_msgsnd ( struct tcb * tcp , long addr , unsigned long count ,
unsigned long flags )
1999-02-19 03:21:36 +03:00
{
long mtype ;
2009-10-09 03:33:15 +04:00
if ( umove ( tcp , addr , & mtype ) < 0 ) {
tprintf ( " %#lx " , addr ) ;
} else {
tprintf ( " {%lu, " , mtype ) ;
printstr ( tcp , addr + sizeof ( mtype ) , count ) ;
2011-09-01 12:00:28 +04:00
tprints ( " } " ) ;
2009-10-09 03:33:15 +04:00
}
tprintf ( " , %lu, " , count ) ;
2014-04-26 03:39:20 +04:00
printflags ( ipc_msg_flags , flags , " MSG_??? " ) ;
2009-10-09 03:33:15 +04:00
}
int sys_msgsnd ( struct tcb * tcp )
{
1999-02-19 03:21:36 +03:00
if ( entering ( tcp ) ) {
2009-11-03 17:38:44 +03:00
tprintf ( " %d, " , ( int ) tcp - > u_arg [ 0 ] ) ;
2005-12-02 06:57:07 +03:00
if ( indirect_ipccall ( tcp ) ) {
2010-04-01 02:22:01 +04:00
tprint_msgsnd ( tcp , tcp - > u_arg [ 3 ] , tcp - > u_arg [ 1 ] ,
tcp - > u_arg [ 2 ] ) ;
2005-12-02 06:57:07 +03:00
} else {
2010-04-01 02:22:01 +04:00
tprint_msgsnd ( tcp , tcp - > u_arg [ 1 ] , tcp - > u_arg [ 2 ] ,
tcp - > u_arg [ 3 ] ) ;
2005-12-02 06:57:07 +03:00
}
1999-02-19 03:21:36 +03:00
}
return 0 ;
}
2009-11-03 17:38:44 +03:00
static void
tprint_msgrcv ( struct tcb * tcp , long addr , unsigned long count , long msgtyp )
1999-02-19 03:21:36 +03:00
{
long mtype ;
2009-11-03 17:38:44 +03:00
if ( syserror ( tcp ) | | umove ( tcp , addr , & mtype ) < 0 ) {
tprintf ( " %#lx " , addr ) ;
} else {
tprintf ( " {%lu, " , mtype ) ;
printstr ( tcp , addr + sizeof ( mtype ) , count ) ;
2011-09-01 12:00:28 +04:00
tprints ( " } " ) ;
2009-11-03 17:38:44 +03:00
}
tprintf ( " , %lu, %ld, " , count , msgtyp ) ;
}
int sys_msgrcv ( struct tcb * tcp )
{
2005-12-02 06:44:12 +03:00
if ( entering ( tcp ) ) {
2009-11-03 17:38:44 +03:00
tprintf ( " %d, " , ( int ) tcp - > u_arg [ 0 ] ) ;
2005-12-02 06:44:12 +03:00
} else {
2005-12-02 06:57:07 +03:00
if ( indirect_ipccall ( tcp ) ) {
struct ipc_wrapper {
struct msgbuf * msgp ;
long msgtyp ;
} tmp ;
2009-11-03 17:38:44 +03:00
if ( umove ( tcp , tcp - > u_arg [ 3 ] , & tmp ) < 0 ) {
tprintf ( " %#lx, %lu, " ,
tcp - > u_arg [ 3 ] , tcp - > u_arg [ 1 ] ) ;
} else {
tprint_msgrcv ( tcp , ( long ) tmp . msgp ,
tcp - > u_arg [ 1 ] , tmp . msgtyp ) ;
}
2014-04-26 03:39:20 +04:00
printflags ( ipc_msg_flags , tcp - > u_arg [ 2 ] , " MSG_??? " ) ;
2005-12-02 06:57:07 +03:00
} else {
2009-11-03 17:38:44 +03:00
tprint_msgrcv ( tcp , tcp - > u_arg [ 1 ] ,
tcp - > u_arg [ 2 ] , tcp - > u_arg [ 3 ] ) ;
2014-04-26 03:39:20 +04:00
printflags ( ipc_msg_flags , tcp - > u_arg [ 4 ] , " MSG_??? " ) ;
2005-12-02 06:57:07 +03:00
}
1999-02-19 03:21:36 +03:00
}
return 0 ;
}
2009-10-08 02:14:00 +04:00
static void
tprint_sembuf ( struct tcb * tcp , long addr , unsigned long count )
1999-02-19 03:21:36 +03:00
{
2009-10-08 02:14:00 +04:00
unsigned long i , max_count ;
if ( abbrev ( tcp ) )
max_count = ( max_strlen < count ) ? max_strlen : count ;
else
max_count = count ;
if ( ! max_count ) {
tprintf ( " %#lx, %lu " , addr , count ) ;
return ;
}
2011-06-07 14:13:24 +04:00
for ( i = 0 ; i < max_count ; + + i ) {
2009-10-08 02:14:00 +04:00
struct sembuf sb ;
if ( i )
2011-09-01 12:00:28 +04:00
tprints ( " , " ) ;
2009-10-08 02:14:00 +04:00
if ( umove ( tcp , addr + i * sizeof ( struct sembuf ) , & sb ) < 0 ) {
if ( i ) {
2011-09-01 12:00:28 +04:00
tprints ( " {???} " ) ;
2009-10-08 02:14:00 +04:00
break ;
} else {
tprintf ( " %#lx, %lu " , addr , count ) ;
return ;
}
} else {
if ( ! i )
2011-09-01 12:00:28 +04:00
tprints ( " { " ) ;
2009-10-08 02:14:00 +04:00
tprintf ( " {%u, %d, " , sb . sem_num , sb . sem_op ) ;
printflags ( semop_flags , sb . sem_flg , " SEM_??? " ) ;
2011-09-01 12:00:28 +04:00
tprints ( " } " ) ;
2009-10-08 02:14:00 +04:00
}
}
if ( i < max_count | | max_count < count )
2011-09-01 12:00:28 +04:00
tprints ( " , ... " ) ;
2009-10-08 00:25:10 +04:00
2009-10-08 02:14:00 +04:00
tprintf ( " }, %lu " , count ) ;
}
int sys_semop ( struct tcb * tcp )
{
1999-02-19 03:21:36 +03:00
if ( entering ( tcp ) ) {
2009-10-08 02:14:00 +04:00
tprintf ( " %lu, " , tcp - > u_arg [ 0 ] ) ;
2005-12-02 06:57:07 +03:00
if ( indirect_ipccall ( tcp ) ) {
2009-10-08 02:14:00 +04:00
tprint_sembuf ( tcp , tcp - > u_arg [ 3 ] , tcp - > u_arg [ 1 ] ) ;
2005-12-02 06:57:07 +03:00
} else {
2009-10-08 02:14:00 +04:00
tprint_sembuf ( tcp , tcp - > u_arg [ 1 ] , tcp - > u_arg [ 2 ] ) ;
2005-12-02 06:57:07 +03:00
}
1999-02-19 03:21:36 +03:00
}
return 0 ;
}
2009-10-08 02:14:00 +04:00
int sys_semtimedop ( struct tcb * tcp )
2003-04-08 05:46:48 +04:00
{
if ( entering ( tcp ) ) {
2009-10-08 02:14:00 +04:00
tprintf ( " %lu, " , tcp - > u_arg [ 0 ] ) ;
2006-04-25 11:22:01 +04:00
if ( indirect_ipccall ( tcp ) ) {
2009-10-08 02:14:00 +04:00
tprint_sembuf ( tcp , tcp - > u_arg [ 3 ] , tcp - > u_arg [ 1 ] ) ;
2011-09-01 12:00:28 +04:00
tprints ( " , " ) ;
2012-12-10 23:18:49 +04:00
# if defined(S390) || defined(S390X)
2011-11-30 16:16:29 +04:00
printtv ( tcp , tcp - > u_arg [ 2 ] ) ;
# else
sys_semtimedop: fix timeval argument index in wrapped call
Looking at the implementation of wrapped semtimedop() call inside glibc
and kernel, I started to believe that timeval should be located in
tcp->u_arg[4] and not tcp->u_arg[5]. Fortunately, tcp->u_arg[5] now
works correctly as well, due to side effects of decode_ipc_subcall().
declaration in header:
int semtimedop(semid, *sops, nsops, *timeout);
0 1 2 3
sys_ipc arguments in glibc on all patforms except s390*:
semid, (int) nsops, 0, CHECK_N (sops, nsops), timeout
0 1 2 3 4
We have to use indexes: 0 3 1 4
sys_ipc arguments on s390*:
semid, (int) nsops, timeout, sops
0 1 2 3
We have to use indexes: 0 3 1 2
* ipc.c (sys_semtimedop) [!S390]: Fix timeval argument index in
indirect_ipccall case.
2012-12-08 00:30:51 +04:00
printtv ( tcp , tcp - > u_arg [ 4 ] ) ;
2011-11-30 16:16:29 +04:00
# endif
2005-12-02 06:57:07 +03:00
} else {
2009-10-08 02:14:00 +04:00
tprint_sembuf ( tcp , tcp - > u_arg [ 1 ] , tcp - > u_arg [ 2 ] ) ;
2011-09-01 12:00:28 +04:00
tprints ( " , " ) ;
2005-12-02 06:57:07 +03:00
printtv ( tcp , tcp - > u_arg [ 3 ] ) ;
}
2003-04-08 05:46:48 +04:00
}
return 0 ;
}
2011-05-30 16:00:14 +04:00
int sys_semget ( struct tcb * tcp )
1999-02-19 03:21:36 +03:00
{
if ( entering ( tcp ) ) {
if ( tcp - > u_arg [ 0 ] )
2006-08-22 11:36:55 +04:00
tprintf ( " %#lx " , tcp - > u_arg [ 0 ] ) ;
1999-02-19 03:21:36 +03:00
else
2011-09-01 12:00:28 +04:00
tprints ( " IPC_PRIVATE " ) ;
2013-02-23 23:07:44 +04:00
tprintf ( " , %lu, " , tcp - > u_arg [ 1 ] ) ;
2005-05-31 Dmitry V. Levin <ldv@altlinux.org>
* util.c (printxval): Change third argument from "char *" to
"const char *".
(printflags): Add third argument, "const char *", with similar
meaning to the third argument of printxval().
* defs.h (printxval): Change third argument from "char *" to
"const char *".
(printflags): Add third argument.
* bjm.c (sys_query_module) [LINUX]: Pass third argument to
printflags().
* desc.c (sys_fcntl): Likewise.
(sys_flock) [LOCK_SH]: Likewise.
(print_epoll_event) [HAVE_SYS_EPOLL_H]: Likewise.
* file.c (sys_open): Likewise.
(solaris_open) [LINUXSPARC]: Likewise.
(sys_access): Likewise.
(sys_chflags, sys_fchflags) [FREEBSD]: Likewise.
(realprintstat) [HAVE_LONG_LONG_OFF_T &&
HAVE_STRUCT_STAT_ST_FLAGS]: Likewise.
(printstat64) [HAVE_STAT64 &&
HAVE_STRUCT_STAT_ST_FLAGS]: Likewise.
(sys_setxattr, sys_fsetxattr): Likewise.
* ipc.c (sys_msgget, sys_msgsnd, sys_msgrcv, sys_semget,
sys_shmget, sys_shmat) [LINUX || SUNOS4 || FREEBSD]: Likewise.
(sys_mq_open) [LINUX]: Likewise.
(printmqattr) [HAVE_MQUEUE_H]: Likewise.
* mem.c (print_mmap) [!HAVE_LONG_LONG_OFF_T]: Likewise.
(sys_mmap64) [_LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T]: Likewise.
(sys_mprotect): Likewise.
(sys_mremap, sys_madvise, sys_mlockall) [LINUX]: Likewise.
(sys_msync) [MS_ASYNC]: Likewise.
(sys_mctl) [MC_SYNC]: Likewise.
(sys_remap_file_pages, sys_mbind, sys_get_mempolicy) [LINUX]:
Likewise.
* net.c (printmsghdr) [HAVE_STRUCT_MSGHDR_MSG_CONTROL]: Likewise.
(sys_send, sys_sendto): Likewise.
(sys_sendmsg) [HAVE_SENDMSG]: Likewise.
(sys_recv, sys_recvfrom): Likewise.
(sys_recvmsg) [HAVE_SENDMSG]: Likewise.
(printicmpfilter) [ICMP_FILTER]: Likewise.
* proc.c (proc_ioctl) [SVR4 && !HAVE_MP_PROCFS || FREEBSD]: Likewise.
* process.c (sys_clone) [LINUX]: Likewise.
(printwaitn): Likewise.
(sys_waitid) [SVR4 || LINUX]: Likewise.
* signal.c (sys_sigvec) [SUNOS4 || FREEBSD]: Likewise.
(sys_sigaction): Likewise.
(printcontext) [SVR4]: Likewise.
(print_stack_t) [LINUX) || FREEBSD]: Likewise.
(sys_rt_sigaction) [LINUX]: Likewise.
* sock.c (sock_ioctl) [LINUX]: Likewise.
* stream.c (sys_putmsg, sys_getmsg): Likewise.
(sys_putpmsg) [SYS_putpmsg]: Likewise.
(sys_getpmsg) [SYS_getpmsg]: Likewise.
(sys_poll): Likewise.
(print_transport_message) [TI_BIND]: Likewise.
(stream_ioctl): Likewise.
* system.c (sys_mount, sys_reboot): Likewise.
(sys_cacheflush) [LINUX && M68K]: Likewise.
(sys_capget, sys_capset) [SYS_capget]: Likewise.
* term.c (term_ioctl) [TIOCMGET]: Likewise.
* time.c (sys_clock_nanosleep, sys_timer_settime) [LINUX]:
Likewise.
Fixes RH#159310.
2005-06-01 23:02:36 +04:00
if ( printflags ( resource_flags , tcp - > u_arg [ 2 ] & ~ 0777 , NULL ) ! = 0 )
2011-09-01 12:00:28 +04:00
tprints ( " | " ) ;
2003-07-17 13:03:04 +04:00
tprintf ( " %#lo " , tcp - > u_arg [ 2 ] & 0777 ) ;
1999-02-19 03:21:36 +03:00
}
return 0 ;
}
2011-05-30 16:00:14 +04:00
int sys_semctl ( struct tcb * tcp )
1999-02-19 03:21:36 +03:00
{
if ( entering ( tcp ) ) {
2013-02-23 23:07:44 +04:00
tprintf ( " %lu, %lu, " , tcp - > u_arg [ 0 ] , tcp - > u_arg [ 1 ] ) ;
2003-01-14 12:46:17 +03:00
PRINTCTL ( semctl_flags , tcp - > u_arg [ 2 ] , " SEM_??? " ) ;
1999-02-19 03:21:36 +03:00
tprintf ( " , %#lx " , tcp - > u_arg [ 3 ] ) ;
}
return 0 ;
}
2011-05-30 16:00:14 +04:00
int sys_shmget ( struct tcb * tcp )
1999-02-19 03:21:36 +03:00
{
if ( entering ( tcp ) ) {
if ( tcp - > u_arg [ 0 ] )
2006-08-22 11:36:55 +04:00
tprintf ( " %#lx " , tcp - > u_arg [ 0 ] ) ;
1999-02-19 03:21:36 +03:00
else
2011-09-01 12:00:28 +04:00
tprints ( " IPC_PRIVATE " ) ;
2013-02-23 23:07:44 +04:00
tprintf ( " , %lu, " , tcp - > u_arg [ 1 ] ) ;
2005-05-31 Dmitry V. Levin <ldv@altlinux.org>
* util.c (printxval): Change third argument from "char *" to
"const char *".
(printflags): Add third argument, "const char *", with similar
meaning to the third argument of printxval().
* defs.h (printxval): Change third argument from "char *" to
"const char *".
(printflags): Add third argument.
* bjm.c (sys_query_module) [LINUX]: Pass third argument to
printflags().
* desc.c (sys_fcntl): Likewise.
(sys_flock) [LOCK_SH]: Likewise.
(print_epoll_event) [HAVE_SYS_EPOLL_H]: Likewise.
* file.c (sys_open): Likewise.
(solaris_open) [LINUXSPARC]: Likewise.
(sys_access): Likewise.
(sys_chflags, sys_fchflags) [FREEBSD]: Likewise.
(realprintstat) [HAVE_LONG_LONG_OFF_T &&
HAVE_STRUCT_STAT_ST_FLAGS]: Likewise.
(printstat64) [HAVE_STAT64 &&
HAVE_STRUCT_STAT_ST_FLAGS]: Likewise.
(sys_setxattr, sys_fsetxattr): Likewise.
* ipc.c (sys_msgget, sys_msgsnd, sys_msgrcv, sys_semget,
sys_shmget, sys_shmat) [LINUX || SUNOS4 || FREEBSD]: Likewise.
(sys_mq_open) [LINUX]: Likewise.
(printmqattr) [HAVE_MQUEUE_H]: Likewise.
* mem.c (print_mmap) [!HAVE_LONG_LONG_OFF_T]: Likewise.
(sys_mmap64) [_LFS64_LARGEFILE || HAVE_LONG_LONG_OFF_T]: Likewise.
(sys_mprotect): Likewise.
(sys_mremap, sys_madvise, sys_mlockall) [LINUX]: Likewise.
(sys_msync) [MS_ASYNC]: Likewise.
(sys_mctl) [MC_SYNC]: Likewise.
(sys_remap_file_pages, sys_mbind, sys_get_mempolicy) [LINUX]:
Likewise.
* net.c (printmsghdr) [HAVE_STRUCT_MSGHDR_MSG_CONTROL]: Likewise.
(sys_send, sys_sendto): Likewise.
(sys_sendmsg) [HAVE_SENDMSG]: Likewise.
(sys_recv, sys_recvfrom): Likewise.
(sys_recvmsg) [HAVE_SENDMSG]: Likewise.
(printicmpfilter) [ICMP_FILTER]: Likewise.
* proc.c (proc_ioctl) [SVR4 && !HAVE_MP_PROCFS || FREEBSD]: Likewise.
* process.c (sys_clone) [LINUX]: Likewise.
(printwaitn): Likewise.
(sys_waitid) [SVR4 || LINUX]: Likewise.
* signal.c (sys_sigvec) [SUNOS4 || FREEBSD]: Likewise.
(sys_sigaction): Likewise.
(printcontext) [SVR4]: Likewise.
(print_stack_t) [LINUX) || FREEBSD]: Likewise.
(sys_rt_sigaction) [LINUX]: Likewise.
* sock.c (sock_ioctl) [LINUX]: Likewise.
* stream.c (sys_putmsg, sys_getmsg): Likewise.
(sys_putpmsg) [SYS_putpmsg]: Likewise.
(sys_getpmsg) [SYS_getpmsg]: Likewise.
(sys_poll): Likewise.
(print_transport_message) [TI_BIND]: Likewise.
(stream_ioctl): Likewise.
* system.c (sys_mount, sys_reboot): Likewise.
(sys_cacheflush) [LINUX && M68K]: Likewise.
(sys_capget, sys_capset) [SYS_capget]: Likewise.
* term.c (term_ioctl) [TIOCMGET]: Likewise.
* time.c (sys_clock_nanosleep, sys_timer_settime) [LINUX]:
Likewise.
Fixes RH#159310.
2005-06-01 23:02:36 +04:00
if ( printflags ( shm_resource_flags , tcp - > u_arg [ 2 ] & ~ 0777 , NULL ) ! = 0 )
2011-09-01 12:00:28 +04:00
tprints ( " | " ) ;
2003-07-17 13:03:04 +04:00
tprintf ( " %#lo " , tcp - > u_arg [ 2 ] & 0777 ) ;
1999-02-19 03:21:36 +03:00
}
return 0 ;
}
2011-05-30 16:00:14 +04:00
int sys_shmctl ( struct tcb * tcp )
1999-02-19 03:21:36 +03:00
{
if ( entering ( tcp ) ) {
tprintf ( " %lu, " , tcp - > u_arg [ 0 ] ) ;
2003-01-14 12:46:17 +03:00
PRINTCTL ( shmctl_flags , tcp - > u_arg [ 1 ] , " SHM_??? " ) ;
2005-12-02 06:57:07 +03:00
if ( indirect_ipccall ( tcp ) ) {
tprintf ( " , %#lx " , tcp - > u_arg [ 3 ] ) ;
} else {
tprintf ( " , %#lx " , tcp - > u_arg [ 2 ] ) ;
}
1999-02-19 03:21:36 +03:00
}
return 0 ;
}
2011-05-30 16:00:14 +04:00
int sys_shmat ( struct tcb * tcp )
1999-02-19 03:21:36 +03:00
{
if ( exiting ( tcp ) ) {
tprintf ( " %lu " , tcp - > u_arg [ 0 ] ) ;
2005-12-02 06:57:07 +03:00
if ( indirect_ipccall ( tcp ) ) {
2013-02-23 23:07:44 +04:00
tprintf ( " , %#lx, " , tcp - > u_arg [ 3 ] ) ;
2005-12-02 06:57:07 +03:00
printflags ( shm_flags , tcp - > u_arg [ 1 ] , " SHM_??? " ) ;
} else {
2013-02-23 23:07:44 +04:00
tprintf ( " , %#lx, " , tcp - > u_arg [ 1 ] ) ;
2005-12-02 06:57:07 +03:00
printflags ( shm_flags , tcp - > u_arg [ 2 ] , " SHM_??? " ) ;
}
1999-02-19 03:21:36 +03:00
if ( syserror ( tcp ) )
return 0 ;
2012-03-16 01:19:36 +04:00
if ( indirect_ipccall ( tcp ) ) {
unsigned long raddr ;
if ( umove ( tcp , tcp - > u_arg [ 2 ] , & raddr ) < 0 )
return RVAL_NONE ;
tcp - > u_rval = raddr ;
}
1999-02-19 03:21:36 +03:00
return RVAL_HEX ;
}
return 0 ;
}
2011-05-30 16:00:14 +04:00
int sys_shmdt ( struct tcb * tcp )
1999-02-19 03:21:36 +03:00
{
2005-12-02 06:57:07 +03:00
if ( entering ( tcp ) ) {
if ( indirect_ipccall ( tcp ) ) {
tprintf ( " %#lx " , tcp - > u_arg [ 3 ] ) ;
} else {
tprintf ( " %#lx " , tcp - > u_arg [ 0 ] ) ;
}
}
1999-02-19 03:21:36 +03:00
return 0 ;
}
2007-01-12 02:19:55 +03:00
int
sys_mq_open ( struct tcb * tcp )
2004-04-17 01:48:40 +04:00
{
if ( entering ( tcp ) ) {
printpath ( tcp , tcp - > u_arg [ 0 ] ) ;
2011-09-01 12:00:28 +04:00
tprints ( " , " ) ;
2004-04-17 01:48:40 +04:00
/* flags */
2009-03-10 23:41:58 +03:00
tprint_open_modes ( tcp - > u_arg [ 1 ] ) ;
2004-04-17 01:48:40 +04:00
if ( tcp - > u_arg [ 1 ] & O_CREAT ) {
# ifndef HAVE_MQUEUE_H
tprintf ( " , %lx " , tcp - > u_arg [ 2 ] ) ;
# else
struct mq_attr attr ;
/* mode */
tprintf ( " , %#lo, " , tcp - > u_arg [ 2 ] ) ;
if ( umove ( tcp , tcp - > u_arg [ 3 ] , & attr ) < 0 )
2013-02-23 23:07:44 +04:00
tprints ( " {???} " ) ;
2004-04-17 01:48:40 +04:00
else
tprintf ( " {mq_maxmsg=%ld, mq_msgsize=%ld} " ,
2012-02-03 22:16:03 +04:00
( long ) attr . mq_maxmsg ,
( long ) attr . mq_msgsize ) ;
2004-04-17 01:48:40 +04:00
# endif
}
}
return 0 ;
}
2007-01-12 02:19:55 +03:00
int
sys_mq_timedsend ( struct tcb * tcp )
2004-04-17 01:48:40 +04:00
{
if ( entering ( tcp ) ) {
tprintf ( " %ld, " , tcp - > u_arg [ 0 ] ) ;
printstr ( tcp , tcp - > u_arg [ 1 ] , tcp - > u_arg [ 2 ] ) ;
tprintf ( " , %lu, %ld, " , tcp - > u_arg [ 2 ] , tcp - > u_arg [ 3 ] ) ;
printtv ( tcp , tcp - > u_arg [ 4 ] ) ;
}
return 0 ;
}
2007-01-12 02:19:55 +03:00
int
sys_mq_timedreceive ( struct tcb * tcp )
2004-04-17 01:48:40 +04:00
{
if ( entering ( tcp ) )
tprintf ( " %ld, " , tcp - > u_arg [ 0 ] ) ;
else {
printstr ( tcp , tcp - > u_arg [ 1 ] , tcp - > u_arg [ 2 ] ) ;
tprintf ( " , %lu, %ld, " , tcp - > u_arg [ 2 ] , tcp - > u_arg [ 3 ] ) ;
printtv ( tcp , tcp - > u_arg [ 4 ] ) ;
}
return 0 ;
}
2007-01-12 02:19:55 +03:00
int
sys_mq_notify ( struct tcb * tcp )
2004-04-17 01:48:40 +04:00
{
if ( entering ( tcp ) ) {
tprintf ( " %ld, " , tcp - > u_arg [ 0 ] ) ;
printsigevent ( tcp , tcp - > u_arg [ 1 ] ) ;
}
return 0 ;
}
2007-01-12 02:19:55 +03:00
static void
printmqattr ( struct tcb * tcp , long addr )
2004-04-17 01:48:40 +04:00
{
if ( addr = = 0 )
2011-09-01 12:00:28 +04:00
tprints ( " NULL " ) ;
2004-04-17 01:48:40 +04:00
else {
# ifndef HAVE_MQUEUE_H
tprintf ( " %#lx " , addr ) ;
# else
struct mq_attr attr ;
if ( umove ( tcp , addr , & attr ) < 0 ) {
2011-09-01 12:00:28 +04:00
tprints ( " {...} " ) ;
2004-04-17 01:48:40 +04:00
return ;
}
2011-09-01 12:00:28 +04:00
tprints ( " {mq_flags= " ) ;
2009-03-10 23:41:58 +03:00
tprint_open_modes ( attr . mq_flags ) ;
2004-04-17 01:48:40 +04:00
tprintf ( " , mq_maxmsg=%ld, mq_msgsize=%ld, mq_curmsg=%ld} " ,
2012-02-03 22:16:03 +04:00
( long ) attr . mq_maxmsg , ( long ) attr . mq_msgsize ,
( long ) attr . mq_curmsgs ) ;
2004-04-17 01:48:40 +04:00
# endif
}
}
2007-01-12 02:19:55 +03:00
int
sys_mq_getsetattr ( struct tcb * tcp )
2004-04-17 01:48:40 +04:00
{
if ( entering ( tcp ) ) {
tprintf ( " %ld, " , tcp - > u_arg [ 0 ] ) ;
printmqattr ( tcp , tcp - > u_arg [ 1 ] ) ;
2011-09-01 12:00:28 +04:00
tprints ( " , " ) ;
2004-04-17 01:48:40 +04:00
} else
printmqattr ( tcp , tcp - > u_arg [ 2 ] ) ;
return 0 ;
}
2012-02-20 21:02:38 +04:00
int
sys_ipc ( struct tcb * tcp )
{
return printargs ( tcp ) ;
}