aboutsummaryrefslogtreecommitdiff
path: root/libps/ps.h
diff options
context:
space:
mode:
authorSamuel Thibault <samuel.thibault@ens-lyon.org>2018-01-08 23:00:37 +0100
committerSamuel Thibault <samuel.thibault@ens-lyon.org>2018-01-08 23:00:37 +0100
commit104f3121f8005b426d4df77b2420cfe5837033d1 (patch)
tree34bb93d3796e7c45dc1c67a5d40fb3bd1604ad9f /libps/ps.h
parent9d3ba19ddc56ad929f673af23eb87ab07ae30631 (diff)
downloadhurd-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/ps.h')
-rw-r--r--libps/ps.h11
1 files changed, 10 insertions, 1 deletions
diff --git a/libps/ps.h b/libps/ps.h
index 3ee142d0..2725b1f4 100644
--- a/libps/ps.h
+++ b/libps/ps.h
@@ -272,6 +272,7 @@ struct proc_stat
unsigned thread_waits_vm_alloced : 1;
unsigned args_vm_alloced : 1;
unsigned env_vm_alloced : 1;
+ unsigned exe_vm_alloced : 1;
/* Various libc ports: */
@@ -305,6 +306,11 @@ struct proc_stat
size_t env_len;
unsigned num_ports;
+
+ /* The path to process's binary executable. */
+ char *exe;
+ /* The length of EXE. */
+ size_t exe_len;
};
/* Proc_stat flag bits; each bit is set in the FLAGS field if that
@@ -344,12 +350,13 @@ struct proc_stat
#define PSTAT_HOOK 0x800000 /* Has a non-zero hook */
#define PSTAT_NUM_PORTS 0x4000000 /* Number of Mach ports in the task */
#define PSTAT_TIMES 0x8000000 /* Task/thread user and system times */
+#define PSTAT_EXE 0x10000000 /* Path to binary executable */
/* Flag bits that don't correspond precisely to any field. */
#define PSTAT_NO_MSGPORT 0x1000000 /* Don't use the msgport at all */
/* Bits from PSTAT_USER_BASE on up are available for user-use. */
-#define PSTAT_USER_BASE 0x10000000
+#define PSTAT_USER_BASE 0x20000000
#define PSTAT_USER_MASK ~(PSTAT_USER_BASE - 1)
/* If the PSTAT_STATE flag is set, then the proc_stats state field holds a
@@ -448,6 +455,8 @@ extern char *proc_stat_state_tags;
#define proc_stat_tty(ps) ((ps)->tty)
#define proc_stat_task_events_info(ps) ((ps)->task_events_info)
#define proc_stat_num_ports(ps) ((ps)->num_ports)
+#define proc_stat_exe(ps) ((ps)->exe)
+#define proc_stat_exe_len(ps) ((ps)->exe_len)
#define proc_stat_has(ps, needs) (((ps)->flags & needs) == needs)
/* True if PS refers to a thread and not a process. */