[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:
zhuzhuzhu
2024-06-13 08:54:02 +08:00
committed by GitHub
parent 58e42caea7
commit 1869c543a6
5 changed files with 92 additions and 6 deletions

View File

@@ -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);