1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 14:17:36 +00:00

Kernel+LibC: Implement the openat() syscall

POSIX's openat() is very similar to open(), except you also provide a
file descriptor referring to a directory from which relative paths
should be resolved.

Passing it the magical fd number AT_FDCWD means "resolve from current
directory" (which is indeed also what open() normally does.)

This fixes libarchive's bsdtar, since it was trying to do something
extremely wrong in the absence of openat() support. The issue has
recently been fixed upstream in libarchive:

https://github.com/libarchive/libarchive/issues/1239

However, we should have openat() support anyway, so I went ahead and
implemented it. :^)

Fixes #748.
This commit is contained in:
Andreas Kling 2019-11-10 13:47:02 +01:00
parent 4f27745136
commit 18348cebf1
6 changed files with 80 additions and 7 deletions

View file

@ -134,7 +134,8 @@ struct timespec;
__ENUMERATE_SYSCALL(fchdir) \
__ENUMERATE_SYSCALL(getrandom) \
__ENUMERATE_SYSCALL(clock_gettime) \
__ENUMERATE_SYSCALL(clock_nanosleep)
__ENUMERATE_SYSCALL(clock_nanosleep) \
__ENUMERATE_SYSCALL(openat)
namespace Syscall {
@ -179,6 +180,14 @@ struct SC_open_params {
u16 mode;
};
struct SC_openat_params {
int dirfd;
const char* path;
int path_length;
int options;
u16 mode;
};
struct SC_select_params {
int nfds;
fd_set* readfds;