summaryrefslogtreecommitdiff
path: root/src/kernel/proc.h
diff options
context:
space:
mode:
authordzwdz2023-06-04 20:43:51 +0200
committerdzwdz2023-06-04 20:43:51 +0200
commit78cb60b644538a33e0479f25393d6c861e3605f8 (patch)
tree15d310b2bba5cce086633c025080155ca36e7c43 /src/kernel/proc.h
parent8fd4943b2721696f86783d22dd2e8d593a22a766 (diff)
kernel: rework /proc/ and process IDs
I'm yet to write proper docs but the TL;DR is: Mounting /proc/ creates a new pid namespace. You're still visible in the old namespace with your old pid, but your children won't be. You see your own pid as 1. Current pids of children will be preserved, pids will be allocated starting from the highest one of your children.
Diffstat (limited to 'src/kernel/proc.h')
-rw-r--r--src/kernel/proc.h18
1 files changed, 16 insertions, 2 deletions
diff --git a/src/kernel/proc.h b/src/kernel/proc.h
index 8a19d8f..dce99fb 100644
--- a/src/kernel/proc.h
+++ b/src/kernel/proc.h
@@ -69,12 +69,19 @@ struct Proc {
Handle *procfs;
} specialh;
- uint32_t cid; /* child id. unique amongst all of this process' siblings */
- uint32_t nextcid; /* the child id to assign to the next spawned child */
uint32_t globalid; /* only for internal use, don't expose to userland */
uint32_t refcount; /* non-owning. should always be 0 on kill */
bool noreap;
+ /* localid is unique in a process namespace.
+ * if pns == self: the process owns a namespace
+ * the lid it sees is 1
+ * the lid its parent sees is localid
+ * otheriwse: nextlid is unused */
+ Proc *pns;
+ uint32_t localid;
+ uint32_t nextlid;
+
/* allocated once, the requests from WAITS4FS get stored here */
VfsReq *reqslot;
@@ -97,6 +104,13 @@ extern Proc *proc_cur;
Proc *proc_seed(void *data, size_t datalen);
Proc *proc_fork(Proc *parent, int flags);
+bool proc_ns_contains(Proc *ns, Proc *proc);
+uint32_t proc_ns_id(Proc *ns, Proc *proc);
+Proc *proc_ns_byid(Proc *ns, uint32_t id);
+/** Like proc_next, but stays in *ns */
+Proc *proc_ns_next(Proc *ns, Proc *p);
+void proc_ns_create(Proc *proc);
+
void proc_kill(Proc *proc, int ret);
/** Kills all descendants. */
void proc_filicide(Proc *proc, int ret);