In broad strokes, that's exactly what we did in Plan 9, with great results, as was said here a while back. The paper ended with a plea to do the same to Unix, which I think is quite doable. https://9p.io/sys/doc/lexnames.html -rob On Fri, Dec 31, 2021 at 2:09 PM Theodore Ts'o wrote: > On Thu, Dec 30, 2021 at 05:31:09PM -0500, Dan Cross wrote: > > On Thu, Dec 30, 2021 at 11:41 AM Theodore Ts'o wrote: > > > On Wed, Dec 29, 2021 at 10:45:12PM -0500, Noel Chiappa wrote: > > > > > From: Bakul Shah > > > > > > > > > My guess is *not* storing a path instead of a ptr to the inode > was done > > > > > to save on memory. > > > > > > > > More probably speed; those old disks were not fast, and on a PDP-11, > disk > > > > caches were so small that converting the path to the current > directory to its > > > > in memory inode could take a bunch of disk reads. > > > > > > The other problem with storing the path as a string is that if > > > higher-level directories get renamed, the path would become > > > invalidated. If you store the cwd as "/foo/bar/baz/quux", and someone > > > renames "/foo/bar" to "/foo/sadness" the cwd-stored-as-a-string would > > > become invalidated. > > > > Why? Presumably as you traversed the filesystem, you'd cache, (path > > component, inode) pairs and keep a ref on the inode. For any given > > file, including $CWD, you'd know it's pathname from the root as you > > accessed it, but if it got renamed, it wouldn't matter because you'd > > have cached a reference to the inode. > > I was responding to Bakul's suggestion that the original Unix > could/should have stored the cwd as a string, instead of a pointer to > a directory inode. If you stored the cwd as a string, then you could > interpret .. by chopping off the last file name component of the > string, and so now you could have hard links to directories and the > file system tree could then be a file system DAG. > > I don't think Bakul's proposal would have worked --- although I > suppose if you disallowed directory renames, I guess it could. Noel's > objection above was a performance one, in that if you had to parse the > path every single time, you'd be much more dependent on the namei > cache --- and that PDP-11 didn't have the memory to support a > sufficiently large cache. > > - Ted > >