[GRASS-dev] [GRASS GIS] #1971: 64bit LFS support for G_ftell() and PRI_OFF_T gis.h

GRASS GIS trac at osgeo.org
Fri May 10 07:48:23 PDT 2013


#1971: 64bit LFS support for G_ftell() and PRI_OFF_T gis.h
-------------------------------------------------+--------------------------
 Reporter:  hamish                               |       Owner:  grass-dev@…              
     Type:  defect                               |      Status:  new                      
 Priority:  critical                             |   Milestone:  6.4.3                    
Component:  LibGIS                               |     Version:  svn-develbranch6         
 Keywords:  r.in.bin, LFS, G_ftell(), PRI_OFF_T  |    Platform:  Linux                    
      Cpu:  x86-64                               |  
-------------------------------------------------+--------------------------

Comment(by glynn):

 Replying to [comment:1 hamish]:

 > AFAICT r.in.bin is the only thing in GRASS 6 which uses G_ftell(), and
 nothing in the grass6-addons repo uses it. It was there in the 6.4.2
 release though, so someone might be using it in a personal addon program.
 Could it harm backwards compatibility to change the function def'n, or
 would it be harmless?

 The worst that can happen is that off_t gets truncated to int when the
 result is assigned (which doesn't apply to r.in.bin, which assigns the
 result of G_ftell() to an off_t), rather than within G_ftell().

 The truncation to int was done in r45468, but I don't know why. Possibly
 to avoid issues with off_t having different sizes in different files
 (didn't LFS have to be enabled on a module-by-module basis in 6.x?).

 The irony is that having G_fseek() return int is even worse than using
 plain fseek(), which returns a long. This imposes a 32-bit limit even on
 "real" 64-bit platforms (i.e. not Windows, where even the 64-bit versions
 have a 32-bit long).

 At the very least, G_fseek() should return a long, if not an off_t.

 > Seeing that it is only r.in.bin, a less invasive fix to get the 6.4.3
 release out the door might be to add the `#ifdef HAVE_FSEEKO` test into
 r.in.bin directly and avoid using G_ftell() altogether.

 7.0 has 31 uses of G_ftell() and 48 uses of G_fseek() (although a bunch of
 those are in r.viewshed and r.terraflow, which all come from the same
 AMI_STREAM template). The fact that 6.x only has one use indicate that
 everything else is using plain ftell(), which means that it will fail on
 files larger than 2GiB.

-- 
Ticket URL: <https://trac.osgeo.org/grass/ticket/1971#comment:2>
GRASS GIS <http://grass.osgeo.org>



More information about the grass-dev mailing list