diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-01-08 23:00:37 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2018-01-08 23:00:37 +0100 |
commit | 104f3121f8005b426d4df77b2420cfe5837033d1 (patch) | |
tree | 34bb93d3796e7c45dc1c67a5d40fb3bd1604ad9f /libps/spec.c | |
parent | 9d3ba19ddc56ad929f673af23eb87ab07ae30631 (diff) | |
download | hurd-104f3121f8005b426d4df77b2420cfe5837033d1.tar.gz hurd-104f3121f8005b426d4df77b2420cfe5837033d1.tar.bz2 hurd-104f3121f8005b426d4df77b2420cfe5837033d1.zip |
Implement /proc/<pid>/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.
Diffstat (limited to 'libps/spec.c')
-rw-r--r-- | libps/spec.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/libps/spec.c b/libps/spec.c index 5e540f87..4760c431 100644 --- a/libps/spec.c +++ b/libps/spec.c @@ -358,6 +358,14 @@ ps_get_num_ports (struct proc_stat *ps) const struct ps_getter ps_num_ports_getter = {"num_ports", PSTAT_NUM_PORTS, (vf) ps_get_num_ports}; +static void +ps_get_exe (struct proc_stat *ps, char **exe_p, int *exe_len_p) +{ + *exe_p = proc_stat_exe (ps); + *exe_len_p = proc_stat_exe_len (ps); +} +const struct ps_getter ps_exe_getter = +{"exe", PSTAT_EXE, ps_get_exe}; /* ---------------------------------------------------------------- */ /* some printing functions */ @@ -1166,6 +1174,8 @@ static const struct ps_fmt_spec specs[] = &ps_zero_fills_getter, ps_emit_int, ps_cmp_ints, ps_nominal_zint}, {"Ports", 0, -5, -1, 0, &ps_num_ports_getter, ps_emit_int, ps_cmp_ints, 0}, + {"Exe", 0, 0, -1, 0, + &ps_exe_getter, ps_emit_string, ps_cmp_strings,ps_nominal_string}, {0} }; |