mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-22 12:35:14 +00:00
Kernel: Make chdir() take path+length
This commit is contained in:
parent
f231e9ea76
commit
c5890afc8b
Notes:
sideshowbarker
2024-07-19 10:19:34 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/c5890afc8bf
3 changed files with 6 additions and 5 deletions
|
@ -1555,12 +1555,13 @@ int Process::sys$readlink(const char* path, char* buffer, ssize_t size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$chdir(const char* path)
|
||||
int Process::sys$chdir(const char* user_path, size_t path_length)
|
||||
{
|
||||
SmapDisabler disabler;
|
||||
if (!validate_read_str(path))
|
||||
if (!validate_read(user_path, path_length))
|
||||
return -EFAULT;
|
||||
auto directory_or_error = VFS::the().open_directory(StringView(path), current_directory());
|
||||
auto path = copy_string_from_user(user_path, path_length);
|
||||
auto directory_or_error = VFS::the().open_directory(path, current_directory());
|
||||
if (directory_or_error.is_error())
|
||||
return directory_or_error.error();
|
||||
m_cwd = *directory_or_error.value();
|
||||
|
|
|
@ -144,7 +144,7 @@ public:
|
|||
int sys$poll(pollfd*, int nfds, int timeout);
|
||||
ssize_t sys$get_dir_entries(int fd, void*, ssize_t);
|
||||
int sys$getcwd(char*, ssize_t);
|
||||
int sys$chdir(const char*);
|
||||
int sys$chdir(const char*, size_t);
|
||||
int sys$fchdir(int fd);
|
||||
int sys$sleep(unsigned seconds);
|
||||
int sys$usleep(useconds_t usec);
|
||||
|
|
|
@ -245,7 +245,7 @@ int fstat(int fd, struct stat* statbuf)
|
|||
|
||||
int chdir(const char* path)
|
||||
{
|
||||
int rc = syscall(SC_chdir, path);
|
||||
int rc = syscall(SC_chdir, path, strlen(path));
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue