summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Kernel/FileDescriptor.cpp16
-rw-r--r--Kernel/Process.cpp1
-rw-r--r--Kernel/Socket.h2
3 files changed, 17 insertions, 2 deletions
diff --git a/Kernel/FileDescriptor.cpp b/Kernel/FileDescriptor.cpp
index a7498832f3..53560b0e8b 100644
--- a/Kernel/FileDescriptor.cpp
+++ b/Kernel/FileDescriptor.cpp
@@ -318,6 +318,20 @@ int FileDescriptor::close()
return 0;
}
+const char* to_string(SocketRole role)
+{
+ switch (role) {
+ case SocketRole::Listener:
+ return "Listener";
+ case SocketRole::Accepted:
+ return "Accepted";
+ case SocketRole::Connected:
+ return "Connected";
+ default:
+ return "None";
+ }
+}
+
String FileDescriptor::absolute_path()
{
Stopwatch sw("absolute_path");
@@ -328,7 +342,7 @@ String FileDescriptor::absolute_path()
if (is_device())
return String::format("device:%u,%u (%s)", m_device->major(), m_device->minor(), m_device->class_name());
if (is_socket())
- return String::format("socket:%x (role: %u)", m_socket.ptr(), m_socket_role);
+ return String::format("socket:%x (role: %s)", m_socket.ptr(), to_string(m_socket_role));
ASSERT(m_inode);
return VFS::the().absolute_path(*m_inode);
}
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index e5f7e2db5a..69c407289e 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -2267,6 +2267,7 @@ int Process::sys$listen(int sockfd, int backlog)
int error;
if (!socket.listen(backlog, error))
return error;
+ descriptor->set_socket_role(SocketRole::Listener);
return 0;
}
diff --git a/Kernel/Socket.h b/Kernel/Socket.h
index 0f5f5d11a5..285db684e0 100644
--- a/Kernel/Socket.h
+++ b/Kernel/Socket.h
@@ -7,7 +7,7 @@
#include <AK/Vector.h>
#include <Kernel/UnixTypes.h>
-enum class SocketRole { None, Accepted, Connected };
+enum class SocketRole { None, Listener, Accepted, Connected };
class Socket : public Retainable<Socket> {
public: