1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 09:17:45 +00:00

Kernel+LibC+LibCore: Implement symlinkat(2)

Co-Authored-By: Daniel Bertalan <dani@danielbertalan.dev>
This commit is contained in:
sin-ack 2022-10-01 11:15:02 +00:00 committed by Andrew Kaster
parent 5c1d5ed51d
commit 9850a69cd1
5 changed files with 11 additions and 2 deletions

View file

@ -672,12 +672,18 @@ int unlinkat(int dirfd, char const* pathname, int flags)
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/symlink.html
int symlink(char const* target, char const* linkpath)
{
return symlinkat(target, AT_FDCWD, linkpath);
}
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/symlinkat.html
int symlinkat(char const* target, int newdirfd, char const* linkpath)
{
if (!target || !linkpath) {
errno = EFAULT;
return -1;
}
Syscall::SC_symlink_params params { { target, strlen(target) }, { linkpath, strlen(linkpath) } };
Syscall::SC_symlink_params params { { target, strlen(target) }, { linkpath, strlen(linkpath) }, newdirfd };
int rc = syscall(SC_symlink, &params);
__RETURN_WITH_ERRNO(rc, rc, -1);
}

View file

@ -95,6 +95,7 @@ int link(char const* oldpath, char const* newpath);
int unlink(char const* pathname);
int unlinkat(int dirfd, char const* pathname, int flags);
int symlink(char const* target, char const* linkpath);
int symlinkat(char const* target, int newdirfd, char const* linkpath);
int rmdir(char const* pathname);
int dup(int old_fd);
int dup2(int old_fd, int new_fd);