Operating System - HP-UX
1832976 Members
2747 Online
110048 Solutions
New Discussion

Is there a 2 gig limit in C programming

 
SOLVED
Go to solution
John Jimenez
Super Advisor

Is there a 2 gig limit in C programming

A process on our monthend is failing. My programmer informed me that file has just reached 2 gig. He is using the fgets and fopen commands. Are there 2 gig limitations on these commands or on "C" program

I am running the following c progam on HP UX 11.11

B3901BA B.11.11.08 HP C/ANSI C Developer's Bundle for HP-UX 11.i (S800)
Hustle Makes things happen
13 REPLIES 13
A. Clay Stephenson
Acclaimed Contributor

Re: Is there a 2 gig limit in C programming

The first thing to check is are "largefiles" enabled for this filesystem? Also check the ulimit value? Are quotas in effect?
If it ain't broke, I can fix that.
John Jimenez
Super Advisor

Re: Is there a 2 gig limit in C programming

This was the first thing that crossed my mind. But it set up for large files like my other ones

/dev/vg06/lvol6 /diamelig vxfs rw,suid,largefiles,delaylog,datainlog 0 2
Hustle Makes things happen
H.Merijn Brand (procura
Honored Contributor

Re: Is there a 2 gig limit in C programming

And also check if the filesystem allows big files

Unless you want to *seek* in largefiles, Clay is right that the largefiles option should be enough, otherwise (when you /do/ need seeks or *big* reads - over 2 Gb) you should compile into 64bit objects

# cc -O +Da2.0w -Ae ...

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
H.Merijn Brand (procura
Honored Contributor

Re: Is there a 2 gig limit in C programming

And also check if the filesystem allows big files

Unless you want to *seek* in largefiles, Clay is right that the largefiles option should be enough, otherwise (when you /do/ need seeks or *big* reads - over 2 Gb) you should compile into 64bit objects

# cc -O +DA2.0w -Ae ...

Enjoy, Have FUN! H.Merijn
Enjoy, Have FUN! H.Merijn
A. Clay Stephenson
Acclaimed Contributor
Solution

Re: Is there a 2 gig limit in C programming

Okay, then this is probably a 32-bit application; if you compile as 64-bit, largefiles are automatic but otherwise (or if you must compile as 32-bit) then you have to take some special steps. e.g. #define _FILE_OFFSET_BITS = 64. If you do a man pread64, you will see the necessary steps.


If it ain't broke, I can fix that.
John Jimenez
Super Advisor

Re: Is there a 2 gig limit in C programming

Do you know how I check if the ulimit value are reached?
How do I check if the quotas in effect?
Hustle Makes things happen
John Jimenez
Super Advisor

Re: Is there a 2 gig limit in C programming

Thank you for putting us onto the right path. Max (programmer)Reviewed the man pages. He set up the FILE_OFFSET_BITS=64. And then he fopen64 program, but still gets a memory core dump on this program. but the program works on last months file.
He wrote a simple program using fopen, fgets, and fprintf and it ran fine. He is not suggesting that I am out of some resource.
Hustle Makes things happen
John Jimenez
Super Advisor

Re: Is there a 2 gig limit in C programming

Here is elig_mon.c which is the original program.
Hustle Makes things happen
John Jimenez
Super Advisor

Re: Is there a 2 gig limit in C programming

Here is the modified program using the 64 command. Can you tell if we are using it correctly?
Hustle Makes things happen
John Jimenez
Super Advisor

Re: Is there a 2 gig limit in C programming

Max noticed that the compiler option was different then the one he used a little while ago. It did run differently now. But he says that he is still running out of time to send the month end file tonight. for tonight, he will have to manually split up the file for tonight and then concantanate the data back together at the end
I guess compiling with the following took a long time and never finished
cc -O +DA2.0w -Ae
I called HP and they suggested running it with +DA2.0W
It compiled, but with errors. We are running out of time today. So we are manually spliting it up and then conctanating the output after to send out.

Thanks again guys

Hustle Makes things happen
John Jimenez
Super Advisor

Re: Is there a 2 gig limit in C programming

Actually it looks like we have a bad record(s). We broke the file up and the smaller one is getting a core dump too.
Hustle Makes things happen
rick jones
Honored Contributor

Re: Is there a 2 gig limit in C programming

Instead of +DA2.0W you should use +DD64. That is the HP-UX platform neutral way to ask for a 64-bit compilation - that is, it will also work when you start compiling on/for Itanium in the future.
there is no rest for the wicked yet the virtuous have no pillows
John Jimenez
Super Advisor

Re: Is there a 2 gig limit in C programming

Thank you for the information. The 2 gig was not acutally my issue this time, but it will be soon. So we will be changing and testing this in the up coming weeks
Hustle Makes things happen