mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:27:45 +00:00
Kernel: Use Userspace<T> for the uname syscall
This commit is contained in:
parent
cfedd62b5c
commit
8dd78201a4
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$clock_nanosleep(Userspace<const Syscall::SC_clock_nanosleep_params*>);
|
||||||
int sys$gethostname(Userspace<char*>, ssize_t);
|
int sys$gethostname(Userspace<char*>, ssize_t);
|
||||||
int sys$sethostname(Userspace<const 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$readlink(Userspace<const Syscall::SC_readlink_params*>);
|
||||||
int sys$ttyname(int fd, Userspace<char*>, size_t);
|
int sys$ttyname(int fd, Userspace<char*>, size_t);
|
||||||
int sys$ptsname(int fd, Userspace<char*>, size_t);
|
int sys$ptsname(int fd, Userspace<char*>, size_t);
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
|
|
||||||
namespace Kernel {
|
namespace Kernel {
|
||||||
|
|
||||||
int Process::sys$uname(utsname* buf)
|
int Process::sys$uname(Userspace<utsname*> buf)
|
||||||
{
|
{
|
||||||
extern String* g_hostname;
|
extern String* g_hostname;
|
||||||
extern Lock* g_hostname_lock;
|
extern Lock* g_hostname_lock;
|
||||||
|
@ -36,14 +36,20 @@ int Process::sys$uname(utsname* buf)
|
||||||
REQUIRE_PROMISE(stdio);
|
REQUIRE_PROMISE(stdio);
|
||||||
if (!validate_write_typed(buf))
|
if (!validate_write_typed(buf))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
|
|
||||||
LOCKER(*g_hostname_lock, Lock::Mode::Shared);
|
LOCKER(*g_hostname_lock, Lock::Mode::Shared);
|
||||||
if (g_hostname->length() + 1 > sizeof(utsname::nodename))
|
if (g_hostname->length() + 1 > sizeof(utsname::nodename))
|
||||||
return -ENAMETOOLONG;
|
return -ENAMETOOLONG;
|
||||||
copy_to_user(buf->sysname, "SerenityOS", 11);
|
|
||||||
copy_to_user(buf->release, "1.0-dev", 8);
|
// We have already validated the entire utsname struct at this
|
||||||
copy_to_user(buf->version, "FIXME", 6);
|
// point, there is no need to re-validate every write to the struct.
|
||||||
copy_to_user(buf->machine, "i686", 5);
|
utsname* user_buf = buf.unsafe_userspace_ptr();
|
||||||
copy_to_user(buf->nodename, g_hostname->characters(), g_hostname->length() + 1);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue