mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:27:35 +00:00
Kernel: Make chdir() take path+length
This commit is contained in:
parent
f231e9ea76
commit
c5890afc8b
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Process::sys$chdir(const char* path)
|
int Process::sys$chdir(const char* user_path, size_t path_length)
|
||||||
{
|
{
|
||||||
SmapDisabler disabler;
|
SmapDisabler disabler;
|
||||||
if (!validate_read_str(path))
|
if (!validate_read(user_path, path_length))
|
||||||
return -EFAULT;
|
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())
|
if (directory_or_error.is_error())
|
||||||
return directory_or_error.error();
|
return directory_or_error.error();
|
||||||
m_cwd = *directory_or_error.value();
|
m_cwd = *directory_or_error.value();
|
||||||
|
|
|
@ -144,7 +144,7 @@ public:
|
||||||
int sys$poll(pollfd*, int nfds, int timeout);
|
int sys$poll(pollfd*, int nfds, int timeout);
|
||||||
ssize_t sys$get_dir_entries(int fd, void*, ssize_t);
|
ssize_t sys$get_dir_entries(int fd, void*, ssize_t);
|
||||||
int sys$getcwd(char*, 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$fchdir(int fd);
|
||||||
int sys$sleep(unsigned seconds);
|
int sys$sleep(unsigned seconds);
|
||||||
int sys$usleep(useconds_t usec);
|
int sys$usleep(useconds_t usec);
|
||||||
|
|
|
@ -245,7 +245,7 @@ int fstat(int fd, struct stat* statbuf)
|
||||||
|
|
||||||
int chdir(const char* path)
|
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);
|
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue