FreeRTOS Support Archive
The FreeRTOS support forum is used to obtain active support directly from Real
Time Engineers Ltd. In return for using our top quality software and services for
free, we request you play fair and do your bit to help others too! Sign up
to receive notifications of new support topics then help where you can.
This is a read only archive of threads posted to the FreeRTOS support forum.
The archive is updated every week, so will not always contain the very latest posts.
Use these archive pages to search previous posts. Use the Live FreeRTOS Forum
link to reply to a post, or start a new support thread.
[FreeRTOS Home] [Live FreeRTOS Forum] [FAQ] [Archive Top] [June 2017 Threads] +FAT ff_filelength() returns Error when file length is >2GBPosted by sonycman on June 5, 2017 Hello.
The fffilelength() function incorrectly interprets big files (>2GB) length as error and returns zero.
This is because it uses MSB of the length value returned by FFFileSize() as an error flag, which in case of the big files leads to misinterpretation of correct value as an erratic.
Regards
Vladimir.
+FAT ff_filelength() returns Error when file length is >2GBPosted by heinbali01 on June 6, 2017 Vladimir, this is indeed something to be finished: files longer than 2 GB.
Throughout the library, signed 32-bit values are used to indicate the length, and negative values are interpreted as an error.
lseek also has an intrinsic problem:
~~~
long lseek(int fd, long offset, int whence);
~~~
FreeRTOS+TCP is using the same syntax for ff_fseek() .
The Posix varian is ok, if off_t is a 64-bit signed integer:
~~~
offt lseek(int fd, offt offset, int whence);
~~~
The +FAT library will not force people to include 64-bit arithmetic.
Right now I have a 2 GB file ( -2,147,483,648 bytes :-) ) on an SD-card and I will test it. To be continued.
+FAT ff_filelength() returns Error when file length is >2GBPosted by sonycman on June 6, 2017 Hello, Hein
Thanks for an explanation.
I understand, that big files support is not so important for the embedded systems.
Its not needed in my case too.
But glad to hear such a support might be available one day in the future :)
+FAT ff_filelength() returns Error when file length is >2GBPosted by heinbali01 on June 6, 2017 All right, I made some minor changes: ff_filelength() will return correct values for files between 0 bytes and 4 GB.
A return value of 0 can mean two things: the size is either 0, or the handle is invalid.
~~~
size_t uxLength;
/* Clear errno. */
stdioSET_ERRNO( 0 );
uxLength = ff_filelength( pxFile );
if( ( uxLength != 0 ) || ( stdioGET_ERRNO() == 0 ) )
{
/* Length equals to uxLength. */
}
else
{
/* Invalid handle. */
}
~~~
Also I introduced a new low-level function that splits up the result and the file length:
~~~
/* Use the following function in case files may get larger than 2 GB. */
int32t FFGetFileSize( FFFILE *pFile, uint32t *pulSize );
~~~
And more importantly: FF_Seek() now works correctly with sizes and offsets larger than 2GB.
Here below I attach 3 files, which are a copy of the '160919' release along with mentioned changes.
~~~
fffile.c
ffstdio.c
include/ff_file.h
~~~
Hein Tibosch
+FAT ff_filelength() returns Error when file length is >2GBPosted by sonycman on June 7, 2017 Thanks a lot, Hein!
This is the best support I have ever seen!
My respects!
Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.
|