Slashes in file names

Barry Margolin barmar at think.com
Wed Feb 13 18:02:47 AEST 1991


In article <2135 at m1.cs.man.ac.uk> dente at els.ee.man.ac.uk (Colin Dente) writes:
>Forgive my ignorance in all this, but how *does* nfs create these
>files with slashes in their names?  It seems rather strange that nfs
>doesn't go through the kernel to do it (and hence get pulled up short
>by namei() etc.)  Perhaps this should go to comp.nfs.clueless, but I
>really don't understand!

It's a fair question about a non-obvious point, don't sell yourself short.

Unix NFS servers are generally implemented *in* the kernel, not as
user-mode processes that make system calls (the nfsd(8) command forks the
specified number of processes, and then they all simply make a
non-returning system call that starts up a server in the kernel).  This
permits them to use inode numbers in file handles, and then access the
files using the extracted inode information.  Since it accesses files and
directories directly, it doesn't go through namei().  Note that the NFS
protocol never passes pathnames from the client to the server (except for
the target of a symbolic link, but it's treated as an arbitrary string by
the NFS server); it is the client's job to parse pathnames and make
separate calls to look up the name at each level of the directory
hierarchy.  For instance, a Unix client with the directory /mnt
NFS-mounted, would perform the following calls when asked to create
/mnt/foo/bar/baz:

	foo_handle = NFS_Lookup(mnt_handle, "foo");
	foo_stat = NFS_Stat(foo_handle);
	if (foo_stat.type != DIRECTORY) error();
	bar_handle = NFS_Lookup(foo_handle, "bar");
	bar_stat = NFS_Stat(bar_handle);
	if (bar_stat.type != DIRECTORY) error();
	NFS_Create (bar_handle, "baz");

Since only file names, not pathnames, are ever passed, the server never
calls namei() to parse the arguments.


--
Barry Margolin, Thinking Machines Corp.

barmar at think.com
{uunet,harvard}!think!barmar



More information about the Comp.unix.internals mailing list