[RFC,PATCH 1/4] Dynamic Pseudo Root
Neil Brown
neilb at suse.de
Sun Dec 9 23:15:06 EST 2007
On Friday December 7, SteveD at redhat.com wrote:
> +
> + for (i = 0; i < MCL_MAXTYPES; i++) {
> + for (exp = exportlist[i]; exp; exp = nxt) {
> + nxt = exp->m_next;
> + if (strcmp(exp->m_export.e_path, "/"))
> + snprintf(path, BUFSIZ, "%s/%s", _PATH_PSEUDO_ROOT,
> + exp->m_export.e_path);
> + if (!is_mountpoint(path)) {
> + exec_mkpath(path);
> + bind_mount(exp->m_export.e_path, path);
> + }
> + }
> + }
The
if (strcmp(exp->m_export.e_path, "/"))
test is odd, and not just because I find that idiom hard to read (it
is testing if e_path is not "/", but there is no "!" or "!=" in the
test).
If e_path is "/", then path is left uninitialised for the following
code.
And is the "!is_mountpoint" test just to avoid binding the same
filesystem twice?
And there is a case (explicitly mentioned in the RFC I believe) that
this doesn't cover.
If I have 3 filesystems: /a, /a/b and /a/b/c, and I export /a and
/a/b/c, then we need to mount a second tmpfs on /a/b before mkpath("/a/b/c").
This could be done fairly easily if we wrote our own mkpath instead of
using "mkdir -p".
To create a path, keep truncating the name until we find something
that exists. If it is a tmpfs, simply do a mkdir, else do a mount,
then a mkdir.
I suspect you could also get rid of the special case of '/' being
exported.
You don't create an initial 'tmpfs' mounted on .../nfs4root. You only
mount tmpfs on demand.
Then "mkpath" for "/" finds that the directory already exists and
simply does a bind mount of "/" to ".../nfs4root".
If (and only if) the exportpoint is 'crossmnt', you mount with
MS_SLAVE. (Though you would want to double check that this does the
right thing).
> +inline int
> +exec_rmdir(char *dir)
> +{
> + char *const myargv[] = {_RMDIR_CMD, dir, NULL};
> +
> + return execute_cmd(_RMDIR_CMD, myargv);
> +}
what is wrong with calling rmdir(dir) directly?
NeilBrown
More information about the NFSv4
mailing list