strace/basic_filters.c

316 lines
7.9 KiB
C
Raw Normal View History

/*
* Copyright (c) 2016 Dmitry V. Levin <ldv@altlinux.org>
* Copyright (c) 2016-2018 The strace developers.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "defs.h"
#include "number_set.h"
#include "filter.h"
#include <regex.h>
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
static bool
qualify_syscall_number(const char *s, struct number_set *set)
{
int n = string_to_uint(s);
if (n < 0)
return false;
bool done = false;
for (unsigned int p = 0; p < SUPPORTED_PERSONALITIES; ++p) {
if ((unsigned) n >= nsyscall_vec[p])
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
continue;
add_number_to_set_array(n, set, p);
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
done = true;
}
return done;
}
static void
regerror_msg_and_die(int errcode, const regex_t *preg,
const char *str, const char *pattern)
{
char buf[512];
regerror(errcode, preg, buf, sizeof(buf));
error_msg_and_die("%s: %s: %s", str, pattern, buf);
}
static bool
qualify_syscall_regex(const char *s, struct number_set *set)
{
regex_t preg;
int rc;
if ((rc = regcomp(&preg, s, REG_EXTENDED | REG_NOSUB)) != 0)
regerror_msg_and_die(rc, &preg, "regcomp", s);
bool found = false;
for (unsigned int p = 0; p < SUPPORTED_PERSONALITIES; ++p) {
for (unsigned int i = 0; i < nsyscall_vec[p]; ++i) {
if (!sysent_vec[p][i].sys_name)
continue;
rc = regexec(&preg, sysent_vec[p][i].sys_name,
0, NULL, 0);
if (rc == REG_NOMATCH)
continue;
else if (rc)
regerror_msg_and_die(rc, &preg, "regexec", s);
add_number_to_set_array(i, set, p);
found = true;
}
}
regfree(&preg);
return found;
}
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
static unsigned int
lookup_class(const char *s)
{
static const struct {
const char *name;
unsigned int value;
} syscall_class[] = {
{ "%desc", TRACE_DESC },
{ "%file", TRACE_FILE },
{ "%memory", TRACE_MEMORY },
{ "%process", TRACE_PROCESS },
{ "%signal", TRACE_SIGNAL },
{ "%ipc", TRACE_IPC },
{ "%network", TRACE_NETWORK },
Implement -e trace=%stat option linux/*/syscallent*.h part is updated automatically by: sed -i '/statx/! s/TF|TSTA,/TF|TST|TSTA,/' linux/*/syscallent*.h * sysent.h (TRACE_STAT): New macro. * syscall.c: Alias LST to TRACE_STAT around syscallent.h inclusion. * qualify.c (lookup_class): Add TRACE_STAT for "%stat". * strace.1 (.SS Filtering): Add information about %stat syscall class. * NEWS: Mention this change. * linux/aarch64/syscallent.h (stat): Add TST flag. * linux/ia64/syscallent.h: Likewise. * linux/mips/syscallent-n32.h: Likewise. * linux/mips/syscallent-n64.h: Likewise. * linux/s390x/syscallent.h: Likewise. * linux/x32/syscallent.h: Likewise. * linux/x86_64/syscallent.h: Likewise. * linux/arm/syscallent.h (oldstat, stat, stat64): Likewise. * linux/bfin/syscallent.h: Likewise. * linux/crisv10/syscallent.h: Likewise. * linux/i386/syscallent.h: Likewise. * linux/m68k/syscallent.h: Likewise. * linux/microblaze/syscallent.h: Likewise. * linux/mips/syscallent-o32.h: Likewise. * linux/powerpc/syscallent.h: Likewise. * linux/sh64/syscallent.h: Likewise. * linux/sh/syscallent.h: Likewise. * linux/avr32/syscallent.h (stat, stat64): Likewise. * linux/hppa/syscallent.h: Likewise. * linux/s390/syscallent.h: Likewise. * linux/sparc64/syscallent.h: Likewise. * linux/sparc/syscallent.h: Likewise. * linux/xtensa/syscallent.h: Likewise. * linux/powerpc64/syscallent.h (oldstat, stat): Likewise. * linux/alpha/syscallent.h (osf_old_stat, osf_stat, stat, stat64): Likewise. * linux/mips/syscallent-compat.h (bsd43_oldstat, bsd43_stat, posix_stat, svr4_stat, svr4_xstat, sysv_stat, sysv_xstat): Likewise. * tests/gen_tests.in (trace_stat): New entry. * tests/trace_stat.in: New file. * tests/Makefile.am (EXTRA_DIST): Add it. * tests/ksysent.c (TST): New macro, defined to 0. * tests/nsyscalls.c: Likewise.
2017-04-18 04:14:52 +03:00
{ "%stat", TRACE_STAT },
Implement -e trace=%lstat option linux/*/syscallent*.h part is updated automatically by: sed -i '/TSTA,.*lx\?stat/ s/TSTA,/TLST|&/' linux/*/syscallent*.h * sysent.h (TRACE_LSTAT): New macro. * syscall.c: Alias TLST to TRACE_LSTAT around syscallent.h inclusion. * qualify.c (lookup_class): Add TRACE_LSTAT for "%lstat". * strace.1 (.SS Filtering): Add information about %lstat syscall class. * NEWS: Mention this change. * linux/aarch64/syscallent.h (lstat): Likewise. * linux/ia64/syscallent.h: Likewise. * linux/mips/syscallent-n32.h: Likewise. * linux/mips/syscallent-n64.h: Likewise. * linux/s390x/syscallent.h: Likewise. * linux/x32/syscallent.h: Likewise. * linux/x86_64/syscallent.h: Likewise. * linux/arm/syscallent.h (lstat, lstat64, oldlstat): Likewise. * linux/bfin/syscallent.h: Likewise. * linux/crisv10/syscallent.h: Likewise. * linux/i386/syscallent.h: Likewise. * linux/m68k/syscallent.h: Likewise. * linux/microblaze/syscallent.h: Likewise. * linux/mips/syscallent-o32.h: Likewise. * linux/powerpc/syscallent.h: Likewise. * linux/sh64/syscallent.h: Likewise. * linux/sh/syscallent.h: Likewise. * linux/sparc64/syscallent.h: Likewise. * linux/sparc/syscallent.h: Likewise. * linux/avr32/syscallent.h (lstat, lstat64): Likewise. * linux/hppa/syscallent.h: Likewise. * linux/powerpc64/syscallent.h: Likewise. * linux/s390/syscallent.h: Likewise. * linux/xtensa/syscallent.h: Likewise. * linux/alpha/syscallent.h (lstat, lstat64, osf_lstat, osf_old_lstat): Likewise. * linux/mips/syscallent-compat.h (bsd43_lstat, posix_lstat, svr4_lstat, sysv_lstat): Likewise. * tests/gen_tests.in (trace_lstat): New entry. * tests/trace_lstat.in: New file. * tests/Makefile.am (EXTRA_DIST): Add it. * tests/ksysent.c (TLST): New macro, defined to 0. * tests/nsyscalls.c: Likewise.
2017-04-18 03:23:05 +03:00
{ "%lstat", TRACE_LSTAT },
Implement -e trace=%fstat option linux/*/syscallent*.h part is updated automatically by: sed -i -e '/TSTA.*fx\?stat/ s/TSTA,/TFST|&/' \ -e 's/\(TD|TF|TFST|TSTA,\)[[:space:]]/\1/' linux/*/syscallent*.h * sysent.h (TRACE_FSTAT): New macro. * syscall.c: Alias TFST to TRACE_FSTAT around syscallent.h inclusion. * qualify.c (lookup_class): Add TRACE_FSTAT for "%fstat". * strace.1 (.SS Filtering): Add information about %fstat syscall class. * NEWS: Mention this change. * linux/32/syscallent.h (fstat64, fstatat64): Add TFST flag. * linux/64/syscallent.h (fstat, newfstatat): Likewise. * linux/aarch64/syscallent.h: Likewise. * linux/ia64/syscallent.h: Likewise. * linux/mips/syscallent-n32.h: Likewise. * linux/mips/syscallent-n64.h: Likewise. * linux/s390x/syscallent.h: Likewise. * linux/x32/syscallent.h: Likewise. * linux/x86_64/syscallent.h: Likewise. * linux/arm/syscallent.h (fstat, fstat64, fstatat64, oldfstat): Likewise. * linux/bfin/syscallent.h: Likewise. * linux/crisv10/syscallent.h: Likewise. * linux/i386/syscallent.h: Likewise. * linux/m68k/syscallent.h: Likewise. * linux/microblaze/syscallent.h: Likewise. * linux/mips/syscallent-o32.h: Likewise. * linux/powerpc/syscallent.h: Likewise. * linux/sh64/syscallent.h: Likewise. * linux/sh/syscallent.h: Likewise. * linux/avr32/syscallent.h (fstat, fstat64, fstatat64): Likewise. * linux/hppa/syscallent.h: Likewise. * linux/s390/syscallent.h: Likewise. * linux/sparc64/syscallent.h: Likewise. * linux/sparc/syscallent.h: Likewise. * linux/xtensa/syscallent.h: Likewise. * linux/alpha/syscallent.h (fstat, fstat64, fstatat64, osf_fstat, osf_old_fstat): Likewise. * linux/powerpc64/syscallent.h (fstat, newfstatat, oldfstat): Likewise. * linux/mips/syscallent-compat.h (bsd43_fstat, bsd43_oldfstat, posix_fstat, svr4_fstat, sysv_fstat): Likewise. * tests/gen_tests.in (trace_fstat): New entry. * tests/trace_fstat.in: New file. * tests/Makefile.am (EXTRA_DIST): Add it. * tests/ksysent.c (TFST): New macro, defined to 0. * tests/nsyscalls.c: Likewise.
2017-04-18 02:52:58 +03:00
{ "%fstat", TRACE_FSTAT },
Implement -e trace=%%stat option linux/*/syscallent*.h part is updated automatically by: sed -i '/TSFA\|stat[iu]s/! s/,[[:space:]]\?\([[:space:]]*SEN(.*stat\)/|TSTA,\1/' \ linux/*/syscallent*.h * sysent.h (TRACE_STAT_LIKE): New macro. * syscall.c: Alias TSTA to TRACE_STAT_LIKE around syscallent.h inclusion. * qualify.c (lookup_class): Add TRACE_STAT_LIKE for "%%stat". * strace.1 (.SS Filtering): Add information about %%stat syscall class. * NEWS: Mention this change. * linux/32/syscallent.h (fstat64, fstatat64, statx): Add TSTA flag. * linux/64/syscallent.h (fstat, newfstatat, statx): Likewise. * linux/aarch64/syscallent.h (fstat, lstat, newfstatat, stat): Likewise. * linux/alpha/syscallent.h (fstat, fstat64, fstatat64, lstat, lstat64, osf_fstat, osf_lstat, osf_old_fstat, osf_old_lstat, osf_old_stat, osf_stat, stat, stat64): Likewise. * linux/arm/syscallent.h (fstat, fstat64, fstatat64, lstat, lstat64, oldfstat, oldlstat, oldstat, stat, stat64, statx): Likewise. * linux/avr32/syscallent.h (fstat, fstat64, fstatat64, lstat, lstat64, stat, stat64): Likewise. * linux/bfin/syscallent.h (fstat, fstat64, fstatat64, lstat, lstat64, oldfstat, oldlstat, oldstat, stat, stat64): Likewise. * linux/crisv10/syscallent.h (fstat, fstat64, fstatat64, lstat, lstat64, oldfstat, oldlstat, oldstat, stat, stat64): Likewise. * linux/hppa/syscallent.h (fstat, fstat64, fstatat64, lstat, lstat64, stat, stat64): Likewise. * linux/i386/syscallent.h (fstat, fstat64, fstatat64, lstat, lstat64, oldfstat, oldlstat, oldstat, stat, stat64, statx): Likewise. * linux/ia64/syscallent.h (fstat, lstat, newfstatat, stat): Likewise. * linux/m68k/syscallent.h (fstat, fstat64, fstatat64, lstat, lstat64, oldfstat, oldlstat, oldstat, stat, stat64, statx): Likewise. * linux/microblaze/syscallent.h (fstat, fstat64, fstatat64, lstat, lstat64, oldfstat, oldlstat, oldstat, stat, stat64): Likewise. * linux/mips/syscallent-compat.h (bsd43_fstat, bsd43_lstat, bsd43_oldfstat, bsd43_oldstat, bsd43_stat, posix_fstat, posix_lstat, posix_stat, svr4_fstat, svr4_fxstat, svr4_lstat, svr4_lxstat, svr4_stat, svr4_xstat, sysv_fstat, sysv_fxstat, sysv_lstat, sysv_lxstat, sysv_stat, sysv_xstat): Likewise. * linux/mips/syscallent-n32.h (fstat, lstat, newfstatat, stat, statx): Likewise. * linux/mips/syscallent-n64.h (fstat, lstat, newfstatat, stat, statx): Likewise. * linux/mips/syscallent-o32.h (fstat, fstat64, fstatat64, lstat, lstat64, oldfstat, oldlstat, oldstat, stat, stat64, statx): Likewise. * linux/powerpc64/syscallent.h (fstat, lstat, newfstatat, oldfstat, oldlstat, oldstat, stat): Likewise. * linux/powerpc/syscallent.h (fstat, fstat64, fstatat64, lstat, lstat64, oldfstat, oldlstat, oldstat, stat, stat64, statx): Likewise. * linux/s390/syscallent.h (fstat, fstat64, fstatat64, lstat, lstat64, stat, stat64, statx): Likewise. * linux/s390x/syscallent.h (fstat, lstat, newfstatat, stat, statx): Likewise. * linux/sh64/syscallent.h (fstat, fstat64, fstatat64, lstat, lstat64, oldfstat, oldlstat, oldstat, stat, stat64): Likewise. * linux/sh/syscallent.h (fstat, fstat64, fstatat64, lstat, lstat64, oldfstat, oldlstat, oldstat, stat, stat64): Likewise. * linux/sparc64/syscallent.h (fstat, fstat64, fstatat64, lstat, lstat64, oldlstat, stat, stat64): Likewise. * linux/sparc/syscallent.h (fstat, fstat64, fstatat64, lstat, lstat64, oldlstat, stat, stat64): Likewise. * linux/x32/syscallent.h (fstat, lstat, newfstatat, stat, statx): Likewise. * linux/x86_64/syscallent.h (fstat, lstat, newfstatat, stat, statx): Likewise. * linux/xtensa/syscallent.h (fstat, fstat64, fstatat64, lstat, lstat64, stat, stat64, statx): Likewise. * tests/gen_tests.in (trace_stat_like): New entry. * tests/trace_stat_like.in: New file. * tests/Makefile.am (EXTRA_DIST): Add it. * tests/ksysent.c (TSTA): New macro, defined to 0. * tests/nsyscalls.c: Likewise.
2017-04-18 02:14:58 +03:00
{ "%%stat", TRACE_STAT_LIKE },
Implement -e trace=%statfs option linux/*/syscallent*.h part is modified automatically by: sed -i 's/TF\(,[[:space:]]*SEN.*[_"]statv\?fs\)/TF|TSF\1/' \ linux/*/syscallent*.h [ldv: rewritten trace_statfs.test using sched.test as a template] * sysent.h (TRACE_STATFS): New macro. * syscall.c: Alias TSF to TRACE_STATFS around syscallent.h inclusion. * qualify.c (lookup_class): Add SCHED_STATFS for "%statfs". * strace.1 (.SS Filtering): Add information about %statfs syscall class. * NEWS: Mention this change. * linux/64/syscallent.h (statfs): Add TSF flag. * linux/aarch64/syscallent.h: Likewise. * linux/x32/syscallent.h: Likewise. * linux/x86_64/syscallent.h: Likewise. * linux/mips/syscallent-n64.h: Likewise. * linux/32/syscallent.h (statfs64): Likewise. * linux/arm/syscallent.h (statfs, statfs64): Likewise. * linux/avr32/syscallent.h: Likewise. * linux/bfin/syscallent.h: Likewise. * linux/crisv10/syscallent.h: Likewise. * linux/hppa/syscallent.h: Likewise. * linux/i386/syscallent.h: Likewise. * linux/ia64/syscallent.h: Likewise. * linux/m68k/syscallent.h: Likewise. * linux/microblaze/syscallent.h: Likewise. * linux/mips/syscallent-n32.h: Likewise. * linux/mips/syscallent-o32.h: Likewise. * linux/powerpc/syscallent.h: Likewise. * linux/powerpc64/syscallent.h: Likewise. * linux/s390/syscallent.h: Likewise. * linux/s390x/syscallent.h: Likewise. * linux/sh/syscallent.h: Likewise. * linux/sh64/syscallent.h: Likewise. * linux/sparc/syscallent.h: Likewise. * linux/sparc64/syscallent.h: Likewise. * linux/xtensa/syscallent.h: Likewise. * linux/alpha/syscallent.h (osf_statfs, osf_statfs64, statfs): Likewise. * linux/mips/syscallent-compat.h (*_statfs, *_statvfs): Likewise. * tests/trace_statfs.test: New test. * tests/Makefile.am (DECODER_TESTS): Add it. * tests/ksysent.c (TSF): New macro, defined to 0. * tests/nsyscalls.c: Likewise.
2017-03-29 12:03:34 +03:00
{ "%statfs", TRACE_STATFS },
Implement -e trace=%fstatfs option linux/*/syscallent*.h part is updated automatically by: sed -i 's/TD,[[:space:]]\([[:space:]]*SEN.*[_"]fstatv\?fs\)/TD|TFSF,\1/' \ linux/*/syscallent*.h * sysent.h (TRACE_FSTATFS): New macro. * syscall.c: Alias TFSF to TRACE_FSTATFS around syscallent.h inclusion. * qualify.c (lookup_class): Add SCHED_FSTATFS for "%fstatfs". * strace.1 (.SS Filtering): Add information about %fstatfs syscall class. * NEWS: Mention this change. * linux/32/syscallent.h (fstatfs64): Add TFSF flag. * linux/64/syscallent.h (fstatfs): Likewise. * linux/aarch64/syscallent.h: Likewise. * linux/mips/syscallent-n64.h: Likewise. * linux/x32/syscallent.h: Likewise. * linux/x86_64/syscallent.h: Likewise. * linux/arm/syscallent.h (fstatfs, fstatfs64): Likewise. * linux/avr32/syscallent.h: Likewise. * linux/bfin/syscallent.h: Likewise. * linux/crisv10/syscallent.h: Likewise. * linux/hppa/syscallent.h: Likewise. * linux/i386/syscallent.h: Likewise. * linux/ia64/syscallent.h: Likewise. * linux/m68k/syscallent.h: Likewise. * linux/microblaze/syscallent.h: Likewise. * linux/mips/syscallent-n32.h: Likewise. * linux/mips/syscallent-o32.h: Likewise. * linux/powerpc/syscallent.h: Likewise. * linux/powerpc64/syscallent.h: Likewise. * linux/s390/syscallent.h: Likewise. * linux/s390x/syscallent.h: Likewise. * linux/sh/syscallent.h: Likewise. * linux/sh64/syscallent.h: Likewise. * linux/sparc/syscallent.h: Likewise. * linux/sparc64/syscallent.h: Likewise. * linux/xtensa/syscallent.h: Likewise. * linux/alpha/syscallent.h (ofs_fstatfs, osf_fstatfs64): Likewise. * linux/mips/syscallent-compat.h (*_fstatfs, *_fstatvfs): Likewise. * tests/gen_tests.in (trace_fstatfs): New entry. * tests/trace_fstatfs.in: New file. * tests/Makefile.am (EXTRA_DIST): Add it. * tests/ksysent.c (TFSF): New macro, defined to 0. * tests/nsyscalls.c: Likewise.
2017-04-17 21:29:44 +03:00
{ "%fstatfs", TRACE_FSTATFS },
Implement -e trace=%%statfs option linux/*/syscallent*.h part is updated automatically by: sed -i 's/\(TSF\),[[:space:]]\?/\1|TSFA,/' linux/*/syscallent*.h sed -i 's/\(TFSF\),/\1|TSFA,/' linux/*/syscallent*.h sed -i 's/0\(,.*ustat\)/TSFA\1/' linux/*/syscallent*.h * sysent.h (TRACE_STATFS_LIKE): New macro. * syscall.c: Alias TSFA to TRACE_STATFS_LIKE around syscallent.h inclusion. * qualify.c (lookup_class): Add SCHED_STATFS_LIKE for "%%statfs". * strace.1 (.SS Filtering): Add information about %%statfs syscall class. * NEWS: Mention this change. * linux/32/syscallent.h (statfs64, fstatfs64): Add TSFA flag. * linux/64/syscallent.h (statfs, fstatfs): Likewise. * linux/aarch64/syscallent.h (statfs, fstatfs, ustat): Likewise. * linux/mips/syscallent-n64.h: Likewise. * linux/x32/syscallent.h: Likewise. * linux/x86_64/syscallent.h: Likewise. * linux/arm/syscallent.h (statfs, statfs64, fstatfs, fstatfs64, ustat): Likewise. * linux/avr32/syscallent.h: Likewise. * linux/bfin/syscallent.h: Likewise. * linux/crisv10/syscallent.h: Likewise. * linux/hppa/syscallent.h: Likewise. * linux/i386/syscallent.h: Likewise. * linux/ia64/syscallent.h: Likewise. * linux/m68k/syscallent.h: Likewise. * linux/microblaze/syscallent.h: Likewise. * linux/mips/syscallent-n32.h: Likewise. * linux/mips/syscallent-o32.h: Likewise. * linux/powerpc/syscallent.h: Likewise. * linux/powerpc64/syscallent.h: Likewise. * linux/s390/syscallent.h: Likewise. * linux/s390x/syscallent.h: Likewise. * linux/sh/syscallent.h: Likewise. * linux/sh64/syscallent.h: Likewise. * linux/sparc/syscallent.h: Likewise. * linux/sparc64/syscallent.h: Likewise. * linux/xtensa/syscallent.h: Likewise. * linux/alpha/syscallent.h (osf_statfs, osf_statfs64, statfs, ofs_fstatfs, osf_fstatfs64, ustat): Likewise. * linux/mips/syscallent-compat.h (*_statfs, *_statvfs, *_fstatfs): Likewise. * tests/gen_tests.in (trace_statfs_like): New entry. * tests/trace_statfs_like.in: New file. * tests/Makefile.am (EXTRA_DIST): Add it. * tests/ksysent.c (TSFA): New macro, defined to 0. * tests/nsyscalls.c: Likewise.
2017-04-16 16:30:29 +03:00
{ "%%statfs", TRACE_STATFS_LIKE },
Add pure syscall flag * basic_filters.c (lookup_class) <syscall_class>: Add "%pure" for TRACE_PURE. * sysent.h (TRACE_PURE): New syscall flag. * sysent_shorthand_defs.h (PU): New shorthand macro. * linux/32/syscallent.h ([172], [173], [174], [175], [176], [177], [178]): Add PU flag to getpid, getppid, getuid, geteuid, getgid, getegid, gettid syscalls. * linux/64/syscallent.h ([172], [173], [174], [175], [176], [177], [178]): Add PU flag to getpid, getppid, getuid, geteuid, getgid, getegid, gettid syscalls. * linux/aarch64/syscallent.h ([1060]): Add PU flag to getpgrp syscalls. * linux/alpha/syscallent.h ([20], [24], [47], [63], [64], [89], [378]): Add PU flag to getxpid, getxuid, getxgid, getpgrp, getpagesize, getdtablesize, gettid syscalls. * linux/arc/syscallent.h ([246]): Add PU flag to arc_gettls syscalls. * linux/arm/syscallent.h ([20], [24], [47], [49], [50], [64], [65], [199], [200], [201], [202], [224], [ARM_FIRST_SHUFFLED_SYSCALL+1+6]): Add PU flag to getpid, getuid, getgid, geteuid, getegid, getppid, getpgrp, getuid32, getgid32, geteuid32, getegid32, gettid, get_tls syscalls. * linux/avr32/syscallent.h ([20], [24], [47], [49], [50], [64], [65], [176]): Add PU flag to getpid, getuid, getgid, geteuid, getegid, getppid, getpgrp, gettid syscalls. * linux/bfin/syscallent.h ([20], [24], [47], [49], [50], [64], [65], [199], [200], [201], [202], [224]): Add PU flag to getpid, getuid, getgid, geteuid, getegid, getppid, getpgrp, getuid32, getgid32, geteuid32, getegid32, gettid syscalls. * linux/hppa/syscallent.h ([20], [24], [47], [49], [50], [64], [65], [206]): Add PU flag to getpid, getuid, getgid, geteuid, getegid, getppid, getpgrp, gettid syscalls. * linux/i386/syscallent.h ([20], [24], [47], [49], [50], [64], [65], [199], [200], [201], [202], [224]): Add PU flag to getpid, getuid, getgid, geteuid, getegid, getppid, getpgrp, getuid32, getgid32, geteuid32, getegid32, gettid syscalls. * linux/ia64/syscallent.h ([1041], [1042], [1046], [1047], [1062], [1063], [1105], [1171]): Add PU flag to getpid, getppid, getuid, geteuid, getgid, getegid, gettid, getpagesize syscalls. * linux/m68k/syscallent.h ([20], [24], [47], [49], [50], [64], [65], [166], [199], [200], [201], [202], [221], [333]): Add PU flag to getpid, getuid, getgid, geteuid, getegid, getppid, getpgrp, getpagesize, getuid32, getgid32, geteuid32, getegid32, gettid, get_thread_area syscalls. * linux/metag/syscallent.h ([248]): Add PU flag to metag_get_tls syscalls. * linux/microblaze/syscallent.h ([20], [24], [47], [49], [50], [64], [65], [199], [200], [201], [202], [224]): Add PU flag to getpid, getuid, getgid, geteuid, getegid, getppid, getpgrp, getuid32, getgid32, geteuid32, getegid32, gettid syscalls. * linux/powerpc64/syscallent.h ([20], [24], [47], [49], [50], [64], [65], [207]): Add PU flag to getpid, getuid, getgid, geteuid, getegid, getppid, getpgrp, gettid syscalls. * linux/powerpc/syscallent.h ([20], [24], [47], [49], [50], [64], [65], [207]): Add PU flag to getpid, getuid, getgid, geteuid, getegid, getppid, getpgrp, gettid syscalls. * linux/s390/syscallent.h ([20], [24], [47], [49], [50], [64], [65], [199], [200], [201], [202], [236]): Add PU flag to getpid, getuid, getgid, geteuid, getegid, getppid, getpgrp, getuid32, getgid32, geteuid32, getegid32, gettid syscalls. * linux/s390x/syscallent.h ([20], [64], [65], [199], [200], [201], [202], [236]): Add PU flag to getpid, getppid, getpgrp, getuid, getgid, geteuid, getegid, gettid syscalls. * linux/sh64/syscallent.h ([20], [24], [47], [49], [50], [64], [65], [199], [200], [201], [202], [252]): Add PU flag to getpid, getuid, getgid, geteuid, getegid, getppid, getpgrp, getuid32, getgid32, geteuid32, getegid32, gettid syscalls. * linux/sh/syscallent.h ([20], [24], [47], [49], [50], [64], [65], [199], [200], [201], [202], [224]): Add PU flag to getpid, getuid, getgid, geteuid, getegid, getppid, getpgrp, getuid32, getgid32, geteuid32, getegid32, gettid syscalls. * linux/sparc64/syscallent.h ([20], [24], [47], [49], [50], [64], [81], [143], [197], [340]): Add PU flag to getpid, getuid, getgid, geteuid, getegid, getpagesize, getpgrp, gettid, getppid, kern_features syscalls. * linux/sparc/syscallent.h ([20], [24], [44], [47], [49], [50], [53], [64], [69], [70], [81], [143], [197], [340]): Add PU flag to getpid, getuid, getuid32, getgid, geteuid, getegid, getgid32, getpagesize, geteuid32, getegid32, getpgrp, gettid, getppid, kern_features syscalls. * linux/x32/syscallent.h ([39], [102], [104], [107], [108], [110], [111], [186]): Add PU flag to getpid, getuid, getgid, geteuid, getegid, getppid, getpgrp, gettid syscalls. * linux/x86_64/syscallent.h ([39], [102], [104], [107], [108], [110], [111], [186]): Add PU flag to getpid, getuid, getgid, geteuid, getegid, getppid, getpgrp, gettid syscalls. * linux/xtensa/syscallent.h ([120], [127], [137], [139], [140], [141], [150], [151]): Add PU flag to getpid, gettid, getuid, getgid, geteuid, getegid, getppid, getpgrp syscalls. * strace.1.in (.SS Filtering): Document it. * NEWS: Mention it.
2018-02-07 20:46:54 +03:00
{ "%pure", TRACE_PURE },
/* legacy class names */
{ "desc", TRACE_DESC },
{ "file", TRACE_FILE },
{ "memory", TRACE_MEMORY },
{ "process", TRACE_PROCESS },
{ "signal", TRACE_SIGNAL },
{ "ipc", TRACE_IPC },
{ "network", TRACE_NETWORK },
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
};
for (unsigned int i = 0; i < ARRAY_SIZE(syscall_class); ++i) {
if (strcmp(s, syscall_class[i].name) == 0)
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
return syscall_class[i].value;
}
return 0;
}
static bool
qualify_syscall_class(const char *s, struct number_set *set)
{
const unsigned int n = lookup_class(s);
if (!n)
return false;
for (unsigned int p = 0; p < SUPPORTED_PERSONALITIES; ++p) {
for (unsigned int i = 0; i < nsyscall_vec[p]; ++i) {
if (sysent_vec[p][i].sys_name &&
(sysent_vec[p][i].sys_flags & n) == n)
add_number_to_set_array(i, set, p);
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
}
}
return true;
}
kernel_long_t
scno_by_name(const char *s, unsigned int p, kernel_long_t start)
{
if (p >= SUPPORTED_PERSONALITIES)
return -1;
for (kernel_ulong_t i = start; i < nsyscall_vec[p]; ++i) {
if (sysent_vec[p][i].sys_name &&
strcmp(s, sysent_vec[p][i].sys_name) == 0)
return i;
}
return -1;
}
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
static bool
qualify_syscall_name(const char *s, struct number_set *set)
{
bool found = false;
for (unsigned int p = 0; p < SUPPORTED_PERSONALITIES; ++p) {
for (kernel_long_t scno = 0;
(scno = scno_by_name(s, p, scno)) >= 0;
++scno) {
add_number_to_set_array(scno, set, p);
found = true;
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
}
}
return found;
}
static bool
qualify_syscall(const char *token, struct number_set *set)
{
bool ignore_fail = false;
while (*token == '?') {
token++;
ignore_fail = true;
}
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
if (*token >= '0' && *token <= '9')
return qualify_syscall_number(token, set) || ignore_fail;
if (*token == '/')
return qualify_syscall_regex(token + 1, set) || ignore_fail;
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
return qualify_syscall_class(token, set)
|| qualify_syscall_name(token, set)
|| ignore_fail;
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
}
/*
* Add syscall numbers to SETs for each supported personality
* according to STR specification.
*/
void
qualify_syscall_tokens(const char *const str, struct number_set *const set)
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
{
/* Clear all sets. */
clear_number_set_array(set, SUPPORTED_PERSONALITIES);
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
/*
* Each leading ! character means inversion
* of the remaining specification.
*/
const char *s = str;
while (*s == '!') {
invert_number_set_array(set, SUPPORTED_PERSONALITIES);
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
++s;
}
if (strcmp(s, "none") == 0) {
/*
* No syscall numbers are added to sets.
* Subsequent is_number_in_set* invocations
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
* will return set[p]->not.
*/
return;
} else if (strcmp(s, "all") == 0) {
/* "all" == "!none" */
invert_number_set_array(set, SUPPORTED_PERSONALITIES);
return;
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
}
/*
* Split the string into comma separated tokens.
* For each token, call qualify_syscall that will take care
* if adding appropriate syscall numbers to sets.
* The absence of tokens or a negative return code
* from qualify_syscall is a fatal error.
*/
char *copy = xstrdup(s);
char *saveptr = NULL;
bool done = false;
for (const char *token = strtok_r(copy, ",", &saveptr);
token; token = strtok_r(NULL, ",", &saveptr)) {
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
done = qualify_syscall(token, set);
if (!done)
error_msg_and_die("invalid system call '%s'", token);
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
}
free(copy);
if (!done)
error_msg_and_die("invalid system call '%s'", str);
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
}
/*
* Add numbers to SET according to STR specification.
*/
void
qualify_tokens(const char *const str, struct number_set *const set,
string_to_uint_func func, const char *const name)
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
{
/* Clear the set. */
clear_number_set_array(set, 1);
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
/*
* Each leading ! character means inversion
* of the remaining specification.
*/
const char *s = str;
while (*s == '!') {
invert_number_set_array(set, 1);
++s;
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
}
if (strcmp(s, "none") == 0) {
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
/*
* No numbers are added to the set.
* Subsequent is_number_in_set* invocations
* will return set->not.
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
*/
return;
} else if (strcmp(s, "all") == 0) {
/* "all" == "!none" */
invert_number_set_array(set, 1);
return;
Implement success injection This extends fault injection syntax with :retval= option. When :retval=VALUE is specified, the syscall number is replaced by -1 and a bogus success VALUE is returned to the callee. * defs.h (fault_opts): Remove err field, add rval field. (MAX_ERRNO_VALUE, FAULT_OPTS_RVAL_DEFAULT, FAULT_OPTS_RVAL_DISABLE): New macros. * qualify.c (parse_fault_token): Handle retval= token. (qualify_fault): Update fault_opts initialization after the move from struct fault_opts.err to struct fault_opts.rval. * syscall.c (arch_set_success): New prototype. (inject_syscall_fault_entering): Check opts->rval instead of opts->err. (update_syscall_fault_exiting): Implement retval injection. * strace.1: Update the section on fault injection. * NEWS: Mention retval= option. * linux/aarch64/set_error.c (arch_set_success): New function. * linux/alpha/set_error.c: Likewise. * linux/arc/set_error.c: Likewise. * linux/arm/set_error.c: Likewise. * linux/avr32/set_error.c: Likewise. * linux/bfin/set_error.c: Likewise. * linux/crisv10/set_error.c: Likewise. * linux/hppa/set_error.c: Likewise. * linux/i386/set_error.c: Likewise. * linux/ia64/set_error.c: Likewise. * linux/m68k/set_error.c: Likewise. * linux/metag/set_error.c: Likewise. * linux/microblaze/set_error.c: Likewise. * linux/mips/set_error.c: Likewise. * linux/nios2/set_error.c: Likewise. * linux/or1k/set_error.c: Likewise. * linux/powerpc/set_error.c: Likewise. * linux/riscv/set_error.c: Likewise. * linux/s390/set_error.c: Likewise. * linux/sh/set_error.c: Likewise. * linux/sh64/set_error.c: Likewise. * linux/sparc/set_error.c: Likewise. * linux/sparc64/set_error.c: Likewise. * linux/tile/set_error.c: Likewise. * linux/x86_64/set_error.c: Likewise. * linux/xtensa/set_error.c: Likewise. Closes: https://github.com/strace/strace/issues/3
2017-01-25 02:59:16 +03:00
}
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
/*
* Split the string into comma separated tokens.
* For each token, find out the corresponding number
* by calling FUNC, and add that number to the set.
* The absence of tokens or a negative answer
* from FUNC is a fatal error.
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
*/
char *copy = xstrdup(s);
char *saveptr = NULL;
int number = -1;
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
for (const char *token = strtok_r(copy, ",", &saveptr);
token; token = strtok_r(NULL, ",", &saveptr)) {
number = func(token);
if (number < 0)
error_msg_and_die("invalid %s '%s'", name, token);
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
add_number_to_set(number, set);
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
}
free(copy);
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
if (number < 0)
error_msg_and_die("invalid %s '%s'", name, str);
Rewrite remaining qual_* parsers using bit sets * defs.h (struct fault_opts): Replace forward declaration with a definition. (qualbits_t, qualify_read, qualify_write, qualify_signals): Remove. (qual_flags): New function prototype. (nsyscall_vec, sysent_vec, fault_vec): New variable prototypes. * qualify.c (abbrev_set, fault_set, raw_set, trace_set, verbose_set): New variables. (qualify_read, qualify_write, qualify_signals): Add static qualifier. (find_errno_by_name, lookup_class, parse_fault_expression, parse_fault_token, qual_flags, qualify, qualify_abbrev, qualify_fault, qualify_raw, qualify_syscall, qualify_syscall_class, qualify_syscall_name, qualify_syscall_number, qualify_syscall_tokens, qualify_trace, qualify_verbose, strip_prefix): New functions. * syscall.c (nsyscall_vec, nsysent_vec): Remove static qualifier. (MAX_NSYSCALLS1, MAX_NSYSCALLS2, MAX_NSYSCALLS, qual_vec, qual_flags, qual_fault, qual_syscall, qual_options, fault_opts, qualify_one, qualify_scno, lookup_class, qualify_syscall_class, qualify_syscall_name, qual_syscall_ex, qual_syscall, strip_prefix, find_errno_by_name, parse_fault_token, parse_fault_expression, qual_fault, qualify): Remove. (decode_socket_subcall, decode_ipc_subcall, decode_mips_subcall, get_scno): Update use of qual_flags. (inject_syscall_fault_entering): Update per-personality allocation of tcp->fault_vec. * tests/fault_injection-exit_group.test: Check parsing of inversed fault sets. * tests/fault_injection.test: Check parsing of -efault=none. * tests/options-syntax.test: Check parsing of invalid syscall numbers.
2016-12-04 17:39:48 +03:00
}