Kaynağa Gözat

fixed the O_APPEND and lseek issue in DFS FatFS.

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2496 bbd45198-f89e-11dd-88c7-29a3b14d5316
bernard.xiong@gmail.com 12 yıl önce
ebeveyn
işleme
a741197fa7
1 değiştirilmiş dosya ile 5 ekleme ve 1 silme
  1. 5 1
      components/dfs/filesystems/elmfat/dfs_elm.c

+ 5 - 1
components/dfs/filesystems/elmfat/dfs_elm.c

@@ -13,6 +13,7 @@
  * 2011-10-08     Bernard      fixed the block size in statfs.
  * 2011-11-23     Bernard      fixed the rename issue.
  * 2012-07-26     aozima       implement ff_memalloc and ff_memfree.
+ * 2012-12-19     Bernard      fixed the O_APPEND and lseek issue.
  */
  
 #include <rtthread.h>
@@ -327,7 +328,9 @@ int dfs_elm_open(struct dfs_fd *file)
 
 			if (file->flags & DFS_O_APPEND)
 			{
-				file->pos = f_lseek(fd, fd->fsize);
+				/* seek to the end of file */
+				f_lseek(fd, fd->fsize);
+				file->pos = fd->fptr;
 			}
 		}
 		else
@@ -452,6 +455,7 @@ int dfs_elm_lseek(struct dfs_fd *file, rt_off_t offset)
 		if (result == FR_OK)
 		{
 			/* return current position */
+			file->pos = fd->fptr;
 			return fd->fptr;
 		}
 	}