2009-04-21 02:40:28 fseek
nive n (INDIA)
Message: 72922
Hi,
I have a issue with fseek function.
ret = fseek (fileptr,seek_offset,SEEK_CURR)
fseek is called with offset : 2012100347. The seek offset is an invalid one and is beyond the file size. fseek should return -1 in this case. But for this case , fseek returns success for more than 4000 times and finally error is returned.
########################################
seek offset : 2012100347, Return Value : 0
seek offset : 2012100347, Return Value : 0
.........
.........
.........
seek offset : 2012100347, Return Value : -1
#########################################
Pls let me know how to resolve this?
QuoteReplyEditDelete
2009-04-21 07:48:48 Re: fseek
Robin Getz (UNITED STATES)
Message: 72976
Nive:
If you compile the same application on your desktop - does it work or fail?
What toolchain release are you using?
-Robin
QuoteReplyEditDelete
2009-04-21 08:09:01 Re: fseek
nive n (INDIA)
Message: 72977
Hi,
I am using 2008r1.5-14 toolchain.
It is working fine in VC++.
Regards,
nive
QuoteReplyEditDelete
2009-04-21 08:26:14 Re: fseek
Robin Getz (UNITED STATES)
Message: 72981
Nive:
Does it work on your Linux host with gcc and glibc?
-Robin
QuoteReplyEditDelete
2009-04-22 00:27:51 Re: fseek
nive n (INDIA)
Message: 73037
Hi,
I tried on Linux host with gcc and glibc.
There too i am facing the same issue.
Thanks,
Nive
QuoteReplyEditDelete
2009-04-22 05:30:21 Re: fseek
Yi Li (CHINA)
Message: 73054
Nive,
I think this is the expected behavior. In manual page of lseek I read:
The lseek() function allows the file offset to be set beyond the end of the file (but this does not change the size of
the file). If data is later written at this point, subsequent reads of the data in the gap (a "hole") return null
bytes ('\0') until data is actually written into the gap.
-Yi
QuoteReplyEditDelete
2009-04-22 08:10:05 Re: fseek
Robin Getz (UNITED STATES)
Message: 73058
Nive:
Yeah - Yi is correct - if you get that result with gcc & glibc - that is the expected behaviour and gcc/Blackfin/uClibc are operating 100% correct.
-Robin
QuoteReplyEditDelete
2009-04-22 08:14:26 Re: fseek
nive n (INDIA)
Message: 73059
Thanks for your info.