Bug 57162 - stat() function in glibc-devel-2.2.4-19 return fail when file larger than 2GB
stat() function in glibc-devel-2.2.4-19 return fail when file larger than 2GB
Status: CLOSED NOTABUG
Product: Red Hat Linux
Classification: Retired
Component: glibc (Show other bugs)
7.1
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Jakub Jelinek
Aaron Brown
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2001-12-06 02:03 EST by Xuan Li
Modified: 2016-11-24 10:02 EST (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2001-12-06 02:03:23 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 Xuan Li 2001-12-06 02:03:16 EST
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0)

Description of problem:
stat(const char* filename, struct stat* buf); return fail when the 
filename specified file larger than 2GB.

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1.create a large file: mybigfile.txt   (must larger than 2GB)
2.use ls -l to see the file size, result is:
 -rw-r--r-- 1 root root 2257265203 Nov 30 14:39 mybigfile.txt
3.create teststat.c
   #include <sys/types.h>
   #include <sys/stat.h>

   int main(int argc, char* argv[])
   {
      int ret;
      struct stat buf;
      if(argc < 2) return -1;
      ret = stat(argv[1], &buf);
      if(ret == 0) printf("file size: %ld\n", buf.st_size);
      else printf("stat error\n");
      return 0;
   }
4.compile mystat.c with 'cc -o mystat mystat.c'
5.run 'mystat mybigfile.txt'


Actual Results:  the mystat program output:
   stat error


Expected Results:  the mystat program output:
   file size: 2257265203      (a number larger than 2GB)

Additional info:

After upgrade stat command to stat-2.5-3, the stat command can output the 
file information larger than 2GB successfully, but what I want to use is 
not the command line, but the stat(const char* filename, struct stat* buf) 
function in program.  It kept failing when file is larger than 2GB even 
after I upgrade glibc to 2.2.4-19.
Comment 1 Jakub Jelinek 2001-12-06 04:19:15 EST
Please read info libc and search for LFS or _FILE_OFFSET_BITS.
You either need to use stat64 (and use appropriate -D, e.g. -D_LARGEFILE64_SOURCE,
or -D_GNU_SOURCE), or use -D_FILE_OFFSET_BITS=64 and have this remapped
transparently (after checking the source that all file offsets are
stored in off_t type variables).

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