fix lseek issue.
git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1032 bbd45198-f89e-11dd-88c7-29a3b14d5316
This commit is contained in:
parent
0486182353
commit
5f85cb2f78
|
@ -364,8 +364,9 @@ int dfs_elm_write(struct dfs_fd* file, const void* buf, rt_size_t len)
|
||||||
RT_ASSERT(fd != RT_NULL);
|
RT_ASSERT(fd != RT_NULL);
|
||||||
|
|
||||||
result = f_write(fd, buf, len, &byte_write);
|
result = f_write(fd, buf, len, &byte_write);
|
||||||
/* update position */
|
/* update position and file size */
|
||||||
file->pos = fd->fptr;
|
file->pos = fd->fptr;
|
||||||
|
file->size = fd->fsize;
|
||||||
if (result == FR_OK) return byte_write;
|
if (result == FR_OK) return byte_write;
|
||||||
|
|
||||||
return elm_result_to_dfs(result);
|
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);
|
RT_ASSERT(fd != RT_NULL);
|
||||||
|
|
||||||
result = f_lseek(fd, offset);
|
result = f_lseek(fd, offset);
|
||||||
|
if (result == FR_OK)
|
||||||
|
{
|
||||||
|
/* return current position */
|
||||||
|
return fd->fptr;
|
||||||
|
}
|
||||||
return elm_result_to_dfs(result);
|
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;
|
bytes=res.READ3res_u.resok.count;
|
||||||
fd->offset += bytes;
|
fd->offset += bytes;
|
||||||
|
/* update current position */
|
||||||
|
file->pos = fd->offset;
|
||||||
memcpy(buf, res.READ3res_u.resok.data.data_val, bytes);
|
memcpy(buf, res.READ3res_u.resok.data.data_val, bytes);
|
||||||
}
|
}
|
||||||
xdr_free((xdrproc_t)xdr_READ3res, (char *)&res);
|
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;
|
bytes=res.WRITE3res_u.resok.count;
|
||||||
fd->offset+=bytes;
|
fd->offset+=bytes;
|
||||||
|
/* update current position */
|
||||||
|
file->pos = fd->offset;
|
||||||
|
/* todo: update file size */
|
||||||
}
|
}
|
||||||
xdr_free((xdrproc_t)xdr_WRITE3res, (char *)&res);
|
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 dfs_file_lseek(struct dfs_fd* fd, rt_off_t offset)
|
||||||
{
|
{
|
||||||
|
int result;
|
||||||
struct dfs_filesystem* fs = fd->fs;
|
struct dfs_filesystem* fs = fd->fs;
|
||||||
|
|
||||||
if (fd == RT_NULL) return -DFS_STATUS_EINVAL;
|
if (fd == RT_NULL) return -DFS_STATUS_EINVAL;
|
||||||
if (fs->ops->lseek == RT_NULL) return -DFS_STATUS_ENOSYS;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue