Bug 128390 - (IT_36853) stat() fails on files larger than 2G
stat() fails on files larger than 2G
Status: CLOSED ERRATA
Product: Red Hat Enterprise Linux 2.1
Classification: Red Hat
Component: sh-utils (Show other bugs)
2.1
i686 Linux
medium Severity medium
: ---
: ---
Assigned To: Tim Waugh
:
: 133386 (view as bug list)
Depends On:
Blocks: 123573
  Show dependency treegraph
 
Reported: 2004-07-22 10:48 EDT by Steve Conklin
Modified: 2007-11-30 17:06 EST (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-12-13 16:35:14 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Steve Conklin 2004-07-22 10:48:14 EDT
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:
Comment 1 Stephen Tweedie 2004-07-22 11:31:22 EDT
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.
Comment 2 Jakub Jelinek 2004-07-22 11:36:00 EDT
For transparent 64-bit file size support actually just
-D_FILE_OFFSET_BITS=64 is enough, _LARGEFILE64_SOURCE is not needed.
Comment 3 Tim Waugh 2004-07-22 11:57:24 EDT
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 }
Comment 5 Steve Conklin 2004-07-26 09:28:12 EDT
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).
Comment 6 Tim Waugh 2004-09-24 03:39:05 EDT
*** Bug 133386 has been marked as a duplicate of this bug. ***
Comment 7 John Flanagan 2004-12-13 16:35:14 EST
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

Note You need to log in before you can comment on or make changes to this bug.