Re: Inconsistent directory information

Tim Walberg (twalberg@terabridge.com)
Wed, 15 Sep 1999 10:35:56 -0500


--pkBzO0lo80FoaZii
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable

"Doctor, it hurts when I..."

"Well, if it hurts, then don't..."

Honestly, I don't know of any *NIX that handles a case like
this entirely gracefully - you've got information on the
current directory and probably the inodes and files in
that directory cached in memory, then you do something
that completely invalidates what the cache says...
Arguably, the kernel maybe should flush any cached information
for all files/directories under a mount point before the
mount is accomplished, but that doesn't even resolve
the whole issue - you've still got the current directory
"open". I think the best option is probably for mount
to **not** succeed if the mount point directory or
any subdirectories or files are open. Probably fairly
expensive to determine, though...

tw

On 09/15/1999 10:49 +0200, Florian Heinz wrote:
>> Hy ;)
>>=09
>> > Hello All,
>> > I found a linux quirk I thought I would mention. I dont think it =
really
>> > hurts anything, but its kind of wierd. I went to a mount point and ra=
n the
>> > commands:
>> >=20
>> > mount .
>> > ls
>> >=20
>> > which is to say I mounted a directory over my CWD and then tried to li=
st
>> > the contents of my CWD. What I get is:
>> >=20
>> > ls: lost+found: No such file or directory
>> > ls: configfile: No such file or directory
>> > ls: buildLibs.sh: No such file or directory
>> > ls: buildLizzard.sh: No such file or directory
>> > ls: runLizzard.sh: No such file or directory
>> > ls: gdbscript: No such file or directory
>> > ls: prefix: No such file or directory
>> > ls: mozbuild: No such file or directory
>> >=20
>> > All these files are in the directory that was mounted on top of the CW=
D.
>> > It looks like some system call is looking at the new directory and some
>> > system call is looking at the old directory.
>> >=20
>> > Interestingly if I run "strace ls" then ls sees all the files in the n=
ew
>> > directory.
>> >=20
>> > Like I said I dont think this is a bug, but it is kind of wierd.
>>=09
>> I think, the problem is, that ls opens "." in the current directory and
>> reads the direntries from "."
>> But the directory "." is in this case different from the cwd, because it
>> refers to the filesystgem just mounted! So ls gets the names of the
>> files in the directory which was just mounted and not the names of the
>> files in cwd.
>> The reason why "ls" says "No such file or directory" is, if you want to
>> have the output colored (you probably have an alias ls=3D'ls --color=3Dy=
es'
>> or sth.), ls makes an "lstat"-syscall for each filename. But this time,
>> lstat searches in cwd (which, as we know, isn't the same as ".", where
>> the filenames were taken from), cannot find the entry and returns
>> -ENOENT.
>>=09
>> The reason why it worked with "strace" is, that strace doesn't use your
>> alias and so ls-output isn't colored, ls doesn't lstat the files it read
>> from "."...
>>=09
>> If I'm wrong, please correct me...
>>=09
>> Florian Heinz
>>=09
>> -
>> To unsubscribe from this list: send the line "unsubscribe linux-kernel" =
in
>> the body of a message to majordomo@vger.rutgers.edu
>> Please read the FAQ at http://www.tux.org/lkml/
End of included message

--=20
+------------------------------+--------------------------+
| Tim Walberg | Phone: 847-782-2472 |
| TERAbridge Technologies Corp | FAX: 847-623-1717 |
| 1375 Tri-State Parkway | twalberg@terabridge.com |
| Gurnee, IL 60031 | 800-SKY-TEL2 PIN 9353299 |
+------------------------------+--------------------------+

--pkBzO0lo80FoaZii
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: PGPfreeware 5.0i for non-commercial use
MessageID: unqgsi4mWjOdqu+KTUxO/dNNQPH1M6FI

iQA/AwUBN9+83MPlnI9tqyVmEQLdeQCgpAp0spJ2ebUJDxI0o3HZ6edyZgwAnjq2
5X+lnrGRM1zYvYxuJ0RIAzjW
=KDlh
-----END PGP SIGNATURE-----

--pkBzO0lo80FoaZii--

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/