]> granicus.if.org Git - strace/log
strace
6 years agosparc, sparc64: implement kern_features decoder
Eugene Syromyatnikov [Wed, 7 Feb 2018 01:11:54 +0000 (02:11 +0100)]
sparc, sparc64: implement kern_features decoder

* sparc.c: New file.
* Makefile.am (EXTRA_DIST): Add it.
* linux/sparc/syscallent.h ([340]): Remove NF flag, set kern_features
decoder.
* linux/sparc64/syscallent.h ([340]): Likewise.
* xlat/sparc_kern_features.in: New file.
* NEWS: Mention this enhancement.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoevdev: move mpers-specific parsers to a separate file
Dmitry V. Levin [Tue, 27 Mar 2018 01:57:00 +0000 (01:57 +0000)]
evdev: move mpers-specific parsers to a separate file

This change reduces binary code duplication on mpers platforms
and prepares evdev parsers to use printxval_bsearch.

* defs.h (evdev_ioctl, print_evdev_ff_type): New prototypes.
* evdev.c (evdev_ioctl): Un-mpersify.
(evdev_write_ioctl) Remove EVIOCSFF case, forward default case
to evdev_write_ioctl_mpers.
(decode_envelope, ff_effect_ioctl): Move to...
* evdev_mpers.c: ... new file.
* Makefile.am (strace_SOURCES): Add evdev_mpers.c.

6 years agoci: install libunwind8-dev
Eugene Syromyatnikov [Mon, 26 Mar 2018 12:55:57 +0000 (14:55 +0200)]
ci: install libunwind8-dev

While in debian/control we use libunwind-dev in Build-Depends, in case
of ci we have to be more conservative and use the name portable across
different ci implementations.

* ci/install-dependencies.sh (common_packages): Add libunwind8-dev.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotests: check injection of return values into a "never fails" syscall
Eugene Syromyatnikov [Sun, 11 Feb 2018 23:45:37 +0000 (00:45 +0100)]
tests: check injection of return values into a "never fails" syscall

* tests/inject-nf.c: New file.
* tests/inject-nf.test: New test.
* tests/.gitignore: Add inject-nf.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(MISC_TESTS): Add inject-nf.test.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoIntroduce raw syscall invocation wrappers
Dmitry V. Levin [Fri, 23 Mar 2018 13:43:13 +0000 (13:43 +0000)]
Introduce raw syscall invocation wrappers

Unfortunately, syscall(3) provided by libc is too smart
for some of our needs.

* linux/raw_syscall.h: New file.
* linux/aarch64/raw_syscall.h: Likewise.
* linux/alpha/raw_syscall.h: Likewise.
* linux/arc/raw_syscall.h: Likewise.
* linux/arm/raw_syscall.h: Likewise.
* linux/avr32/raw_syscall.h: Likewise.
* linux/bfin/raw_syscall.h: Likewise.
* linux/hppa/raw_syscall.h: Likewise.
* linux/i386/raw_syscall.h: Likewise.
* linux/ia64/raw_syscall.h: Likewise.
* linux/m68k/raw_syscall.h: Likewise.
* linux/metag/raw_syscall.h: Likewise.
* linux/microblaze/raw_syscall.h: Likewise.
* linux/mips/raw_syscall.h: Likewise.
* linux/nios2/raw_syscall.h: Likewise.
* linux/or1k/raw_syscall.h: Likewise.
* linux/powerpc/raw_syscall.h: Likewise.
* linux/powerpc64/raw_syscall.h: Likewise.
* linux/riscv/raw_syscall.h: Likewise.
* linux/s390/raw_syscall.h: Likewise.
* linux/s390x/raw_syscall.h: Likewise.
* linux/sh/raw_syscall.h: Likewise.
* linux/sh64/raw_syscall.h: Likewise.
* linux/sparc/raw_syscall.h: Likewise.
* linux/sparc64/raw_syscall.h: Likewise.
* linux/tile/raw_syscall.h: Likewise.
* linux/x32/raw_syscall.h: Likewise.
* linux/x86_64/raw_syscall.h: Likewise.
* linux/xtensa/raw_syscall.h: Likewise.
* Makefile.am (EXTRA_DIST): Add them.

6 years agotests: fix potentially unbound variable in kernel_version_code
Dmitry V. Levin [Fri, 23 Mar 2018 13:43:13 +0000 (13:43 +0000)]
tests: fix potentially unbound variable in kernel_version_code

Fix the following use case:

$ sh -uc '. tests/init.sh; kernel_version_code 4.5'
tests/init.sh: line 242: 3: unbound variable

* tests/init.sh (kernel_version_code): Fix potentially unbound variable.

6 years agostrace: further optimize unblocking of the delay signal handler
Dmitry V. Levin [Fri, 23 Mar 2018 00:20:33 +0000 (00:20 +0000)]
strace: further optimize unblocking of the delay signal handler

Do not unblock the delay signal handler unless the delay timer is armed.

* defs.h (is_delay_timer_created): Remove.
(is_delay_timer_armed, delay_timer_expired): New prototypes.
* delay.c (delay_timer_is_armed): New static variable.
(is_delay_timer_created): Add static qualifier.
(is_delay_timer_armed, delay_timer_expired): New functions.
(arm_delay_timer): Set delay_timer_is_armed.
* strace.c (next_event): Use is_delay_timer_armed instead of
is_delay_timer_created to check whether the delay signal handler
has to be unblocked.
(timer_sighandler): Invoke delay_timer_expired.

6 years agostrace: rewrite restart error handling without sigsetjmp/siglongjmp
Dmitry V. Levin [Fri, 23 Mar 2018 00:20:33 +0000 (00:20 +0000)]
strace: rewrite restart error handling without sigsetjmp/siglongjmp

Further simplify and optimize error handling of the delay signal handler
by replacing sigsetjmp/siglongjmp mechanism with an error flag.

* strace.c: Do not include <setjmp.h>.
(restart_failed): New volatile variable.
(timer_jmp_buf): Remove.
(next_event): Cache is_delay_timer_created() return value,
remove sigsetjmp invocation, check restart_failed instead.
(timer_sighandler): Replace siglongjmp with setting restart_failed.

6 years agostrace: do not call sigsetjmp without a delay timer
Dmitry V. Levin [Fri, 23 Mar 2018 00:20:33 +0000 (00:20 +0000)]
strace: do not call sigsetjmp without a delay timer

As sigsetjmp costs a syscall, do not call it unless a delay timer
is already created and its signal handler is going to be unblocked.

* strace.c (next_event): Move sigsetjmp invocation under
is_delay_timer_created() condition.

Optimizes: v4.21-108-gba8e768 ("Implement delay injection")

6 years agotests/bpf.c: convert TEST_BPF_ macro to a function
Eugene Syromyatnikov [Tue, 20 Mar 2018 08:04:17 +0000 (09:04 +0100)]
tests/bpf.c: convert TEST_BPF_ macro to a function

As it looks like there's no compelling reason to keep it as a macro and
leaving it so quite complicates modification of the routine and makes
them error-prone.

* tests/bpf.c (TEST_BPF_): Convert it to...
(test_bpf): ...this.  Rename cmd_ to cmd, cmd_str_ to cmd_str,
init_first_ to init_first, print_first_ to print_first, init_attr_
to init_attr, print_attr_ to print_attr.
(TEST_BPF): Call test_bpf_ instead of TEST_BPF_.

6 years agotests: btrfs.c whitespace cleanup
Eugene Syromyatnikov [Wed, 21 Feb 2018 23:26:29 +0000 (00:26 +0100)]
tests: btrfs.c whitespace cleanup

* tests/btrfs.c: Add spaces after PRI* format specifiers.

6 years agotests: check delay injection
Elvira Khabirova [Sun, 18 Feb 2018 20:21:49 +0000 (23:21 +0300)]
tests: check delay injection

* tests/delay.c: New file.
* tests/delay.test: New test.
* tests/.gitignore: Add delay.
* tests/Makefile.am (check_PROGRAMS): Likewise.
(delay_LDADD): New variable.
(MISC_TESTS): Add delay.test.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoImplement delay injection
Elvira Khabirova [Sun, 18 Feb 2018 20:21:48 +0000 (23:21 +0300)]
Implement delay injection

Add -e inject=SET:delay_enter= and -e inject=SET:delay_exit= options.

* configure.ac (AC_SEARCH_LIBS): Check for timer_create -lrt.
* delay.c: New file.
* Makefile.am (strace_SOURCES): Add it.
(strace_LDADD): Add $(timer_LIBS).
* defs.h (INJECT_F_DELAY_ENTER, INJECT_F_DELAY_EXIT,
TCB_INJECT_DELAY_EXIT, TCB_DELAYED, inject_delay_exit, syscall_delayed):
New macros.
(alloc_delay_data, fill_delay_data, is_delay_timer_created,
arm_delay_timer, delay_tcb): New prototypes.
(struct inject_data): Replace reserved field with delay_idx.
(struct tcb): Add delay_expiration_time field.
* filter_qualify.c (parse_delay_token): New function.
(parse_inject_token): Use it.
(qualify_inject_common): Initialize struct inject_opts.data.delay_idx.
* strace.c: Include <setjmp.h>
(timer_jmp_buf, timer_set): New static variables.
(timer_sighandler, restart_delayed_tcb, restart_delayed_tcbs): New
functions.
(init): Block SIGALRM, set SIGALRM handler.
(dispatch_event): Do not restart delayed syscalls.
(next_event): Unblock SIGALRM during wait4 invocation.
* syscall.c (tamper_with_syscall_entering): Arm delay timer if
INJECT_F_DELAY_ENTER injection flag is set, set TCB_INJECT_DELAY_EXIT
flag if INJECT_F_DELAY_EXIT injection flag is set.
tamper_with_syscall_exiting): Arm delay timer if inject_delay_exit.
(syscall_exiting_trace): Call tamper_with_syscall_exiting in case of
inject_delay_exit.
(syscall_exiting_finish): Clear TCB_INJECT_DELAY_EXIT flag.
* strace.1.in: Document delay injection.
* NEWS: Mention this improvement.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoDo not block handled signals in interactive mode
Dmitry V. Levin [Thu, 22 Mar 2018 06:23:25 +0000 (06:23 +0000)]
Do not block handled signals in interactive mode

Let these signals be handled asynchronously as they are acted on
only when waiting for process state changes.

* strace.c (start_set, blocked_set): Remove.
(set_sighandler): Do not update blocked_set.
(startup_attach, init, next_event): Remove all sigprocmask calls.

6 years agobpf: improve handling of various sizes of bpf_prog_attr structure
Eugene Syromyatnikov [Thu, 22 Feb 2018 02:17:04 +0000 (03:17 +0100)]
bpf: improve handling of various sizes of bpf_prog_attr structure

As program attributes have been added gradually over kernel versions,
attribute size less than expected should be printed accordingly.

* bpf.c (DEF_BPF_CMD_DECODER(BPF_PROG_LOAD)): Do not print structure
fields if their size is less than the initially introduced (in Linux
commit v3.18-rc1~52^2~1^2~7) version.  Print fields of union bpf_attr
introduced in various kernel versions when the length is big enough
(new fields were introduced in Linux commits v3.18-rc1~52^2~1^2~4,
v4.1-rc1~84^2~50, and v4.12-rc2~34^2~29^2~2).
* tests/bpf.c (print_BPF_PROG_LOAD_first): Update expected output.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobtrfs: print struct btrfs_ioctl_logical_ino_args.reserved if non-zero
Eugene Syromyatnikov [Wed, 21 Feb 2018 23:24:16 +0000 (00:24 +0100)]
btrfs: print struct btrfs_ioctl_logical_ino_args.reserved if non-zero

* btrfs.c (btrfs_ioctl) <case BTRFS_IOC_LOGICAL_INO>: Print
struct btrfs_ioctl_logical_ino_args.reserved field if it is not zero.
* tests/btrfs.c (btrfs_test_ino_path_ioctls): Check it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoMove is_filled and IS_ZERO to macros.h, rename IS_ZERO to IS_ARRAY_ZERO
Eugene Syromyatnikov [Wed, 21 Feb 2018 23:21:35 +0000 (00:21 +0100)]
Move is_filled and IS_ZERO to macros.h, rename IS_ZERO to IS_ARRAY_ZERO

* s390.c: Replace all IS_ZERO invocations with IS_ARRAY_ZERO.
(is_filled, IS_ZERO): Move...
* macros.h: ...here.
(is_filled): Add inline qualifier, add const qualifier to ptr.
(IS_ZERO): Rename to IS_ARRAY_ZERO, cast arr_ to "const char *".

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agompers.m4: enhance workaround for missing gnu/stubs-*.h files
Dmitry V. Levin [Tue, 20 Mar 2018 20:44:34 +0000 (20:44 +0000)]
mpers.m4: enhance workaround for missing gnu/stubs-*.h files

Make generated empty gnu stub files available for mpers_test.sh check.

* m4/mpers.m4 (st_MPERS): Add $IFLAG to CPPFLAGS for mpers_test.sh
invocation.

Complements: v4.11~223 ("mpers.m4: workaround missing gnu/stubs-*.h files")

6 years agoREADME.md: add references to binary strace packages
Eugene Syromyatnikov [Mon, 19 Mar 2018 19:49:58 +0000 (20:49 +0100)]
README.md: add references to binary strace packages

* README.md: Add references to binary strace packages in OBS,
Fedora rawhide, and Sisyphus.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoINSTALL-git.md: enhance phrasing
Eugene Syromyatnikov [Mon, 19 Mar 2018 04:49:27 +0000 (05:49 +0100)]
INSTALL-git.md: enhance phrasing

* INSTALL-git.md: Enhance phrasing.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobootstrap: distribute README
Dmitry V. Levin [Tue, 20 Mar 2018 12:11:34 +0000 (12:11 +0000)]
bootstrap: distribute README

* bootstrap: Install README before invoking autoreconf to get README
included into distributed tarball.

Fixes: v4.21-93-g4bb8454 ("Move README to dist subdirectory")
6 years agoReplace struct timeval with struct timespec in time measurements
Dmitry V. Levin [Fri, 16 Mar 2018 00:55:58 +0000 (00:55 +0000)]
Replace struct timeval with struct timespec in time measurements

This is required to implement more precise time measurements.

* Makefile.am (strace_LDADD): Add $(clock_LIBS).
* defs.h (struct tcb): Change the type of stime, dtime, and etime fields
from struct timeval to struct timespec, all users updated.
(syscall_exiting_decode, syscall_exiting_trace, count_syscall): Change
the type of "struct timeval *" argument to "struct timespec *", all
users updated.
(tv_nz, tv_cmp, tv_float, tv_add, tv_sub, tv_div, tv_mul): Rename to
ts_nz, ts_cmp, ts_float, ts_add, ts_sub, ts_div, and ts_mul.  Change
the type of all "struct timeval *" arguments to "struct timespec *",
all users updated.
* util.c (tv_nz, tv_cmp, tv_float, tv_add, tv_sub, tv_div, tv_mul):
Rename to ts_nz, ts_cmp, ts_float, ts_add, ts_sub, ts_div, and ts_mul.
Change the type of all "struct timeval *" arguments to "struct timespec *".
* count.c (struct call_counts): Change the type of "time" field
from struct timeval to struct timespec, all users updated.
(overhead): Change type from struct timeval to struct timespec, all
users updated.
(count_syscall): Change the type of "struct timeval *" argument to
"struct timespec *".
* strace.c (printleader): Change the type of struct timeval variables
to struct timespec, call clock_gettime instead of gettimeofday.
(next_event, trace_syscall): Change the type of struct timeval variables
to struct timespec.
* syscall.c (syscall_entering_finish, syscall_exiting_decode): Call
clock_gettime instead of gettimeofday.

6 years agoFix -O option handling
Dmitry V. Levin [Tue, 20 Mar 2018 02:30:24 +0000 (02:30 +0000)]
Fix -O option handling

Fast syscalls usually take less than a microsecond of system cpu time
nowadays, making -O option almost useless.

* count.c (call_summary_pers): Avoid negative time counts.
* tests/count.test: Check it.
* NEWS: Mention it.

6 years agocount: cleanup count_syscall
Dmitry V. Levin [Fri, 16 Mar 2018 00:55:58 +0000 (00:55 +0000)]
count: cleanup count_syscall

* count.c (shortest): Remove.
(overhead): Initialize to zero.
(call_summary_pers): Remove shortest handling.
(count_syscall): Remove dead code.  The remaining code does the same
wrong calculations as before the change, though.

6 years agoprintleader: cleanup tflag handling
Dmitry V. Levin [Fri, 16 Mar 2018 00:55:58 +0000 (00:55 +0000)]
printleader: cleanup tflag handling

* strace.c (printleader): Move declarations of variables closer
to their first use.

6 years agoMove install.texi to maint subdirectory
Dmitry V. Levin [Fri, 16 Mar 2018 00:55:58 +0000 (00:55 +0000)]
Move install.texi to maint subdirectory

This file comes from GNU Autoconf and is used to generate INSTALL file.

* install.texi: Move...
* maint/install.texi: ...here.

6 years agodoc: update commit requirements
Eugene Syromyatnikov [Wed, 14 Mar 2018 19:43:47 +0000 (20:43 +0100)]
doc: update commit requirements

* README-hacking (Requirements): Enhance phrasing.
(Commit log requirements): Rename to "Commit requirements",
describe "absence of whitespace errors" requirement, add references
to the Linux kernel coding style and scripts/checkpatch.pl script.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoMove README to dist subdirectory
Eugene Syromyatnikov [Wed, 14 Mar 2018 16:53:04 +0000 (17:53 +0100)]
Move README to dist subdirectory

README was originally written for users of distribution tarballs.
Nowadays it appears to be confusing for those who build strace
using a GIT version of strace source code.

* README: Move...
* dist/README: ...here.
* bootstrap: Copy README from dist subdirectory to the toplevel
directory after successful autoreconf.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
References: https://github.com/strace/strace/issues/56

6 years agoREADME: synchronise with README.md
Eugene Syromyatnikov [Wed, 14 Mar 2018 16:51:13 +0000 (17:51 +0100)]
README: synchronise with README.md

* README: Extend description, reference COPYING.

6 years agopoll.c: remove special INFTIM handling
Eugene Syromyatnikov [Sat, 10 Mar 2018 05:27:21 +0000 (06:27 +0100)]
poll.c: remove special INFTIM handling

On Linux, poll syscall interprets any negative timeout value as an
infinite timeout, so no need to handle BSD-specific INFTIM.

* poll.c (SYS_FUNC(poll)): Remove INFTIM handling.

6 years agobuild: do not hardcode -lrt
Dmitry V. Levin [Wed, 14 Mar 2018 21:15:55 +0000 (21:15 +0000)]
build: do not hardcode -lrt

Depending on libc implementation, various -lrt functions can be
implemented either in -lc or in -lrt.  For example, starting with
glibc-2.17 the clock_* suite of functions is available directly in -lc.

Check whether clock_* and mq_* suites of functions are provided
by -lrt or by the main C library, do not link with -lrt unnecessarily.

This change affects only tests yet, but this is going to be
more important as soon as strace starts using clock_gettime.

* configure.ac (AC_SEARCH_LIBS): Check for clock_gettime and mq_open
in -lrt.
(AC_SUBST): Add clock_LIBS and mq_LIBS.
* tests/Makefile.am (mq_LDADD): Replace -lrt with $(mq_LIBS).
(threads_execve_LDADD, times_LDADD): Replace -lrt with $(clock_LIBS).

6 years agotests: do not link with -lrt unnecessarily
Dmitry V. Levin [Wed, 14 Mar 2018 21:15:55 +0000 (21:15 +0000)]
tests: do not link with -lrt unnecessarily

* tests/Makefile.am (attach_f_p_LDADD): Remove -lrt.
(clock_xettime_LDADD, mq_sendrecv_LDADD, mq_sendrecv_read_LDADD,
mq_sendrecv_write_LDADD): Remove.

6 years agoOptimize pid2tcb
Dmitry V. Levin [Tue, 1 Mar 2016 14:42:58 +0000 (14:42 +0000)]
Optimize pid2tcb

Introduce an internal cache of pid2tcb translations.
This can save more than 80% of CPU user time spent by strace.

Tested using the following setup:

#include <unistd.h>
#include <sys/stat.h>
#include <sys/wait.h>
int main()
{
int i;
sleep(1);
for (i = 1; i < 1000; ++i) {
pid_t pid = fork();
if (pid < 0)
return 2;
if (pid)
return wait(&i) != pid || i;
}
sleep(1);
for (i = 0; i < 10000000; ++i)
umask(0777);
return 0;
}

old$ ./set_ptracer_any ./pid2tcb >pid2tcb.wait & \
  while [ ! -s pid2tcb.wait ]; do sleep 0.1; done; \
  time -f '%Uuser %Ssystem %eelapsed %PCPU' \
  ../strace -qq -enone -esignal=none -f -p $!
5.51user 104.90system 122.45elapsed 90%CPU

new$ ./set_ptracer_any ./pid2tcb >pid2tcb.wait & \
  while [ ! -s pid2tcb.wait ]; do sleep 0.1; done; \
  time -f '%Uuser %Ssystem %eelapsed %PCPU' \
  ../strace -qq -enone -esignal=none -f -p $!
1.29user 102.78system 114.97elapsed 90%CPU

6 years agoEnable USE_SEIZE code unconditionally
Dmitry V. Levin [Tue, 13 Mar 2018 20:54:25 +0000 (20:54 +0000)]
Enable USE_SEIZE code unconditionally

It is by no means an experimental code.

* defs.h (USE_SEIZE): Remove.
* strace.c [!USE_SEIZE]: Remove.

6 years agoci: clone musl from the local server
Dmitry V. Levin [Tue, 13 Mar 2018 15:12:14 +0000 (15:12 +0000)]
ci: clone musl from the local server

Assume that strace project on the local server contains an appropriate
musl repository, use this repository instead of hardcoded github
location.

* ci/install-dependencies.sh (clone_repo): Use local server by default.
(musl-gcc): Un-hardcode the location of musl repository.

6 years agoci: refactor cloning of additional repositories
Dmitry V. Levin [Tue, 13 Mar 2018 15:12:14 +0000 (15:12 +0000)]
ci: refactor cloning of additional repositories

* ci/install-dependencies.sh (clone_repo): New function.
Use it instead of direct invocations of git clone.

6 years agoci: extend error diagnostics when configure invocation fails
Dmitry V. Levin [Tue, 13 Mar 2018 15:12:14 +0000 (15:12 +0000)]
ci: extend error diagnostics when configure invocation fails

* ci/run-build-and-tests.sh: Include $CC -dumpspecs output in addition
to config.log when ./configure fails.

6 years agoci: rename travis-build.sh and travis-install.sh scripts
Dmitry V. Levin [Tue, 13 Mar 2018 13:19:02 +0000 (13:19 +0000)]
ci: rename travis-build.sh and travis-install.sh scripts

* travis-build.sh: Rename to ci/run-build-and-tests.sh, all callers
updated.
* travis-install.sh: Rename to ci/install-dependencies.sh, all callers
updated.

6 years agotests: extend ioctl.test libc protection to -y output
Dmitry V. Levin [Tue, 13 Mar 2018 01:53:04 +0000 (01:53 +0000)]
tests: extend ioctl.test libc protection to -y output

* tests/ioctl.test: Extend the filter of ioctl calls with standard
descriptor arguments to -y output.

6 years agoptp.c: print field names and use macros form print_fields.h
Harsha Sharma [Sat, 10 Mar 2018 06:21:59 +0000 (11:51 +0530)]
ptp.c: print field names and use macros form print_fields.h

* ptp.c: Include "print_fields.h".
(ptp_ioctl): Print field names with field values for PTP_PEROUT_REQUEST,
use macros from print_fields.h.

6 years agotests: add check for decoding of netfilter subsystem
Chen Jingpiao [Sun, 11 Mar 2018 12:14:57 +0000 (20:14 +0800)]
tests: add check for decoding of netfilter subsystem

* tests/netlink_netfilter.c(test_nfgenmsg): Add check for decoding
of netfilter subsystem.

6 years agonfnetlink: introduce generic netfilter subsystem decoder
Chen Jingpiao [Sun, 11 Mar 2018 12:14:56 +0000 (20:14 +0800)]
nfnetlink: introduce generic netfilter subsystem decoder

* netlink_netfilter.c: Include "nlattr.h".
(decode_netlink_netfilter): Call decode_nlattr.

6 years agoMove nl_netfilter_msg_types definition from netlink.c to netlink_netfilter.c
Chen Jingpiao [Sat, 10 Mar 2018 01:44:35 +0000 (09:44 +0800)]
Move nl_netfilter_msg_types definition from netlink.c to netlink_netfilter.c

The side effect of #include "xlat/nl_netfilter_msg_types.h" is
NFNL_MSG_BATCH_* constants properly defined in that header file.
While netlink.c does not use these constants itself,
netlink_netfilter.c is going to need them soon.

* defs.h (nl_netfilter_msg_types): New xlat prototype.
* netlink.c: Move inclusion of "xlat/nl_netfilter_msg_types.h" ...
* netlink_netfilter.c: ... here.

6 years agotests: add check for NETLINK_NETFILTER parser
Chen Jingpiao [Thu, 8 Mar 2018 14:53:45 +0000 (22:53 +0800)]
tests: add check for NETLINK_NETFILTER parser

* tests/netlink_netfilter.c: Include <netinet/in.h>, <arpa/inet.h>
and <linux/netfilter/nf_tables.h>.
Replace "netlink.h" with "test_netlink.h".
(NFNL_SUBSYS_NFTABLES, NFT_MSG_NEWTABLE): New macros.
(test_nlmsg_done, test_nfgenmsg): New functions.
(main): Use them.

6 years agonetlink: introduce NETLINK_NETFILTER parser
Chen Jingpiao [Thu, 8 Mar 2018 14:53:44 +0000 (22:53 +0800)]
netlink: introduce NETLINK_NETFILTER parser

* netlink_netfilter.c: New file.
* Makefile.am (strace_SOURCES): Add it.
* defs.h (decode_netlink_netfilter): New prototype.
* netlink.c (netlink_decoders): Add NETLINK_NETFILTER.
* xlat/netfilter_versions.in: New file.

6 years agoxlat: remove NFNL_SUBSYS_COUNT constant
Chen Jingpiao [Sun, 11 Mar 2018 12:16:01 +0000 (20:16 +0800)]
xlat: remove NFNL_SUBSYS_COUNT constant

NFNL_SUBSYS_COUNT is not a symbol with some constant value, it changes
with time, just print it as an unrecognized number.

* xlat/nl_netfilter_subsys_ids.in (NFNL_SUBSYS_COUNT): Remove.

6 years agoinject_data: make room for more injection features
Dmitry V. Levin [Sat, 10 Mar 2018 00:13:04 +0000 (00:13 +0000)]
inject_data: make room for more injection features

* defs.h (struct inject_data): Squeeze flags and signo fields from
uint16_t to uint8_t to make room for more injection features.

6 years agoxlat: sort v4l2_pix_fmts.in and v4l2_sdr_fmts.in
Eugene Syromyatnikov [Wed, 7 Mar 2018 14:18:55 +0000 (15:18 +0100)]
xlat: sort v4l2_pix_fmts.in and v4l2_sdr_fmts.in

* xlat/v4l2_pix_fmts.in: Sort by value, add a comment about sorting.
* xlat/v4l2_sdr_fmts.in: Likewise.

6 years agoxlat: add comments to all sorted xlat files
Dmitry V. Levin [Fri, 9 Mar 2018 02:48:30 +0000 (02:48 +0000)]
xlat: add comments to all sorted xlat files

Add a short comment describing the method used to sort entries.

* xlat/ethernet_protocols.in: Update the comment about sorting.
* xlat/fsmagic.in: Likewise.
* xlat/evdev_keycode.in: Add a comment about sorting.
* xlat/hw_breakpoint_type.in: Likewise.
* xlat/perf_hw_cache_id.in: Likewise.
* xlat/perf_hw_cache_op_id.in: Likewise.
* xlat/perf_hw_cache_op_result_id.in: Likewise.
* xlat/perf_hw_id.in: Likewise.
* xlat/perf_sw_ids.in: Likewise.
* xlat/perf_type_id.in: Likewise.

6 years agobpf: remove page size caching
Eugene Syromyatnikov [Mon, 5 Mar 2018 09:17:44 +0000 (10:17 +0100)]
bpf: remove page size caching

get_pagesize() has a static cache anyway, no need to duplicate it.

* bpf.c (SYS_FUNC(bpf)): Remove static size_t page_size and its
initialisation, use get_pagesize() as the size of buf directly.

6 years agobpf_filter: fix indentation of the switch clause
Eugene Syromyatnikov [Thu, 22 Feb 2018 05:30:54 +0000 (06:30 +0100)]
bpf_filter: fix indentation of the switch clause

* bpf_filter.c (print_bpf_filter_code): Fix switch clause indentation.

6 years agoxlat: provide fallback definitions for arch-independent mmap flags
Dmitry V. Levin [Thu, 8 Mar 2018 22:27:26 +0000 (22:27 +0000)]
xlat: provide fallback definitions for arch-independent mmap flags

This is important for recently introduced MAP_SHARED_VALIDATE flag.

* xlat/mmap_flags.in (MAP_SHARED, MAP_PRIVATE, MAP_SHARED_VALIDATE):
Add constant values.

Fixes: v4.21-67-g8c209d1 ("tests: fix remap_file_pages.test breakage on hppa")
6 years agobpf: print kern_version in the form of KERNEL_VERSION macro
Eugene Syromyatnikov [Thu, 22 Feb 2018 01:44:04 +0000 (02:44 +0100)]
bpf: print kern_version in the form of KERNEL_VERSION macro

* bpf.c (DEF_BPF_CMD_DECODER(BPF_PROG_LOAD)): Print
union bpf_attr.kern_version in the form of KERNEL_VERSION macro call.
* tests/bpf.c: Update expected output.

6 years agotests: fix remap_file_pages.test breakage on hppa
Eugene Syromyatnikov [Mon, 5 Mar 2018 03:15:53 +0000 (04:15 +0100)]
tests: fix remap_file_pages.test breakage on hppa

Apparently, hppa is the only architecture that has MAP_TYPE
defined to 0x3 instead of 0xf, and the tests hit that corner case.

* tests/remap_file_pages.c (main) [MAP_HUGETLB]: Print the value
of mapping type depending on the architecture (MAP_SHARED_VALIDATE
for hppa and unknown value for other architectures).

Fixes: v4.21~59 ("xlat: update MAP_* constants")
6 years agoSort Ethernet protocols xlat
Eugene Syromyatnikov [Fri, 16 Feb 2018 18:01:24 +0000 (19:01 +0100)]
Sort Ethernet protocols xlat

* defs.h (ethernet_protocols_size): New declaration.
* netlink_packet_diag.c (decode_packet_diag_req): Use
printxval_searchnn to print Ethernet protocols.
* sockaddr.c (ethernet_protocols_size): New constant, item count
in ethernet_protocols array.
(print_sockaddr_data_ll): Use printxval_search instead of
printxval to print Ethernet protocols.
* xlat/ethernet_protocols.in: Sort it by value, add comment
about the fact.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoChange sorted arrays to be terminated with XLAT_END like unsorted arrays
Eugene Syromyatnikov [Wed, 7 Mar 2018 18:07:59 +0000 (19:07 +0100)]
Change sorted arrays to be terminated with XLAT_END like unsorted arrays

It is quite unwieldy to have this distinction between sorted and
unsorted arrays when we can just decrement the size in a wrapper.

* defs.h (printxval_search): Decrement array size.
* xlat/fsmagic.in (#unterminated): Remove.
* xlat/hw_breakpoint_type.in (#unterminated): Remove.
* xlat/perf_hw_cache_id.in (#unterminated): Remove.
* xlat/perf_hw_cache_op_id.in (#unterminated): Remove.
* xlat/perf_hw_cache_op_result_id.in (#unterminated): Remove.
* xlat/perf_hw_id.in (#unterminated): Remove.
* xlat/perf_sw_ids.in (#unterminated): Remove.
* xlat/perf_type_id.in (#unterminated): Remove.
* xlat/gen.sh (gen_header): Remove #unterminated support.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agostrace.1.in: add a note about tracing of scripts without shebang
Eugene Syromyatnikov [Wed, 28 Feb 2018 17:17:26 +0000 (18:17 +0100)]
strace.1.in: add a note about tracing of scripts without shebang

* strace.1.in (.SH NOTES): Note that tracing of scripts without shebang
won't work.

Reported-by: Mike Parker
Closes: https://github.com/strace/strace/issues/46
6 years agostrace.1.in: mention that -c suppresses regular output
Eugene Syromyatnikov [Wed, 28 Feb 2018 16:25:31 +0000 (17:25 +0100)]
strace.1.in: mention that -c suppresses regular output

As the note that -C makes strace "also print regular output" can be
easily overlooked.

* strace.1.in (.SS Statistics) <.TP .B \-c>: Mention that -c supresses
regular output.

6 years agoerrnoent.h: add ERECALLCONFLICT
Eugene Syromyatnikov [Wed, 28 Feb 2018 16:12:04 +0000 (17:12 +0100)]
errnoent.h: add ERECALLCONFLICT

* linux/errnoent.h ([530]): Add ERECALLCONFLICT error introduced by
Linux commit v4.7-rc1~40^2~6.
* linux/alpha/errnoent.h ([530]): Likewise.
* linux/hppa/errnoent.h ([530]): Likewise.
* linux/mips/errnoent.h ([530]): Likewise.
* linux/sparc/errnoent.h ([530]): Likewise.

6 years agoxlat: add BPF_F_ALLOW_MULTI constant
Eugene Syromyatnikov [Thu, 1 Mar 2018 19:19:16 +0000 (20:19 +0100)]
xlat: add BPF_F_ALLOW_MULTI constant

* xlat/bpf_attach_flags.in (BPF_F_ALLOW_MULTI): New constant, introduced
by Linux commit v4.15-rc1~84^2~558^2~7.

6 years agoxlat: add BPF_MAP_TYPE_CPUMAP constant
Eugene Syromyatnikov [Thu, 1 Mar 2018 18:50:39 +0000 (19:50 +0100)]
xlat: add BPF_MAP_TYPE_CPUMAP constant

* xlat/bpf_map_types.in (BPF_MAP_TYPE_CPUMAP): New constant, introduced
by Linux commit v4.15-rc1~84^2~427^2~4.

6 years agotests/test_printstrn.c: do not declare i again
Eugene Syromyatnikov [Fri, 2 Mar 2018 05:19:03 +0000 (06:19 +0100)]
tests/test_printstrn.c: do not declare i again

6 years agotests/s390_sthyi.c: make utility functions inline
Eugene Syromyatnikov [Thu, 1 Mar 2018 05:28:05 +0000 (06:28 +0100)]
tests/s390_sthyi.c: make utility functions inline

When built with --enable-gcc-Werror, s390_sthyi test build fails
with the following error:

s390_sthyi.c:63:1: error: ‘print_u8’ defined but not used [-Werror=unused-function]
 print_u8(const char *prefix, unsigned char *buf, unsigned int offs, bool zero)
 ^~~~~~~~

Apparently, after some back and forth, all occurrences of printing u8
values landed under verbose printing, so this function is no longer
used in non-verbose mode.  Let's avoid this in the future by inlining
all the utility functions in this test.

* tests/s390_sthyi.c (print_0x8, print_u8, print_u16, print_x32,
print_weight, ebcdic2ascii, is_empty, print_ebcdic): Add inline
qualifier.
[!VERBOSE] (is_empty): Remove "# if VERBOSE" guard.

6 years agobtrfs: print struct btrfs_ioctl_logical_ino_args.flags field
Eugene Syromyatnikov [Wed, 21 Feb 2018 23:18:10 +0000 (00:18 +0100)]
btrfs: print struct btrfs_ioctl_logical_ino_args.flags field

The field has been introduced in Linux commit v4.15-rc1~135^2~17.

* btrfs.c: Implement decoding of
struct btrfs_ioctl_logical_ino_args.flags field.
* configure.ac: Check for struct btrfs_ioctl_logical_ino_args.flags
presence in linux/btrfs.h.
* tests/btrfs.c: Update expected output, add additional checks.
* xlat/btrfs_logical_ino_args_flags.in: New file.

6 years agobtrfs.c: print __u64 fields with pointer semantics using printaddr64
Eugene Syromyatnikov [Wed, 21 Feb 2018 22:20:46 +0000 (23:20 +0100)]
btrfs.c: print __u64 fields with pointer semantics using printaddr64

* btrfs.c (btrfs_ioctl) <case BTRFS_IOC_INO_PATHS>: Print fspath field
with printaddr64.
(btrfs_ioctl) <case BTRFS_IOC_LOGICAL_INO>: Print inodes field with
printaddr64.
* tests/btrfs.c: Add checks for NULL in fspath and inodes fields.
* NEWS: Mention it.

6 years agoutil.c: introduce printaddr64
Eugene Syromyatnikov [Wed, 21 Feb 2018 22:15:54 +0000 (23:15 +0100)]
util.c: introduce printaddr64

Sometimes, 64-bit value is expected to be interpreted as an address
(in BTRFS ioctl interface, for example).

* defs.h (printaddr64): New declaration.
* util.c (printaddr64): Rename from printaddr, change argument type
to uint64_t.
(printaddr): Turn into a thin wrapper around printaddr64.
(printnum_addr_int, printnum_addr_int64): Use printaddr64 instead of
printaddr.  printnum_addr_int64 is not used outside the cases where
kernel_long is less or equal than 64 bit currently, so this change
should be safe.

6 years agoprctl: add decoding of PR_SVE_SET_VL and PR_SVE_GET_VL commands
Eugene Syromyatnikov [Wed, 21 Feb 2018 19:57:16 +0000 (20:57 +0100)]
prctl: add decoding of PR_SVE_SET_VL and PR_SVE_GET_VL commands

These commands were introduced in Linux commit v4.15-rc1~110^2~9.

* xlat/pr_sve_vl_flags.in: New file.
* xlat/prctl_options.in: Likewise.
* prctl.c: Include "xstring.h" and "xlat/pr_sve_vl_flags.h".
[!PR_SVE_VL_LEN_MASK] (PR_SVE_VL_LEN_MASK): New macro constant.
(sprint_sve_val): New function.
(SYS_FUNC(prctl)): Add decoding for PR_SVE_GET_VL and PR_SVE_SET_VL
commands.
* NEWS: Mention it.

6 years agoImplement PTRACE_SECCOMP_GET_METADATA ptrace request decoding
Eugene Syromyatnikov [Wed, 21 Feb 2018 18:20:54 +0000 (19:20 +0100)]
Implement PTRACE_SECCOMP_GET_METADATA ptrace request decoding

* defs.h (seccomp_filter_flags): New declaration.
* process.c (SYS_FUNC(ptrace)): Implement PTRACE_SECCOMP_GET_METADATA
request decoding.
* ptrace.h [!PTRACE_SECCOMP_GET_METADATA] (PTRACE_SECCOMP_GET_METADATA):
New macro constant.
* xlat/ptrace_cmds.in (PTRACE_SECCOMP_GET_METADATA): New constant.
* tests/ptrace.c (main): Add some checks for PTRACE_SECCOMP_GET_METADATA
request decoding.
* NEWS: Mention it.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agobuild: prepare for -Wimplicit-fallthrough=5
Dmitry V. Levin [Tue, 6 Mar 2018 23:52:08 +0000 (23:52 +0000)]
build: prepare for -Wimplicit-fallthrough=5

* gcc_compat.h (ATTRIBUTE_FALLTHROUGH): New macro.
* block.c (block_ioctl): Use it instead of "fall through" comment.
* btrfs.c (btrfs_ioctl): Likewise.
* loop.c (loop_ioctl): Likewise.
* mtd.c (mtd_ioctl): Likewise.
* rtc.c (rtc_ioctl): Likewise.
* v4l2.c (v4l2_ioctl): Likewise.
* dm.c (dm_decode_values): Likewise.
* process.c (SYS_FUNC(ptrace)): Likewise.
* quota.c (decode_cmd_data): Likewise.
* ucopy.c (umovestr): Likewise.
* unwind.c (unwind_print_stacktrace, unwind_capture_stacktrace)):
Likewise.
* term.c (term_ioctl): Add ATTRIBUTE_FALLTHROUGH.
* ioctl.c (ioctl_decode) [ALPHA || POWERPC]: Likewise.
* m4/st_warn_cflags.m4 (gl_WARN_ADD): Add -Wimplicit-fallthrough=5.
* tests/ioctl_v4l2.c (init_v4l2_format): Reorganize the switch statement
without implicit fallthrough.

6 years agoxlat: add eBPF-based device controller constants
Eugene Syromyatnikov [Tue, 20 Feb 2018 18:48:08 +0000 (19:48 +0100)]
xlat: add eBPF-based device controller constants

Add new BPF_PROG_TYPE_CGROUP_DEVICE eBPF program type and new
BPF_CGROUP_DEVICE eBPF program attach type, added in Linux commit
v4.15-rc1~84^2~120^2~2.

* xlat/bpf_attach_type.in (BPF_CGROUP_DEVICE): New constant.
* xlat/bpf_prog_types.in (BPF_PROG_TYPE_CGROUP_DEVICE): Likewise.
* NEWS: Mention it.

6 years agoxlat: provide fallback definitions for input event constants
Eugene Syromyatnikov [Mon, 19 Feb 2018 18:25:44 +0000 (19:25 +0100)]
xlat: provide fallback definitions for input event constants

Values added using the following pair of commands:

$ cat xlat/evdev_keycode.in |
while read r; do [ -n "$r" ] &&
sed -rn 's/^#define[[:space:]]+('$r'[[:space:]]+[^[:space:]]+).*/\1/p' \
~/dev/linux/include/uapi/linux/input-event-codes.h || echo;
done > xlat/evdev_keycode.in.new
$ sort -s -n -k1,1 \
<(awk '{if (NF>1) {last = strtonum($2)}; printf("%d %s\n", last, $0)}' \
xlat/evdev_keycode.in.new) \
| sed 's/^[0-9]* //'  > xlat/evdev_keycode.in

It also verifies that the values are sorted and bsearch-ready.

* xlat/evdev_keycode.in: Add constant values.

6 years agoxlat: update the list of input event constants
Eugene Syromyatnikov [Mon, 19 Feb 2018 17:53:24 +0000 (18:53 +0100)]
xlat: update the list of input event constants

Remove some duplicating definitions and add the new ones.

* xlat/evdev_keycode.in (KEY_HANGUEL): Remove, an alternative name for
KEY_HANGEUL.
(KEY_DIRECTION): Remove, an alternative name for KEY_ROTATE_DISPLAY.
(KEY_BRIGHTNESS_ZERO): Remove, an alternative name for
KEY_BRIGHTNESS_AUTO.
(KEY_WIMAX): Remove, an alternative name for KEY_WWAN.
(BTN_A): Remove, an alternative name for BTN_SOUTH.
(BTN_B): Remove, an alternative name for BTN_EAST.
(BTN_X): Remove, an alternative name for BTN_NORTH.
(BTN_Y): Remove, an alternative name for BTN_WEST.
(BTN_STYLUS3): New constant, added in Linux commit v4.15-rc1~114^2^2~1.
(KEY_BRIGHTNESS_TOGGLE): Remove, an alternative name for
KEY_DISPLAYTOGGLE.
(KEY_ROTATE_LOCK_TOGGLE): New constant, added in Linux commit
v4.16-rc1~54^2~67.
(KEY_DATA): New constant, added in Linux commit v4.9-rc8~12^2.
(KEY_ONSCREEN_KEYBOARD): New constant, added in Linux commit
v4.12-rc1~126^2~2^12~5.
* NEWS: Mention it.

6 years agoxlat: provide fallback definitions for SCTP socket option constants
Eugene Syromyatnikov [Fri, 16 Feb 2018 18:36:07 +0000 (19:36 +0100)]
xlat: provide fallback definitions for SCTP socket option constants

Values for SCTP_GET_PEER_ADDRS_NUM_OLD, SCTP_GET_PEER_ADDRS_OLD,
SCTP_GET_LOCAL_ADDRS_NUM_OLD, SCTP_GET_LOCAL_ADDRS_OLD are reconstructed
from Linux commit v2.6.33-rc1~388^2~167^2~7.

xlat/socksctpoptions.in: Add constant values.

6 years agoxlat: update the list of SCTP socket option constants
Eugene Syromyatnikov [Fri, 16 Feb 2018 18:26:02 +0000 (19:26 +0100)]
xlat: update the list of SCTP socket option constants

* xlat/socksctpoptions.in (SCTP_DELAYED_ACK): Rename to...
(SCTP_DELAYED_SACK): ...this, per Linux commit v2.6.38-rc2~33^2.
(SCTP_SOCKOPT_PEELOFF_FLAGS): New constant, introduced in Linux commit
v4.13-rc1~157^2~39.
(SCTP_STREAM_SCHEDULER): New constant, introduced in Linux commit
v4.15-rc1~84^2~567^2~3.
(SCTP_STREAM_SCHEDULER_VALUE): New constant, introduced in Linux commit
v4.15-rc1~84^2~567^2~2.
(SCTP_INTERLEAVING_SUPPORTED): New constant, introduced in Linux commit
 v4.16-rc1~123^2~384^2~11.
* NEWS: Mention it.

6 years agoxlat: provide fallback definitions for Ethernet protocol constants
Eugene Syromyatnikov [Fri, 16 Feb 2018 17:44:42 +0000 (18:44 +0100)]
xlat: provide fallback definitions for Ethernet protocol constants

As those are not architecture-specific.

* xlat/ethernet_protocols.in: Add values to constants.

6 years agoxlat: update the list of Ethernet protocol constants
Eugene Syromyatnikov [Fri, 16 Feb 2018 17:28:44 +0000 (18:28 +0100)]
xlat: update the list of Ethernet protocol constants

* xlat/ethernet_protocols.in (ETH_P_ERSPAN2): New constant, introduced
in Linux commit v4.16-rc1~123^2~355^2~2.
(ETH_P_IBOE): New constant, introduced in commit v4.11-rc1~73^2~74.
* NEWS: Mention it.

6 years agov4l2: print known pixel/SDR formats
Eugene Syromyatnikov [Thu, 15 Feb 2018 20:16:15 +0000 (21:16 +0100)]
v4l2: print known pixel/SDR formats

* xlat/v4l2_pix_fmts.in: New file.
* xlat/v4l2_sdr_fmts.in: Likewise.
* v4l2.c [!v4l2_fourcc_be] (v4l2_fourcc_be): New macro.
(print_pixelformat): Add xlat parameter, print constant name
as a comment if it has been found in xlat.
(print_v4l2_fmtdesc, print_v4l2_frmivalenum): Pass v4l2_pix_fmts
to print_pixelformat.
(print_v4l2_format_fmt) <case V4L2_BUF_TYPE_VIDEO_CAPTURE, case
V4L2_BUF_TYPE_VIDEO_OUTPUT, case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE,
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, case V4L2_BUF_TYPE_VBI_CAPTURE,
case V4L2_BUF_TYPE_VBI_OUTPUT>: Pass v4l2_pix_fmts to print_pixelformat.
(print_v4l2_format_fmt) <case V4L2_BUF_TYPE_SDR_OUTPUT, case
V4L2_BUF_TYPE_SDR_CAPTURE>: Pass v4l2_sdr_fmts to print_pixelformat.
* tests/v4l2.c: Test it, update expected output.
* NEWS: Mention it.

6 years agov4l2: v4l2_fourcc is endianness-agnostic
Eugene Syromyatnikov [Thu, 1 Mar 2018 23:45:16 +0000 (00:45 +0100)]
v4l2: v4l2_fourcc is endianness-agnostic

v4l2_fourcc(a, b, c, d) is defined as (a | (b << 8) | (c << 16) | (d << 24)
regardless of endianness (no mnemonic on big-endian architectures),
so we don't need special handling for WORDS_BIGENDIAN both in decoder
and in the test.

* v4l2.c (print_pixelformat): Change initialisation to a simple
assignment of character array.
* tests/ioctl_v4l2.c [WORDS_BIGENDIAN]: Remove.
* NEWS: Mention this fix.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
Fixes: v4.10~371 "Implement Video4Linux video-input ioctls decoder"
6 years agotests: do not include <stdbool.h> in files that include "tests.h"
Dmitry V. Levin [Thu, 1 Mar 2018 01:00:24 +0000 (01:00 +0000)]
tests: do not include <stdbool.h> in files that include "tests.h"

Starting with commit v4.21-37-g4f63bc70ca95012d72e288fc3c1eeb3ba26068a4,
<stdbool.h> is included by tests.h, so all tests that already include
"tests.h" do not need to include <stdbool.h>.

* tests/btrfs.c: Do not include <stdbool.h>.
* tests/file_handle.c: Likewise.
* tests/futex.c: Likewise.
* tests/ioctl_dm.c: Likewise.
* tests/ioctl_loop.c: Likewise.
* tests/ioctl_sock_gifconf.c: Likewise.
* tests/keyctl.c: Likewise.
* tests/mq_sendrecv.c: Likewise.
* tests/perf_event_open.c: Likewise.
* tests/s390_guarded_storage.c: Likewise.
* tests/s390_pci_mmio_read_write.c: Likewise.
* tests/s390_sthyi.c: Likewise.
* tests/xet_thread_area_x86.c: Likewise.

6 years agotests: check printing of block/char device numbers in -yy mode
Eugene Syromyatnikov [Mon, 29 Jan 2018 17:50:09 +0000 (18:50 +0100)]
tests: check printing of block/char device numbers in -yy mode

* tests/dev-yy.c: New file.
* tests/pure_executables.list: Add dev-yy.
* tests/.gitignore: Likewise.
* tests/gen_tests.in (dev-yy): New test.

6 years agoprintfd: print character/block device number in -yy mode
Eugene Syromyatnikov [Thu, 25 Jan 2018 16:53:23 +0000 (17:53 +0100)]
printfd: print character/block device number in -yy mode

* util.c: Include <sys/stat.h>, <sys/sysmacros.h>,
and "largefile_wrappers.h".
(printsocket, printdev): New functions.
(printfd): Move socket matching/printing logic to printsocket.  Check
also for printdev.  Escape opening angle bracket in addition to closing angle
bracket as it can show up as a separator in printdev.
* tests/fsync-y.c: Update expected output.
* strace.1.in: Mention this.
* NEWS: Likewise.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agoutil.c: escape closing angle bracket in printfd
Eugene Syromyatnikov [Fri, 2 Feb 2018 18:06:31 +0000 (19:06 +0100)]
util.c: escape closing angle bracket in printfd

* util.c (printfd): Use print_quoted_string_ex instead of
print_quoted_string, specify ">" as escape_chars argument.
* tests/fsync-y.c (main): Update expected output.
* NEWS: Mention it.

6 years agoutil.c: add support for additional escape characters in string_quote
Eugene Syromyatnikov [Fri, 2 Feb 2018 17:46:29 +0000 (18:46 +0100)]
util.c: add support for additional escape characters in string_quote

Quotes are not always used to denote string limits; printfd uses angle
brackets for that, for example.  As result, mechanism for supplying
set of additional characters in order to avoid ambiguities regarding
the end of the quoted string is needed.

* defs.h (string_quote): Add escape_chars parameter.
(print_quoted_string_ex): New function prototype.
* util.c (string_quote): Add escape_chars parameter.
(print_quoted_string_ex): Rename from print_quoted_string, add
escape_chars parameter, pass it to string_quote call.
(print_quoted_string): Turn into a thin wrapper around
print_quoted_string_ex.
(printstr_ex): Pass NULL as escape_chars argument of string_quote call.
* socketutils.c (unix_parse_response): Pass NULL as escape_chars
argument of string_quote call.
* tests/print_quoted_string.c (print_octal): New function.
print_quoted_memory_ex): Use it.  Add escape_chars parameter.
(print_quoted_memory): Pass NULL as escape_chars argument
of print_quoted_memory_ex call.
* tests/tests.h (print_quoted_string_ex, print_quoted_memory_ex): Add
escape_chars parameter.
* tests/fsync-y.c: Pass NULL as escape_chars argument of
print_quoted_string_ex call.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotests: check file name printing in strace -y mode
Eugene Syromyatnikov [Fri, 2 Feb 2018 16:21:22 +0000 (17:21 +0100)]
tests: check file name printing in strace -y mode

* tests/fsync-y.c: New file.
* tests/.gitignore: Add fsync-y.
* tests/Makefile.am (check_PROGRAMS): Likewise.
* tests/gen_tests.in (fsync-y): New test.

Co-Authored-by: Dmitry V. Levin <ldv@altlinux.org>
6 years agotests: add print_quoted_string_ex and print_quoted_memory_ex functions
Eugene Syromyatnikov [Fri, 2 Feb 2018 16:58:18 +0000 (17:58 +0100)]
tests: add print_quoted_string_ex and print_quoted_memory_ex functions

* tests/tests.h (print_quoted_string_ex, print_quoted_memory_ex): New
declarations.
* tests/print_quoted_string.c (print_quoted_string_ex): New function,
a thin wrapper around print_quoted_memory_ex wrapper.
(print_quoted_memory_ex): Rename from print_quoted_memory, add quote
argument.
(print_quoted_memory): Turn into a thin wrapper around
print_quoted_memory_ex.

6 years agotests: check escaping in string printing
Eugene Syromyatnikov [Fri, 2 Feb 2018 16:29:36 +0000 (17:29 +0100)]
tests: check escaping in string printing

* tests/test_printstrn.c (test_print_memory): New function.
(test_printstrn): Use it.

6 years agoDo not go full octal if the next char is '8' or '9'
Eugene Syromyatnikov [Fri, 2 Feb 2018 15:15:48 +0000 (16:15 +0100)]
Do not go full octal if the next char is '8' or '9'

* util.c (string_quote): Change the upper limit for the next character
in unabbreviated octal printing from '9' to '7'.
* tests/print_quoted_string.c (print_quoted_memory): Likewise.

6 years agotests: fix abbreviated octal escape check in print_quoted_memory
Eugene Syromyatnikov [Fri, 2 Feb 2018 12:39:30 +0000 (13:39 +0100)]
tests: fix abbreviated octal escape check in print_quoted_memory

* tests/print_quoted_string.c (print_quoted_memory): Check the next
character after octal-escaped one instead of the first one in the
string.

6 years agoutil.c: reduce indentation in non-hexadecimal case in string_quote
Eugene Syromyatnikov [Thu, 1 Feb 2018 19:13:53 +0000 (20:13 +0100)]
util.c: reduce indentation in non-hexadecimal case in string_quote

As it is already too deep there.

* util.c (string_quote): Add string_ended label, jump there
after the loop in "if (usehex)" case.

6 years agoutil.c: fix switch statement indentation in string_quote
Eugene Syromyatnikov [Thu, 1 Feb 2018 19:08:08 +0000 (20:08 +0100)]
util.c: fix switch statement indentation in string_quote

While we are here, let's also remove unnecessary break statement
in the default case.

6 years agoReplace fopen_for_input and fopen_for_output with fopen_stream
Dmitry V. Levin [Tue, 27 Feb 2018 13:14:38 +0000 (13:14 +0000)]
Replace fopen_for_input and fopen_for_output with fopen_stream

* largefile_wrappers.h (fopen_for_input, fopen_for_output): Replace
with fopen_stream.
* mmap_cache.c (fopen_for_input) Likewise.
* strace.c (fopen_for_output): Likewise.

6 years agoUpdate the list of INET_DIAG_BC_* operators
Eugene Syromyatnikov [Thu, 15 Feb 2018 18:55:16 +0000 (19:55 +0100)]
Update the list of INET_DIAG_BC_* operators

* linux/inet_diag.h (INET_DIAG_BC_S_EQ, INET_DIAG_BC_D_EQ): New
enumeration items introduced by linux kernel commit v4.16-rc1~123^2~259.
* xlat/inet_diag_bytecodes.in (INET_DIAG_BC_S_EQ, INET_DIAG_BC_D_EQ): New
constants.
* NEWS: Mention it.

6 years agoxlat: update the list of SCHED_FLAG_* constants
Eugene Syromyatnikov [Thu, 15 Feb 2018 18:41:28 +0000 (19:41 +0100)]
xlat: update the list of SCHED_FLAG_* constants

* xlat/sched_flags.in (SCHED_FLAG_RECLAIM, SCHED_FLAG_DL_OVERRUN): New
constants introduced by linux kernel commits v4.13-rc1~205^2~27 and
v4.16-rc1~164^2~8, respectively.
(SCHED_FLAG_RESET_ON_FORK): Add constant value.
* tests/sched_xetattr.c: Update expected output.
* NEWS: Mention it.

6 years agoxlat: provide fallback definitions for arch-independent poll event flags
Eugene Syromyatnikov [Thu, 15 Feb 2018 18:08:14 +0000 (19:08 +0100)]
xlat: provide fallback definitions for arch-independent poll event flags

* xlat/pollflags.in (POLLIN, POLLPRI, POLLOUT, POLLRDNORM, POLLRDBAND,
POLLERR, POLLHUP, POLLNVAL, POLL_BUSY_LOOP): Add constant values.

6 years agoxlat: update the list of poll event flags
Eugene Syromyatnikov [Thu, 15 Feb 2018 17:34:25 +0000 (18:34 +0100)]
xlat: update the list of poll event flags

POLL_BUSY_LOOP was introduced by linux kernel commit v3.11-rc1~64^2~129
as POLL_LL and then renamed in v3.11-rc1~64^2~9.  POLLRDHUP was
introduced by linux kernel commit v2.6.17-rc1~796.  POLLMSG and
POLLREMOVE predate git repository.  POLLFREE was introduced by linux
kernel commit v3.3-rc5~8 for internal use only.

* xlat/pollflags.in (POLLMSG, POLLREMOVE, POLLRDHUP, POLL_BUSY_LOOP):
New constants.
* NEWS: Mention it.

6 years agoxlat: add arch-specific si_codes constants
Eugene Syromyatnikov [Mon, 12 Feb 2018 19:45:24 +0000 (20:45 +0100)]
xlat: add arch-specific si_codes constants

Based on Linux commits v4.16-rc1~159^2~17, v4.16-rc1~159^2~16,
v4.16-rc1~159^2~15, and v4.16-rc1~159^2~14.

* xlat/sigbus_codes.in (BUS_OPFETCH): New constant.
* xlat/sigfpe_codes.in (FPE_MDAOVF, __FPE_DECOVF, __FPE_DECDIV,
__FPE_DECERR, __FPE_INVASC, __FPE_INVDEC): New constants.
* xlat/sigill_codes.in (ILL_ILLPARAOP, ILL_ILLEXCPT, ILL_CPLB_VI,
ILL_CPLB_MISS, ILL_CPLB_MULHIT, ILL_DBLFLT, ILL_HARDWALL, ILL_BADIADDR,
__ILL_BREAK, __ILL_BNDMOD): Likewise.
* xlat/sigsegv_codes.in (SEGV_STACKFLOW, __SEGV_PSTKOVF): Likewise.
* xlat/sigtrap_codes.in (TRAP_STEP, TRAP_TRACEFLOW, TRAP_WATCHPT,
TRAP_ILLTRAP): Likewise.
* NEWS: Mention it.

6 years agortnl_tc: support new TCA_* attributes
Eugene Syromyatnikov [Mon, 12 Feb 2018 19:26:32 +0000 (20:26 +0100)]
rtnl_tc: support new TCA_* attributes

* xlat/rtnl_tc_attrs.in (TCA_HW_OFFLOAD, TCA_INGRESS_BLOCK,
TCA_EGRESS_BLOCK): New constants introduced by linux kernel commits
v4.15-rc4~13^2~5^2~2 and v4.16-rc1~123^2~139^2~5.
* rtnl_tc.c (tcmsg_nla_decoders) <TCA_HW_OFFLOAD, TCA_INGRESS_BLOCK,
TCA_EGRESS_BLOCK>: New items.

6 years agortnl_link: add decoding of new IFLA_* attributes
Eugene Syromyatnikov [Mon, 12 Feb 2018 19:02:58 +0000 (20:02 +0100)]
rtnl_link: add decoding of new IFLA_* attributes

* xlat/rtnl_link_attrs.in (IFLA_NEW_NETNSID, IFLA_IF_NETNSID,
IFLA_CARRIER_UP_COUNT, IFLA_CARRIER_DOWN_COUNT, IFLA_NEW_IFINDEX): New
constants introduced by linux kernel commits v4.15-rc1~84^2~557,
v4.15-rc1~84^2~133^2, v4.16-rc1~123^2~91, and v4.16-rc1~123^2~24^2.
* rtnl_link.c (ifinfomsg_nla_decoders) <IFLA_NEW_NETNSID,
IFLA_IF_NETNSID, IFLA_CARRIER_UP_COUNT, IFLA_CARRIER_DOWN_COUNT,
IFLA_NEW_IFINDEX>: New items.

6 years agortnl_link: implement IFLA_EVENT_* decoding
Eugene Syromyatnikov [Mon, 12 Feb 2018 18:58:47 +0000 (19:58 +0100)]
rtnl_link: implement IFLA_EVENT_* decoding

* rtnl_link.c (decode_ifla_event): New function.
(ifinfomsg_nla_decoders) <[IFLA_EVENT]>: Use it.
* xlat/rtnl_ifla_events.in: New file.
* NEWS: Mention it.

6 years agoxlat: update the list of RWF_* constants
Eugene Syromyatnikov [Mon, 12 Feb 2018 18:41:41 +0000 (19:41 +0100)]
xlat: update the list of RWF_* constants

* xlat/rwf_flags.in (RWF_APPEND): New constant introduced by linux
kernel commit v4.16-rc1~145^2~7.
* NEWS: Mention it.