1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-24 22:07:34 +00:00

Kernel: sys$readlink() should return the number of bytes written out

This commit is contained in:
Andreas Kling 2020-01-27 21:47:30 +01:00
parent a7b984ec49
commit c64904a483
2 changed files with 6 additions and 1 deletions

View file

@ -1854,7 +1854,7 @@ int Process::sys$readlink(const Syscall::SC_readlink_params* user_params)
if (link_target.length() + 1 > params.buffer.size)
return -ENAMETOOLONG;
copy_to_user(params.buffer.data, link_target.characters(), link_target.length() + 1);
return 0;
return link_target.length() + 1;
}
int Process::sys$chdir(const char* user_path, size_t path_length)

View file

@ -210,6 +210,11 @@ void test_unlink_symlink()
perror("symlink");
ASSERT_NOT_REACHED();
}
char buffer[PATH_MAX];
rc = readlink("/tmp/linky", buffer, sizeof(buffer));
ASSERT(rc == strlen("/proc/2/foo") + 1);
rc = unlink("/tmp/linky");
if (rc < 0) {
perror("unlink");