Commit Graph

275 Commits

Author SHA1 Message Date
sourceturner 4b4dc2ce94 implement housekeeping for posix timers 2026-05-24 19:14:02 +02:00
Jeremy Soller 6ef45672d1 Merge branch 'fix-fstatat' into 'master'
fix: Fix fstatat by passing O_PATH when calling openat2

See merge request redox-os/relibc!1362
2026-05-20 06:29:10 -06:00
Ibuki.O 0e2f24125a fix: Fix fstatat by passing O_PATH when calling openat2 2026-05-20 12:11:11 +09:00
Wildan M 4a7f2d80ff Avoid StringWriter cast and string format 2026-05-20 09:10:25 +07:00
David Finder 1dbc61932a Alarm fix 2026-05-18 16:52:04 -06:00
Connor-GH e2486379b1 Remove redundant code and impl them in terms of *at functions
The following functions were replaced with their *at variants or
similar:
- lstat -> lstat -> fstatat
- stat -> stat -> fstatat
- fstat -> fstatat
- fchmod -> fchmodat
- fchown -> fchownat
- lchown -> fchownat
- mkfifo -> mkfifoat
- open -> openat
- renameat -> renameat2
- rmdir -> unlinkat
- unlink -> unlinkat
- symlink-> symlinkat

The `open_flags` logic for fstatat was redundant, as this is already
handled (and better so) in `openat2`.

Additionally, the fstatat test succeeds in os-test, and no longer
returns EINVAL. This is because `O_SYMLINK` is no longer
unconditionally passed like it was before. This is a problem because
redoxfs returns EINVAL if a node isn't a symlink but set `O_SYMLINK`.
2026-05-05 15:30:46 -05:00
Connor-GH 03103893ef add utimensat
This addition removes duplicated code and also passes an os-test.

The `AT_EMPTY_PATH` duplicated code will be taken care of in the future.
2026-05-05 10:42:32 -05:00
Connor-GH cf65eedbaf platform/redox: migrate more functions to use their *at variants
Additionally, this adds the `SYMLOOP_MAX` constant in `limits.h` to
replace the `MAX_LEVEL` magic number used during symlink resolution.

`fstat` was kept because it is more difficult than the others to do a
drop-in replacement in terms of `fstatat` for since a naive approach
would cause mutual recursion.
2026-05-04 11:44:53 -05:00
auronandace 05b8ffbcb7 import timespec from time rather than bits 2026-05-03 14:33:39 +01:00
Wildan M ea667cdca1 Support disarming timer 2026-05-03 05:06:25 +07:00
Wildan M 9188a9e354 Make timer_internal_t atomic 2026-05-03 05:02:29 +07:00
Wildan M d16dfade59 Use less cloning for timespec 2026-05-03 03:21:06 +07:00
Wildan M 7b0354ca3d Use type casts for timespec conversion 2026-05-03 03:09:52 +07:00
Connor-GH 22faf6b615 fchownat: fix behavior for uid == -1 && gid == -1
Previously, this would error with EINVAL since the conversion to
unsigned int would fail on -1. Now, we do a bitwise conversion via
an `as` cast.
2026-04-29 15:23:56 -05:00
Connor-GH 313f2be0f8 Pal: Add default method impls and remove duplicated code
I noticed that the Linux and Redox PALs both do very similar things for
a given FS function and its *at variant. For example, `mkdir()` is just
a call to `mkdirat()`. POSIX requires these to be equivalent.
Additionally, we use AT_EMPTY_PATH in some places but note that this is
not POSIX and is instead an extension that Linux (and Redox) implement.
That doesn't really matter though, since this is an implementation
detail. Implementations can choose to implement these functions anyway
and ignore the default impl. Such a case is `fstat`, because the current
Redox impl of `fstatat` relies on `fstat`, and this would cause infinite
recursion.

Future work:

POSIX says that `fcntl(fd, F_DUPFD, 0);` shall be equivalent to
`dup(fd);`. `dup2` might have cases where it can be implemented using
`dup3`. `dup` seemingly cannot be implemented in terms of `dup2`, so the
`fcntl` default implementation is sufficient. `pipe(fds)` is equivalent to
`pipe2(fds, 0);`.
2026-04-23 14:18:04 -05:00
Connor-GH 24e250c339 add faccessat(2) and fchownat(2)
Additionally, we were using the `access` syscall for x86_64 for our
linux PAL. I looked at the linux source and found that using the
`access`
syscall is equivalent to using `faccessat` as we do now: https://elixir.bootlin.com/linux/v6.17.5/source/fs/open.c#L550

Also, some of the `fcntl.h` functions were accidentally implemented and exported from `unistd.h`. They are supposed to be implemented in `fcntl.h` and exported to `unistd.h`. This is now the behavior.
2026-04-20 17:20:18 -05:00
Connor-GH 0ff79b80a2 add unlinkat(2), symlinkat(2), linkat(2) and expose openat(2)
`linkat(2)` doesn't have `AT_EMPTY_PATH` as a valid flag in this
implementation because it isn't POSIX. We have it (and have
support for it), but it is more effort to add it. If we need it at some
point, it can be added in about 3 lines.

`openat(2)` previously wasn't exposed, and William was not aware of
`Sys::openat`'s existence. We use it under the hood for `mkfifoat(2)`
and friends, so expose it as a libc API. This helps to pass more os-test tests.

Lastly, the 3 implemented syscalls here help pass some os-test tests.
2026-04-20 10:58:25 -05:00
Akshit Gaur 87b16e6d12 Priority Scheduler 2026-04-17 18:45:46 -06:00
auronandace 49f96a96e6 rename bits_time to bits_timespec for consistency 2026-04-09 10:50:04 +01:00
Peter Limkilde Svendsen 2d2aa5592b Document Pal methods 2026-04-06 20:12:04 +02:00
Zero e0c9b0ed03 feat(signal): Implement alarm() and timer_settime logic
Adds the implementation for the `alarm()` function and its underlying
`alarm_timespec` helper. This involves managing a process-global POSIX timer
to deliver SIGALRM signals.
2026-03-31 00:09:07 +02:00
Wildan M 0db44c3f72 Fix fchmodat with AT_EMPTY_PATH 2026-03-17 03:12:34 +07:00
Connor-GH a60b7cefc1 uname: update to reflect version info given from scheme
We recently updated the kernel to give the "version" info in the
uname scheme. Now, we also put this info in the `utsname` struct for the
`uname` function.
2026-03-15 15:49:10 -05:00
Ibuki.O ac88c8f670 refactor: Migrate fstat*/fchmod/getdents/ftruncate/futimens to stdfscall 2026-03-14 13:35:39 +09:00
auronandace 3ea60eeb72 timespec clone followup for redox 2026-03-11 14:51:06 +00:00
Wildan M fb07b5f982 Implement getgroups 2026-03-07 11:02:50 +07:00
Ibuki Omatsu 3385c66c6c refactor: Reimplement the *at functions using openat and CWD fd 2026-03-01 07:08:31 -07:00
Ibuki Omatsu cab0021461 refactor: Move protocols into libredox 2026-02-28 08:04:47 -07:00
Ibuki Omatsu bd9c6f1440 refactor: Make processes have cwd as a capability 2026-02-26 06:09:27 -07:00
Jeremy Soller 1ff26de318 Merge branch 'flock' into 'master'
feat(redox): flocking

See merge request redox-os/relibc!1037
2026-02-25 08:20:46 -07:00
Jeremy Soller e8fb4604fb Merge branch 'fix-mprotect' into 'master'
fix: return EINVAL for invalid `prot` of `mprotect`

Closes #259

See merge request redox-os/relibc!976
2026-02-24 08:10:46 -07:00
Anhad Singh d1c031f1b5 feat(redox): F_{OFD}_{GETLK,SETLK}
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-25 01:43:45 +11:00
Anhad Singh 73ef851d59 feat(redox): F_OFD_SETLK
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-24 22:36:19 +11:00
Anhad Singh aa317238f1 feat(redox/fcntl): F_SETLK
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-23 23:55:11 +11:00
auronandace 874e11b147 grp and inttypes cleanup 2026-02-19 15:51:33 +00:00
auronandace c8d9b4deca remove unused import 2026-02-19 12:51:12 +00:00
auronandace 2d647590a7 remove reference to clone 2026-02-19 12:20:54 +00:00
auronandace dcca06f80e add imports 2026-02-19 12:09:46 +00:00
auronandace 406b889c1f remove unneeded file 2026-02-19 11:55:31 +00:00
auronandace 5cd6b99588 tackle a few lint instances 2026-02-17 13:00:52 +00:00
auronandace 1191d8e1b4 extract timespec to a bits header 2026-02-12 13:07:24 +00:00
auronandace 6792e49563 missed 2 more 2026-02-10 16:33:52 +00:00
auronandace 11f28342f9 unused_imports redox follow-up 2026-02-10 16:29:37 +00:00
auronandace df37258ed2 usused_unsafe follow-up for redox 2026-02-08 15:52:55 +00:00
auronandace 48224dc5ff redox unused_mut follow-up 2026-02-08 09:14:05 +00:00
Marsman deb4a529be fix: return EINVAL for invalid prot of mprotect 2026-02-08 08:18:36 +00:00
Ron Williams 2c3201eaeb move timeval to sys_select 2026-01-30 15:53:15 +00:00
Wildan M f15322453b Convert all println to log or todo 2026-01-25 05:27:38 +07:00
sourceturner defd2ce7c3 Deny deny-unsafe_op_in_unsafe_fn on the crate level 2026-01-21 00:41:57 +01:00
sourceturner 582e6eba69 Use unsafe blocks in some more unsafe functions
Building with redoxer showed some more places
that have to use unsafe blocks
2026-01-21 00:41:43 +01:00