mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-23 09:46:04 -05:00
Kernel: Use Userspace<T> for the uname syscall
This commit is contained in:
parent
cfedd62b5c
commit
8dd78201a4
Notes:
sideshowbarker
2024-07-19 04:05:40 +09:00
Author: https://github.com/bgianfo Commit: https://github.com/SerenityOS/serenity/commit/8dd78201a44 Pull-request: https://github.com/SerenityOS/serenity/pull/3062 Reviewed-by: https://github.com/awesomekling
2 changed files with 13 additions and 7 deletions
|
@ -252,7 +252,7 @@ public:
|
|||
int sys$clock_nanosleep(Userspace<const Syscall::SC_clock_nanosleep_params*>);
|
||||
int sys$gethostname(Userspace<char*>, ssize_t);
|
||||
int sys$sethostname(Userspace<const char*>, ssize_t);
|
||||
int sys$uname(utsname*);
|
||||
int sys$uname(Userspace<utsname*>);
|
||||
int sys$readlink(Userspace<const Syscall::SC_readlink_params*>);
|
||||
int sys$ttyname(int fd, Userspace<char*>, size_t);
|
||||
int sys$ptsname(int fd, Userspace<char*>, size_t);
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
namespace Kernel {
|
||||
|
||||
int Process::sys$uname(utsname* buf)
|
||||
int Process::sys$uname(Userspace<utsname*> buf)
|
||||
{
|
||||
extern String* g_hostname;
|
||||
extern Lock* g_hostname_lock;
|
||||
|
@ -36,14 +36,20 @@ int Process::sys$uname(utsname* buf)
|
|||
REQUIRE_PROMISE(stdio);
|
||||
if (!validate_write_typed(buf))
|
||||
return -EFAULT;
|
||||
|
||||
|
||||
LOCKER(*g_hostname_lock, Lock::Mode::Shared);
|
||||
if (g_hostname->length() + 1 > sizeof(utsname::nodename))
|
||||
return -ENAMETOOLONG;
|
||||
copy_to_user(buf->sysname, "SerenityOS", 11);
|
||||
copy_to_user(buf->release, "1.0-dev", 8);
|
||||
copy_to_user(buf->version, "FIXME", 6);
|
||||
copy_to_user(buf->machine, "i686", 5);
|
||||
copy_to_user(buf->nodename, g_hostname->characters(), g_hostname->length() + 1);
|
||||
|
||||
// We have already validated the entire utsname struct at this
|
||||
// point, there is no need to re-validate every write to the struct.
|
||||
utsname* user_buf = buf.unsafe_userspace_ptr();
|
||||
copy_to_user(user_buf->sysname, "SerenityOS", 11);
|
||||
copy_to_user(user_buf->release, "1.0-dev", 8);
|
||||
copy_to_user(user_buf->version, "FIXME", 6);
|
||||
copy_to_user(user_buf->machine, "i686", 5);
|
||||
copy_to_user(user_buf->nodename, g_hostname->characters(), g_hostname->length() + 1);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue