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

Kernel: Customize absolute_path() for more file types

This commit is contained in:
Sergey Bugaev 2019-08-10 19:10:36 +03:00 committed by Andreas Kling
parent 1d03391488
commit dadf6337ef
7 changed files with 91 additions and 15 deletions

View file

@ -254,3 +254,29 @@ StringView LocalSocket::socket_path() const
int len = strnlen(m_address.sun_path, sizeof(m_address.sun_path));
return { m_address.sun_path, len };
}
String LocalSocket::absolute_path(const FileDescription& description) const
{
StringBuilder builder;
builder.append("socket:");
builder.append(socket_path());
switch (role(description)) {
case Role::Listener:
builder.append(" (listening)");
break;
case Role::Accepted:
builder.appendf(" (accepted from pid %d)", origin_pid());
break;
case Role::Connected:
builder.appendf(" (connected to pid %d)", acceptor_pid());
break;
case Role::Connecting:
builder.append(" (connecting)");
break;
default:
break;
}
return builder.to_string();
}