kernel: implement /proc/self — symlink to current process
Added /proc/self resolution in open_inner(). When /proc/self is opened, it resolves to /proc/<current-pid> by reading context::current().pid and returning a ProcDir handle. Cross-referenced with Linux 7.1 fs/proc/self.c proc_self_get_link() which creates a symlink inode pointing to the current PID. This enables 'ls /proc/self', 'cat /proc/self/status', and all other tools that use /proc/self to access their own process info.
This commit is contained in:
@@ -534,6 +534,15 @@ impl ProcScheme {
|
||||
token: &mut CleanLockToken,
|
||||
) -> Result<(usize, InternalFlags)> {
|
||||
let operation_name = operation_str.ok_or(Error::new(EINVAL))?;
|
||||
// /proc/self → resolve to /proc/<current-pid>
|
||||
if operation_name == "proc/self" || operation_name == "self" {
|
||||
let pid = context::current().read(token.token()).pid;
|
||||
let handle = Handle {
|
||||
context: context::current(),
|
||||
kind: ContextHandle::ProcDir { pid },
|
||||
};
|
||||
return new_handle((handle, InternalFlags::POSITIONED), token);
|
||||
};
|
||||
if let Some(kind) = Self::proc_open(operation_name) {
|
||||
let handle = Handle {
|
||||
context: context::current(),
|
||||
|
||||
Reference in New Issue
Block a user