“find: .: No such file or directory” while using find on the current directory

find

Find command seems not to work at all. For example, I'm in a directory where there absolutely is file named index.php and I execute this:

[root@server htdocs]# find . -name "index.php"
find: .: No such file or directory

I always get this no such file or directory error.

No matter what path I define, or what file I search for, I always get this error. I'm pretty sure that I'm overlooking something very simple. Can someone point out what I'm doing wrong?

[root@server htdocs]# pwd
/srv/www/htdocs
[root@server htdocs]# type -a find
find is /usr/bin/find
[root@server htdocs]# ls -la | grep index.php
-rw-rw-r--  1 andris users  413 Sep  1  2013 index.php
[root@server htdocs]# find . -name "index.php"
find: .: No such file or directory
[root@server htdocs]# find .
.
find: .: No such file or directory

[root@server htdocs]# stat .
  File: `.'
  Size: 4096            Blocks: 8          IO Block: 4096   directory
Device: ca00h/51712d    Inode: 155686      Links: 12
Access: (0775/drwxrwxr-x)  Uid: (  504/  andris)   Gid: (  100/   users)
Access: 2014-06-17 19:37:22.000000000 +0000
Modify: 2014-06-08 21:06:16.000000000 +0000
Change: 2014-06-08 21:06:16.000000000 +0000

[root@server htdocs]# find --version
GNU find version 4.2.27
Features enabled: D_TYPE O_NOFOLLOW(enabled) LEAF_OPTIMISATION SELINUX

strace find . output: https://gist.github.com/andrisp/f3adaf740548eead33da

[root@server htdocs]# find . -noleaf -name "index.php"
find: .: No such file or directory

Best Answer

According to your strace output, and I have no idea about the reason, the open() function prefix filenames with /proc/ :

open(".", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = 4
fcntl64(4, F_SETFD, FD_CLOEXEC) = 0
getdents64(4, /* 21 entries */, 32768) = 664
getgid32() = 0
stat64("/proc/index.php", 0xbfc53bd0) = -1 ENOENT (No such file or directory)
getgid32() = 0
stat64("/proc/.svn", 0xbfc53bd0) = -1 ENOENT (No such file or directory)
getgid32() = 0
stat64("/proc/init-dist.php", 0xbfc53bd0) = -1 ENOENT (No such file or directory)
getgid32() = 0
stat64("/proc/landing-page.html", 0xbfc53bd0) = -1 ENOENT (No such file or directory)
getgid32() = 0
[...]
stat64("/proc/js", 0xbfc53bd0) = -1 ENOENT (No such file or directory)
getgid32() = 0
stat64("/proc/extras", 0xbfc53bd0) = -1 ENOENT (No such file or directory)
getgid32() = 0
stat64("/proc/sitemaps", 0xbfc53bd0) = -1 ENOENT (No such file or directory)
getdents64(4, /* 0 entries */, 32768) = 0
Related Question