diff options
| author | Po Lu <luangruo@yahoo.com> | 2026-05-28 11:31:16 +0800 |
|---|---|---|
| committer | Po Lu <luangruo@yahoo.com> | 2026-05-28 11:31:16 +0800 |
| commit | 330b4e2a942a6ff506bab72503f940c9b65d395f (patch) | |
| tree | 20b612b2766020801501f5d489e5566b58a3ff58 | |
| parent | 6728239f32f7be4e9974b9f1bfc650b2f1083e82 (diff) | |
Fix the Android build again
* exec/trace.c (ARRAYELTS, establish_seccomp_filter): Restore
ARRAYELTS, since Gnulib is not available in the exec library.
| -rw-r--r-- | exec/trace.c | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/exec/trace.c b/exec/trace.c index a194b87ca84..da9ac96c6ff 100644 --- a/exec/trace.c +++ b/exec/trace.c @@ -28,7 +28,6 @@ along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>. */ #include <string.h> #include <assert.h> #include <signal.h> -#include <stdcountof.h> #include <unistd.h> #include <stdlib.h> #include <errno.h> @@ -1539,6 +1538,9 @@ static int interesting_syscalls[] = READLINKAT_SYSCALL, }; +/* Number of elements in an array. */ +#define ARRAYELTS(arr) (sizeof (arr) / sizeof (arr)[0]) + /* Install a secure computing filter that will notify attached tracers when a system call of interest to this module is received. Value is 0 if successful, 1 otherwise. */ @@ -1546,7 +1548,7 @@ static int interesting_syscalls[] = static int establish_seccomp_filter (void) { - struct sock_filter statements[1 + countof (interesting_syscalls) + 2]; + struct sock_filter statements[1 + ARRAYELTS (interesting_syscalls) + 2]; struct sock_fprog program; int index, rc; @@ -1565,27 +1567,27 @@ establish_seccomp_filter (void) statements[index] = ((struct sock_filter) BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, EXEC_SYSCALL, - countof (interesting_syscalls), 0)); index++; + ARRAYELTS (interesting_syscalls), 0)); index++; #ifdef OPEN_SYSCALL statements[index] = ((struct sock_filter) BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, OPEN_SYSCALL, - countof (interesting_syscalls) - index + 1, 0)); index++; + ARRAYELTS (interesting_syscalls) - index + 1, 0)); index++; #endif /* OPEN_SYSCALL */ statements[index] = ((struct sock_filter) BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, OPENAT_SYSCALL, - countof (interesting_syscalls) - index + 1, 0)); index++; + ARRAYELTS (interesting_syscalls) - index + 1, 0)); index++; #ifdef READLINK_SYSCALL statements[index] = ((struct sock_filter) BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, READLINK_SYSCALL, - countof (interesting_syscalls) - index + 1, 0)); index++; + ARRAYELTS (interesting_syscalls) - index + 1, 0)); index++; #endif /* READLINK_SYSCALL */ statements[index] = ((struct sock_filter) BPF_JUMP (BPF_JMP + BPF_JEQ + BPF_K, READLINKAT_SYSCALL, - countof (interesting_syscalls) - index + 1, 0)); index++; + ARRAYELTS (interesting_syscalls) - index + 1, 0)); index++; /* If not intercepted above, permit this system call to execute as normal. */ @@ -1598,7 +1600,7 @@ establish_seccomp_filter (void) if (rc) return 1; - program.len = countof (statements); + program.len = ARRAYELTS (statements); program.filter = statements; rc = prctl (PR_SET_SECCOMP, SECCOMP_MODE_FILTER, &program); if (rc) |
