php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50150 stat() / lstat() does not work on a mounted cifs
Submitted: 2009-11-11 12:34 UTC Modified: 2010-03-04 20:01 UTC
Votes:2
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: balanalin2003 at yahoo dot com Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.3.0 OS: ubuntu 9.10
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
15 - 6 = ?
Subscribe to this entry?

 
 [2009-11-11 12:34 UTC] balanalin2003 at yahoo dot com
Description:
------------
Starting program: /php-cli/bin/php /home/alin/Desktop/test.php
[Thread debugging using libthread_db enabled]

Breakpoint 1, php_stat (
    filename=0x87e2e80 "/mount/Arena/tickers.txt", 
    filename_length=24, type=17, return_value=0x87e283c, 
    tsrm_ls=0x86ea050)
    at /home/alin/Desktop/arhive/php-5.3.0/ext/standard/filestat.c:762
762	{
(gdb) bt
#0  php_stat (filename=0x87e2e80 "/mount/Arena/tickers.txt", 
    filename_length=24, type=17, return_value=0x87e283c, 
    tsrm_ls=0x86ea050)
    at /home/alin/Desktop/arhive/php-5.3.0/ext/standard/filestat.c:762
#1  0x0826c85b in php_if_stat (ht=1, return_value=0x87e283c, 
    return_value_ptr=0x0, this_ptr=0x0, return_value_used=1, 
    tsrm_ls=0x86ea050)
    at /home/alin/Desktop/arhive/php-5.3.0/ext/standard/filestat.c:1125
#2  0x081ca23c in phar_stat (ht=1, return_value=0x87e283c, 
    return_value_ptr=0x0, this_ptr=0x0, return_value_used=1, 
    tsrm_ls=0x86ea050)
    at /home/alin/Desktop/arhive/php-5.3.0/ext/phar/func_interceptors.c:1034
#3  0x083913f6 in zend_do_fcall_common_helper_SPEC (
    execute_data=0x88126f4, tsrm_ls=0x86ea050)
    at /home/alin/Desktop/arhive/php-5.3.0/Zend/zend_vm_execute.h:313
#4  0x08395aec in ZEND_DO_FCALL_SPEC_CONST_HANDLER (
    execute_data=0x88126f4, tsrm_ls=0x86ea050)
    at /home/alin/Desktop/arhive/php-5.3.0/Zend/zend_vm_execute.h:1601
#5  0x083906c6 in execute (op_array=0x87e2ecc, tsrm_ls=0x86ea050)
    at /home/alin/Desktop/arhive/php-5.3.0/Zend/zend_vm_execute.h:104
#6  0x0835ee92 in zend_execute_scripts (type=8, tsrm_ls=0x86ea050, 
    retval=0x0, file_count=3)
    at /home/alin/Desktop/arhive/php-5.3.0/Zend/zend.c:1188
#7  0x082dacb9 in php_execute_script (primary_file=0xbffff660, 
    tsrm_ls=0x86ea050)
    at /home/alin/Desktop/arhive/php-5.3.0/main/main.c:2196
#8  0x08434634 in main (argc=2, argv=0xbffff7f4)
---Type <return> to continue, or q <return> to quit---
    at /home/alin/Desktop/arhive/php-5.3.0/sapi/cli/php_cli.c:1188
(gdb) continue
Continuing.

Warning: stat(): stat failed for /mount/Arena/tickers.txt in /home/alin/Desktop/test.php on line 3
bool(false)

Program exited normally.
---------------------------------------
 stat /mount/Arena2/tickers.txt
  File: `/mount/Arena2/tickers.txt'
  Size: 184118245 	Blocks: 359680     IO Block: 16384  regular file
Device: 16h/22d	Inode: 23080948090339228  Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2009-11-11 14:29:25.125000000 +0200
Modify: 2009-11-10 17:26:20.099468800 +0200
Change: 2009-11-10 17:26:20.099468800 +0200


Reproduce code:
---------------
<?php

var_dump(stat("/mount/Arena/tickers.txt"));
?>

Actual result:
--------------
Warning: stat(): stat failed for /mount/Arena/tickers.txt in /home/alin/Desktop/test.php on line 3
bool(false)

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-11-11 12:38 UTC] jani@php.net
And you're sure it's not this bug:

https://bugs.launchpad.net/ubuntu/+source/linux/+bug/220658
 [2009-11-11 13:31 UTC] balanalin2003 at yahoo dot com
well i think is not the same because if i run from the terminal:

stat /mount/Arena2/tickers.txt 

i get:

 stat /mount/Arena2/tickers.txt
  File: `/mount/Arena2/tickers.txt'
  Size: 184118245 	Blocks: 359680     IO Block: 16384  regular file
Device: 16h/22d	Inode: 23080948090339228  Links: 1
Access: (0755/-rwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/   
root)
Access: 2009-11-11 14:29:25.125000000 +0200
Modify: 2009-11-10 17:26:20.099468800 +0200
Change: 2009-11-10 17:26:20.099468800 +0200

if i have a script like this:

<?php

$fp=fopen("/mount/Arena2/tickers.txt","r");
echo (fgets($fp));
?>

i get first line from that file;
only stat() is the problem
 [2009-11-12 17:44 UTC] jani@php.net
Yes, but stat on command line might be different to stat() function. :)
Please check the kernel version compared to where this bug is fixed.
(and when you give feedback, use the "Edit Submission" link, NOT the "Add Comment"..)
 [2009-11-16 06:29 UTC] balanalin2003 at yahoo dot com
root@alin-laptop:~# uname -r
2.6.31-14-generic



Launchpad Janitor  wrote on 2009-01-12:  	  #20

This bug was fixed in the package linux - 2.6.28-4.10



so if i have 2.6.31 and it was fixed in 2.6.28, this shouldn't bee the problem

thanks for you're response
 [2009-11-16 09:49 UTC] jani@php.net
Please try using this snapshot:

  http://snaps.php.net/php5.3-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

And use --disable-phar in your configure line.
 [2009-11-17 12:28 UTC] balanalin2003 at yahoo dot com
still getting this error, it may be a problem with my os, or the mount because i have try it on a fedora 7 and filesize worked, 

wait until you get another report to confirm this, i'm using java until then.

Thanks
 [2009-11-17 12:37 UTC] jani@php.net
Most likely OS issue. Not PHP bug -> Bogus.
 [2010-03-04 18:49 UTC] mpiazza at benefitresource dot com
Using SuSE v11.2 with Kernel v2.6.31.5-0.1-default
I have the same problem with the SuSE provided PHP v5.3.1 and with clean builds of v5.3.1 and v5.2.13. 

I can stat from the command line (even through PHP using shell_exec) but all stat() related PHP functions fail. The interesting thing is that stat() works on Linux CIFS shares, but not Windows CIFS shares. Is there some way I can print debug information for each step of the stat() function in the C code to better trouble shoot this?  If its a streams problem, can you describe what exactly the problem is? 

Its not isolated to one machine either. There are several systems in my office that exhibit the same problem.

It works properly under SuSE v10.3 and PHP v4.4.0.

At the very least, an indication as to what caused the failure would be helpful in the PHP error message.
 [2010-03-04 18:54 UTC] mpiazza at benefitresource dot com
I would like to add that the command line stat returns an Inode value of  281474976718220 on the 'broken' system and 55187670 on the 'working' system.

This is suspect to me. Shouldn't it be the same across the board?
 [2010-03-04 19:14 UTC] rasmus@php.net
This doesn't sound like a PHP problem at all.  My best guess is that you have a 
32/64-bit mismatch here.  And PHP doesn't currently support 64-bit inodes.  There 
are some patches floating around that will eventually be folded in to address 
this though.  See bug #48886
 [2010-03-04 19:41 UTC] mpiazza at benefitresource dot com
If support needs to be added to PHP, isn't that a PHP problem. 

Based on rasmus's suggestion, I've discovered a workaround for now.
If you specify "-o noserverino" at mount time the client will assign the inodes instead of the server. I am unaware of any side effects of doing this besides the possibility of not being able to detect hard links correctly.
 [2010-03-04 20:01 UTC] rasmus@php.net
It's a feature request that has already been covered elsewhere, not a bug.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Sep 17 10:01:26 2019 UTC