Re: [RFC] File flags handling - proposal for API.

Alexander Viro (viro@math.psu.edu)
Fri, 25 Jun 1999 22:40:36 -0400 (EDT)


On Fri, 25 Jun 1999, Linus Torvalds wrote:

> For example, I would _like_ to have something like this:
>
> PATH=~/bin:$PATH
>
> and then in my bin directory I'd have my own binaries, some of them with
> their own configuration files. For example, it could look like this:
>
> ~/bin/netscape
> default -> /usr/local/bin/netscape
> cache/
> config
> cookies/
>
> and when somebody executes ~/bin/netscape (which is a directory with a
> shorthand - the shorthand just happens to be _another_ shorthand, namely a
> symlink), they actually end up _executing_ /usr/local/bin/netscape through
> the shorthands, and netscape could be taught to look at argv[0] as the
> location for it's own config files.
>
> So then I could have two versions of netscape, each with its own
> configuration and cache, and there would be no clashes due to both trying
> to populate my home directory. More importantly, I wouldn't ever even have
> to _see_ the files, except if I went out searching.

Hrrrmmm... There is a neat alternative giving almost the same effect.
And possible on every fs. I *am* going to try it anyway, and if it will
not suck too hard I'ld like to submit it when the things will get stable
enough.

Description:
a) some dentries are marked as bindings-bearing.
b) binding is a pair of dentries + ID.
c) each process has an associated ID. They are inherited over
fork(). clone() can be used to create a new one.
d) when you create a new ID all bindings with the ID of parent are
cloned and clones get the new ID.
e) when lookup gets to binding-bearing dentry it makes a lookup in
bindings cache by (ID, first dentry). And returns the second dentry.
f) user can add/remove a binding provided that he owns the "from"
object.
g) new utility - add/remove binding.
h) new utility - fork, creating a new ID, do bindings and exec the
given command.

Look how it can work: your ~/bin/netscape is a script saying
(I don't use netscape, so names of config files are made up - sorry)

#!/bin/sh
DIR = ~/foo/bar/baz
exec new_namespace "/usr/local/bin/netscape" \
~/.netscaperc $DIR/netscaperc1 \
~/.netscapedir $DIR/foo \
/tmp/.netscape-cache-linus $DIR/bar

... and there you go. Notice that all processes launched by the resulting
netscape will see the namespace as if we had a corresponding bunch of
symlinks. But everything else would see the normal (or screwed in their
own way) namespace. No need to touch netscape, rewrite it, whatever.
Doesn't depend on any environment variables. Moreover, since login is
suid-root it *can* fork-with-new-namespace and bind ~/<something> on /tmp
before dropping EUID 0. Settings can be taken from /etc/bindings which
would look so:

linus:/tmp:~/tmp:/var/spool/mail:/export/server42/mail:

There are evaluated symlinks for you ;-) And it can be done fairly fast.
Completely on VFS level. Atop of any filesystem. I'm going to try it.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/