Skip to content
Snippets Groups Projects
Commit 610afe9c authored by Gregory Nutt's avatar Gregory Nutt
Browse files

FAT performance improvement. In large files, seeking to a position fromt he...

FAT performance improvement. In large files, seeking to a position fromt he beginning of the file can be very time consuming.  ftell does lssek(fd, 0, SET_CURR).  In that case, that is wasted time since we are going to seek to the same position.  This fix short-circutes fat_seek() in all cases where we attempt to seek to curren position.  Suggested by Nate Weibley
parent 1f9799b6
No related branches found
No related tags found
No related merge requests found
......@@ -1054,6 +1054,18 @@ static off_t fat_seek(FAR struct file *filep, off_t offset, int whence)
return -EINVAL;
}
/* Special case: We are seeking to the current position. This would
* happen normally with ftell() which does lseek(fd, 0, SEEK_CUR) but can
* also happen in other situation such as when SEEK_SET is used to assure
* assure sequential access in a multi-threaded environment where there
* may be are multiple users to the file descriptor.
*/
if (position == filep->f_pos)
{
return OK;
}
/* Make sure that the mount is still healthy */
fat_semtake(fs);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment