From 104f3121f8005b426d4df77b2420cfe5837033d1 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Mon, 8 Jan 2018 23:00:37 +0100 Subject: Implement /proc//exe by adding proc_set/get_exe to the proc server, making exec call proc_set_exe, and libps call proc_get_exe. procfs can then just retrieve the information to make the "exe" symlink. * hurd/process.defs (proc_set_exe, proc_get_exe): New RPCs. * hurd/process_request.defs: Likewise. * hurd/process_reply.defs: Add skips for proc_set_exe and proc_get_exe RPCs. * proc/proc.h (struct proc): Add `exe' field. * proc/info.c (S_proc_set_exe, S_proc_get_exe): New functions. * proc/mgt.c (process_has_exited): Free p->exe. (S_proc_child): Duplicate parent `exe' into child's `exe'. * exec/exec.c (do_exec): Call proc_set_exe when a filename is available. * libps/ps.h (struct proc_stat): Add `exe_vm_alloced', `exe', and `exe_len' field. (PSTAT_EXE): New macro. (PSTAT_USER_BASE): Change value to make room. (proc_stat_exe, proc_stat_exe_len): New macros. * libps/procstat.c (proc_stat_set_flags): Handle PSTAT_EXE case by calling proc_get_exe. * libps/spec.c (ps_get_exe): New function. (ps_exe_getter): New structure. (ps_fmt_spec): Add "Exe" specification. * procfs/process.c (process_file_symlink_make_node, process_file_gc_exe): New functions. (procfs_dir_entry): Add "exe" entry. * startup/startup.c (launch_core_servers): Set exe paths for startup, auth, proc, and fs servers. (frob_kernel_process): Set exe path for kernel task. (S_startup_essential_task): Set exe path for exec server. --- startup/startup.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'startup') diff --git a/startup/startup.c b/startup/startup.c index 81a67716..9a06f7c2 100644 --- a/startup/startup.c +++ b/startup/startup.c @@ -832,6 +832,7 @@ launch_core_servers (void) assert_perror_backtrace (err); err = proc_mark_exec (procserver); assert_perror_backtrace (err); + proc_set_exe (procserver, "/hurd/startup"); /* Declare that the filesystem and auth are our children. */ err = proc_child (procserver, fstask); @@ -845,6 +846,7 @@ launch_core_servers (void) assert_perror_backtrace (err); err = proc_mark_exec (authproc); assert_perror_backtrace (err); + proc_set_exe (authproc, "/hurd/auth"); err = install_as_translator (); if (err) @@ -883,6 +885,7 @@ launch_core_servers (void) { proc_mark_important (procproc); proc_mark_exec (procproc); + proc_set_exe (procproc, "/hurd/proc"); mach_port_deallocate (mach_task_self (), procproc); } @@ -898,6 +901,7 @@ launch_core_servers (void) assert_perror_backtrace (err); err = proc_mark_exec (fsproc); assert_perror_backtrace (err); + proc_set_exe (fsproc, "fs"); fprintf (stderr, ".\n"); @@ -1045,6 +1049,8 @@ frob_kernel_process (void) err = record_essential_task ("kernel", task); assert_perror_backtrace (err); + proc_set_exe (proc, "kernel"); + err = task_get_bootstrap_port (task, &kbs); assert_perror_backtrace (err); if (kbs == MACH_PORT_NULL) @@ -1455,6 +1461,7 @@ S_startup_essential_task (mach_port_t server, mach_port_t execproc; proc_task2proc (procserver, task, &execproc); proc_mark_important (execproc); + proc_set_exe (execproc, "/hurd/exec"); } else if (!strcmp (name, "proc")) procinit = 1; -- cgit v1.2.3