From 56ea07b02df6912459f1cec0d085b28ea947fb67 Mon Sep 17 00:00:00 2001 From: "goprife@gmail.com" Date: Thu, 9 Feb 2012 13:53:01 +0000 Subject: [PATCH] fix bugs in debug.c of jffs2 git-svn-id: https://rt-thread.googlecode.com/svn/trunk@1941 bbd45198-f89e-11dd-88c7-29a3b14d5316 --- .../dfs/filesystems/jffs2/jffs2_config.h | 2 +- components/dfs/filesystems/jffs2/src/debug.c | 1 + .../dfs/filesystems/jffs2/src/flashio.c | 27 +++++++++++-------- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/components/dfs/filesystems/jffs2/jffs2_config.h b/components/dfs/filesystems/jffs2/jffs2_config.h index 4bec81902..9a8e2c565 100644 --- a/components/dfs/filesystems/jffs2/jffs2_config.h +++ b/components/dfs/filesystems/jffs2/jffs2_config.h @@ -18,7 +18,7 @@ #define CONFIG_JFFS2_FS_DEBUG 0 /* 1 or 2 */ /* jffs2 gc thread section */ -#define CYGOPT_FS_JFFS2_GCTHREAD +//#define CYGOPT_FS_JFFS2_GCTHREAD #define CYGNUM_JFFS2_GC_THREAD_PRIORITY 20 #define CYGNUM_JFFS2_GS_THREAD_TICKS 20 #define CYGNUM_JFFS2_GC_THREAD_TICKS 20 diff --git a/components/dfs/filesystems/jffs2/src/debug.c b/components/dfs/filesystems/jffs2/src/debug.c index 250021c9d..3a7c5ea6f 100644 --- a/components/dfs/filesystems/jffs2/src/debug.c +++ b/components/dfs/filesystems/jffs2/src/debug.c @@ -15,6 +15,7 @@ #include #include #include +#include #include "nodelist.h" #include "debug.h" diff --git a/components/dfs/filesystems/jffs2/src/flashio.c b/components/dfs/filesystems/jffs2/src/flashio.c index 88b87891f..b69206b35 100644 --- a/components/dfs/filesystems/jffs2/src/flashio.c +++ b/components/dfs/filesystems/jffs2/src/flashio.c @@ -23,13 +23,15 @@ int jffs2_flash_read(struct jffs2_sb_info * c, cyg_uint32 offset, size_t * return_size, unsigned char *buffer) { + cyg_uint32 len; struct super_block *sb = OFNI_BS_2SFFJ(c); - *return_size = rt_mtd_read(RT_MTD_DEVICE(sb->s_dev), offset, buffer, size); - + len = rt_mtd_read(RT_MTD_DEVICE(sb->s_dev), offset, buffer, size); + if (len != size) + return -EIO; //rt_kprintf("fread: offset %d, size %d, ret size %d\n", // offset, size, *return_size); - + * return_size = len; return ENOERR; } @@ -37,13 +39,16 @@ int jffs2_flash_write(struct jffs2_sb_info * c, cyg_uint32 offset, const size_t size, size_t * return_size, unsigned char *buffer) { + cyg_uint32 len; struct super_block *sb = OFNI_BS_2SFFJ(c); - *return_size = rt_mtd_write(RT_MTD_DEVICE(sb->s_dev), offset, buffer, size); - - rt_kprintf("fwrite: offset %d, size %d, ret size %d\n", - offset, size, *return_size); + len = rt_mtd_write(RT_MTD_DEVICE(sb->s_dev), offset, buffer, size); + if (len != size) + return -EIO; + //rt_kprintf("fwrite: offset %d, size %d, ret size %d\n", + // offset, size, *return_size); + * return_size = len; return ENOERR; } @@ -53,7 +58,7 @@ int jffs2_flash_erase(struct jffs2_sb_info * c, rt_err_t result; struct super_block *sb = OFNI_BS_2SFFJ(c); - rt_kprintf("erase: offset %d\n", jeb->offset); + //rt_kprintf("erase: offset %d\n", jeb->offset); result = rt_mtd_erase_block(RT_MTD_DEVICE(sb->s_dev), jeb->offset); if (result != RT_EOK) @@ -107,7 +112,7 @@ int jffs2_flash_direct_writev(struct jffs2_sb_info *c, memcpy(cbufptr, vecs[j].iov_base, vecs[j].iov_len); cbufptr += vecs[j].iov_len; } - rt_kprintf("direct_write: offset %d, size %d\n", to, sizetomalloc); + //rt_kprintf("direct_write: offset %d, size %d\n", to, sizetomalloc); ret = jffs2_flash_write(c, to, sizetomalloc, &thislen, (unsigned char *) cbuf); if (thislen > totvecsize) // in case it was aligned up @@ -128,7 +133,7 @@ int jffs2_flash_direct_writev(struct jffs2_sb_info *c, lentowrite &= ~(sizeof(int) - 1); memcpy(buf, vecs[i].iov_base, lentowrite); - rt_kprintf("direct_write: offset %d, size %d\n", to, lentowrite); + //rt_kprintf("direct_write: offset %d, size %d\n", to, lentowrite); ret = jffs2_flash_write(c, to, lentowrite, &thislen, (unsigned char *) &buf); if (thislen > vecs[i].iov_len) @@ -137,7 +142,7 @@ int jffs2_flash_direct_writev(struct jffs2_sb_info *c, } else { - rt_kprintf("direct_writev: offset %d, size %d\n", to, vecs[i].iov_len); + //rt_kprintf("direct_writev: offset %d, size %d\n", to, vecs[i].iov_len); ret = jffs2_flash_write(c, to, vecs[i].iov_len, &thislen, vecs[i].iov_base); }