1820879 Members
3605 Online
109628 Solutions
New Discussion юеВ

fseek error

 
Amith_2
Frequent Advisor

fseek error

Hello guys,

I have a problem with fseek here.It gives me an error 27 (EFBIG File too large). The file on which i am doing the fseek has reached 1.99GB by size at that time.
Is there any LARGE FILE restriction for fseek. If so how can i resolve this.

Regards
Amith
14 REPLIES 14
Steven E. Protter
Exalted Contributor

Re: fseek error

Shalom Amith,

The filesystem was created without largefiles enabled.

Two choices.

1) use newfs with the option -o largefiles to recreate the filesystem.
2) use fsadm to convert the filesystem for large files.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Denver Osborn
Honored Contributor

Re: fseek error

ulimit could be a factor (ulimit -f)

Is the file you're working on currently larger than 2GB? If so, then the filesystem where it resides is probably not the issue.

-denver
Amith_2
Frequent Advisor

Re: fseek error

Steve ,

There are some other files in the same file system whcih is of size greater than 4GB. If it is a file system problem then , such files will not be there.

Is there any restriction in fseek ??

Many Thanks
Amith
Denver Osborn
Honored Contributor

Re: fseek error

ok... looks like you need fseeko(), I saw it in a largfiles whitepaper then searched google for "fseek() fseeko() site:itrc.hp.com" to find this thread.

http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=857114&admit=-682735245+1152124371842+28353475

hope it helps,
-denver
A. Clay Stephenson
Acclaimed Contributor

Re: fseek error

Note that the offset argument is a signed long int; if you compile with _LARGEFILE_SOURCE defined then fseeko which uses an off_t as the offset argument will be used.

One approach that would make your code more portable and POSIX compliant would be to use lseek(), read(), and write() using file descriptors rather than the higher level *FILE abstractions although, you would also need to handle the buffering yourself as well if needed.
If it ain't broke, I can fix that.
Amith_2
Frequent Advisor

Re: fseek error

Hello ,

I tried changing the call to fseeko and compiled using the _LARGEFILE_SOURCE option , still the error persists.
I checkmed the file system attributes in /etc/fstab in that also "largefiles" option is enabled. It is a vxfs file system.

Any inputs ??
A. Clay Stephenson
Acclaimed Contributor

Re: fseek error

It is actually possible that since you are feeding it a signed long that the value is negative due to underflow; it is also possible that you have hit the processes ulimit since either condition could set errno = EFBIG so if this fails with fseeko using an off_t as the actual parameter then I would suspect ulimit. Just before this fseeko, insert a ulimit(UL_GETFSIZE) and determine the current number of blocks allowed.
If it ain't broke, I can fix that.
Amith_2
Frequent Advisor

Re: fseek error

Hi,

I inserted a ulimit(UL_GETFSIZE) in my program and it displayed 4194303( 4194303 * 512 = 2GB).
But when i type the command from the user prompt , it displays the ulimit as unlimited. The ulimit -a output is
time(seconds) unlimited
file(blocks) unlimited
data(kbytes) 488280
stack(kbytes) 58592
memory(kbytes) unlimited
coredump(blocks) 4194303
nofiles(descriptors) 1024

Could you please tell me when this can happen and how can i resolve it .

Thanks
Amith
A. Clay Stephenson
Acclaimed Contributor

Re: fseek error

You have now found your fseek() problem. I assume that you executed the ulimit command just before executing the program with the fseek() in it --- and as the same user. Even in that case there is still a simple explanation as to why ulimit is now smaller: there is a ulimit(UL_SETFSIZE,newsize) somewhere in your program -- although it may be in a library object. Note that the most recent ulimit() always wins.
If it ain't broke, I can fix that.
Amith_2
Frequent Advisor

Re: fseek error

I am not able to find any place in the source where in the ulimit is set to a different size.

Can i set it to a higher value by using the UL_SETFSIZE option.
And also could you please tell me whether the output of the ulimit command is a long int or double ?
Amith_2
Frequent Advisor

Re: fseek error

I am attaching a sample code along with this posting. I have tried to set the ulimit to 4Gb using this code.
But it shows only 4194303 (2GB) when i display the ulimit.

Could you please tell me why this is happening. The ulimit -a output of the user shows that the file size limit is unlimited and the file system can handle files greater than 2GB (largfiles enabled).

Regards
Amith
A. Clay Stephenson
Acclaimed Contributor

Re: fseek error

First, you may be hitting the Soft limit:

Execute these two commands:
ulimit -Hf
ulimit -Sf

and post the resukt. I have a funny feeling that you are not running the POSIX shell.

I would also modify your little C program to get the current ulimit before trying to set it. A regular user is not allowed to increase ulimit.

If it ain't broke, I can fix that.
Amith_2
Frequent Advisor

Re: fseek error

The output of the commands are:

$>ulimit -Hf
unlimited
$>ulimit -Sf
unlimited
$>

Amith_2
Frequent Advisor

Re: fseek error

Also i am compiling the programs in korn shell (ksh).
But executing the programs in POSIX.
Will that be a problem.