mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-02-05 05:23:46 +00:00
[FIX][DFSv2][ELMFAT]修复多线程环境下lseek返回值概率性被篡改的问题
This commit is contained in:
@@ -629,7 +629,7 @@ int dfs_elm_flush(struct dfs_file *file)
|
||||
off_t dfs_elm_lseek(struct dfs_file *file, off_t offset, int wherece)
|
||||
{
|
||||
FRESULT result = FR_OK;
|
||||
|
||||
off_t pos = 0;
|
||||
switch (wherece)
|
||||
{
|
||||
case SEEK_SET:
|
||||
@@ -656,11 +656,12 @@ off_t dfs_elm_lseek(struct dfs_file *file, off_t offset, int wherece)
|
||||
RT_ASSERT(fd != RT_NULL);
|
||||
rt_mutex_take(&file->vnode->lock, RT_WAITING_FOREVER);
|
||||
result = f_lseek(fd, offset);
|
||||
pos = fd->fptr;
|
||||
rt_mutex_release(&file->vnode->lock);
|
||||
if (result == FR_OK)
|
||||
{
|
||||
/* return current position */
|
||||
return fd->fptr;
|
||||
return pos;
|
||||
}
|
||||
}
|
||||
else if (file->vnode->type == FT_DIRECTORY)
|
||||
|
||||
Reference in New Issue
Block a user