1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 12:38:12 +00:00

Kernel: Replace "current" with Thread::current and Process::current

Suggested by Sergey. The currently running Thread and Process are now
Thread::current and Process::current respectively. :^)
This commit is contained in:
Andreas Kling 2020-02-17 15:04:27 +01:00
parent 4f4af24b9d
commit 48f7c28a5c
37 changed files with 257 additions and 252 deletions

View file

@ -68,7 +68,7 @@ IPv4Socket::IPv4Socket(int type, int protocol)
: Socket(AF_INET, type, protocol)
{
#ifdef IPV4_SOCKET_DEBUG
kprintf("%s(%u) IPv4Socket{%p} created with type=%u, protocol=%d\n", current->process().name().characters(), current->pid(), this, type, protocol);
kprintf("%s(%u) IPv4Socket{%p} created with type=%u, protocol=%d\n", Process::current->name().characters(), Process::current->pid(), this, type, protocol);
#endif
m_buffer_mode = type == SOCK_STREAM ? BufferMode::Bytes : BufferMode::Packets;
if (m_buffer_mode == BufferMode::Bytes) {
@ -111,9 +111,9 @@ KResult IPv4Socket::bind(const sockaddr* user_address, socklen_t address_size)
return KResult(-EINVAL);
auto requested_local_port = ntohs(address.sin_port);
if (!current->process().is_superuser()) {
if (!Process::current->is_superuser()) {
if (requested_local_port < 1024) {
dbg() << current->process() << " (uid " << current->process().uid() << ") attempted to bind " << class_name() << " to port " << requested_local_port;
dbg() << Process::current << " (uid " << Process::current->uid() << ") attempted to bind " << class_name() << " to port " << requested_local_port;
return KResult(-EACCES);
}
}
@ -232,7 +232,7 @@ ssize_t IPv4Socket::sendto(FileDescription&, const void* data, size_t data_lengt
int nsent = protocol_send(data, data_length);
if (nsent > 0)
current->did_ipv4_socket_write(nsent);
Thread::current->did_ipv4_socket_write(nsent);
return nsent;
}
@ -244,7 +244,7 @@ ssize_t IPv4Socket::receive_byte_buffered(FileDescription& description, void* bu
if (!description.is_blocking())
return -EAGAIN;
auto res = current->block<Thread::ReadBlocker>(description);
auto res = Thread::current->block<Thread::ReadBlocker>(description);
LOCKER(lock());
if (!m_can_read) {
@ -259,7 +259,7 @@ ssize_t IPv4Socket::receive_byte_buffered(FileDescription& description, void* bu
ASSERT(!m_receive_buffer.is_empty());
int nreceived = m_receive_buffer.read((u8*)buffer, buffer_length);
if (nreceived > 0)
current->did_ipv4_socket_read((size_t)nreceived);
Thread::current->did_ipv4_socket_read((size_t)nreceived);
m_can_read = !m_receive_buffer.is_empty();
return nreceived;
@ -293,7 +293,7 @@ ssize_t IPv4Socket::receive_packet_buffered(FileDescription& description, void*
return 0;
}
auto res = current->block<Thread::ReadBlocker>(description);
auto res = Thread::current->block<Thread::ReadBlocker>(description);
LOCKER(lock());
if (!m_can_read) {
@ -351,7 +351,7 @@ ssize_t IPv4Socket::recvfrom(FileDescription& description, void* buffer, size_t
nreceived = receive_packet_buffered(description, buffer, buffer_length, flags, addr, addr_length);
if (nreceived > 0)
current->did_ipv4_socket_read(nreceived);
Thread::current->did_ipv4_socket_read(nreceived);
return nreceived;
}
@ -463,7 +463,7 @@ int IPv4Socket::ioctl(FileDescription&, unsigned request, unsigned arg)
{
REQUIRE_PROMISE(inet);
auto* ifr = (ifreq*)arg;
if (!current->process().validate_read_typed(ifr))
if (!Process::current->validate_read_typed(ifr))
return -EFAULT;
char namebuf[IFNAMSIZ + 1];
@ -475,7 +475,7 @@ int IPv4Socket::ioctl(FileDescription&, unsigned request, unsigned arg)
switch (request) {
case SIOCSIFADDR:
if (!current->process().is_superuser())
if (!Process::current->is_superuser())
return -EPERM;
if (ifr->ifr_addr.sa_family != AF_INET)
return -EAFNOSUPPORT;
@ -483,14 +483,14 @@ int IPv4Socket::ioctl(FileDescription&, unsigned request, unsigned arg)
return 0;
case SIOCGIFADDR:
if (!current->process().validate_write_typed(ifr))
if (!Process::current->validate_write_typed(ifr))
return -EFAULT;
ifr->ifr_addr.sa_family = AF_INET;
((sockaddr_in&)ifr->ifr_addr).sin_addr.s_addr = adapter->ipv4_address().to_u32();
return 0;
case SIOCGIFHWADDR:
if (!current->process().validate_write_typed(ifr))
if (!Process::current->validate_write_typed(ifr))
return -EFAULT;
ifr->ifr_hwaddr.sa_family = AF_INET;
{