diff options
author | Andreas Kling <awesomekling@gmail.com> | 2020-01-10 23:48:44 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2020-01-10 23:48:44 +0100 |
commit | 29b3d95004471578e915f1feee892288b18606f3 (patch) | |
tree | 6a49e4dcd8a10ce3af0729855e58c138a451ba4a /Kernel/FileSystem | |
parent | 3f9e4cd24e89c13018947fc967d1801b17c0ec3f (diff) | |
download | serenity-29b3d95004471578e915f1feee892288b18606f3.zip |
Kernel: Expose a process's filesystem root as a /proc/PID/root symlink
In order to preserve the absolute path of the process root, we save the
custody used by chroot() before stripping it to become the new "/".
There's probably a better way to do this.
Diffstat (limited to 'Kernel/FileSystem')
-rw-r--r-- | Kernel/FileSystem/ProcFS.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Kernel/FileSystem/ProcFS.cpp b/Kernel/FileSystem/ProcFS.cpp index ef4eeb0717..4a5c2c7130 100644 --- a/Kernel/FileSystem/ProcFS.cpp +++ b/Kernel/FileSystem/ProcFS.cpp @@ -80,6 +80,7 @@ enum ProcFileType { FI_PID_fds, FI_PID_exe, // symlink FI_PID_cwd, // symlink + FI_PID_root, // symlink FI_PID_fd, // directory __FI_PID_End, @@ -571,6 +572,14 @@ Optional<KBuffer> procfs$pid_cwd(InodeIdentifier identifier) return handle->process().current_directory().absolute_path().to_byte_buffer(); } +Optional<KBuffer> procfs$pid_root(InodeIdentifier identifier) +{ + auto handle = ProcessInspectionHandle::from_pid(to_pid(identifier)); + if (!handle) + return {}; + return handle->process().root_directory_for_procfs().absolute_path().to_byte_buffer(); +} + Optional<KBuffer> procfs$self(InodeIdentifier) { char buffer[16]; @@ -1030,6 +1039,7 @@ InodeMetadata ProcFSInode::metadata() const break; case FI_PID_cwd: case FI_PID_exe: + case FI_PID_root: metadata.mode = 0120400; break; case FI_Root: @@ -1408,6 +1418,7 @@ ProcFS::ProcFS() m_entries[FI_PID_fds] = { "fds", FI_PID_fds, false, procfs$pid_fds }; m_entries[FI_PID_exe] = { "exe", FI_PID_exe, false, procfs$pid_exe }; m_entries[FI_PID_cwd] = { "cwd", FI_PID_cwd, false, procfs$pid_cwd }; + m_entries[FI_PID_root] = { "root", FI_PID_root, false, procfs$pid_root }; m_entries[FI_PID_fd] = { "fd", FI_PID_fd, false }; } |