Skip to content

Commit

Permalink
Kernel: sys$readlink() should return the number of bytes written out
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Jan 27, 2020
1 parent a7b984e commit c64904a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Kernel/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 5 additions & 0 deletions Userland/test_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit c64904a

Please sign in to comment.