php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15260 file_exists doesn't work with 2G+ files
Submitted: 2002-01-28 14:57 UTC Modified: 2002-03-20 00:00 UTC
Votes:3
Avg. Score:4.7 ± 0.5
Reproduced:3 of 3 (100.0%)
Same Version:0 (0.0%)
Same OS:2 (66.7%)
From: wweng at kencast dot com Assigned:
Status: No Feedback Package: *Directory/Filesystem functions
PHP Version: 4.0.5 OS: Linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: wweng at kencast dot com
New email:
PHP Version: OS:

 

 [2002-01-28 14:57 UTC] wweng at kencast dot com
I have a 4G file in /opt/incoming called /opt/incoming/bigpackage.pck

I used 

if(file_exists("/opt/incoming/bigpackage.pck"))
    echo "Exists";
else
    echo "Not exists";

and it always returns me "Not exists".

I suspect the file_exists function has problem with 2G+ files.


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-28 14:59 UTC] jan@php.net
can you please test either PHP 4.1.1 (latest release) or a cvs snapshot (snaps.php.net) ?
 [2002-01-28 15:00 UTC] mrobinso@php.net
This is a limitation of the filesystem (and linux
kernel without LFS support), not php.
 [2002-01-28 15:02 UTC] jan@php.net
how can he have a file of 4GB if his filesystem does not support it?
 [2002-01-28 15:15 UTC] wweng at kencast dot com
Actually, I do have a 4Gig file on the file system. (Since we used the 64bit file operation for our software on all our file  I/O) 

[root@ECTWO root] ls -la /opt/incoming
total 4399256
drwxrwxr-x 2 **** **** 4096 Jan 28 13:35
drwxr-xr-x 5 root root 4096 Jan 28 10:44
-rw-rw-r-- 1 **** **** 4499238984 May 10 2001 BigPackage.fpk.pck
 [2002-01-28 15:15 UTC] wweng at kencast dot com
Where can I (and how do I) get the source code to file_exists function?
 [2002-01-28 15:17 UTC] jan@php.net
and then again, can you please test with a more recent PHP release?
 [2002-01-28 15:26 UTC] wweng at kencast dot com
Can not seem to find the RPM(php-4.1.1) for Redhat 7.2. :(

There is no build environment on testing machines.
 [2002-01-28 15:44 UTC] wweng at kencast dot com
I believe I had found the reason of this bug.

file_exists function ultimately calls VCWD_STAT function defined in TSRM/tsrm_virtual_cwd.h. However, the VCWD_STAT function is only a macro for stat(path, mode), and under Linux, you need stat64 for 64 bit file stats operations.

hmm, and all the file I/Os under PHP right now do not support 64 bits. This is bad...
 [2002-01-28 20:43 UTC] mrobinso@php.net
If the OS is compiled and installed on a 64 bit system,
or with large file support (read: kernel, libc, others)
then calls to stat() and friends return 64-bit structures. You don't need to call stat64 expressly. A stock RedHat-7.2
box isn't 64bit compliant unless it's compiled that way.

The VCWD_STAT macro uses stat(path, buff), not
stat(path, mode). I've had a look at stat.h and see
the references to stat64(path, buff) if large file
support is defined, but I'm in a little over my head
here, so I bow to jan@php.net's mastery of php
internals.  :)

I don't have access to a 64bit box or fs to confirm, so I guess I jumped the gun on this one, but IMHO, this isn't a
PHP *bug*.

Sorry for the confusion.

 [2002-01-28 20:53 UTC] wweng at kencast dot com
From what I had been researching on google, compiling a package with uniformed 64 bits I/O functions requires -D_FILE_OFFSET_BITS=64 (and kernel 2.4.x and glibc 2.2.2+). I greped through the php 4.1.1 source code downloaded from php.net, couldn't find any trace of such option in any of the files. (At least I would think it should exist in the Makefile.ams) Maybe it had been forgotten?
 [2002-03-20 00:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed Jan 15 15:01:31 2025 UTC