]> granicus.if.org Git - strace/log
strace
9 years agoblock.c: enhance block ioctl parser
Dmitry V. Levin [Sun, 5 Jul 2015 12:15:03 +0000 (15:15 +0300)]
block.c: enhance block ioctl parser

* block.c: Update for RVAL_DECODED.
Define BLKROTATIONAL and BLKZEROOUT.
(block_ioctl): Decode them.  Use printnum_short, printnum_int,
printnum_long, printpair_int64, and umove_or_printaddr.
(print_blkpg_req, block_ioctl): Use umove_or_printaddr.

9 years agoblkpg_ops: add BLKPG_RESIZE_PARTITION constant
Dmitry V. Levin [Sun, 5 Jul 2015 12:15:03 +0000 (15:15 +0300)]
blkpg_ops: add BLKPG_RESIZE_PARTITION constant

* xlat/blkpg_ops.in: Add BLKPG_RESIZE_PARTITION.

Reported-by: Christian Neukirchen <chneukirchen@gmail.com>
9 years agoloop.c: enhance loop ioctl parser
Dmitry V. Levin [Sat, 4 Jul 2015 14:40:02 +0000 (17:40 +0300)]
loop.c: enhance loop ioctl parser

Decode as much data on entering syscall as possible.

* loop.c: Include <linux/ioctl.h> instead of <sys/ioctl.h>.
Update for RVAL_DECODED.
(decode_loop_info, decode_loop_info64): New functions.
(loop_ioctl): Use them.  Decode LOOP_SET_STATUS, LOOP_SET_STATUS64,
LOOP_SET_FD, LOOP_CHANGE_FD, LOOP_CTL_ADD and LOOP_CTL_REMOVE on
entering syscall.
Print LOOP_SET_FD and LOOP_CHANGE_FD arguments using printfd.

9 years agortc.c: enhance rtc ioctl parser
Dmitry V. Levin [Sat, 4 Jul 2015 12:07:35 +0000 (15:07 +0300)]
rtc.c: enhance rtc ioctl parser

* rtc.c: Update for RVAL_DECODED.
(print_rtc): Rename to print_rtc_time.
(decode_rtc_time, decode_rtc_wkalrm): New functions.
(rtc_ioctl): Use them.
[RTC_VL_READ]: Decode RTC_VL_READ.
Use printnum_long for RTC_IRQP_READ and RTC_EPOCH_READ decoding.

9 years agoUse printpair_int
Dmitry V. Levin [Mon, 6 Jul 2015 22:33:39 +0000 (22:33 +0000)]
Use printpair_int

* evdev.c (repeat_ioctl): Use printpair_int.
* net.c (do_pipe, sys_socketpair): Likewise.

9 years agoAdd several generic integer pairs printing functions
Dmitry V. Levin [Sun, 5 Jul 2015 22:09:29 +0000 (22:09 +0000)]
Add several generic integer pairs printing functions

Add functions to fetch and print pairs of integer types.
Note that these printers do not attempt to fetch data
in case of exiting(tcp) && syserror(tcp).

printnum_* printers will follow as soon as all callers are made ready
for this change.

* defs.h (printpair_int, printpair_long, printpair_int64): New
prototypes.
* util.c (DEF_PRINTPAIR): New macro.
(printpair_int, printpair_long, printpair_int64): New functions.

9 years agoAdd two generic integer printing functions
Dmitry V. Levin [Sun, 5 Jul 2015 22:09:29 +0000 (22:09 +0000)]
Add two generic integer printing functions

Add printnum_short and printnum_int64 in addition to already existing
printnum_int and printnum_long.

* defs.h (printnum_short, printnum_int64): New prototypes.
* util.c (DEF_PRINTNUM): New macro.
(printnum_int, printnum_long): Use DEF_PRINTNUM.
(printnum_short, printnum_int64): New functions.

9 years agoAdd address printing functions
Dmitry V. Levin [Sun, 5 Jul 2015 22:09:29 +0000 (22:09 +0000)]
Add address printing functions

printaddr is a simple function implementing "print NULL or address"
idiom.
umoven_or_printaddr is a wrapper around umoven that has the same return
value semantics as umoven but also prints the address when the data
is not going to be fetched (in case of exiting(tcp) && syserror(tcp))
or cannot be fetched (umoven fails).
umove_or_printaddr is a macro wrapper around umoven_or_printaddr that
mirrors umove wrapper around umoven.

* defs.h (printaddr, umoven_or_printaddr): New prototypes.
(umove_or_printaddr): New macro.
* util.c (printaddr, umoven_or_printaddr): New functions.

9 years agoImplement RVAL_DECODED flag
Dmitry V. Levin [Wed, 8 Jul 2015 14:10:56 +0000 (14:10 +0000)]
Implement RVAL_DECODED flag

Implement a method for "on entering" parsers to return
"done with decoding" information to their callers.

If a syscall parser called from trace_syscall_entering returns a value
with RVAL_DECODED bit set, record this value in tcp->sys_func_rval
and use it in trace_syscall_exiting instead of calling the parser on
exiting syscall.

If an ioctl parser returned RVAL_DECODED, this would tell
SYS_FUNC(ioctl) that the decoding is finished but fallback printing of
the ioctl command argument is needed, while e.g. RVAL_DONE+1 would mean
that the decoding is finished and no fallback decoding is needed.

* defs.h (struct tcb): Add sys_func_rval.
(RVAL_DECODED): New macro.
* syscall.c (trace_syscall_entering): Initialize tcp->sys_func_rval
along with setting TCB_INSYSCALL flag.
(trace_syscall_exiting): Use tcp->sys_func_rval instead of calling
tcp->s_ent->sys_func when the former has RVAL_DECODED flag set.
Reset tcp->sys_func_rval along with clearing TCB_INSYSCALL flag.
* ioctl.c (sys_ioctl): Set RVAL_DECODED flag on exiting.
Print ioctl argument iff RVAL_DECODED is set and fallback decoding
is requested.

9 years agotime.c: move rtc ioctl parser to a separate file
Dmitry V. Levin [Sat, 4 Jul 2015 08:56:21 +0000 (08:56 +0000)]
time.c: move rtc ioctl parser to a separate file

* rtc.c: new file
* Makefile.am (strace_SOURCES): Add it.
* time.c (print_rtc, rtc_ioctl): Move to rtc.c.

9 years agoterm.c: fix typo
Dmitry V. Levin [Sun, 5 Jul 2015 16:30:10 +0000 (16:30 +0000)]
term.c: fix typo

* term.c: Rename TCLFLSH to TCFLSH.

9 years agoDo not include sys/filio.h
Dmitry V. Levin [Sun, 5 Jul 2015 16:18:45 +0000 (16:18 +0000)]
Do not include sys/filio.h

* configure.ac (AC_CHECK_HEADERS): Remove sys/filio.h.
* term.c: Do not include <sys/filio.h>.

9 years agoioctl: prepare ioctl_decode_command_number for future changes
Dmitry V. Levin [Thu, 2 Jul 2015 22:31:11 +0000 (22:31 +0000)]
ioctl: prepare ioctl_decode_command_number for future changes

* ioctl.c (ioctl_decode_command_number): Change 1st arg to struct tcb*.
(sys_ioctl): Update callers.

9 years agoioctl: simplify ioctl_decode signature
Dmitry V. Levin [Thu, 2 Jul 2015 22:27:51 +0000 (22:27 +0000)]
ioctl: simplify ioctl_decode signature

* ioctl.c (ioctl_decode): Remove 2nd and 3rd parameters.
(sys_ioctl): Update callers.

9 years agoioctl: consistently use name "code" for ioctl request code
Dmitry V. Levin [Thu, 2 Jul 2015 22:23:53 +0000 (22:23 +0000)]
ioctl: consistently use name "code" for ioctl request code

* ioctl.c (evdev_decode_number, hiddev_decode_number,
ioctl_decode_command_number): Rename "arg" to "code".

9 years agoMove ioctl syscall parser to ioctl.c
Dmitry V. Levin [Thu, 2 Jul 2015 21:37:23 +0000 (21:37 +0000)]
Move ioctl syscall parser to ioctl.c

* io.c (sys_ioctl): Move ...
* ioctl.c: ... here.
(ioctl_lookup, ioctl_next_match, ioctl_print_code, ioctl_decode,
ioctl_decode_command_number): Declare as static.
* defs.h (ioctl_lookup, ioctl_next_match, ioctl_print_code,
ioctl_decode, ioctl_decode_command_number): Remove.

9 years agoioctl: remove obsolete registry of ioctl characters
Dmitry V. Levin [Thu, 2 Jul 2015 21:34:39 +0000 (21:34 +0000)]
ioctl: remove obsolete registry of ioctl characters

* ioctl.c: Remove registry of ioctl characters.

9 years agoFix filtering of <unavailable> syscalls
Dmitry V. Levin [Mon, 29 Jun 2015 11:57:44 +0000 (11:57 +0000)]
Fix filtering of <unavailable> syscalls

* syscall.c (trace_syscall_exiting): Skip filtered syscalls also in case
of get_regs or get_syscall_result failure.
* tests/filter-unavailable.c: New file.
* tests/filter-unavailable.expected: Likewise.
* tests/filter-unavailable.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add filter-unavailable.
(filter_unavailable_LDFLAGS): Add -pthread.
(TESTS): Add filter-unavailable.test.
(EXTRA_DIST): Add filter-unavailable.expected.
* tests/.gitignore: Add filter-unavailable.

Reported-by: Bryan Matsuo <bryan.matsuo@gmail.com>
9 years agoFix -qq option in conjunction with -o option
Dmitry V. Levin [Mon, 29 Jun 2015 14:37:26 +0000 (14:37 +0000)]
Fix -qq option in conjunction with -o option

This change makes -qq option work in conjunction with -o option,
thus complementing commit v4.7-222-g01997cf.

* strace.c (init): Do not reset qflag.

9 years agoxtensa: wire up new syscalls
Dmitry V. Levin [Tue, 30 Jun 2015 16:31:33 +0000 (16:31 +0000)]
xtensa: wire up new syscalls

* linux/xtensa/syscallent.h (bpf, execveat): New entries.

9 years agobfin: wire up new syscalls
Dmitry V. Levin [Tue, 30 Jun 2015 16:25:10 +0000 (16:25 +0000)]
bfin: wire up new syscalls

* linux/bfin/syscallent.h (kcmp, finit_module, sched_setattr,
sched_getattr, renameat2, seccomp, getrandom, memfd_create,
bpf, execveat): New entries.

9 years agoalpha: wire up new syscalls
Dmitry V. Levin [Tue, 30 Jun 2015 15:39:46 +0000 (15:39 +0000)]
alpha: wire up new syscalls

* linux/alpha/syscallent.h (getrandom, memfd_create, execveat):
New entries.

9 years agotests: skip stat32 test if struct stat is defined incorrectly
Dmitry V. Levin [Wed, 17 Jun 2015 20:58:33 +0000 (20:58 +0000)]
tests: skip stat32 test if struct stat is defined incorrectly

If stat.st_mode returned by syscall is 0, it means that the definition
of struct stat in <asm/stat.h> is incorrect.  This is the case e.g. on
mips n32 where the only available stat syscall is 64-bit but at the same
time struct stat defined by <asm/stat.h> is 32-bit.

* tests/stat.c (main) [NR_stat]: Return 77 if st_mode is 0.

9 years agoConsistenly use #ifdef to check for AC_DEFINE'd macros
Dmitry V. Levin [Wed, 17 Jun 2015 20:09:13 +0000 (20:09 +0000)]
Consistenly use #ifdef to check for AC_DEFINE'd macros

* aio.c (print_common_flags): Use #ifdef in the check for
HAVE_STRUCT_IOCB_U_C_FLAGS.
* defs.h: Use #ifdef in the check for HAVE_LITTLE_ENDIAN_LONG_LONG.
* net.c: Use #ifdef in the check for HAVE_SENDMSG.
* syscall.c (dumpio): Likewise.
* printstat.h (DO_PRINTSTAT): Use #ifdef in checks for
HAVE_STRUCT_STAT_ST_* macros.
* util.c: Use #ifdef in checks for HAVE_SYS_XATTR_H.

9 years agoxattr: move fallback definitions of xattr flags to xlat/
Dmitry V. Levin [Wed, 17 Jun 2015 19:54:21 +0000 (19:54 +0000)]
xattr: move fallback definitions of xattr flags to xlat/

* xattr.c: Include <sys/xattr.h> insread of <linux/xattr.h>.
Move definitions of XATTR_* flags ...
* xlat/xattrflags.in: ... here.

9 years agolink: move fallback definitions of AT_* constants to xlat/
Dmitry V. Levin [Wed, 17 Jun 2015 19:45:26 +0000 (19:45 +0000)]
link: move fallback definitions of AT_* constants to xlat/

* link.c: Move definitions of AT_* constants ...
* xlat/at_flags.in: ... here.

9 years agonet: move fallback definitions of SOL_* constants to xlat/
Dmitry V. Levin [Wed, 17 Jun 2015 19:22:10 +0000 (19:22 +0000)]
net: move fallback definitions of SOL_* constants to xlat/

* net.c: Move definitions of SOL_* constants ...
* xlat/socketlayers.in: ... here.

9 years agofutex: move fallback definitions of futex constants to xlat/
Dmitry V. Levin [Wed, 17 Jun 2015 19:00:17 +0000 (19:00 +0000)]
futex: move fallback definitions of futex constants to xlat/

* futex.c: Move definitions of FUTEX_OP_CMP_* constants ...
* xlat/futexwakecmps.in: ... here.
* futex.c: Move definitions of other FUTEX_OP_* constants ...
* xlat/futexwakeops.in: ... here.
* futex.c: Move definitions of remaining FUTEX_* constants except
FUTEX_PRIVATE_FLAG and FUTEX_CLOCK_REALTIME flags ...
* xlat/futexops.in: ... here.

9 years agoclone: move definitions of cloning flags to xlat/
Dmitry V. Levin [Wed, 17 Jun 2015 18:36:53 +0000 (18:36 +0000)]
clone: move definitions of cloning flags to xlat/

* clone.c: Include <sched.h>.  Move definitions of CLONE_* flags ...
* xlat/clone_flags.in: ... here.

9 years agoUpdate mount flags constants
Dmitry V. Levin [Tue, 16 Jun 2015 00:31:45 +0000 (00:31 +0000)]
Update mount flags constants

* mount.c: Remove definitions of mount flags constants.
* xlat/mount_flags.in: Update from linux v4.0, add default values.

9 years agomount: update parser to match kernel behaviour
Dmitry V. Levin [Tue, 16 Jun 2015 10:53:25 +0000 (10:53 +0000)]
mount: update parser to match kernel behaviour

* mount.c (sys_mount): Do not decode type and data strings for
MS_SHARED, MS_PRIVATE, MS_SLAVE, and MS_UNBINDABLE mount flags
that do not imply valid strings.

9 years agomount: robustify MS_MGC_VAL decoding
Dmitry V. Levin [Tue, 16 Jun 2015 01:28:34 +0000 (01:28 +0000)]
mount: robustify MS_MGC_VAL decoding

* mount.c (sys_mount): When printing mount flags, do not assume that
(flags & MS_MGC_MSK) == MS_MGC_VAL.

9 years agonet: decode setsockopt() multicast arguments
Dmitry V. Levin [Mon, 8 Jun 2015 14:19:46 +0000 (14:19 +0000)]
net: decode setsockopt() multicast arguments

* configure.ac (AC_CHECK_FUNCS): Add inet_pton.
* net.c (print_mreq, print_mreq6): New functions.
(print_setsockopt): Use them to decode IP_ADD_MEMBERSHIP,
IP_DROP_MEMBERSHIP, IPV6_ADD_MEMBERSHIP, IPV6_DROP_MEMBERSHIP,
IPV6_JOIN_ANYCAST, and IPV6_LEAVE_ANYCAST.
* tests/ip_mreq.c: New file.
* tests/ip_mreq.expected: Likewise.
* tests/ip_mreq.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add ip_mreq.
(TESTS): Add ip_mreq.test.
(EXTRA_DIST): ip_mreq.expected.
* tests/.gitignore: Add ip_mreq.

Based on patch by Ben Noordhuis <info@bnoordhuis.nl>.

9 years agoUpdate IPV6 socket options constants
Dmitry V. Levin [Mon, 8 Jun 2015 23:01:09 +0000 (23:01 +0000)]
Update IPV6 socket options constants

* xlat/sockipv6options.in: Update from linux v4.0.

9 years agonet: factor out interface index printing code
Dmitry V. Levin [Fri, 5 Jun 2015 20:13:21 +0000 (20:13 +0000)]
net: factor out interface index printing code

* net.c (print_ifindex): New function.
(printsock) [HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID]: Use it.

9 years agoConsistently use error_msg instead of fprintf(stderr)
Dmitry V. Levin [Mon, 25 May 2015 22:51:19 +0000 (22:51 +0000)]
Consistently use error_msg instead of fprintf(stderr)

* linux/alpha/get_scno.c: Use error_msg.
* linux/arm/get_scno.c: Likewise.
* linux/mips/get_scno.c: Likewise.
* linux/sh/get_scno.c: Likewise.
* linux/x86_64/get_scno.c: Likewise.
* exit.c (sys_exit): Likewise.
* pathtrace.c (pathtrace_select, pathtrace_match): Likewise.
* strace.c (alloctcb, droptcb, detach, startup_attach,
test_ptrace_seize, init, cleanup, print_debug_info,
maybe_allocate_tcb, startup_tcb, trace): Likewise.
* syscall.c (update_personality, trace_syscall_exiting,
get_scno): Likewise.
* unwind.c (DPRINTF): Likewise.
* tests/bexecve.test: Update patterns.
* tests/detach-stopped.test: Likewise.

9 years agoConsistently print OOM diagnostic messages
Dmitry V. Levin [Mon, 25 May 2015 20:33:31 +0000 (23:33 +0300)]
Consistently print OOM diagnostic messages

* bjm.c (sys_query_module): Use error_msg to print OOM diagnostics.
* util.c (dumpiov, dumpstr): Likewise.

9 years agoIntroduce memory allocation wrappers
Dmitry V. Levin [Mon, 25 May 2015 20:41:02 +0000 (20:41 +0000)]
Introduce memory allocation wrappers

Introduce wrappers to the following functions that do memory allocation:
malloc, calloc, realloc, strdup.

This commit is a follow-up to the related discussions in strace-devel ML:
http://sourceforge.net/p/strace/mailman/message/33618180/
http://sourceforge.net/p/strace/mailman/message/33733470/

* defs.h (xmalloc, xcalloc, xreallocarray, xstrdup): New prototypes.
* xmalloc.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* count.c (count_syscall, call_summary_pers): Use xcalloc.
* desc.c (decode_select): Use xmalloc.
* dirent.c (sys_getdents, sys_getdents64): Likewise.
* net.c (sys_recvmmsg): Use xstrdup.
* pathtrace.c (storepath): Use xreallocarray.
(pathtrace_match): Use xmalloc.
* strace.c (die_out_of_memory): Move to xmalloc.c.
(expand_tcbtab): Use xcalloc and xreallocarray.
(startup_child): Use xstrdup.
(init): Use xmalloc, xcalloc, and xstrdup.
* syscall.c (reallocate_qual): Use xreallocarray.
(qualify): Use xstrdup.
* unwind.c (unwind_tcb_init): Use xmalloc.
(build_mmap_cache): Use xcalloc, xreallocarray, and xstrdup.
(get_symbol_name): Use xreallocarray.
(stacktrace_walk, queue_put): Use xmalloc.
* util.c (printstr): Use xmalloc.
* vsprintf.c (strace_vfprintf): Likewise.

9 years agoFix ioctl entries on 32-bit architectures with 64-bit aligned structures
Dmitry V. Levin [Thu, 21 May 2015 16:19:40 +0000 (16:19 +0000)]
Fix ioctl entries on 32-bit architectures with 64-bit aligned structures

Some ioctl constants are defined to different values on those 32-bit
architectures where structures containing a 64-bit field are aligned on
a 8-byte boundary and have a size multiple of 8 bytes, and on other
32-bit architectures.

* configure.ac: Check the size of a structure containing a 64-bit field.
* linux/32/ioctls_inc.h: Rename to ...
* linux/32/ioctls_inc_align32.h: ... this.
* linux/32/ioctls_inc_align64.h: New file.
* linux/32/ioctls_inc.h: Include either 32/ioctls_inc_align32.h
or ioctls_inc_align64.h depending on SIZEOF_STRUCT_I64_I32.
* Makefile.am (EXTRA_DIST): Add linux/32/ioctls_inc_align32.h and
* linux/32/ioctls_inc_align64.h.
* tests/ioctl.c (main): Test for VIDIOC_ENUMINPUT.
* tests/ioctl.expected: Check VIDIOC_ENUMINPUT decoding.

Reported-by: Philippe De Muyter <phdm@macqel.be>
9 years agomaint: make linux/kvm.h parseable on arm
Dmitry V. Levin [Thu, 21 May 2015 16:12:31 +0000 (16:12 +0000)]
maint: make linux/kvm.h parseable on arm

* maint/ioctls_sym.sh [AARCH64 || ARM]: Add missing definitions for
structures referenced from linux/kvm.h.

9 years agov4l2: add decoding for VIDIOC_S_CROP's arg
Philippe De Muyter [Wed, 20 May 2015 15:50:21 +0000 (17:50 +0200)]
v4l2: add decoding for VIDIOC_S_CROP's arg

* v4l2.c (v4l2_ioctl): Add decoding for VIDIOC_S_CROP's arg.

9 years agoAdd support for Altera's Nios-II softcore architecture
Ezequiel Garcia [Sat, 18 Apr 2015 20:33:27 +0000 (17:33 -0300)]
Add support for Altera's Nios-II softcore architecture

This commit adds strace support for Altera's Nios-II.  The architecture
is supported by Linux since v3.19, and it implements the generic syscall
ABI.

* configure.ac: Add nios2 support.
* cacheflush.c [NIOS2] (sys_cacheflush): New function.
* linux/nios2/*: New Nios-II specific files.
* Makefile.am (EXTRA_DIST): Add them.

Signed-off-by: Ezequiel Garcia <ezequiel@vanguardiasur.com.ar>
9 years agov4l2: VIDIOC_CROPCAP: add missing braces around arg printout
Philippe De Muyter [Tue, 19 May 2015 21:54:21 +0000 (23:54 +0200)]
v4l2: VIDIOC_CROPCAP: add missing braces around arg printout

* v4l2.c (v4l2_ioctl): case VIDIOC_CROPCAP: add missing braces around arg
printout.

9 years agomaint: avoid effects of locale when sorting files
Dmitry V. Levin [Tue, 19 May 2015 18:00:07 +0000 (18:00 +0000)]
maint: avoid effects of locale when sorting files

* maint/ioctls_gen.sh: Invoke sort with LC_COLLATE=C.
* maint/ioctls_hex.sh: Likewise.
* maint/ioctls_sym.sh: Likewise.

Reported-by: Philippe De Muyter <phdm@macqel.be>
9 years agov4l2: add decoding for VIDIOC_CREATE_BUFS's arg.
Philippe De Muyter [Sat, 18 Apr 2015 13:06:43 +0000 (15:06 +0200)]
v4l2: add decoding for VIDIOC_CREATE_BUFS's arg.

* v4l2.c (v4l2_ioctl): Add decoding for VIDIOC_CREATE_BUFS's arg.

9 years agomips o32: decode indirect syscall
Dmitry V. Levin [Fri, 17 Apr 2015 09:14:19 +0000 (09:14 +0000)]
mips o32: decode indirect syscall

Implement decoding of MIPS O32 specific indirect syscall.

* syscall.c [LINUX_MIPSO32] (decode_mips_subcall, sys_syscall):
New functions.
(trace_syscall_entering) [LINUX_MIPSO32]: Use decode_mips_subcall.
* linux/mips/syscallent-o32.h (4000): Change sys_func to sys_syscall.

Reported-and-tested-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
9 years agodebian: add gawk to Build-Depends
Dmitry V. Levin [Tue, 14 Apr 2015 17:22:54 +0000 (17:22 +0000)]
debian: add gawk to Build-Depends

* debian/control (Build-Depends): Add gawk.
Patch by Reiner Herrmann <reiner@reiner-h.de>.

This fixes Debian bug #780992.

9 years agotests: fix bexecve.test for the case of mixed personalities
Dmitry V. Levin [Tue, 14 Apr 2015 16:04:08 +0000 (16:04 +0000)]
tests: fix bexecve.test for the case of mixed personalities

Fix bexecve.test when the executable being run does not match the
native architecture.

* tests/bexecve.test: Use "set_ptracer_any" instead of "sh".
Allow for a personality switch notification in the strace output.

9 years agotests: add a test for "resuming interrupted nanosleep"
Dmitry V. Levin [Tue, 7 Apr 2015 21:18:23 +0000 (21:18 +0000)]
tests: add a test for "resuming interrupted nanosleep"

* tests/restart_syscall.test: New test.
* tests/restart_syscall.expected: New file.
* tests/restart_syscall_unknown.expected: Likewise.
* tests/Makefile.am (TESTS): Add restart_syscall.test.
(EXTRA_DIST): Add restart_syscall.expected
(TEST_LOG_COMPILER): Change to "env".
(OS, ARCH, AM_TEST_LOG_FLAGS): Define.
and restart_syscall_unknown.expected.

9 years agotests: strip executable bit from *.expected files
Dmitry V. Levin [Tue, 7 Apr 2015 21:11:50 +0000 (21:11 +0000)]
tests: strip executable bit from *.expected files

9 years agoDeclare syscall parsers using SYS_FUNC macro
Dmitry V. Levin [Tue, 7 Apr 2015 01:36:50 +0000 (01:36 +0000)]
Declare syscall parsers using SYS_FUNC macro

Introduce SYS_FUNC macro to declare and define all syscall parsers.

* Makefile.am (BUILT_SOURCES, CLEANFILES): Add sys_func.h.
(sys_func.h): New rule.
* defs.h (SYS_FUNC_NAME, SYS_FUNC): New macros.
* linux/syscall.h: Include "sys_func.h".
[NEED_UID16_PARSERS]: Use SYS_FUNC to declare uid16 syscall parsers.
Remove other declarations.
* linux/alpha/syscallent.h (160, 161): Add sys_ prefix to osf_statfs
and osf_fstatfs syscall parsers.
* *.c: Use SYS_FUNC to define syscall parsers.

9 years agoFix confusing "resuming interrupted unknown" message
Denys Vlasenko [Tue, 7 Apr 2015 10:46:59 +0000 (12:46 +0200)]
Fix confusing "resuming interrupted unknown" message

Dmitry reported seeing the following:

    $ sleep 2 & sleep 1; ./strace -erestart_syscall -p $!
    [1] 12345
    Process 12345 attached
    restart_syscall(<... resuming interrupted unknown ...>) = 0

Fixing it by replacing "unknown" with "system call".

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agotests: workaround old gawk versions that do not provide @include support
Dmitry V. Levin [Mon, 6 Apr 2015 23:40:13 +0000 (23:40 +0000)]
tests: workaround old gawk versions that do not provide @include support

Some of our tests use GNU awk @include extension, but not all currently
used versions of GNU awk support it.  Skip these tests if gawk does not
provide @include support.

* tests/init.sh (check_gawk): New function.
(match_awk): Use it.

9 years agotests: rewrite umovestr2.test without using grep
Dmitry V. Levin [Mon, 6 Apr 2015 22:17:28 +0000 (22:17 +0000)]
tests: rewrite umovestr2.test without using grep

The regular expression generated by umovestr2.c on systems with large
page size is too big for GNU grep.  Rewrite the test to use diff
instead of grep.

* tests/umovestr2.test: Use match_diff instead of match_grep.
* tests/umovestr2.c (main): Convert output from regexp to plain text.

9 years agoCleanup process_vm_writev syscall decoding
Dmitry V. Levin [Tue, 31 Mar 2015 21:00:39 +0000 (21:00 +0000)]
Cleanup process_vm_writev syscall decoding

* process_vm.c (sys_process_vm_writev): Do not check for syserror,
it is not applicable on entering syscall.

9 years agoumovestr: read chunks of memory up to pagesize at a time
Dmitry V. Levin [Tue, 31 Mar 2015 19:45:08 +0000 (19:45 +0000)]
umovestr: read chunks of memory up to pagesize at a time

* defs.h (get_pagesize): New prototype.
* mem.c (get_pagesize) Make global.
* util.c (PAGMASK): Remove.
(vm_read_mem): New process_vm_readv proxy function.
(umoven, umovestr): Use it.
(umovestr): Read chunks up to pagesize at a time.

9 years agoumovestr: fix short read bug
Dmitry V. Levin [Tue, 31 Mar 2015 18:52:57 +0000 (18:52 +0000)]
umovestr: fix short read bug

* util.c (umovestr): Check the right address.
* tests/umovestr.c: New file.
* tests/umovestr2.c: Likewise.
* tests/umovestr.expected: Likewise.
* tests/umovestr.test: New test.
* tests/umovestr2.test: Likewise.
* tests/Makefile.am (check_PROGRAMS): Add umovestr and umovestr2.
(TESTS): Add umovestr.test and umovestr2.test.
(EXTRA_DIST): Add umovestr.expected.
* tests/.gitignore: Add umovestr and umovestr2.

Reported-by: Josef T. Burger <bolo@cs.wisc.edu>
9 years agoWhen process_vm_readv fails with EPERM, try PTRACE_PEEKDATA
Dmitry V. Levin [Mon, 30 Mar 2015 15:21:55 +0000 (15:21 +0000)]
When process_vm_readv fails with EPERM, try PTRACE_PEEKDATA

process_vm_readv() and ptrace(PTRACE_PEEKDATA) have inconsistent access
control rules wrt traced processes: process_vm_readv() is more likely to
fail with EPERM than ptrace(PTRACE_PEEKDATA) when tracing a process that
has execve'd a privileged executable.

* util.c (umoven, umovestr): If process_vm_readv returned EPERM,
fall back to ptrace(PTRACE_PEEKDATA).

Reported-by: Andrew Guertin <lists@dolphinling.net>
9 years agoUse macros for gcc attributes
Dmitry V. Levin [Sun, 29 Mar 2015 22:45:03 +0000 (22:45 +0000)]
Use macros for gcc attributes

* defs.h (error_msg, perror_msg, error_msg_and_die, perror_msg_and_die,
die_out_of_memory, printllval, printnum_int, printnum_long, tprintf):
Use ATTRIBUTE_* macros for gcc attributes.
* file.c (struct stat64): Likewise.
* statfs.c (struct compat_statfs64): Likewise.
* strace.c (die, exec_or_die, init): Likewise.
* linux/sparc/arch_sigreturn.c: Likewise.
* linux/ubi-user.h: Likewise.

9 years agoIntroduce macros for gcc attributes
Dmitry V. Levin [Sun, 29 Mar 2015 22:42:55 +0000 (22:42 +0000)]
Introduce macros for gcc attributes

Define macros for gcc attributes that are already in use
or going to be used soon.

* defs.h (GNUC_PREREQ, ATTRIBUTE_NORETURN, ATTRIBUTE_FORMAT,
ATTRIBUTE_ALIGNED, ATTRIBUTE_PACKED, ATTRIBUTE_MALLOC,
ATTRIBUTE_NOINLINE, ATTRIBUTE_ALLOC_SIZE): New macros.

9 years agoInclude <linux/ioctl.h> for _IOC_* macros
Felix Janda [Sat, 28 Mar 2015 17:40:13 +0000 (18:40 +0100)]
Include <linux/ioctl.h> for _IOC_* macros

Fix a compilation failure with musl libc.

* evdev.c: Include <linux/ioctl.h>.
* ioctl.c: Include <linux/ioctl.h> instead of <asm/ioctl.h>.
* ioctlsort.c: Likewise.

Reported-by: Dima Krasner <dima@dimakrasner.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
9 years agoInclude <sys/stat.h> for S_I* macros
Felix Janda [Sat, 28 Mar 2015 17:21:09 +0000 (18:21 +0100)]
Include <sys/stat.h> for S_I* macros

Fix a compilation failure with musl libc.

* mknod.c: Include <sys/stat.h>.
* printmode.c: Likewise.

Reported-by: Dima Krasner <dima@dimakrasner.com>
Acked-by: Mike Frysinger <vapier@gentoo.org>
9 years agosignal.c: move siginfo_t parsers to a separate file
Dmitry V. Levin [Fri, 27 Mar 2015 23:28:15 +0000 (23:28 +0000)]
signal.c: move siginfo_t parsers to a separate file

* printsiginfo.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (printsiginfo): Change second argument's type from int to bool.
* signal.c: Stop defining siginfo_t related constants.
Move inclusion of xlat/sig*_codes.h files to printsiginfo.c
(printsigsource, printsigval, printsiginfo_at): Move to printsiginfo.c.
(printsiginfo): Change second argument's type from int to bool,
split, and move to printsiginfo.c.

9 years agoUpdate siginfo_t constants
Dmitry V. Levin [Fri, 27 Mar 2015 22:51:51 +0000 (22:51 +0000)]
Update siginfo_t constants

* xlat/sigbus_codes.in: Add BUS_MCEERR_AR and BUS_MCEERR_AO,
add default values.
* xlat/sigtrap_codes.in: Add TRAP_BRANCH and TRAP_HWBKPT,
add default values.
* xlat/sigsegv_codes.in: Add SEGV_BNDERR, add default values.
* xlat/sigchld_codes.in: Add default values.
* xlat/sigemt_codes.in: Likewise.
* xlat/sigfpe_codes.in: Likewise.
* xlat/sigill_codes.in: Likewise.
* xlat/siginfo_codes.in: Likewise.
* xlat/sigpoll_codes.in: Likewise.
* xlat/sigsys_codes.in: Likewise.

9 years agosignal.c: move sigaltstack parser to a separate file
Dmitry V. Levin [Thu, 26 Mar 2015 13:03:25 +0000 (13:03 +0000)]
signal.c: move sigaltstack parser to a separate file

* sigaltstack.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* signal.c (print_stack_t, sys_sigaltstack): Move to sigaltstack.c.
* xlat/sigaltstack_flags.in: Add default values.

9 years agoMove sparc64 get_scno() code where it belongs
Denys Vlasenko [Wed, 25 Mar 2015 14:22:49 +0000 (15:22 +0100)]
Move sparc64 get_scno() code where it belongs

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agosparc: rename personality 2 files to personality 1
Denys Vlasenko [Wed, 25 Mar 2015 14:11:36 +0000 (15:11 +0100)]
sparc: rename personality 2 files to personality 1

Run-tested in qemu 32-bit sparc.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agosparc: delete personality 1
Denys Vlasenko [Wed, 25 Mar 2015 13:16:08 +0000 (14:16 +0100)]
sparc: delete personality 1

Personality 1 for sparc and sparc64 appears to be an old attempt
to support stracing Solaris binaries.

It stalled after the only syscall, solaris_open, was covered:
all other solaris_foo's are printargs.

This change deletes personality 1. Now sparc is an one-personality
arch, and sparc64 is a two-personality one.

For clarity, pure renaming of personality 2 files to personality 1 for sparc64
is performed in the next commit - this prevents a state where syscallent1.h
seems to indergo a lot of changes, where in fact in is deleted, and then
replaced by syscallent2.h

Therefore, tree at this commit will not build.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agoqemu_multiarch_testing/*: make it easier to do debug in sandboxes
Denys Vlasenko [Tue, 24 Mar 2015 19:54:26 +0000 (20:54 +0100)]
qemu_multiarch_testing/*: make it easier to do debug in sandboxes

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agosparc: fix v4.10-25-g8497b62 fallout
Denys Vlasenko [Tue, 24 Mar 2015 18:39:47 +0000 (19:39 +0100)]
sparc: fix v4.10-25-g8497b62 fallout

Before:

$ sleep 3 & ./strace -p $!
Process 8703 attached
syscall: unknown syscall trap 1a800003 00025d58
syscall_516(0, 0x40080000, 0, 0xfc000f00, 0x28, 0xefc03b18) = 0
exit_group(0)                           = ?
+++ exited with 0 +++

After:

$ sleep 3 & ./strace -p $!
Process 8725 attached
restart_syscall(<... resuming interrupted nanosleep ...>) = 0
exit_group(0)                           = ?
+++ exited with 0 +++

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agoget_scno: add diagnostics for invalid syscall numbers
Dmitry V. Levin [Tue, 24 Mar 2015 01:59:07 +0000 (01:59 +0000)]
get_scno: add diagnostics for invalid syscall numbers

* syscall.c (get_scno): Print a debug level message
for !SCNO_IS_VALID syscall numbers.

9 years agoarm: fix v4.10-25-g8497b62 fallout
Dmitry V. Levin [Mon, 23 Mar 2015 23:00:37 +0000 (23:00 +0000)]
arm: fix v4.10-25-g8497b62 fallout

Starting with commit v4.10-25-g8497b62,

arm$ ./strace true
pid 1234 stray syscall exit
Segmentation fault

Fix this by updating ARM syscall sanity check.
In particular, get_scno() should not set TCB_INSYSCALL flag because
other code assumes that s_ent is properly initialized when this flag
is set.

* linux/arm/get_scno.c: Check syscall number after fetching.
Do not apply the check to SCNO_IN_RANGE syscalls.
Do not set TCB_INSYSCALL flag.
Extend diagnostics and move it to debug level.

9 years agomips: fix pipe syscall decoding
Dmitry V. Levin [Mon, 23 Mar 2015 23:14:08 +0000 (23:14 +0000)]
mips: fix pipe syscall decoding

* linux/mips/arch_getrval2.c: New file.
* Makefile.am (EXTRA_DIST): Add it.
* defs.h [MIPS] (HAVE_GETRVAL2): Define.

9 years agosigreturn.c: split arch specific code into separate arch files
Dmitry V. Levin [Mon, 23 Mar 2015 21:16:07 +0000 (21:16 +0000)]
sigreturn.c: split arch specific code into separate arch files

Split code that use arch-specific registers to separate arch files.

* sigreturn.c (sys_sigreturn): Move arch-specific code
to linux/*/arch_sigreturn.c, include "arch_sigreturn.c".
* linux/arch_sigreturn.c: New file.
* Makefile.am (EXTRA_DIST): Add linux/arch_sigreturn.c
and linux/*/arch_sigreturn.c files.

9 years agosyscall.c: split arch specific code into separate arch files
Dmitry V. Levin [Sun, 22 Mar 2015 22:13:55 +0000 (22:13 +0000)]
syscall.c: split arch specific code into separate arch files

Split code that use arch-specific registers to separate arch files.

* syscall.c: Move definitions of variables containing fetched registers
to linux/*/arch_regs.c files.
[HAVE_GETRVAL2] (getrval2): Move arch-specific code
to linux/*/arch_getrval2.c, include "arch_getrval2.c".
(print_pc): Move arch-specific code to linux/*/print_pc.c files,
include "print_pc.c".
[X86_64] (x86_64_getregs_old): Rename to getregs_old, move to
linux/x86_64/getregs_old.c, include "getregs_old.c".
[POWERPC] (powerpc_getregs_old): Rename to getregs_old, move to
linux/powerpc/getregs_old.c, include "getregs_old.c".
(get_regs) [X86_64, POWERPC]: Update callers.
(get_scno): Move arch-specific code to linux/*/get_scno.c,
include "get_scno.c".
(get_syscall_args): Move arch-specific code
to linux/*/get_syscall_args.c, include "get_syscall_args.c".
(get_error): Move arch-specific code to linux/*/get_error.c,
include "get_error.c".
(get_syscall_result): Move arch-specific code
to linux/*/get_syscall_result.c, include "get_syscall_result.c".
* Makefile.am (EXTRA_DIST): Add new linux/*/*.c files.

9 years agosyscall.c: prepare for the split
Dmitry V. Levin [Sun, 22 Mar 2015 18:09:55 +0000 (18:09 +0000)]
syscall.c: prepare for the split

Move functions that use arch-specific registers to the end of file.

9 years agoMove get_regs error check from trace_syscall_entering to get_scno
Dmitry V. Levin [Mon, 23 Mar 2015 18:48:32 +0000 (18:48 +0000)]
Move get_regs error check from trace_syscall_entering to get_scno

Starting with commit v4.10-25-g8497b62, get_scno() can be called outside
trace_syscall_entering(), so move the get_regs_error check from
trace_syscall_entering() to get_scno().

* syscall.c (trace_syscall_entering): Move get_regs_error check ...
(get_scno): ... here.

9 years agoalpha, ia64, sh, sparc, sparc64: fix pipe and pipe2 syscalls decoding
Dmitry V. Levin [Mon, 23 Mar 2015 00:04:27 +0000 (00:04 +0000)]
alpha, ia64, sh, sparc, sparc64: fix pipe and pipe2 syscalls decoding

Fix pipe syscall decoding on alpha.
Fix pipe2 syscall decoding on ia64, sh, sparc, and sparc64.

* configure.ac (AC_CHECK_FUNCS): Add pipe2.
* defs.h [ALPHA || IA64 || SH || SPARC || SPARC64] (HAVE_GETRVAL2):
Define.
* net.c (do_pipe): Check HAVE_GETRVAL2 instead of architecture macros.
Do not use getrval2 for pipe2 decoding.
Print address if umove call fails.
* syscall.c (getrval2): Check HAVE_GETRVAL2 instead of architecture
macros.  Implement for [ALPHA].
* tests/pipe.c: New file.
* tests/pipe.expected: New file.
* tests/pipe.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add pipe.
(TESTS): Add pipe.test.
(EXTRA_DIST): Add pipe.expected.
* tests/.gitignore: Add pipe.

9 years agodecode_socket_subcall: fetch all arguments with a single umoven call
Dmitry V. Levin [Sun, 22 Mar 2015 15:52:40 +0000 (15:52 +0000)]
decode_socket_subcall: fetch all arguments with a single umoven call

* syscall.c (decode_socket_subcall): Replace umoven fetch loop
with a single umoven call.

9 years agoNew test: test/many_looping_threads.c
Denys Vlasenko [Sat, 21 Mar 2015 19:59:39 +0000 (20:59 +0100)]
New test: test/many_looping_threads.c

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agotest/.gitignore: add missing test targets
Denys Vlasenko [Sat, 21 Mar 2015 19:19:02 +0000 (20:19 +0100)]
test/.gitignore: add missing test targets

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agoTrivial optimization in sys_sigreturn()
Denys Vlasenko [Sat, 21 Mar 2015 19:11:53 +0000 (20:11 +0100)]
Trivial optimization in sys_sigreturn()

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agoChange last parameter of umoven() from char* to void*
Denys Vlasenko [Sat, 21 Mar 2015 18:50:53 +0000 (19:50 +0100)]
Change last parameter of umoven() from char* to void*

Saves tons of casts.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agoRemove unused struct tcb::inst field
Denys Vlasenko [Sat, 21 Mar 2015 18:30:53 +0000 (19:30 +0100)]
Remove unused struct tcb::inst field

It is unused since we dropped support for kernels without PTRACE_SETOPTIONS.

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agotest/Makefile: add missing test targets
Denys Vlasenko [Sat, 21 Mar 2015 17:54:16 +0000 (18:54 +0100)]
test/Makefile: add missing test targets

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agoMove the comment about termination logic where it belongs
Denys Vlasenko [Sat, 21 Mar 2015 17:40:53 +0000 (18:40 +0100)]
Move the comment about termination logic where it belongs

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agostartup_tcb() never fails, remove code which checks for failures
Denys Vlasenko [Sat, 21 Mar 2015 17:13:45 +0000 (18:13 +0100)]
startup_tcb() never fails, remove code which checks for failures

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agoShow the syscall name in "resuming interrupted call" message
Denys Vlasenko [Sat, 21 Mar 2015 16:51:52 +0000 (17:51 +0100)]
Show the syscall name in "resuming interrupted call" message

When signal is received, or if we have attached to a process,
current syscall (if process is in one) gets restarted.

Some syscalls are restarted via "restart_syscall()" mechanism.
On such sycalls, we don't show _which_ syscall gets restarted.

IOW: users want to see "resuming interrupted nanosleep"
instead of "resuming interrupted call" when they attach to "sleep 999".

Kernel does expose this information. The only thing we need is
to fetch syscall# on attach, and save it.

This patch does this. It adds tcp->s_prev_ent, which is
a pointer to struct_sysent of the previous syscall of this tracee.
It can be NULL.

sys_restart_syscall() is made to use it when the message is generated.

To similarly handle restart_syscall() *after signals*, not just
on attach, on each syscall exit patch saves exited syscall's data
in the same member (tcp->s_prev_ent).

Example:

    $ sleep 3 & strace -p $!
    Process 8728 attached
    restart_syscall(<... resuming interrupted nanosleep ...>) = 0
    _exit(0)                                = ?
    +++ exited with 0 +++

Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
9 years agotests: add a test for mmap/mprotect/munmap decoding
Dmitry V. Levin [Thu, 19 Mar 2015 22:03:32 +0000 (22:03 +0000)]
tests: add a test for mmap/mprotect/munmap decoding

* tests/mmap.c: New file.
* tests/mmap64.c: New file.
* tests/mmap.test: New test.
* tests/mmap64.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add mmap and mmap64.
(mmap64_CFLAGS): Define.
(TESTS): Add mmap.test and mmap64.test.
* tests/.gitignore: Add mmap and mmap64.

9 years agosparc, sparc64: fix decoding of mmap2
Dmitry V. Levin [Thu, 19 Mar 2015 22:58:22 +0000 (22:58 +0000)]
sparc, sparc64: fix decoding of mmap2

* linux/sparc/syscallent.h (mmap2): Decode with sys_mmap_4koff,
not sys_mmap.
* linux/sparc64/syscallent2.h (mmap2): Decode with sys_mmap_pgoff,
not sys_mmap.

9 years agotests: add a test for SECCOMP_MODE_FILTER decoding
Dmitry V. Levin [Thu, 19 Mar 2015 00:40:49 +0000 (00:40 +0000)]
tests: add a test for SECCOMP_MODE_FILTER decoding

* tests/seccomp.c: New file.
* tests/seccomp.test: New test.
* tests/Makefile.am (check_PROGRAMS): Add seccomp.
(TESTS): Add seccomp.test.
* tests/.gitignore: Add seccomp.

9 years agotests: factor out common awk code
Dmitry V. Levin [Wed, 18 Mar 2015 19:14:02 +0000 (19:14 +0000)]
tests: factor out common awk code

Factor out awk code used in several tests to match.awk.

* tests/match.awk: New file.
* tests/Makefile.am (EXTRA_DIST): Add it.
* tests/caps.awk: Use it.
* tests/getdents.awk: Likewise.
* tests/getrandom.awk: Likewise.
* tests/select.awk: Likewise.
* tests/sigaction.awk: Likewise.
* tests/init.sh (match_awk): Use gawk not awk.  Define AWKPATH.
* tests/getdents.test: Likewise.

9 years agotests: skip netlink based tests when resources are not available
Dmitry V. Levin [Wed, 18 Mar 2015 20:18:27 +0000 (20:18 +0000)]
tests: skip netlink based tests when resources are not available

* tests/netlink_inet_diag.c (main): Return 77 if socket, bind,
or listen syscall fail.
* tests/netlink_unix_diag.c (main): Likewise.

9 years agoaarch64, arm: decode extra padded compat struct statfs64
Dmitry V. Levin [Wed, 18 Mar 2015 16:32:04 +0000 (16:32 +0000)]
aarch64, arm: decode extra padded compat struct statfs64

According to arch/arm/kernel/sys_oabi-compat.c,
struct statfs64 has extra padding with EABI.

* statfs.c [AARCH64 || defined ARM] (COMPAT_STATFS64_PADDED_SIZE):
Define.
(do_statfs64_fstatfs64): New function, factored out from sys_statfs64.
[COMPAT_STATFS64_PADDED_SIZE]: Check it in addition to
sizeof(struct compat_statfs64).
(sys_statfs64, sys_fstatfs64): Use do_statfs64_fstatfs64.

Reported-and-tested-by: Elliott Hughes <enh@google.com>
9 years agotests: factor out common shell code to functions
Dmitry V. Levin [Tue, 17 Mar 2015 17:07:57 +0000 (17:07 +0000)]
tests: factor out common shell code to functions

Factor out shell code used in several tests to common functions.

* tests/fanotify_mark.expected: New file.
* tests/ioctl.expected: New file.
* tests/net-fd.expected: New file.
* tests/net.expected: New file.
* tests/statfs.expected: New file.
* tests/sun_path.expected: New file.
* tests/uio.expected: New file.
* tests/ipc.sh: New file.
* tests/Makefile.am (EXTRA_DIST): Add them.
* tests/init.sh (dump_log_and_fail_with, run_prog,
run_prog_skip_if_failed, run_strace, run_strace_merge,
match_awk, match_diff, match_grep): New functions.
* tests/*.test: Use them.

9 years agoShow f_flags field in printstatfs
Elliott Hughes [Tue, 17 Mar 2015 23:00:31 +0000 (16:00 -0700)]
Show f_flags field in printstatfs

printstatfs64 was right, but printstatfs was missing f_flags.
Noticed on aarch64.

* statfs.c (printstatfs) [_STATFS_F_FLAGS]: Print statfs.f_flags.

Signed-off-by: Elliott Hughes <enh@google.com>
9 years agotests/uid*: use fchown* instead of chown*
Dmitry V. Levin [Mon, 16 Mar 2015 18:10:21 +0000 (18:10 +0000)]
tests/uid*: use fchown* instead of chown*

Newer architectures have no chown syscall, so use fchown* syscalls
for testing printuid.

* tests/uid.test: Use fchown instead of chown.
* tests/uid.c: Test __NR_fchown instead of __NR_chown.
(main): Use __NR_fchown instead of __NR_chown.
* tests/uid32.c: Test __NR_fchown32 instead of __NR_chown32.
(main): Use __NR_fchown32 instead of __NR_chown32.
* tests/uid16.c: Test __NR_fchown and __NR_fchown32 instead
of __NR_chown and __NR_chown32.
(main): Use __NR_fchown instead of __NR_chown.
* tests/uid.awk: Update regexp.

9 years agostat64-v.test: add newfstatat syscall support
Dmitry V. Levin [Mon, 16 Mar 2015 17:18:40 +0000 (17:18 +0000)]
stat64-v.test: add newfstatat syscall support

Newer architectures have no stat syscall, so stat() is implemented there
using newfstatat syscall.

* tests/stat.c (STAT_FNAME): Rename to STAT_PREFIX.  Update callers.
[_FILE_OFFSET_BITS == 64] (STAT_PREFIX): Add newfstatat support.
(main) [!NR_stat]: Add newfstatat support.

Reported-by: Andreas Schwab <schwab@suse.de>
9 years agoaarch64: properly decode generic syscalls
Andreas Schwab [Thu, 12 Mar 2015 15:17:45 +0000 (16:17 +0100)]
aarch64: properly decode generic syscalls

* linux/aarch64/syscallent1.h: Don't override entries 277 to 1023.

9 years agotests: verify that all patterns match
Andreas Schwab [Wed, 11 Mar 2015 16:49:06 +0000 (17:49 +0100)]
tests: verify that all patterns match

* tests/ipc_msg.test: Count matches to verify that all patterns match.
* tests/ipc_sem.test: Likewise.
* tests/ipc_shm.test: Likewise.
* tests/stat32-v.test: Likewise.
* tests/stat64-v.test: Likewise.