php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #65445 filesize() fails for files with high inode number
Submitted: 2013-08-13 20:27 UTC Modified: 2017-03-17 22:55 UTC
From: michal at michal dot waw dot pl Assigned:
Status: Duplicate Package: Filesystem function related
PHP Version: 5.5.1 OS: Linux
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:
38 + 12 = ?
Subscribe to this entry?

 
 [2013-08-13 20:27 UTC] michal at michal dot waw dot pl
Description:
------------
I have a file for which filesize() can't return value. "stat" result for this file:

Original file:
  File: 'DSC_5196_fx-1553725666.JPG'
  Size: 1907383         Blocks: 3728       IO Block: 4096   regular file
Device: 803h/2051d      Inode: 5905591363  Links: 1
Access: (0644/-rw-r--r--)  Uid: (   51/    http)   Gid: (   51/    http)
Access: 2013-08-13 00:47:28.107477918 +0200
Modify: 2013-08-12 21:38:27.219913208 +0200
Change: 2013-08-13 00:47:08.931478654 +0200
 Birth: -

I've made an exact copy, in same dir, same permissions:

Copy:
  File: 'DSC_5196_fx-1553725666_X.JPG'
  Size: 1907383         Blocks: 3728       IO Block: 4096   regular file
Device: 803h/2051d      Inode: 144         Links: 1
Access: (0644/-rw-r--r--)  Uid: (   51/    http)   Gid: (   51/    http)
Access: 2013-08-13 00:45:48.000000000 +0200
Modify: 2013-08-12 21:38:27.000000000 +0200
Change: 2013-08-13 00:47:28.199477914 +0200
 Birth: -

filesize() works for this new file.

I can't find any other difference between these two files.

I checked that filesize() works for files with inode number less or equal to 4126207367and doesn't work for files with inode number equal or greater than 4358705632. I didn't find files with inode number in between but I'm still looking.

To me it seems that filesize() has problem with inode number higher than 2^32.

Test script:
---------------
<html>
<body>
<pre>
<?

$f1 = '/home/services/httpd/html.galeria.michal.waw.pl/gallery/var/albums/988_Rok-2013/Sobota/DSC_5196_fx-1553725666.JPG';
$f2 = '/home/services/httpd/html.galeria.michal.waw.pl/gallery/var/albums/988_Rok-2013/Sobota/DSC_5196_fx-1553725666_X.JPG';

print $f1.": ".filesize($f1)."\n";
print $f2.": ".filesize($f2)."\n";

?>
</pre>
</body>
</html>

Expected result:
----------------
I expected to see sizes of both files.

Actual result:
--------------
Warning: filesize(): stat failed for /home/services/httpd/html.galeria.XXX/gallery/var/albums/988_Rok-2013/333_Rydzewo-04-06.08.2013/Sobota/DSC_5196_fx-1553725666.JPG in /home/services/httpd/html.galeria.michal.waw.pl/gallery3-3.0.x/test.php on line 13
/home/services/httpd/html.galeria.XXX/gallery/var/albums/988_Rok-2013/333_Rydzewo-04-06.08.2013/Sobota/DSC_5196_fx-1553725666.JPG: 
/home/services/httpd/html.galeria.XXX/gallery/var/albums/988_Rok-2013/333_Rydzewo-04-06.08.2013/Sobota/DSC_5196_fx-1553725666_X.JPG: 1907383

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-08-13 21:02 UTC] johannes@php.net
-Status: Open +Status: Feedback
 [2013-08-13 21:02 UTC] johannes@php.net
Are you using a 32 or 64 it system?
Could you please run the following on command line to see whether the syscall for stat succeeds or fails so we can narrow the search:

$ strace php -nr 'filesize("DSC_5196_fx-1553725666.JPG");'

The relevant output is towards the end something like

stat("DSC_5196_fx-1553725666.JPG", 0x7fff38d27f80) = -1 ENOENT (No such file or directory)
write(1, "\nWarning: filesize(): stat faile"..., 96

or

stat("DSC_5196_fx-1553725666.JPG", {st_mode=S_IFREG|0644, st_size=0, ...}) = 0

thanks.
 [2013-08-13 21:33 UTC] michal at michal dot waw dot pl
-Status: Feedback +Status: Open
 [2013-08-13 21:33 UTC] michal at michal dot waw dot pl
This is 32bit system.

Here is the output:
stat64("DSC_5196_fx-1553725666.JPG", {st_mode=S_IFREG|0644, st_size=1907383, ...}) = 0
write(1, "\nWarning: filesize(): stat faile"..., 96) = 96

Please tell me if I can help in any way.
 [2013-08-16 10:52 UTC] michal at michal dot waw dot pl
It is a problem with stat(2) C function. For files with inode >= 2^32 it returns error:

errno: 75 (Value too large for defined data type)
 [2013-08-16 16:15 UTC] michal at michal dot waw dot pl
Source of the problem lies in lack of support for files larger than 2GB.

From what I read in different places enabling LFS in PHP is not possible, as it requires doing so in Apache and many libraries.

The easiest solution for me is to force XFS to not use inode numbers greater than 2^32 ("inode32" mount option).

Still I hope one day PHP will have LFS enabled.
 [2017-03-17 22:55 UTC] pollita@php.net
-Status: Open +Status: Duplicate
 [2017-03-17 22:55 UTC] pollita@php.net
Bug #45040
 [2022-04-11 06:47 UTC] giw42161 at uooos dot com
Century Law Firm is the best team of lawyers for divorce case, Drt Case, High Court Matter, Civil and Criminal Cases and more in Delhi. 
(https://centurylawfirm.in/)gist.github.com
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 13:01:29 2024 UTC