提交 5f85cb2f 编写于 作者: B bernard.xiong

fix lseek issue.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1032 bbd45198-f89e-11dd-88c7-29a3b14d5316
上级 04861823
......@@ -364,8 +364,9 @@ int dfs_elm_write(struct dfs_fd* file, const void* buf, rt_size_t len)
RT_ASSERT(fd != RT_NULL);
result = f_write(fd, buf, len, &byte_write);
/* update position */
/* update position and file size */
file->pos = fd->fptr;
file->size = fd->fsize;
if (result == FR_OK) return byte_write;
return elm_result_to_dfs(result);
......@@ -392,6 +393,11 @@ int dfs_elm_lseek(struct dfs_fd* file, rt_off_t offset)
RT_ASSERT(fd != RT_NULL);
result = f_lseek(fd, offset);
if (result == FR_OK)
{
/* return current position */
return fd->fptr;
}
return elm_result_to_dfs(result);
}
......
......@@ -557,6 +557,8 @@ int nfs_read(struct dfs_fd* file, void *buf, rt_size_t count)
}
bytes=res.READ3res_u.resok.count;
fd->offset += bytes;
/* update current position */
file->pos = fd->offset;
memcpy(buf, res.READ3res_u.resok.data.data_val, bytes);
}
xdr_free((xdrproc_t)xdr_READ3res, (char *)&res);
......@@ -606,6 +608,9 @@ int nfs_write(struct dfs_fd* file, const void *buf, rt_size_t count)
{
bytes=res.WRITE3res_u.resok.count;
fd->offset+=bytes;
/* update current position */
file->pos = fd->offset;
/* todo: update file size */
}
xdr_free((xdrproc_t)xdr_WRITE3res, (char *)&res);
......
......@@ -290,12 +290,19 @@ int dfs_file_flush(struct dfs_fd* fd)
*/
int dfs_file_lseek(struct dfs_fd* fd, rt_off_t offset)
{
int result;
struct dfs_filesystem* fs = fd->fs;
if (fd == RT_NULL) return -DFS_STATUS_EINVAL;
if (fs->ops->lseek == RT_NULL) return -DFS_STATUS_ENOSYS;
return fs->ops->lseek(fd, offset);
result = fs->ops->lseek(fd, offset);
/* update current position */
if (result >= 0)
fd->pos = result;
return result;
}
/**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册