mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:27:34 +00:00
Kernel: Added the ability to set the hostname via new syscall
Userland/hostname: Now takes parameter to set the hostname LibC/unistd: Added sethostname function
This commit is contained in:
parent
03f68a51af
commit
f191b84b50
7 changed files with 40 additions and 9 deletions
|
@ -712,6 +712,18 @@ int Process::sys$gethostname(char* buffer, ssize_t size)
|
|||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$sethostname(const char* hostname, ssize_t length)
|
||||
{
|
||||
REQUIRE_PROMISE(stdio);
|
||||
if (length < 0)
|
||||
return -EINVAL;
|
||||
LOCKER(*s_hostname_lock, Lock::Mode::Shared);
|
||||
if (length > 64)
|
||||
return -ENAMETOOLONG;
|
||||
*s_hostname = validate_and_copy_string_from_user(hostname, length);
|
||||
return 0;
|
||||
}
|
||||
|
||||
pid_t Process::sys$fork(RegisterState& regs)
|
||||
{
|
||||
REQUIRE_PROMISE(proc);
|
||||
|
|
|
@ -223,6 +223,7 @@ public:
|
|||
int sys$clock_settime(clockid_t, timespec*);
|
||||
int sys$clock_nanosleep(const Syscall::SC_clock_nanosleep_params*);
|
||||
int sys$gethostname(char*, ssize_t);
|
||||
int sys$sethostname(const char*, ssize_t);
|
||||
int sys$uname(utsname*);
|
||||
int sys$readlink(const Syscall::SC_readlink_params*);
|
||||
int sys$ttyname_r(int fd, char*, ssize_t);
|
||||
|
|
|
@ -63,6 +63,7 @@ namespace Kernel {
|
|||
__ENUMERATE_SYSCALL(getcwd) \
|
||||
__ENUMERATE_SYSCALL(gettimeofday) \
|
||||
__ENUMERATE_SYSCALL(gethostname) \
|
||||
__ENUMERATE_SYSCALL(sethostname) \
|
||||
__ENUMERATE_SYSCALL(chdir) \
|
||||
__ENUMERATE_SYSCALL(uname) \
|
||||
__ENUMERATE_SYSCALL(set_mmap_name) \
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue