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:
parent
4f4af24b9d
commit
48f7c28a5c
37 changed files with 257 additions and 252 deletions
|
@ -63,12 +63,12 @@ LocalSocket::LocalSocket(int type)
|
|||
LOCKER(all_sockets().lock());
|
||||
all_sockets().resource().append(this);
|
||||
|
||||
m_prebind_uid = current->process().uid();
|
||||
m_prebind_gid = current->process().gid();
|
||||
m_prebind_uid = Process::current->uid();
|
||||
m_prebind_gid = Process::current->gid();
|
||||
m_prebind_mode = 0666;
|
||||
|
||||
#ifdef DEBUG_LOCAL_SOCKET
|
||||
kprintf("%s(%u) LocalSocket{%p} created with type=%u\n", current->process().name().characters(), current->pid(), this, type);
|
||||
kprintf("%s(%u) LocalSocket{%p} created with type=%u\n", Process::current->name().characters(), Process::current->pid(), this, type);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
@ -105,12 +105,12 @@ KResult LocalSocket::bind(const sockaddr* user_address, socklen_t address_size)
|
|||
auto path = String(address.sun_path, strnlen(address.sun_path, sizeof(address.sun_path)));
|
||||
|
||||
#ifdef DEBUG_LOCAL_SOCKET
|
||||
kprintf("%s(%u) LocalSocket{%p} bind(%s)\n", current->process().name().characters(), current->pid(), this, safe_address);
|
||||
kprintf("%s(%u) LocalSocket{%p} bind(%s)\n", Process::current->name().characters(), Process::current->pid(), this, safe_address);
|
||||
#endif
|
||||
|
||||
mode_t mode = S_IFSOCK | (m_prebind_mode & 04777);
|
||||
UidAndGid owner { m_prebind_uid, m_prebind_gid };
|
||||
auto result = VFS::the().open(path, O_CREAT | O_EXCL | O_NOFOLLOW_NOERROR, mode, current->process().current_directory(), owner);
|
||||
auto result = VFS::the().open(path, O_CREAT | O_EXCL | O_NOFOLLOW_NOERROR, mode, Process::current->current_directory(), owner);
|
||||
if (result.is_error()) {
|
||||
if (result.error() == -EEXIST)
|
||||
return KResult(-EADDRINUSE);
|
||||
|
@ -145,10 +145,10 @@ KResult LocalSocket::connect(FileDescription& description, const sockaddr* addre
|
|||
memcpy(safe_address, local_address.sun_path, sizeof(local_address.sun_path));
|
||||
|
||||
#ifdef DEBUG_LOCAL_SOCKET
|
||||
kprintf("%s(%u) LocalSocket{%p} connect(%s)\n", current->process().name().characters(), current->pid(), this, safe_address);
|
||||
kprintf("%s(%u) LocalSocket{%p} connect(%s)\n", Process::current->name().characters(), Process::current->pid(), this, safe_address);
|
||||
#endif
|
||||
|
||||
auto description_or_error = VFS::the().open(safe_address, O_RDWR, 0, current->process().current_directory());
|
||||
auto description_or_error = VFS::the().open(safe_address, O_RDWR, 0, Process::current->current_directory());
|
||||
if (description_or_error.is_error())
|
||||
return KResult(-ECONNREFUSED);
|
||||
|
||||
|
@ -175,13 +175,13 @@ KResult LocalSocket::connect(FileDescription& description, const sockaddr* addre
|
|||
return KSuccess;
|
||||
}
|
||||
|
||||
if (current->block<Thread::ConnectBlocker>(description) != Thread::BlockResult::WokeNormally) {
|
||||
if (Thread::current->block<Thread::ConnectBlocker>(description) != Thread::BlockResult::WokeNormally) {
|
||||
m_connect_side_role = Role::None;
|
||||
return KResult(-EINTR);
|
||||
}
|
||||
|
||||
#ifdef DEBUG_LOCAL_SOCKET
|
||||
kprintf("%s(%u) LocalSocket{%p} connect(%s) status is %s\n", current->process().name().characters(), current->pid(), this, safe_address, to_string(setup_state()));
|
||||
kprintf("%s(%u) LocalSocket{%p} connect(%s) status is %s\n", Process::current->name().characters(), Process::current->pid(), this, safe_address, to_string(setup_state()));
|
||||
#endif
|
||||
|
||||
if (!is_connected()) {
|
||||
|
@ -265,7 +265,7 @@ ssize_t LocalSocket::sendto(FileDescription& description, const void* data, size
|
|||
return -EPIPE;
|
||||
ssize_t nwritten = send_buffer_for(description).write((const u8*)data, data_size);
|
||||
if (nwritten > 0)
|
||||
current->did_unix_socket_write(nwritten);
|
||||
Thread::current->did_unix_socket_write(nwritten);
|
||||
return nwritten;
|
||||
}
|
||||
|
||||
|
@ -299,7 +299,7 @@ ssize_t LocalSocket::recvfrom(FileDescription& description, void* buffer, size_t
|
|||
return -EAGAIN;
|
||||
}
|
||||
} else if (!can_read(description)) {
|
||||
auto result = current->block<Thread::ReadBlocker>(description);
|
||||
auto result = Thread::current->block<Thread::ReadBlocker>(description);
|
||||
if (result != Thread::BlockResult::WokeNormally)
|
||||
return -EINTR;
|
||||
}
|
||||
|
@ -308,7 +308,7 @@ ssize_t LocalSocket::recvfrom(FileDescription& description, void* buffer, size_t
|
|||
ASSERT(!buffer_for_me.is_empty());
|
||||
int nread = buffer_for_me.read((u8*)buffer, buffer_size);
|
||||
if (nread > 0)
|
||||
current->did_unix_socket_read(nread);
|
||||
Thread::current->did_unix_socket_read(nread);
|
||||
return nread;
|
||||
}
|
||||
|
||||
|
@ -389,7 +389,7 @@ KResult LocalSocket::chown(uid_t uid, gid_t gid)
|
|||
if (m_file)
|
||||
return m_file->chown(uid, gid);
|
||||
|
||||
if (!current->process().is_superuser() && (current->process().euid() != uid || !current->process().in_group(gid)))
|
||||
if (!Process::current->is_superuser() && (Process::current->euid() != uid || !Process::current->in_group(gid)))
|
||||
return KResult(-EPERM);
|
||||
|
||||
m_prebind_uid = uid;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue