From 6202b6c155dfd68fac6b75810501576decc5b9f4 Mon Sep 17 00:00:00 2001 From: "goprife@gmail.com" Date: Wed, 15 Feb 2012 07:28:47 +0000 Subject: [PATCH] fix bugs in lseek in dfs_posix.c and dfs_jffs2.c git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1946 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- components/dfs/filesystems/jffs2/dfs_jffs2.c | 6 ++++-- components/dfs/src/dfs_posix.c | 7 ++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/components/dfs/filesystems/jffs2/dfs_jffs2.c b/components/dfs/filesystems/jffs2/dfs_jffs2.c index 176f7c65f0..5c06149a8c 100644 --- a/components/dfs/filesystems/jffs2/dfs_jffs2.c +++ b/components/dfs/filesystems/jffs2/dfs_jffs2.c @@ -438,10 +438,12 @@ static int dfs_jffs2_lseek(struct dfs_fd* file, jffs2_file = (cyg_file *)(file->data); /* set offset as current offset */ - jffs2_file_lseek(jffs2_file, &offset, SEEK_SET); + result = jffs2_file_lseek(jffs2_file, &offset, SEEK_SET); if (result) return jffs2_result_to_dfs(result); - return 0; + /* update file position */ + file->pos = offset; + return offset; } /* return the size of struct dirent*/ diff --git a/components/dfs/src/dfs_posix.c b/components/dfs/src/dfs_posix.c index 14ce10fa7a..f9608e4ac5 100644 --- a/components/dfs/src/dfs_posix.c +++ b/components/dfs/src/dfs_posix.c @@ -199,11 +199,16 @@ off_t lseek(int fd, off_t offset, int whence) case DFS_SEEK_END: offset += d->size; break; + + default: + rt_set_errno(-DFS_STATUS_EINVAL); + return -1; + } if (offset < 0) { - rt_set_errno(DFS_STATUS_EINVAL); + rt_set_errno(-DFS_STATUS_EINVAL); return -1; } result = dfs_file_lseek(d, offset);