mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-05-28 09:56:32 +08: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)
|
off_t dfs_elm_lseek(struct dfs_file *file, off_t offset, int wherece)
|
||||||
{
|
{
|
||||||
FRESULT result = FR_OK;
|
FRESULT result = FR_OK;
|
||||||
|
off_t pos = 0;
|
||||||
switch (wherece)
|
switch (wherece)
|
||||||
{
|
{
|
||||||
case SEEK_SET:
|
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_ASSERT(fd != RT_NULL);
|
||||||
rt_mutex_take(&file->vnode->lock, RT_WAITING_FOREVER);
|
rt_mutex_take(&file->vnode->lock, RT_WAITING_FOREVER);
|
||||||
result = f_lseek(fd, offset);
|
result = f_lseek(fd, offset);
|
||||||
|
pos = fd->fptr;
|
||||||
rt_mutex_release(&file->vnode->lock);
|
rt_mutex_release(&file->vnode->lock);
|
||||||
if (result == FR_OK)
|
if (result == FR_OK)
|
||||||
{
|
{
|
||||||
/* return current position */
|
/* return current position */
|
||||||
return fd->fptr;
|
return pos;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (file->vnode->type == FT_DIRECTORY)
|
else if (file->vnode->type == FT_DIRECTORY)
|
||||||
|
|||||||
Reference in New Issue
Block a user