diff options
author | sin-ack <sin-ack@users.noreply.github.com> | 2022-02-10 11:30:33 +0000 |
---|---|---|
committer | Brian Gianforcaro <b.gianfo@gmail.com> | 2022-04-23 10:43:32 -0700 |
commit | bc7c8879c5d3230c0caf3ea922446e27c6f77cbc (patch) | |
tree | afcd145a2ceb9a105836e3a5facd4e651b612c8d /Userland/Libraries/LibC | |
parent | a5514fece9cc15738bf41d579b203630c809fe8e (diff) | |
download | serenity-bc7c8879c5d3230c0caf3ea922446e27c6f77cbc.zip |
Kernel+LibC+LibCore: Implement the unlinkat(2) syscall
Diffstat (limited to 'Userland/Libraries/LibC')
-rw-r--r-- | Userland/Libraries/LibC/unistd.cpp | 8 | ||||
-rw-r--r-- | Userland/Libraries/LibC/unistd.h | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/Userland/Libraries/LibC/unistd.cpp b/Userland/Libraries/LibC/unistd.cpp index f613be7a19..cd88b63a90 100644 --- a/Userland/Libraries/LibC/unistd.cpp +++ b/Userland/Libraries/LibC/unistd.cpp @@ -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); } diff --git a/Userland/Libraries/LibC/unistd.h b/Userland/Libraries/LibC/unistd.h index 8ce3ac92e4..b6e56d9591 100644 --- a/Userland/Libraries/LibC/unistd.h +++ b/Userland/Libraries/LibC/unistd.h @@ -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); |