From 8b97ea95c7fb12167c1d89519e9276bbfadf50c9 Mon Sep 17 00:00:00 2001 From: Aleksandr Vyhovanec Date: Fri, 5 Jan 2018 20:52:53 +0000 Subject: [PATCH] Merged in AVyhovanec/nuttx (pull request #564) FAT. Effectively handles the situation when a new file position is within the current sector. * Find begin of the next token * EOL * revert * Accelerates the work of the FS with a multitude of operations to write small pieces of data within the current sector. Approved-by: Gregory Nutt --- fs/fat/fs_fat32.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fs/fat/fs_fat32.c b/fs/fat/fs_fat32.c index e3ad8b166c0..30c8ce1c3a8 100644 --- a/fs/fat/fs_fat32.c +++ b/fs/fat/fs_fat32.c @@ -1071,10 +1071,13 @@ static off_t fat_seek(FAR struct file *filep, off_t offset, int whence) * 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. + * Effectively handles the situation when a new file position is within + * the current sector. */ - if (position == filep->f_pos) + if (position / fs->fs_hwsectorsize == filep->f_pos / fs->fs_hwsectorsize) { + filep->f_pos = position; return OK; }