[comp.unix.questions] example of general name space usage

gwyn@smoke.BRL.MIL (Doug Gwyn) (10/09/90)

In some newsgroup, probably either this one or comp.std.unix, there has
recently been some debate about the utility of having all objects in a
single uniform name space.  While reading the paper "Plan 9 from Bell
Labs", I came across a marvelous example of why this IS a good idea:
A first draft of the "ps" process on Plan 9 would be just
	cat /proc/*/status
Think about it..

brnstnd@kramden.acf.nyu.edu (Dan Bernstein) (10/09/90)

In article <14060@smoke.BRL.MIL> gwyn@smoke.BRL.MIL (Doug Gwyn) writes:
> In some newsgroup, probably either this one or comp.std.unix, there has
> recently been some debate about the utility of having all objects in a
> single uniform name space.  While reading the paper "Plan 9 from Bell
> Labs", I came across a marvelous example of why this IS a good idea:
> A first draft of the "ps" process on Plan 9 would be just
> 	cat /proc/*/status
> Think about it..

So what? It would be just as easy if /proc were in a separate namespace,
and had a program other than cat to open process files. In fact, one can
easily argue that a fixed, two-level structure would be a much more
natural way to deal with processes. /proc does fit reasonably well into
the filesystem, because processes are static (they don't appear or
disappear until they take explicit action), local, and reliable; but
unreliable, dynamic, remote I/O objects probably don't belong in the
same namespace.

Very few programs actually need open(). The ones that use it become more
flexible when you take away open() and use existing file descriptors,
though you do need one program---I nominate the shell---to deal with
namespaces.

A marvelous example of the flexibility you get by using file descriptors
as the powerful abstraction they are: A recent article in alt.security
mentions an implementation of ACLs under UNIX. Did the implementor have
to change the kernel? No! Did he have to change programs to make them
cooperate with the ACL structure? No! He just had a setuid program do
the dirty work and *pass the file descriptor to your program*.

---Dan

gwyn@smoke.BRL.MIL (Doug Gwyn) (10/09/90)

In article <4932:Oct902:45:5390@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes:
>So what? It would be just as easy if /proc were in a separate namespace,
>and had a program other than cat to open process files.

My point was that no process-specific applications were required.
The shell (/bin/rc) performs the globbing to find out what exists
in the specified subspace, and passes the list to "cat" which
copies the contents of each object in sequence to the standard
output.  This is an example of using standard tools in novel ways,
which is the main reason that UNIX is as useful as it is.  There
is great power in universality.