lkml.org 
[lkml]   [1999]   [Sep]   [15]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Inconsistent directory information
Hy ;)

> 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 ran the
> commands:
>
> mount .
> ls
>
> which is to say I mounted a directory over my CWD and then tried to list
> the contents of my CWD. What I get is:
>
> 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
>
> All these files are in the directory that was mounted on top of the CWD.
> It looks like some system call is looking at the new directory and some
> system call is looking at the old directory.
>
> Interestingly if I run "strace ls" then ls sees all the files in the new
> directory.
>
> Like I said I dont think this is a bug, but it is kind of wierd.

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='ls --color=yes'
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.

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 "."...

If I'm wrong, please correct me...

Florian Heinz

-
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/

\
 
 \ /
  Last update: 2005-03-22 13:54    [W:0.612 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site