qualify_scno(const char *const s, const unsigned int bitflag,
const int not, const struct fault_opts *const fopts)
{
- int i = string_to_uint_upto(s, MAX_NSYSCALLS - 1);
- if (i < 0)
+ int n = string_to_uint_upto(s, MAX_NSYSCALLS - 1);
+ if (n < 0)
return false;
- qualify_one(i, bitflag, not, -1, fopts);
+ if (not && fopts) {
+ /* set bitflag for all syscall numbers except n */
+ unsigned int p;
+ for (p = 0; p < SUPPORTED_PERSONALITIES; ++p) {
+ unsigned int i;
+
+ for (i = 0; i < nsyscall_vec[p]; ++i) {
+ if (i != (unsigned int) n
+ && sysent_vec[p][i].sys_name) {
+ qualify_one(i, bitflag, 0, p, fopts);
+ }
+ }
+ }
+ } else {
+ qualify_one(n, bitflag, not, -1, fopts);
+ }
+
return true;
}
unsigned int i;
for (i = 0; i < nsyscall_vec[p]; ++i) {
- if (sysent_vec[p][i].sys_name
- && (sysent_vec[p][i].sys_flags & n) == n) {
- qualify_one(i, bitflag, not, p, fopts);
+ if (!sysent_vec[p][i].sys_name)
+ continue;
+ const bool match = (sysent_vec[p][i].sys_flags & n) == n;
+ if (match ^ (not && fopts)) {
+ qualify_one(i, bitflag, not && !fopts, p, fopts);
}
}
}
unsigned int i;
for (i = 0; i < nsyscall_vec[p]; ++i) {
- if (sysent_vec[p][i].sys_name
- && strcmp(s, sysent_vec[p][i].sys_name) == 0) {
- qualify_one(i, bitflag, not, p, fopts);
- found = true;
+ if (!sysent_vec[p][i].sys_name)
+ continue;
+ const bool match = !strcmp(s, sysent_vec[p][i].sys_name);
+ found = found || match;
+ if (match ^ (not && fopts)) {
+ qualify_one(i, bitflag, not && !fopts, p, fopts);
}
}
}
"strace -e fault=$* failed to handle an argument error properly"
}
-for arg in '' , ,, ,,, : :: ::: \
+for arg in '' , ,, ,,, : :: ::: \! \!, \!: \
invalid_syscall_name \
invalid_syscall_name:when=3 \
- -1 \
+ -1 \!-1 \
-1:when=4 \
-2 \
-2:when=5 \
- 32767 \
+ 32767 \!32767 \
32767:when=6 \
- chdir:42 \
+ chdir:42 \!chdir:42 \
chdir:42:when=7 \
chdir:invalid \
chdir:invalid:when=8 \
chdir:when=65536:error=30 \
chdir:when=1+65536 \
chdir:when=1+65536:error=31 \
+ file,nonsense \
+ \!desc,nonsense \
+ chdir,nonsense \
+ \!chdir,nonsense \
+ 1,nonsense \
+ \!1,nonsense \
; do
$STRACE -e fault="$arg" true 2> "$LOG" &&
fail_with "$arg"