From e7883d5df7c8d58d01acfa0115ba31e285ab694a Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Tue, 27 Aug 2024 11:00:42 -0700 Subject: [PATCH] Include support for euidaccess/eaccess (#22455) Fixes: #22392 --- src/library_syscall.js | 2 +- src/struct_info.json | 1 + src/struct_info_generated.json | 1 + src/struct_info_generated_wasm64.json | 1 + test/other/{test_err.cpp => test_err.c} | 0 test/other/test_euidaccess.c | 10 ++++++++++ test/other/test_euidaccess.out | 2 ++ test/test_other.py | 5 ++++- tools/system_libs.py | 2 +- 9 files changed, 21 insertions(+), 3 deletions(-) rename test/other/{test_err.cpp => test_err.c} (100%) create mode 100644 test/other/test_euidaccess.c create mode 100644 test/other/test_euidaccess.out diff --git a/src/library_syscall.js b/src/library_syscall.js index 0f963a81f9f7..c87c70864387 100644 --- a/src/library_syscall.js +++ b/src/library_syscall.js @@ -950,7 +950,7 @@ var SyscallsLibrary = { #endif path = SYSCALLS.getStr(path); #if ASSERTIONS - assert(flags === 0); + assert(flags === 0 || flags == {{{ cDefs.AT_EACCESS }}}); #endif path = SYSCALLS.calculateAt(dirfd, path); if (amode & ~{{{ cDefs.S_IRWXO }}}) { diff --git a/src/struct_info.json b/src/struct_info.json index ccddbb21023b..525c96c28b8f 100644 --- a/src/struct_info.json +++ b/src/struct_info.json @@ -99,6 +99,7 @@ "F_DUPFD", "F_SETLK", "O_WRONLY", + "AT_EACCESS", "AT_FDCWD", "AT_SYMLINK_NOFOLLOW", "AT_REMOVEDIR", diff --git a/src/struct_info_generated.json b/src/struct_info_generated.json index e842d718ed7f..d1fa6f32447b 100644 --- a/src/struct_info_generated.json +++ b/src/struct_info_generated.json @@ -39,6 +39,7 @@ "AL_VELOCITY": 4102, "ATOMICS_WAIT_NOT_EQUAL": 1, "ATOMICS_WAIT_TIMED_OUT": 2, + "AT_EACCESS": 512, "AT_EMPTY_PATH": 4096, "AT_FDCWD": -100, "AT_NO_AUTOMOUNT": 2048, diff --git a/src/struct_info_generated_wasm64.json b/src/struct_info_generated_wasm64.json index a82d7e850d9a..8995b4452909 100644 --- a/src/struct_info_generated_wasm64.json +++ b/src/struct_info_generated_wasm64.json @@ -39,6 +39,7 @@ "AL_VELOCITY": 4102, "ATOMICS_WAIT_NOT_EQUAL": 1, "ATOMICS_WAIT_TIMED_OUT": 2, + "AT_EACCESS": 512, "AT_EMPTY_PATH": 4096, "AT_FDCWD": -100, "AT_NO_AUTOMOUNT": 2048, diff --git a/test/other/test_err.cpp b/test/other/test_err.c similarity index 100% rename from test/other/test_err.cpp rename to test/other/test_err.c diff --git a/test/other/test_euidaccess.c b/test/other/test_euidaccess.c new file mode 100644 index 000000000000..4968a686c293 --- /dev/null +++ b/test/other/test_euidaccess.c @@ -0,0 +1,10 @@ +#define _GNU_SOURCE + +#include +#include + +int main() { + printf("eaccess:%d\n", eaccess(".", F_OK)); + printf("euidaccess:%d\n", euidaccess(".", F_OK)); + return 0; +} diff --git a/test/other/test_euidaccess.out b/test/other/test_euidaccess.out new file mode 100644 index 000000000000..197b9117fc8e --- /dev/null +++ b/test/other/test_euidaccess.out @@ -0,0 +1,2 @@ +eaccess:0 +euidaccess:0 diff --git a/test/test_other.py b/test/test_other.py index 062756fbb950..7cb6d54d3eac 100644 --- a/test/test_other.py +++ b/test/test_other.py @@ -12407,7 +12407,10 @@ def test_deterministic(self): self.assertIdentical(one, two) def test_err(self): - self.do_other_test('test_err.cpp') + self.do_other_test('test_err.c') + + def test_euidaccess(self): + self.do_other_test('test_euidaccess.c') def test_shared_flag(self): # Test that `-shared` flag causes object file generation but gives a warning diff --git a/tools/system_libs.py b/tools/system_libs.py index 652de74dad1a..e04ee951ae0e 100644 --- a/tools/system_libs.py +++ b/tools/system_libs.py @@ -1235,7 +1235,7 @@ def get_files(self): ]) libc_files += files_in_path( path='system/lib/libc/musl/src/legacy', - filenames=['getpagesize.c', 'err.c']) + filenames=['getpagesize.c', 'err.c', 'euidaccess.c']) libc_files += files_in_path( path='system/lib/libc/musl/src/linux',