php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48099 stat failed on a readable / writable file in NFS mount
Submitted: 2009-04-28 13:23 UTC Modified: 2009-04-30 19:42 UTC
From: offset at galvanet dot com Assigned:
Status: Not a bug Package: Filesystem function related
PHP Version: 5.2.9 OS: Linux
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: offset at galvanet dot com
New email:
PHP Version: OS:

 

 [2009-04-28 13:23 UTC] offset at galvanet dot com
Description:
------------
is_file and filesize not working on a NFS mount.
These files are readable and writable for user (Using PHP CLI).

is_file and filesize working for local files. Not for NFS mounts.

By the way, file_exist is working.

The code is working under PHP 5.2.3 (cli). And not under PHP 5.2.9 (cli)

Reproduce code:
---------------
echo "Full path : $SourceFile\n";
	
if (!chmod($SourceFile, 0777)) {
   echo "Unable to Chmod file\n";
}
		
clearstatcache();
	
if (!file_exists($SourceFile)) {
    echo "Source file not found\n";
}

$FileSize = filesize($SourceFile);

if (!$FileSize) {
    echo "Source file empty !\n";
}



Expected result:
----------------
Full path : /home/files/3/4/0/340db92364af5c0616187f6e1db86ed7

.. and continue the script

Actual result:
--------------
Full path : /home/files/3/4/0/340db92364af5c0616187f6e1db86ed7
Source file empty !

# ls -lah /home/files/3/4/0/340db92364af5c0616187f6e1db86ed7
-rwxrwxrwx 1 nobody nobody 9.5M Apr 26 12:00 /home/files/3/4/0/340db92364af5c0616187f6e1db86ed7



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-28 14:50 UTC] offset at galvanet dot com
Strace on php execution return that :

stat64("/home/files/3/4/0/340db92364af5c0616187f6e1db86ed7", {st_mode=S_IFREG|0444, st_size=9888768, ...}) = 0
write(2, "PHP Warning:  filesize(): stat f"..., 139PHP Warning:  filesize(): stat failed for /home/files/3/4/0/340db92364af5c0616187f6e1db86ed7 in /root/test.php on line 3
 [2009-04-28 18:14 UTC] jani@php.net
This might be related to ug #45040 (And LFS support in general..)

 [2009-04-28 18:57 UTC] jani@php.net
As I don't have any NFS mounted stuff available anywhere, can you try 
this:

# CFLAGS=`getconf LFS_CFLAGS` ./config.nice
# make clean && make

And then try that script of yours.
 [2009-04-28 22:28 UTC] offset at galvanet dot com
It's working with LFS support.

Stat is exactly the same :
stat64("/home/files/3/4/0/340db92364af5c0616187f6e1db86ed7", {st_mode=S_IFREG|0444, st_size=9888768, ...}) = 0

But after the size is writen correctly :
write(1, "9888768", 79888768)                  = 7

(Working on a 32bit system)

Thanks
 [2009-04-30 19:42 UTC] jani@php.net
I'm closing this report in favor of bug #45040 (where the actual fix 
originally was proposed) 
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 23:01:29 2024 UTC