|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[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 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 11:00:01 2025 UTC |
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.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.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.