Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!barmar From: barmar@think.com (Barry Margolin) Newsgroups: comp.unix.internals Subject: Re: Slashes in file names Message-ID: <1991Feb13.070247.25878@Think.COM> Date: 13 Feb 91 07:02:47 GMT References: <2135@m1.cs.man.ac.uk> Sender: news@Think.COM Organization: Thinking Machines Corporation, Cambridge MA, USA Lines: 41 In article <2135@m1.cs.man.ac.uk> dente@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@think.com {uunet,harvard}!think!barmar