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

Kernel+LibC+LibCore: Implement the unlinkat(2) syscall

This commit is contained in:
sin-ack 2022-02-10 11:30:33 +00:00 committed by Brian Gianforcaro
parent a5514fece9
commit bc7c8879c5
7 changed files with 31 additions and 6 deletions

View file

@ -644,7 +644,13 @@ int link(char const* old_path, char const* new_path)
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlink.html
int unlink(char const* pathname)
{
int rc = syscall(SC_unlink, pathname, strlen(pathname));
return unlinkat(AT_FDCWD, pathname, 0);
}
// https://pubs.opengroup.org/onlinepubs/9699919799/functions/unlinkat.html
int unlinkat(int dirfd, char const* pathname, int flags)
{
int rc = syscall(SC_unlink, dirfd, pathname, strlen(pathname), flags);
__RETURN_WITH_ERRNO(rc, rc, -1);
}

View file

@ -92,6 +92,7 @@ int ttyname_r(int fd, char* buffer, size_t);
off_t lseek(int fd, off_t, int whence);
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 rmdir(char const* pathname);
int dup(int old_fd);

View file

@ -854,7 +854,7 @@ ErrorOr<void> unlink(StringView path)
return Error::from_errno(EFAULT);
#ifdef __serenity__
int rc = syscall(SC_unlink, path.characters_without_null_termination(), path.length());
int rc = syscall(SC_unlink, AT_FDCWD, path.characters_without_null_termination(), path.length(), 0);
HANDLE_SYSCALL_RETURN_VALUE("unlink"sv, rc, {});
#else
String path_string = path;