summaryrefslogtreecommitdiff
path: root/Kernel
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2019-02-03 04:54:52 +0100
committerAndreas Kling <awesomekling@gmail.com>2019-02-03 04:54:52 +0100
commite895d6c48e9ee0c7ed78942a1f17fd4840a055a9 (patch)
treecef684e1bb0ad6109d35cba5d98d6f1677d33710 /Kernel
parentc2adfd0e2d1c7036cec0bc841af3d8e907693520 (diff)
downloadserenity-e895d6c48e9ee0c7ed78942a1f17fd4840a055a9.zip
Kernel: Add /proc/self, a symlink to the /proc/$PID.
This will be useful for implementing things like /dev/stdin.
Diffstat (limited to 'Kernel')
-rw-r--r--Kernel/ProcFileSystem.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/Kernel/ProcFileSystem.cpp b/Kernel/ProcFileSystem.cpp
index 3030efa29e..5db983fc29 100644
--- a/Kernel/ProcFileSystem.cpp
+++ b/Kernel/ProcFileSystem.cpp
@@ -150,6 +150,13 @@ ByteBuffer procfs$pid_cwd(Process& process)
return VFS::the().absolute_path(*inode).to_byte_buffer();
}
+ByteBuffer procfs$self(SynthFSInode&)
+{
+ char buffer[16];
+ ksprintf(buffer, "%u", current->pid());
+ return ByteBuffer::copy((const byte*)buffer, strlen(buffer));
+}
+
void ProcFS::add_process(Process& process)
{
InterruptDisabler disabler;
@@ -400,6 +407,7 @@ bool ProcFS::initialize()
add_file(create_generated_file("cpuinfo", procfs$cpuinfo));
add_file(create_generated_file("inodes", procfs$inodes));
add_file(create_generated_file("dmesg", procfs$dmesg));
+ add_file(create_generated_file("self", procfs$self, 00120777));
m_sys_dir = add_file(create_directory("sys"));
return true;
}