mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2025-12-27 17:40:22 +00:00
[fix]fix tmpfs bug (#8970)
* first * second * thrid * Update SConscript * tmpfs testcase default n * Update dfs_tmpfs.c * format document --------- Co-authored-by: zhujiale <zhujiale@rt-thread.com>
This commit is contained in:
@@ -294,18 +294,17 @@ find_subpath:
|
||||
|
||||
static ssize_t dfs_tmpfs_read(struct dfs_file *file, void *buf, size_t count, off_t *pos)
|
||||
{
|
||||
rt_size_t length;
|
||||
ssize_t length;
|
||||
struct tmpfs_file *d_file;
|
||||
|
||||
d_file = (struct tmpfs_file *)file->vnode->data;
|
||||
RT_ASSERT(d_file != NULL);
|
||||
|
||||
rt_mutex_take(&file->vnode->lock, RT_WAITING_FOREVER);
|
||||
|
||||
if (count < file->vnode->size - *pos)
|
||||
ssize_t size = (ssize_t)file->vnode->size;
|
||||
if ((ssize_t)count < size - *pos)
|
||||
length = count;
|
||||
else
|
||||
length = file->vnode->size - *pos;
|
||||
length = size - *pos;
|
||||
|
||||
if (length > 0)
|
||||
memcpy(buf, &(d_file->data[*pos]), length);
|
||||
|
||||
Reference in New Issue
Block a user