1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 08:27:45 +00:00

Kernel: Use Userspace<T> for the fstat syscall

This commit is contained in:
Brian Gianforcaro 2020-08-09 14:57:50 -07:00 committed by Andreas Kling
parent 8dd78201a4
commit 431145148e
2 changed files with 3 additions and 4 deletions

View file

@ -224,7 +224,7 @@ public:
ssize_t sys$read(int fd, Userspace<u8*>, ssize_t);
ssize_t sys$write(int fd, const u8*, ssize_t);
ssize_t sys$writev(int fd, const struct iovec* iov, int iov_count);
int sys$fstat(int fd, stat*);
int sys$fstat(int fd, Userspace<stat*>);
int sys$stat(Userspace<const Syscall::SC_stat_params*>);
int sys$lseek(int fd, off_t, int whence);
int sys$kill(pid_t pid_or_pgid, int sig);

View file

@ -31,7 +31,7 @@
namespace Kernel {
int Process::sys$fstat(int fd, stat* user_statbuf)
int Process::sys$fstat(int fd, Userspace<stat*> user_statbuf)
{
REQUIRE_PROMISE(stdio);
if (!validate_write_typed(user_statbuf))
@ -39,8 +39,7 @@ int Process::sys$fstat(int fd, stat* user_statbuf)
auto description = file_description(fd);
if (!description)
return -EBADF;
stat buffer;
memset(&buffer, 0, sizeof(buffer));
stat buffer = {};
int rc = description->fstat(buffer);
copy_to_user(user_statbuf, &buffer);
return rc;