static int bfs_statx(int at_fd, const char *at_path, int at_flags, unsigned int mask, struct statx *buf) {
// Android9: statx forbidden, using fstatat
struct stat sb;
int ret = fstatat(at_fd, at_path, &sb, at_flags);
if (ret == 0) {
memset(buf, 0, sizeof(*buf));
buf->stx_mask = STATX_BASIC_STATS;
buf->stx_mode = sb.st_mode;
buf->stx_uid = sb.st_uid;
buf->stx_gid = sb.st_gid;
buf->stx_size = sb.st_size;
buf->stx_blksize = sb.st_blksize;
buf->stx_blocks = sb.st_blocks;
buf->stx_atime.tv_sec = sb.st_atime;
buf->stx_mtime.tv_sec = sb.st_mtime;
buf->stx_ctime.tv_sec = sb.st_ctime;
// birthtime leave not filled
}
return ret;
}
~/.../deb/bfs-4.1 $ strace -f bin/bfs 2>&1 | tail -55
[pid 20021] close(1014) = -1 EBADF (Bad file descriptor)
[pid 20021] close(1015) = -1 EBADF (Bad file descriptor)
[pid 20021] close(1016) = -1 EBADF (Bad file descriptor)
[pid 20021] close(1017) = -1 EBADF (Bad file descriptor)
[pid 20021] close(1018) = -1 EBADF (Bad file descriptor)
[pid 20021] close(1019) = -1 EBADF (Bad file descriptor)
[pid 20021] close(1020) = -1 EBADF (Bad file descriptor)
[pid 20021] close(1021) = -1 EBADF (Bad file descriptor)
[pid 20021] close(1022) = -1 EBADF (Bad file descriptor)
[pid 20021] close(1023) = -1 EBADF (Bad file descriptor)
[pid 20021] openat(AT_FDCWD, "/dev/null", O_RDWR|O_LARGEFILE) = 0
[pid 20021] dup3(0, 1, 0) = 1
[pid 20021] dup3(0, 2, 0) = 2
[pid 20021] pipe2([3, 4], 0) = 0
[pid 20021] clone(child_stack=NULL, flags=0strace: Process 20022 attached
) = 20022
[pid 20022] gettid( <unfinished ...>
[pid 20021] close(4 <unfinished ...>
[pid 20022] <... gettid resumed>) = 20022
[pid 20021] <... close resumed>) = 0
[pid 20022] dup3(4, 1, 0 <unfinished ...>
[pid 20021] read(3 <unfinished ...>
[pid 20022] <... dup3 resumed>) = 1
[pid 20022] close(3) = 0
[pid 20022] close(4) = 0
[pid 20022] capget({version=_LINUX_CAPABILITY_VERSION_3, pid=0}, {effective=0, permitted=0, inheritable=0}) = 0
[pid 20022] execve("/system/bin/crash_dump32", ["crash_dump32", "20020", "20021", "1"], 0xbe91756c /* 38 vars */) = -1 EPERM (Operation not permitted)
[pid 20022] --- SIGSEGV {si_signo=SIGSEGV, si_code=SEGV_ACCERR, si_addr=0xb532bf40} ---
[pid 20022] +++ killed by SIGSEGV +++
[pid 20021] <... read resumed>, "", 4) = 0
[pid 20021] socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 4
[pid 20021] connect(4, {sa_family=AF_UNIX, sun_path="/dev/socket/logdw"}, 110) = 0
[pid 20021] clock_gettime(CLOCK_REALTIME, {tv_sec=1776604893, tv_nsec=825753319}) = 0
[pid 20021] writev(4, [{iov_base="\4", iov_len=1}, {iov_base="4N", iov_len=2}, {iov_base="\335\326\344i\347\37671", iov_len=8}, {iov_base="\7", iov_len=1}, {iov_base="libc\0", iov_len=5}, {iov_base="crash_dump helper failed to exec"..., iov_len=33}], 6) = 50
[pid 20021] close(4) = 0
[pid 20021] close(3) = 0
[pid 20021] wait4(20022, 0xb532cf88, 0, NULL) = -1 ECHILD (No child processes)
[pid 20021] socket(AF_UNIX, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0) = 3
[pid 20021] connect(3, {sa_family=AF_UNIX, sun_path="/dev/socket/logdw"}, 110) = 0
[pid 20021] clock_gettime(CLOCK_REALTIME, {tv_sec=1776604893, tv_nsec=829694882}) = 0
[pid 20021] writev(3, [{iov_base="\4", iov_len=1}, {iov_base="4N", iov_len=2}, {iov_base="\335\326\344i\242#t1", iov_len=8}, {iov_base="\7", iov_len=1}, {iov_base="libc\0", iov_len=5}, {iov_base="failed to wait for crash_dump he"..., iov_len=57}], 6) = 74
[pid 20021] close(3) = 0
[pid 20021] exit(0) = ?
[pid 20020] futex(NULL, FUTEX_WAIT, 20021, NULL) = 4
[pid 20021] +++ exited with 0 +++
prctl(0 /* PR_??? */, 0x1, 0x4e35, 0, 0) = 31
sigaction(0, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0xb53add70}, {sa_handler=SIG_DFL, sa_mask=[TRAP FPE SEGV USR2 PIPE STKFLT CHLD CONT TTIN TTOU XFSZ PROF IO PWR RTMIN], sa_flags=SA_RESTORER|SA_RESTART|SA_RESETHAND|SA_SIGINFO|SA_NOCLDSTOP|0x21358098, sa_restorer=0xb53add7c}) = 31
sigaction(0, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0xb53add70}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0xb53add70}) = 0
getpid() = 526046578
gettid() = 20020
rt_tgsigqueueinfo(0, 20020, SIGSYS, {si_signo=SIGSYS, si_code=SYS_SECCOMP, si_call_addr=0xb50aed6c, si_syscall=__NR_statx, si_arch=AUDIT_ARCH_ARM}) = 0
statx(1, "", AT_STATX_SYNC_AS_STAT|AT_NO_AUTOMOUNT|AT_EMPTY_PATH, STATX_ALL|STATX_MNT_ID|STATX_MNT_ID_UNIQUE <unfinished ...>
--- SIGSYS {si_signo=SIGSYS, si_code=SYS_SECCOMP, si_call_addr=0xb50aed6c, si_syscall=397, si_arch=0 /* AUDIT_ARCH_??? */} ---
<... statx resumed> <unfinished ...>) = ?
+++ killed by SIGSYS +++
~/.../deb/bfs-4.1 $ bin/bfs . -maxdepth 1
Bad system call bin/bfs . -maxdepth 1
~/.../deb/bfs-4.1 $ nano src/stat.c
~/.../deb/bfs-4.1 $ make clean;CFLAGS="-mfpu=neon -O3 -Wno-implicit-function-declaration -D_GNU_SOURCE" ./configure
[ RM ] bin obj
[ GEN] gen/vars.mk
[ CC ] build/empty.c ✔
[ CC ] flags/std.c ✔
[ CC ] flags/pthread.c ✔
[ CC ] flags/Wformat.c ✔
[ CC ] flags/bind-now.c ✔
[ CC ] flags/deps.c ✔
[ CC ] flags/Wimplicit-fallthrough.c ✔
[ CC ] flags/Wmissing-decls.c ✔
[ CC ] flags/Wimplicit.c ✔
[ CC ] flags/Wshadow.c ✔
[ CC ] flags/Wmissing-var-decls.c ✔
[ CC ] flags/Wstrict-prototypes.c ✔
[ CC ] flags/Wsign-compare.c ✔
[ CC ] flags/Wundef-prefix.c ✔
[ GEN] gen/flags.mk
[ CC ] with/libcap.c ✘
[ CC ] with/liburing.c ✘
[ CC ] with/libselinux.c ✘
[ CC ] with/libacl.c ✔
[ CC ] with/oniguruma.c ✔
[ GEN] gen/pkgs.mk
[ GEN] gen/config.mk
[ CC ] has/--st-birthtim.c ✘
[ CC ] has/_Fork.c ✘
[ CC ] has/builtin-riscv-pause.c ✘
[ CC ] has/acl-is-trivial-np.c ✘
[ CC ] has/acl-trivial.c ✘
[ CC ] has/acl-get-entry.c ✔
[ CC ] has/acl-get-file.c ✔
[ CC ] has/acl-get-tag-type.c ✔
[ CC ] has/confstr.c ✘
[ CC ] has/extattr-get-link.c ✘
[ CC ] has/extattr-get-file.c ✘
[ CC ] has/extattr-list-file.c ✘
[ CC ] has/extattr-list-link.c ✘
[ CC ] has/dprintf.c ✔
[ CC ] has/fdclosedir.c ✘
[ CC ] has/getdents.c ✘
[ CC ] has/getdents64.c ✘
[ CC ] has/getmntent-2.c ✘
[ CC ] has/getmntinfo.c ✘
[ CC ] has/io-uring-max-workers.c ✘
[ CC ] has/getprogname-gnu.c ✘
[ CC ] has/getmntent-1.c ✔
[ CC ] has/getdents64-syscall.c ✔
[ CC ] has/getprogname.c ✔
[ CC ] has/pipe2.c ✔
[ CC ] has/posix-getdents.c ✘
[ CC ] has/posix-spawn-addfchdir.c ✘
[ CC ] has/posix-spawn-addfchdir-np.c ✘
[ CC ] has/pthread-set-name-np.c ✘
[ CC ] has/pragma-nounroll.c ✔
[ CC ] has/pthread-setname-np.c ✔
[ CC ] has/sched-getaffinity.c ✔
[ CC ] has/st-acmtimespec.c ✘
[ CC ] has/st-birthtim.c ✘
[ CC ] has/st-flags.c ✘
[ CC ] has/st-acmtim.c ✔
[ CC ] has/st-birthtimespec.c ✘
[ CC ] has/statx.c ✘
[ CC ] has/statx-syscall.c ✔
[ CC ] has/strerror-l.c ✔
[ CC ] has/string-to-flags.c ✘
[ CC ] has/strerror-r-posix.c ✘
[ CC ] has/strtofflags.c ✘
[ CC ] has/strerror-r-gnu.c ✔
[ CC ] has/tcgetwinsize.c ✔
[ CC ] has/tcsetwinsize.c ✔
[ CC ] has/timegm.c ✔
[ CC ] has/timer-create.c ✔
[ CC ] has/uselocale.c ✔
[ CC ] has/tm-gmtoff.c ✔
[ GEN] gen/config.h
~/.../deb/bfs-4.1 $ CFLAGS="-mfpu=neon -O3 -Wno-implicit-function-declaration -D_GNU_SOURCE" make -j7
[ CC ] src/bar.c
[ CC ] src/main.c
[ CC ] src/alloc.c
[ CC ] src/bftw.c
[ CC ] src/bfstd.c
[ CC ] src/color.c
[ CC ] src/ctx.c
[ CC ] src/diag.c
[ CC ] src/dir.c
[ CC ] src/dstring.c
[ CC ] src/eval.c
[ CC ] src/exec.c
[ CC ] src/expr.c
[ CC ] src/fsade.c
[ CC ] src/ioq.c
[ CC ] src/mtab.c
[ CC ] src/opt.c
[ CC ] src/parse.c
[ CC ] src/printf.c
[ CC ] src/pwcache.c
[ CC ] src/sighook.c
[ CC ] src/stat.c
[ CC ] src/thread.c
[ CC ] src/typo.c
[ CC ] src/trie.c
[ CC ] src/xregex.c
[ CC ] src/xspawn.c
[ CC ] src/xtime.c
[ CC ] src/version.c
[ LD ] bin/bfs
~/.../deb/bfs-4.1 $ bin/bfs . -maxdepth 1
.
./LICENSE
./Makefile
./README.md
./bench
./build
./completions
./configure
./docs
./src
./tests
./gen
./obj
./bin
32-bit Android9 termux patch suggested
bfs_statx emulation via fstatat
Bug was as follows:
After fix: