Commit Graph

290 Commits

Author SHA1 Message Date
Josh Megnauth f5d432644f Implement renameat, renameat2
Like the other "at" functions, renameat renames files with respect with
a directory descriptor. "renameat2" is Linux specific but really nice -
it adds a flag which supports atomically swapping two files or failing
if the target already exists. The latter is easily supported in relibc.
The former requires redoxfs support.

Besides the impl itself, I refactored "cap_path_at" into what it really
is: a mini openat2-like function.
2025-10-21 14:47:39 -04:00
Wildan Mubarok 7416ba6ff3 Implement posix_getdents 2025-09-23 10:57:13 -06:00
Josh Megnauth 85c5e889fb Implement fchmodat
Capability based `fchmod`. I also implemented unit tests for chmod,
fchmod, and fchmodat.

The unit tests check Redox-specific behavior, so some of the tests are
disabled for Linux.
2025-09-21 10:04:11 -04:00
Josh Megnauth c555503a35 Implement readlinkat
Like readlink except capability based. Most of this patch is refactoring
fstatat into a reusable, openat-like private function.
2025-09-18 01:27:55 +00:00
Josh Megnauth c6a9a165ec Implement fdopendir and fdclosedir
`fdopendir` takes ownership of a directory file descriptor instead of
opening one with a path. `fdclosedir` is a FreeBSD extension that
transfers ownership of the file descriptor in DIR to the user.
2025-09-17 08:24:48 -04:00
Josh Megnauth 639e0f2cd7 Add lstat test 2025-09-05 23:59:36 -04:00
Josh Megnauth c899feb774 Implement fstatat
Linux's variant uses the syscall as intended. Redox's variant uses fpath
to build a path to pass to fstat from the file descriptor plus the file
name. Unlike the syscall, this isn't atomic so the liminal space between
fpath/getcwd and fstat is subject to TOCTOU.

Beyond fstatat, I moved the stat test to its correct location and added
an assert since the output of the test is unchecked.

I also added AT_FDCWD which seems to be -100 across Unixes. The other
AT_* constants are unimplemented for now.
2025-08-27 08:21:41 -04:00
Josh Megnauth 9d2f5d95dc Implement confstr (unistd.h)
The implementation for confstr is straightforward. Most of the constants
return 1 on both musl and glibc. The only constant that doesn't is
required for Fish.

I also switched an #[unsafe(no_mangle)] from my last patch back
to a #[no_mangle] because we need to bump cbindgen. #[unsafe(no_mangle)]
is required for Rust 2024.
2025-08-22 22:13:51 -04:00
Jeremy Soller 551c79c526 Merge branch 'redoxer-test' into 'master'
Enable some tests in Redox

See merge request redox-os/relibc!685
2025-08-11 14:11:16 -06:00
Darley Barreto b0aac4e8f6 Enable some tests in Redox 2025-08-11 14:11:15 -06:00
Wildan M c7405e09bd Add statvfs tests to Makefile 2025-08-07 07:35:40 +07:00
Josh Megnauth e677ad55d5 Better priorities & LOG_UPTO for syslog.h
* Fix PERROR to match musl/glibc better
* More unit tests + enabled on Linux
* Pack priority and facility into one i32 and check the bits with
  bitflags
* Add LOG_UPTO (logic is straight from musl)

Not done:
* "%m" - this could just be added to printf
* LOG_CONS
2025-08-01 23:45:26 -04:00
Bendeguz Pisch 4fc80ea7b0 Implement syslog functionality 2025-07-17 22:49:51 -06:00
Ron Williams 770dc71816 Fix CI, Add signal.h constants 2025-07-11 20:28:45 -06:00
4lDO2 df228ddd79 Add remaining tests. 2025-04-20 21:17:39 +02:00
4lDO2 240a41861c Rebase, misc fixes for test suite. 2025-04-20 21:17:39 +02:00
Josh Williams 77cf9fc2a1 added tests to makefile and run_tests 2025-04-20 21:17:39 +02:00
Josh Williams 70b997b249 switched to master makefile, run_tests and test_helpers 2025-04-20 21:17:39 +02:00
Josh Williams 2d3374f176 add tests to makefile and run_tests 2025-04-20 21:17:38 +02:00
Josh Williams 2bc44dba9d modify makefile and run_tests
fix compiler warnings
2025-04-20 21:17:38 +02:00
Josh Williams a2e19224a4 add signals-tests to makefile and run_tests 2025-04-20 21:17:38 +02:00
4lDO2 37b60b67e0 Add and fix test for kill&waitpid. 2025-04-19 19:27:02 +02:00
4lDO2 0083043736 Write and fix waitpid_multiple test. 2025-04-19 19:27:02 +02:00
4lDO2 134914c580 Expand waitpid test. 2025-04-19 19:27:00 +02:00
4lDO2 c99e9c7db3 Add waitpid test back. 2025-04-19 19:27:00 +02:00
4lDO2 9e769fcb57 Add pthread_exit test.
This caught a bug in the kernel where it would return Ok(24) when
passing zero extra-munmap length.
2025-04-19 19:27:00 +02:00
Josh Megnauth a4826bd48c Implement BSD's err.h 2025-04-18 12:34:45 +00:00
Josh Megnauth e827b4f61f Add strptime tests 2025-03-29 14:01:29 +00:00
Darley Barreto dda7142385 Few improvements to time.h 2025-02-26 23:58:57 +00:00
Ron Williams 6ea993bf46 Fix sigqueue test 2025-02-07 22:04:01 +00:00
Peter Limkilde Svendsen 38d22bd735 Suppress warnings about deprecated declarations in C 2025-01-30 21:41:52 +01:00
Jeremy Soller 25b0da4876 Merge branch 'sigsetjmp_x64_implementation' into 'master'
Implement sigsetjmp and siglongjmp for X64

See merge request redox-os/relibc!478
2025-01-04 00:29:19 +00:00
Bendeguz Pisch 35a3efd936 Implement sigsetjmp and siglongjmp for X64 2025-01-04 00:29:19 +00:00
Darley Barreto c14b2cee4c Adding tzset, timezone awareness, and some tweaks 2025-01-02 20:19:34 +00:00
Darley Barreto ae5a5256b4 Add missing functions to string.h 2024-12-28 22:46:45 +00:00
Anhad Singh 1db68ab978 feat(ld.so): scopes
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-12-24 20:51:53 +11:00
Peter Limkilde Svendsen 93b6374d1e Reimplement memcpy() using slices, fix unaligned read/write, add test 2024-12-23 19:14:44 +00:00
bitstr0m 5d6ae507e1 Implement glob.h 2024-12-12 15:17:16 +00:00
Anhad Singh e8e6b8cbc5 fix(expected): dynamic bins
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-26 19:51:06 +11:00
Anhad Singh 22bbdb025c misc(tests): fix compilation of dlfcn.c
From man dlopen(3)
> According to the ISO C standard, casting between function
> pointers and 'void *', as done above, produces undefined results.
> POSIX.1-2001 and POSIX.1-2008 accepted this state of affairs and
> proposed the following workaround:
>
>   *(void **) (&cosine) = dlsym(handle, "cos");
>
> This (clumsy) cast conforms with the ISO C standard and will
> avoid any compiler warnings.
>
> The 2013 Technical Corrigendum 1 to POSIX.1-2008 improved matters
> by requiring that conforming implementations support casting
> 'void *' to a function pointer.  Nevertheless, some compilers
> (e.g., gcc with the '-pedantic' option) may complain about the
> cast used in this program.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-25 18:00:03 +11:00
Anhad Singh 00746c2566 misc(tests): disable dlfcn test for now
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-25 12:31:33 +11:00
Anhad Singh 7aa340570f chore: enable dynamic tests
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2024-11-25 12:13:03 +11:00
Jeremy Soller 2c73cc947c Merge branch 'memmem' into 'master'
Implement memmem()

See merge request redox-os/relibc!560
2024-11-17 16:18:15 +00:00
Peter Limkilde Svendsen 6a765ed88f Implement memmem() 2024-11-17 16:18:14 +00:00
Jeremy Soller caac784caa Merge branch 'iso646' into 'master'
Add iso646.h and corresponding tests

See merge request redox-os/relibc!555
2024-11-17 16:16:11 +00:00
Josh Megnauth 5348273ccc Emit C attributes via cbindgen 2024-11-17 16:15:07 +00:00
Peter Limkilde Svendsen 56d05e2cdc Add iso646.h and corresponding tests 2024-11-10 16:19:15 +01:00
Peter Limkilde Svendsen 41264dc8b1 Add NulTerminatedInclusive iterator, rewrite/fix strchr/wcschr 2024-10-22 22:12:24 +00:00
Jeremy Soller d794dc7704 Merge branch 'test' into 'master'
Add sigaltstack test

See merge request redox-os/relibc!518
2024-09-28 16:09:48 +00:00
4lDO2 07af4e49f7 Add sigaltstack test. 2024-09-28 16:51:17 +02:00