Advanced Namespace Tools blog
14 February 2017
Design for Independent /srv Namespaces
After a few years of pikeshedding discussions, I'm finally going to make an attempt to add multiple independent /srv namespaces to ANTS. There are two basic motivations, one technical, one social.
- For running multiple independent environments simultaneously, it is convenient if the standard names in /srv are available to each without collision.
- Several of the people who have expressed interest in ANTS have asked about this feature
Once the feature is added, I expect the majority reaction will be "I said it's a dumb idea all along", with a minority opinion of "cool idea, but I think it should have been implemented differently." This is reasonable and to be expected.
Design for /srv Namespaces
Several different ideas for how this should work have been discussed. One idea, not identical but related, is having separate subdirectories within srv. Another idea is providing an attach specifier to the mount of srv. I'm going with something different: I'm copying the design of /env.
The main motivation for this is consistency. Plan 9, almost above all else, attempts to be internally consistent. As much as possible, the same mechanisms and interfaces should be reused whenever possible. Because of the precedent of the existing design of /env, I felt like it made the most sense to copy it as much as possible.
So: the plan is to add a new flag to rfork, to provide the option of receiving a new clean copy of a /srv device. I don't think there should be an option to receive a new copy of the parent srv, because unlike environment variables, the chans connected to files in /srv cannot be duplicated.
Implementation Plan
I believe this modification will require changes to the following five files:
- /sys/src/9/port/devsrv.c : to make all the routines refer to a srv chosen from the user process srvgroup.
- /sys/src/9/port/proc.c : to add initialization/teardown of the srvgroup data.
- /sys/srv/9/port/sysproc.c : to add the necessary flag to rfork and create the usable srvgroup data.
- /sys/src/9/port/portdat.h : to add the srvgroup to the Proc structure.
- /sys/src/9/port/portfns.h : to make the closesgrp() function available.
Changes to make use of the modification in userspace should be limited to:
- /sys/include/libc.h : to add the new rfork flag.
- /sys/src/cmd/rc/plan9.c : to add an equivalent new rfork flag.
The goal is to make the minimal changes necessary, following the template of how envgrp is handled as much as possible.