From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2) Gecko/20040301 Description of problem: stat() call fails on files over 2G. It failed on U4 and also with the new glibc in the U5beta (glibc-2.2.4-32.16). This was originally reported as "/usr/bin/test -f" fails with large files. Issue tracker #36853 Here is a small program that demonstrates the problem. [root@jarjar footest]# ls -l total 2152536 -rw-r--r-- 1 root root 145 Jul 16 16:46 ls-out -rwxr-xr-x 1 root root 16417 Jul 22 09:25 stattest -rw-r--r-- 1 root root 380 Jul 22 09:25 stattest.c -rw-r--r-- 1 root root 49 Jul 22 09:16 stattest.c~ -rw-r--r-- 1 root root 2202009600 Jul 16 16:45 test-file [root@jarjar footest]# cat stattest.c #include <stdio.h> #include <sys/stat.h> #include <sys/errno.h> main() { struct stat st; int retval; retval = stat ("./test-file", &st); printf("Big file result = %d\n", retval); if (retval < 0) printf("errno = %d\n", errno); retval = stat ("./ls-out", &st); printf("Small file result = %d\n", retval); if (retval < 0) printf("errno = %d\n", errno); } [root@jarjar footest]# ./stattest Big file result = -1 errno = 75 Small file result = 0 Version-Release number of selected component (if applicable): glibc-2.2.4-32.16 How reproducible: Always Steps to Reproduce: 1. Create a large file 2. run the test program 3. observe the results Actual Results: stat call fails Expected Results: stat call doesn't fail Additional info:
error 75 is EOVERFLOW. 32-bit stat() is *required* to return EOVERFLOW for files larger than 2G. See http://ftp.sas.com/standards/large.file/ for the relevant standards. If you want the stat to succeed, you must either use the stat64() variant --- if necessary, enabling that via #define _LARGEFILE64_SOURCE 1 or compile with transparent 64-bit file size support by using that #define plus #define _FILE_OFFSET_BITS 64 Only if you do the latter will stat() automatically use the 64-bit extended struct stat. If "/usr/bin/test -f" is failing, that implies the test binary is not using the 64-bit stat variants as it should do.
For transparent 64-bit file size support actually just -D_FILE_OFFSET_BITS=64 is enough, _LARGEFILE64_SOURCE is not needed.
Well /usr/bin/test belongs to sh-utils, doesn't it? For some reason the spec file explicitly uses --disable-largefile when running configure: %configure %{?this_os_is_linux: --disable-largefile --enable-pam }
I've rebuilt sh-utils without --disable-largefile, and it solved this problem. Also, all the tests in the script tests/test/test-tests passed (for what that's wort).
*** Bug 133386 has been marked as a duplicate of this bug. ***
An errata has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on the solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHBA-2004-458.html