Web lists-archives.com

Re: A Basic Mount Observation




On Tue, May 07, 2019 at 11:20:57AM -0400, Dan Ritter wrote:
> Martin McCormick wrote: 
> > 	I may just be remembering things the wrong way [...]

[about not immediatlely "seeing" the results of a mount on the CWD]

[...]

> mkdir point
> cd point
> touch original
> ls

[practical demonstration illustrating that]

> This behavior has always been consistent in Linux, as far as I am aware.
> 
> The handle to your current directory cannot be changed out from
> underneath you; only when you move away from it can it be
> released, and from then on you see the new mount.

Makes sense: the current shell (and that is from where we're looking
at things) keeps the current working directory, CWD, open. This inode
doesn't go away after a mount -- thus as long as the shell doesn't
close it (by, e.g., changing to another directory), it will keep
"seeing" that directory, even if a new process doing an open() will
"see" the result after the mount.

You can achieve similarly funny results by removing a file (or directory)
while it's kept open by a process.

Cheers
-- tomás

Attachment: signature.asc
Description: Digital signature