Writing files larger than 2 GB in Solaris 2.6

Writing files larger than 2 GB in Solaris 2.6

Post by Chris Busic » Sat, 13 Sep 1997 04:00:00



I need to write a program to make a file larger than 2 GB using Solaris
2.6.
I can create a large file by "cat"ing two 2 GB files together.  Solaris
has no
problem with this.

When I try to write a C program, using gcc or sun native compilers, the
program
generates errors when trying to write records out past the 2 GB
barrier.  I think this
is because my libraries are still using a signed long (32 bit) to
maintain position in the file.

Does anybody know of a compiler that doesn't have this restriction? (or
has updated
libraries)
            ---  OR ----

Is it just a configuration error with my compiler?

Chris Busick

 
 
 

Writing files larger than 2 GB in Solaris 2.6

Post by Gavin Maltb » Sat, 13 Sep 1997 04:00:00



> I need to write a program to make a file larger than 2 GB using Solaris
> 2.6.
> I can create a large file by "cat"ing two 2 GB files together.  Solaris
> has no
> problem with this.

> When I try to write a C program, using gcc or sun native compilers, the
> program
> generates errors when trying to write records out past the 2 GB
> barrier.  I think this
> is because my libraries are still using a signed long (32 bit) to
> maintain position in the file.

> Does anybody know of a compiler that doesn't have this restriction? (or
> has updated
> libraries)
>             ---  OR ----

> Is it just a configuration error with my compiler?

You need to read the lfcompile(5) and lfcompile64(5) manpages.
Standard compilation env is all 32-bit, so off_t is signed 32-bit
and you can't get beyond 2Gb.  

If you have private libraries that have 32-bit off_t's etc
"burned in" then you've got more work on your hands :-)

Transitional environment (lfcompile64(5)) is most easily
enabled with _LARGEFILE64_SOURCE=1 before #includes (or on
compile line).  This exports both xxx() and xxx64() versions
of all library and system calls that are concerned with
file offsets (open, lseek etc).  It's not the preferred
environment if you can work with the largefile API instead,
but can be used as a quick way of making and application
largefile aware.  Code looks ugly because there are
xxx64() calls littering it.  Some components of the OS
require this environment --- eg, if you're working with
procfs, /dev/kmem etc.

The largefile API (lfcompile(5)) is enabled with _FILE_OFFSET_BITS=64.
xxx64() calls are not exported (so you can't use this form in
source) but xxx() calls are internally mapped to the xxx64() 64 bit
form.

Last note:  if you're just experimenting with largefiles and
don't really care what the content is,  use holey files
larger than 2Gb --- you don't need gigabytes of diskspace
to play then.

Cheers

Gavin

 
 
 

1. HELP: Apache on Solaris 2.6 w/ log files > 2 GB

I'm having a problem with Apache on Solaris 2.6. When a log file grows to
2^31 bytes (2 GB), Apache stops writing to the file. I know this has
something to do with largefile support, but I don't know how to get Apache
to support this. Has anyone had any similar problems?

I am aware of the rotatelogs program, but I cannot use it because I use the
CustomLog directive which seems to require a filename. Since the file
outputted by rotatelogs always has a filename which changes based on the
date, using rotatelogs does not seem to be a solution.

If possible please reply via email as well as to this group.

Thanks,

Patrick

---| iThink therefore iMac |------------+

 url: http://www.firstweb.com
------------------------| got iMac? |---+

2. system hangs 1.2.13 AHA-2940 & SB16-SCSI-II & ATI Mach64

3. Writing files larger than 2GB from AIX to Solaris

4. talk/talkd and ^Z

5. How to fwrite/write file exceed 2gig on solaris 2.6?

6. RADIUS PPP : problems

7. Files larger than 2 GB on Intel/Linux

8. Term110 not working ...

9. files larger than 2 GB

10. Logfiles larger than 2 GB on solaris 7 ?

11. Looking for authors to help write a Certified Solaris Administrators (CSA) study guide for Solaris 2.6.

12. How do I configure a IDE 30 Gb quantum HD on solaris 2.6?