Re: [squeak-dev] filesize reporting 0 for very large files

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] filesize reporting 0 for very large files

David T. Lewis
 
On Sun, Mar 18, 2012 at 10:00:46PM -0400, David T. Lewis wrote:

> On Sun, Mar 18, 2012 at 06:55:10PM -0700, Eliot Miranda wrote:
> > Hi David,
> >
> > On Sun, Mar 18, 2012 at 6:30 PM, David T. Lewis <[hidden email]> wrote:
> >
> > > On a Linux system, the data types that represent file positions are 32 bits
> > > in size when the program is compiled in 32-bit mode (using the -m32
> > > compiler
> > > option), and they are 64 bits in size when the program is compiled in
> > > 64-bit
> > > mode. The relevant data types are off_t and size_t, and if you compile the
> > > following in 32-bit mode (-m32) and compare the same program compiled in
> > > 64-bit mode, you can see the difference:
> > >
> > >  #include <stdio.h>
> > >  #include <sys/types.h>
> > >  main() {
> > >    printf("off_t is %d\n", sizeof(off_t));
> > >    printf("size_t is %d\n", sizeof(size_t));
> > >  }
> > >
> >
> > Not quite.  One can modify this by defining something like
> > _LARGEFILE64_SOURCE at compile time.  e.g.
> > see _LARGEFILE_SOURCE _LARGEFILE64_SOURCE & _FILE_OFFSET_BITS in
> > http://www.delorie.com/gnu/docs/glibc/libc_13.html.  I'll check that the
> > appropriate one is defined when building Cog asap.
>
> Excellent, thank you!

(CC to vm-dev)

I note that Nicolai Hess has just added a note to the Mantis issue with
a similar tip and pointers to additional things that may need attention
in the support code.

http://bugs.squeak.org/view.php?id=7522

Dave

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] filesize reporting 0 for very large files

Bert Freudenberg


On 19.03.2012, at 03:11, David T. Lewis wrote:

> On Sun, Mar 18, 2012 at 10:00:46PM -0400, David T. Lewis wrote:
>> On Sun, Mar 18, 2012 at 06:55:10PM -0700, Eliot Miranda wrote:
>>> Hi David,
>>>
>>> On Sun, Mar 18, 2012 at 6:30 PM, David T. Lewis <[hidden email]> wrote:
>>>
>>>> On a Linux system, the data types that represent file positions are 32 bits
>>>> in size when the program is compiled in 32-bit mode (using the -m32
>>>> compiler
>>>> option), and they are 64 bits in size when the program is compiled in
>>>> 64-bit
>>>> mode. The relevant data types are off_t and size_t, and if you compile the
>>>> following in 32-bit mode (-m32) and compare the same program compiled in
>>>> 64-bit mode, you can see the difference:
>>>>
>>>> #include <stdio.h>
>>>> #include <sys/types.h>
>>>> main() {
>>>>   printf("off_t is %d\n", sizeof(off_t));
>>>>   printf("size_t is %d\n", sizeof(size_t));
>>>> }
>>>>
>>>
>>> Not quite.  One can modify this by defining something like
>>> _LARGEFILE64_SOURCE at compile time.  e.g.
>>> see _LARGEFILE_SOURCE _LARGEFILE64_SOURCE & _FILE_OFFSET_BITS in
>>> http://www.delorie.com/gnu/docs/glibc/libc_13.html.  I'll check that the
>>> appropriate one is defined when building Cog asap.
>>
>> Excellent, thank you!
>
> (CC to vm-dev)
>
> I note that Nicolai Hess has just added a note to the Mantis issue with
> a similar tip and pointers to additional things that may need attention
> in the support code.
>
> http://bugs.squeak.org/view.php?id=7522
>
> Dave

Found at http://www.suse.de/~aj/linux_lfs.html
=======================
For using LFS in user programs, the programs have to use the LFS API. This involves recompilation and changes of programs. The API is documented in the glibc manual (the libc info pages) which can be read with e.g. "info libc".
In a nutshell for using LFS you can choose either of the following:
        • Compile your programs with "gcc -D_FILE_OFFSET_BITS=64". This forces all file access calls to use the 64 bit variants. Several types change also, e.g. off_t becomes off64_t. It's therefore important to always use the correct types and to not use e.g. int instead of off_t. For portability with other platforms you should use getconf LFS_CFLAGS which will return -D_FILE_OFFSET_BITS=64 on Linux platforms but might return something else on e.g. Solaris. For linking, you should use the link flags that are reported via getconf LFS_LDFLAGS. On Linux systems, you do not need special link flags.
        • Define _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE. With these defines you can use the LFS functions like open64 directly.
        • Use the O_LARGEFILE flag with open to operate on large files.
A complete documentation of the feature test macros like _FILE_OFFSET_BITS and _LARGEFILE_SOURCE is in the glibc manual (run e.g. "info libc 'Feature Test Macros'").
The LFS API is also documented in the LFS standard which is available at http://ftp.sas.com/standards/large.file/x_open.20Mar96.html.
=======================


- Bert -