bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bash scripting and large files: input with the read builtin from a r


From: Bob Proulx
Subject: Re: Bash scripting and large files: input with the read builtin from a redirection gives unexpected result with files larger than 2GB.
Date: Sun, 4 Mar 2012 13:05:42 -0700
User-agent: Mutt/1.5.21 (2010-09-15)

Chet Ramey wrote:
> Jean-François Gagné wrote:
> > uname output: Linux xxxxxxxx 2.6.32-5-amd64 #1 SMP Tue Jun 14 09:42:28 UTC 
> > 2011 x86_64 GNU/Linux
> > Machine Type: x86_64-pc-linux-gnu
>
> Compile and run the attached program.  If it prints out `4', which it does
> on all of the Debian systems I've tried, file offsets are limited to 32
> bits, and accessing files greater than 2 GB is going to be unreliable.

Apparently all of the Debian systems you have tried are 32-bits
systems.  On the reporter's 64-bit amd64 system it will print out 8.

Additionally the bash configure script includes the AC_SYS_LARGEFILE
macro which will test the ability of the system to use large files and
if the system is capable it will define _FILE_OFFSET_BITS=64 and in
that case the size off_t will be 8 bytes too.  If you compile the test
program with -D_FILE_OFFSET_BITS=64 the result will also be 8 even on
32-bit systems.

By default the 32-bit bash will be large file aware on all systems
that support large files and will have been compiled with
_FILE_OFFSET_BITS=64.  I just looked in the config.log from a build of
bash and it included these lines in the resulting config.log file.

  configure:4710: checking for special C compiler options needed for large files
  configure:4805: result: no
  configure:4811: checking for _FILE_OFFSET_BITS value needed for large files
  ...
  configure:4922: result: 64
  ...
  ac_cv_sys_file_offset_bits=64

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]