[TUHS] moving directories in svr2

Bakul Shah bakul at iitbombay.org
Fri Dec 31 15:12:26 AEST 2021



> On Dec 30, 2021, at 7:08 PM, Theodore Ts'o <tytso at mit.edu> 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 <tytso at mit.edu> 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.  

Note that this is already broken!

$ mkdir -p ~/a/b; cd ~/a/b; mv ~/a /tmp # /tmp is on a diff filesystem
$ cd ..
cd: no such file or directory: .. 

At least with the change[1] I was talking about, cd .. would not be
an error! At least with this change the behavior is more consistent!

Now if you want bug for bug compatibility then yes, you can't make any
changes but usually it is more a cost/benefit tradeoff as far as any
breaking changes are concerned. NFS broke a few things for example
and most of us put up with that.

[1] cwd as string, not allowing multiple links to a dir. I speculated
about the latter but any benefit is not worth the cost.
not worth it.





More information about the TUHS mailing list