|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #51404 is_dir() returns false on cifs mounted share
Submitted: 2010-03-26 20:34 UTC Modified: 2010-06-08 14:33 UTC
From: neversaynever at tut dot by Assigned:
Status: Not a bug Package: Directory function related
PHP Version: Irrelevant OS: Linux
Private report: No CVE-ID: None
 [2010-03-26 20:34 UTC] neversaynever at tut dot by
I upgraded my kernel to 2.6.31 (stable) and has php-5.2.12 (stable), but
php function is_dir() returns false for folder on my cifs mounted share.

strace php -r 'var_dump(is_dir("/path_to_mounted_folder/"));'

stat64("/path_to_mounted_folder/", {st_mode=S_IFDIR|0755, st_size=32768, ...}) = 0 
gettimeofday({1269602972, 30466}, NULL) = 0
write(1, "bool(false)\n", 12bool(false)
)           = 12

Test script:
php -r 'var_dump(is_dir("/path_to_mounted_folder/"));'

Expected result:

Actual result:


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2010-06-08 14:33 UTC]
-Status: Open +Status: Bogus
 [2010-06-08 14:33 UTC]
I'm sure PHP doesn't affect any of system functions, including stat().
You get what your stat() returns -> not PHP problem.
 [2010-06-09 20:06 UTC] digitalaudiorock at gmail dot com
I have to agree with the original poster.  Running php 5.2.13 Under Gentoo I have problems with is_dir() on CIFS shares with 2.6.31 and 2.6.32.  On a machine I have running 2.6.30 I don't see the issue.  Here's a CIFS mounted directory that reports is_dir() as false even though chdir() reports true:

php -r 'var_dump(is_dir("/home/tom/mount/sql"));'

php -r 'var_dump(chdir("/home/tom/mount/sql"));'

Here's the equivalent in perl that reports true:

perl -e '(-d "/home/tom/mount/sql") && print "OK\n"'

ls -ald /home/tom/mount/sql
drwxr-xr-x 1 tom tom 0 Apr 28  2008 /home/tom/mount/sql

That's a windows share mounted as administrator of the windows machine. While this may be caused somehow by CIFS changes in the kernel, there truely is something ugly going on here and it's caused me some serious problems.

 [2010-06-09 20:49 UTC] digitalaudiorock at gmail dot com
I just found a blog post (which I had to dredge out of the google cache) where someone figured this out.  The CIFS mount is now apparently using the serverino option by default.  In the case of Windows shares this appears to be resulting in huge inode numbers which are causing is_dir() to report false.  Using the noserverino option prevents this.  Scary stuff.
 [2011-05-07 01:00 UTC] josh at 6bit dot com
Just spent 5 hours trying to figure out an issue that was caused by this bugger... 
If PERL handles this case properly then there must be a small issue with PHP's 
implementation. I'm happy to attempt to provide a patch if someone can point me in 
the proper direction.
 [2011-05-07 02:42 UTC] digitalaudiorock at gmail dot com
I could be wrong, but since this appears to be related to the large inode numbers caused by the newer CIFS code defaulting to serverino, I'll bet the 32 bit integer limit may be part of this issue.  If so, you're no more likely to fix this than, for example, the 2GB limit with filesize().

It'd be interesting to know if this can be reproduced with 64 php builds.

I've stuck with my previous work-around of using noserverino with my CIFS mounts.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Jul 17 23:01:28 2024 UTC