Bug #68209 [Com]: php does not work with files that have 64bit inodes (on a 32bit kernels)
| From: | glen at delfi dot ee | Date: | Fri, 10 Oct 2014 19:21:14 +0000 |
| Subject: | Bug #68209 [Com]: php does not work with files that have 64bit inodes (on a 32bit kernels) | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-188012@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=68209&edit=1
ID: 68209
Comment by: glen at delfi dot ee
Reported by: arekm at maven dot pl
Summary: php does not work with files that have 64bit inodes
(on a 32bit kernels)
Status: Open
Type: Bug
Package: *General Issues
PHP Version: 5.6.1
Block user comment: N
Private report: N
New Comment:
AFAIK it is not that safe to enable LFS, as then libraries linked with PHP need to be LFS compatible
too.
see http://lists.pld-linux.org/mailman/pipermail/pld-devel-en/2014-May/023935.html
or top of that thread:
http://lists.pld-linux.org/mailman/pipermail/pld-devel-en/2014-May/thread.html#23916
Previous Comments:
------------------------------------------------------------------------
[2014-10-10 18:53:55] arekm at maven dot pl
Fixed summary.
------------------------------------------------------------------------
[2014-10-10 18:53:14] arekm at maven dot pl
Description:
------------
It's perfectly valid to have files with 64bit inodes on a system with 32bit Linux kernel.
Unfortunately php is not capable of handling these files. Example:
[arekm@farm 100]$ ls -li 100.txt
425201762433 -rw-r--r-- 1 root root 0 10-08 23:09 100.txt
[arekm@farm 100]$ php --version
PHP 5.6.0 (cli) (built: Aug 28 2014 20:53:25)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
[arekm@farm 100]$ php -r "var_dump(stat('100.txt'));"
PHP Warning: stat(): stat failed for 100.txt in Command line code on line 1
bool(false)
[arekm@farm 100]$ file /usr/bin/php
/usr/bin/php: symbolic link to `php56'
[arekm@farm 100]$ file /usr/bin/php56
/usr/bin/php56: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically linked (uses
shared libs), for GNU/Linux 2.6.16, BuildID[sha1]=9b3d30e4bb089221042dfbe36ca43c8b69a8021f, stripped
The whole problem comes from PHP not being compiled with
// this makes LFS (large file support) functions to be used
// (so glibc stat64() will be called instead of stat())
#define _LARGEFILE_SOURCE
// this makes resulting binary ready for 64bit off_t type (off64_t) this stat()
// won't die with EOVERFLOW errno (see stat(2) for more details)
#define _FILE_OFFSET_BITS=64
The solution is simple. Add
AC_SYS_LARGEFILE
macro to configure.ac. configure will then figure out what defines are needed to get LFS support.
Two reasons to get LFS enabled with php:
- files over 2GB will be correctly handled on 32bit kernels
- small files that have 64bit inodes will be correctly handled on 32bit kernels
ps. there are some bugs that will be uncovered in PHP with LFS enabled (some nesting detection
error). That bug would need to be fixed too.
Test script:
---------------
php -r "var_dump(stat('test_file.txt'));"
is enough but test_file.txt needs to have 64bit inode number. To get test file with 64bit inode
number do:
# create sparse 10T image
[arekm@farm test]$ truncate -s 10T testimage
# create fs on it (it will take about 2GB on filesystem), note agcount got set to 10
[arekm@farm test]$ mkfs.xfs testimage
meta-data=testimage isize=256 agcount=10, agsize=268435455 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0
data = bsize=4096 blocks=2684354550, imaxpct=5
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal log bsize=4096 blocks=521728, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[arekm@farm test]$ mkdir mntpoint
[arekm@farm test]$ sudo bash
# mount with inode64 option. This option is default in recent kernels.
[root@farm test]# mount testimage mntpoint -o inode64
[root@farm test]# for i in
seq 1 100; do mkdir mntpoint/$i && touch
mntpoint/$i/$i.txt; done
[root@farm test]# ls -l mntpoint/100/100.txt
-rw-r--r-- 1 root root 0 Oct 10 20:42 mntpoint/100/100.txt
# make sure one of txt files created has 64bit inode
[root@farm test]# ls -li mntpoint/100/100.txt
38654705811 -rw-r--r-- 1 root root 0 Oct 10 20:42 mntpoint/100/100.txt
# so test php now on it
[root@farm test]# php -r 'stat("mntpoint/100/100.txt");';
PHP Warning: stat(): stat failed for mntpoint/100/100.txt in Command line code on line 1
[root@farm test]#
Expected result:
----------------
Working stat().
Actual result:
--------------
PHP Warning: stat(): stat failed for mntpoint/100/100.txt in Command line code on line 1
failure.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=68209&edit=1