summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--components/dfs/SConscript19
-rw-r--r--components/dfs/filesystems/jffs2/cyg/compress/src/zutil.h2
-rw-r--r--components/dfs/filesystems/jffs2/dfs_jffs2.c60
-rw-r--r--components/dfs/filesystems/jffs2/include/linux/jffs2_fs_sb.h1
-rw-r--r--components/dfs/filesystems/jffs2/jffs2_config.h31
-rw-r--r--components/dfs/filesystems/jffs2/kernel/linux/config.h17
-rw-r--r--components/dfs/filesystems/jffs2/kernel/linux/kernel.h1
-rw-r--r--components/dfs/filesystems/jffs2/kernel/linux/slab.h2
-rw-r--r--components/dfs/filesystems/jffs2/porting.c7
-rw-r--r--components/dfs/filesystems/jffs2/porting.h51
-rw-r--r--components/dfs/filesystems/jffs2/src/compr_rubin.c4
-rw-r--r--components/dfs/filesystems/jffs2/src/compr_zlib.c2
-rw-r--r--components/dfs/filesystems/jffs2/src/debug.h4
-rw-r--r--components/dfs/filesystems/jffs2/src/erase.c2
-rw-r--r--components/dfs/filesystems/jffs2/src/flashio.c10
-rw-r--r--components/dfs/filesystems/jffs2/src/fs-ecos.c10
-rw-r--r--components/dfs/filesystems/jffs2/src/gc.c20
-rw-r--r--components/dfs/filesystems/jffs2/src/gcthread.c7
-rw-r--r--components/dfs/filesystems/jffs2/src/nodelist.c2
-rw-r--r--components/dfs/filesystems/jffs2/src/nodelist.h3
-rw-r--r--components/dfs/filesystems/jffs2/src/nodemgmt.c4
-rw-r--r--components/dfs/filesystems/jffs2/src/os-ecos.h22
-rw-r--r--components/dfs/filesystems/jffs2/src/os-rtthread.h6
-rw-r--r--components/dfs/filesystems/jffs2/src/pushpull.h2
-rw-r--r--components/dfs/filesystems/jffs2/src/read.c2
-rw-r--r--components/dfs/filesystems/jffs2/src/readinode.c4
-rw-r--r--components/dfs/filesystems/jffs2/src/write.c10
-rw-r--r--include/rtdef.h1
28 files changed, 186 insertions, 120 deletions
diff --git a/components/dfs/SConscript b/components/dfs/SConscript
index 728bcd65d0..e2f5709492 100644
--- a/components/dfs/SConscript
+++ b/components/dfs/SConscript
@@ -96,6 +96,18 @@ filesystems/uffs/flash/nand_ids.c
jffs2 = Split('''
filesystems/jffs2/dfs_jffs2.c
filesystems/jffs2/porting.c
+
+filesystems/jffs2/cyg/compress/src/adler32.c
+filesystems/jffs2/cyg/compress/src/compress.c
+filesystems/jffs2/cyg/compress/src/deflate.c
+filesystems/jffs2/cyg/compress/src/infback.c
+filesystems/jffs2/cyg/compress/src/inffast.c
+filesystems/jffs2/cyg/compress/src/inflate.c
+filesystems/jffs2/cyg/compress/src/inftrees.c
+filesystems/jffs2/cyg/compress/src/trees.c
+filesystems/jffs2/cyg/compress/src/uncompr.c
+filesystems/jffs2/cyg/compress/src/zutil.c
+
filesystems/jffs2/cyg/crc/crc16.c
filesystems/jffs2/cyg/crc/crc32.c
filesystems/jffs2/cyg/crc/posix_crc.c
@@ -104,12 +116,14 @@ filesystems/jffs2/src/build.c
filesystems/jffs2/src/compr.c
filesystems/jffs2/src/compr_rtime.c
filesystems/jffs2/src/compr_rubin.c
+filesystems/jffs2/src/compr_zlib.c
filesystems/jffs2/src/debug.c
filesystems/jffs2/src/dir-ecos.c
filesystems/jffs2/src/erase.c
filesystems/jffs2/src/flashio.c
filesystems/jffs2/src/fs-ecos.c
filesystems/jffs2/src/gc.c
+filesystems/jffs2/src/gcthread.c
filesystems/jffs2/src/malloc-ecos.c
filesystems/jffs2/src/nodelist.c
filesystems/jffs2/src/nodemgmt.c
@@ -158,8 +172,9 @@ if GetDepend('RT_USING_DFS_JFFS2'):
path = path + [RTT_ROOT + '/components/dfs/filesystems/jffs2/src', \
RTT_ROOT + '/components/dfs/filesystems/jffs2/kernel', \
RTT_ROOT + '/components/dfs/filesystems/jffs2/include', \
- RTT_ROOT + '/components/dfs/filesystems/jffs2']
- CPPDEFINES = CPPDEFINES + ['__ECOS']
+ RTT_ROOT + '/components/dfs/filesystems/jffs2', \
+ RTT_ROOT + '/components/dfs/filesystems/jffs2/cyg/compress']
+ #CPPDEFINES = CPPDEFINES + ['__ECOS', 'CYGOPT_FS_JFFS2_WRITE', 'CYGPKG_FS_JFFS2_RET_DIRENT_DTYPE']
group = DefineGroup('Filesystem', src_local, depend = ['RT_USING_DFS'], CPPPATH = path, CPPDEFINES = CPPDEFINES)
diff --git a/components/dfs/filesystems/jffs2/cyg/compress/src/zutil.h b/components/dfs/filesystems/jffs2/cyg/compress/src/zutil.h
index 013754a1f7..a91c9a5eb7 100644
--- a/components/dfs/filesystems/jffs2/cyg/compress/src/zutil.h
+++ b/components/dfs/filesystems/jffs2/cyg/compress/src/zutil.h
@@ -28,7 +28,7 @@
# include <stddef.h>
# endif
# include <string.h>
-# include <stdlib.h>
+//# include <stdlib.h> //remove by prife @ 2012/1/30
#endif
#ifdef NO_ERRNO_H
# ifdef _WIN32_WCE
diff --git a/components/dfs/filesystems/jffs2/dfs_jffs2.c b/components/dfs/filesystems/jffs2/dfs_jffs2.c
index b8baa42c56..d84a69bf88 100644
--- a/components/dfs/filesystems/jffs2/dfs_jffs2.c
+++ b/components/dfs/filesystems/jffs2/dfs_jffs2.c
@@ -23,6 +23,7 @@
#include "dfs_jffs2.h"
#include "porting.h"
+#include <string.h>
#define FILE_PATH_MAX 256 /* the longest file path */
@@ -31,10 +32,6 @@
#if DEVICE_PART_MAX > 1
#error "support only one jffs2 partition on a flash device!"
#endif
-
-extern cyg_fileops jffs2_fileops;
-extern cyg_fileops jffs2_dirops;
-extern struct cyg_fstab_entry jffs2_fste;
/* make sure the following struct var had been initilased to 0! */ //fixme
struct device_part
@@ -165,7 +162,7 @@ static int dfs_jffs2_mount(struct dfs_filesystem* fs,
* s_dev in struct super_block, and mte->data will be
* filled with jffs2_sb(see the source of jffs2_mount.
*/
- mte->data = (CYG_ADDRWORD)fs->dev_id;
+ mte->data = (CYG_ADDRWORD)fs->dev_id;
device_partition[index].dev = fs->dev_id;
/* after jffs2_mount, mte->data will not be dev_id any more */
@@ -175,7 +172,7 @@ static int dfs_jffs2_mount(struct dfs_filesystem* fs,
return jffs2_result_to_dfs(result);
}
/* save this pointer */
- device_partition[index].mte = mte;
+ device_partition[index].mte = mte;
return 0;
}
@@ -204,7 +201,6 @@ static int dfs_jffs2_unmount(struct dfs_filesystem* fs)
{
if (device_partition[index].dev == fs->dev_id)
{
- struct cyg_mtab_entry * mte;
result = jffs2_umount(device_partition[index].mte);
if (result)
return jffs2_result_to_dfs(result);
@@ -237,7 +233,7 @@ static int dfs_jffs2_statfs(struct dfs_filesystem* fs,
RT_ASSERT(mte->data != NULL);
- jffs2_get_info_from_sb(mte->data, &info);
+ jffs2_get_info_from_sb((void *)mte->data, &info);
buf->f_bsize = info.sector_size;
buf->f_blocks = info.nr_blocks;
buf->f_bfree = info.free_size; //fixme need test!
@@ -259,7 +255,7 @@ static int dfs_jffs2_open(struct dfs_fd* file)
int result;
cyg_file * jffs2_file;
struct cyg_mtab_entry * mte;
- const char * name;
+ const char * name;
oflag = file->flags;
@@ -311,7 +307,7 @@ static int dfs_jffs2_open(struct dfs_fd* file)
if (oflag & DFS_O_TRUNC) mode |= JFFS2_O_TRUNC;
/* Creates a new file. The function fails if the file is already existing. */
if (oflag & DFS_O_EXCL) mode |= JFFS2_O_EXCL;
-// if (oflag & DFS_O_APPEND) mode |= JFFS2_O_APPEND;
+// if (oflag & DFS_O_APPEND) mode |= JFFS2_O_APPEND;
result = jffs2_open(mte, 0, name, mode, jffs2_file);
if (result != 0)
@@ -325,16 +321,16 @@ static int dfs_jffs2_open(struct dfs_fd* file)
file->data = jffs2_file;
file->pos = jffs2_file->f_offset;
file->size = 0;
- jffs2_file_lseek(jffs2_file, &(file->size), SEEK_END);
- jffs2_file->f_offset = file->pos;
+ jffs2_file_lseek(jffs2_file, (off_t *)(&(file->size)), SEEK_END);
+ jffs2_file->f_offset = (off_t)file->pos;
- if (oflag & DFS_O_APPEND)
+ if (oflag & DFS_O_APPEND)
{
- file->pos = file->size;
+ file->pos = file->size;
jffs2_file->f_offset = file->size;
}
return 0;
-}
+}
static int dfs_jffs2_close(struct dfs_fd* file)
{
@@ -407,7 +403,7 @@ static int dfs_jffs2_write(struct dfs_fd* file,
RT_ASSERT(file->data != NULL);
jffs2_file = (cyg_file *)(file->data);
uio_s.uio_iov = &iovec;
- uio_s.uio_iov->iov_base = buf;
+ uio_s.uio_iov->iov_base = (void *)buf;
uio_s.uio_iov->iov_len = len;
uio_s.uio_iovcnt = 1; //must be 1
//uio_s.uio_offset //not used...
@@ -457,7 +453,7 @@ static int dfs_jffs2_getdents(struct dfs_fd* file,
struct CYG_IOVEC_TAG iovec;
struct jffs2_dirent jffs2_d;
struct dirent * d;
- rt_uint32_t index;
+ rt_uint32_t index;
int result;
RT_ASSERT(file->data != RT_NULL);
@@ -525,7 +521,7 @@ static int dfs_jffs2_unlink(struct dfs_filesystem* fs, const char* path)
path++;
/* judge file type, dir is to be delete by rmdir, others by unlink */
- result = jffs2_ops_stat(mte, mte->root, path, &s);
+ result = jffs2_porting_stat(mte, mte->root, path, (void *)&s);
if (result)
return jffs2_result_to_dfs(result);
@@ -555,12 +551,12 @@ static int dfs_jffs2_rename(struct dfs_filesystem* fs,
result = _find_fs(&mte, fs->dev_id);
if (result)
- return -DFS_STATUS_ENOENT;
+ return -DFS_STATUS_ENOENT;
if (*oldpath == '/')
oldpath += 1;
if (*newpath == '/')
- newpath += 1;
+ newpath += 1;
result = jffs2_rename(mte, mte->root, oldpath, mte->root, newpath);
if (result)
@@ -572,19 +568,21 @@ static int dfs_jffs2_stat(struct dfs_filesystem* fs, const char *path, struct st
{
int result;
struct jffs2_stat s;
- cyg_mtab_entry * mte;
+ cyg_mtab_entry * mte;
/* deal the path for jffs2 */
RT_ASSERT(!((path[0] == '/') && (path[1] == 0)));
if (path[0] == '/')
- path++;
-
+ path++;
+
result = _find_fs(&mte, fs->dev_id);
if (result)
- return -DFS_STATUS_ENOENT;
+ return -DFS_STATUS_ENOENT;
+
+// result = jffs2_ops_stat(mte, mte->root, path, &s);
+ result = jffs2_porting_stat(mte, mte->root, path, (void *)&s);
- result = jffs2_ops_stat(mte, mte->root, path, &s);
if (result)
return jffs2_result_to_dfs(result);
/* convert to dfs stat structure */
@@ -593,16 +591,16 @@ static int dfs_jffs2_stat(struct dfs_filesystem* fs, const char *path, struct st
case JFFS2_S_IFREG:
st->st_mode = DFS_S_IFREG | DFS_S_IRUSR | DFS_S_IRGRP | DFS_S_IROTH |
DFS_S_IWUSR | DFS_S_IWGRP | DFS_S_IWOTH;
- break;
+ break;
case JFFS2_S_IFDIR:
- st->st_mode = DFS_S_IFDIR | DFS_S_IXUSR | DFS_S_IXGRP | DFS_S_IXOTH;
- break;
+ st->st_mode = DFS_S_IFDIR | DFS_S_IXUSR | DFS_S_IXGRP | DFS_S_IXOTH;
+ break;
- default:
- st->st_mode = DFS_DT_UNKNOWN; //fixme
+ default:
+ st->st_mode = DFS_DT_UNKNOWN; //fixme
break;
- }
+ }
st->st_dev = 0;
st->st_size = s.st_size;
diff --git a/components/dfs/filesystems/jffs2/include/linux/jffs2_fs_sb.h b/components/dfs/filesystems/jffs2/include/linux/jffs2_fs_sb.h
index 1e21546622..066e9400bc 100644
--- a/components/dfs/filesystems/jffs2/include/linux/jffs2_fs_sb.h
+++ b/components/dfs/filesystems/jffs2/include/linux/jffs2_fs_sb.h
@@ -3,6 +3,7 @@
#ifndef _JFFS2_FS_SB
#define _JFFS2_FS_SB
+#include "jffs2_config.h"
#include <linux/types.h>
#include <linux/spinlock.h>
#include <linux/workqueue.h>
diff --git a/components/dfs/filesystems/jffs2/jffs2_config.h b/components/dfs/filesystems/jffs2/jffs2_config.h
new file mode 100644
index 0000000000..18b01b8ae5
--- /dev/null
+++ b/components/dfs/filesystems/jffs2/jffs2_config.h
@@ -0,0 +1,31 @@
+#ifndef JFFS2_CONFIG_H
+#define JFFS2_CONFIG_H
+
+#define __ECOS /* must be defined */
+
+#define CYGPKG_FS_JFFS2_RET_DIRENT_DTYPE /* should be enabled */
+#if defined(CYGPKG_FS_JFFS2_RET_DIRENT_DTYPE)
+ #define CYGPKG_FILEIO_DIRENT_DTYPE
+#endif
+
+#define CYGOPT_FS_JFFS2_WRITE /* if not defined, jffs2 is read only*/
+
+/* jffs2 debug output opion */
+#define CONFIG_JFFS2_FS_DEBUG 0 /* 1 or 2 */
+
+/* jffs2 gc thread section */
+#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
+
+//#define CONFIG_JFFS2_FS_WRITEBUFFER /* should not be enabled */
+
+/* zlib section*/
+//#define CONFIG_JFFS2_ZLIB
+//#define CONFIG_JFFS2_RTIME
+//#define CONFIG_JFFS2_RUBIN
+//#define CONFIG_JFFS2_CMODE_NONE
+//#define CONFIG_JFFS2_CMODE_SIZE
+
+#endif
diff --git a/components/dfs/filesystems/jffs2/kernel/linux/config.h b/components/dfs/filesystems/jffs2/kernel/linux/config.h
index 4e14c05109..355e175f65 100644
--- a/components/dfs/filesystems/jffs2/kernel/linux/config.h
+++ b/components/dfs/filesystems/jffs2/kernel/linux/config.h
@@ -1,13 +1,12 @@
#ifndef __LINUX_CONFIG_H__
-#define __LINUX_CONFIG_H__
-
-#define CONFIG_JFFS2_FS_DEBUG 0
+#define __LINUX_CONFIG_H__
+
#define GFP_KERNEL 0
-
+
/* #define CONFIG_JFFS2_FS_WRITEBUFFER 0 */
-/* #define CONFIG_JFFS2_PROC */
-/* #define CONFIG_JFFS2_RTIME */
-/* #define CONFIG_JFFS2_RUBIN */
-/* #define CONFIG_JFFS2_ZLIB */
-
+/* #define CONFIG_JFFS2_PROC */
+/* #define CONFIG_JFFS2_RTIME */
+/* #define CONFIG_JFFS2_RUBIN */
+/* #define CONFIG_JFFS2_ZLIB */
+
#endif /* __LINUX_CONFIG_H__ */
diff --git a/components/dfs/filesystems/jffs2/kernel/linux/kernel.h b/components/dfs/filesystems/jffs2/kernel/linux/kernel.h
index b695930109..f215cd5685 100644
--- a/components/dfs/filesystems/jffs2/kernel/linux/kernel.h
+++ b/components/dfs/filesystems/jffs2/kernel/linux/kernel.h
@@ -2,6 +2,7 @@
#define __LINUX_KERNEL_H__
//#include <cyg/infra/diag.h>
//#include <stdio.h> //mod by prife @ 2011/11/20
+#include "jffs2_config.h"
#define jiffies 100
diff --git a/components/dfs/filesystems/jffs2/kernel/linux/slab.h b/components/dfs/filesystems/jffs2/kernel/linux/slab.h
index 5b711b829d..c950123deb 100644
--- a/components/dfs/filesystems/jffs2/kernel/linux/slab.h
+++ b/components/dfs/filesystems/jffs2/kernel/linux/slab.h
@@ -1,7 +1,7 @@
#ifndef __LINUX_SLAB_H__
#define __LINUX_SLAB_H__
-#include <stdlib.h> //prife
+//#include <stdlib.h> //prife
#include <asm/page.h> /* Don't ask. Linux headers are a mess. */
diff --git a/components/dfs/filesystems/jffs2/porting.c b/components/dfs/filesystems/jffs2/porting.c
index f8722497f2..03963c8a8c 100644
--- a/components/dfs/filesystems/jffs2/porting.c
+++ b/components/dfs/filesystems/jffs2/porting.c
@@ -1,6 +1,5 @@
#include <linux/kernel.h>
#include "nodelist.h"
-#include "os-ecos.h"
#include "porting.h"
@@ -22,3 +21,9 @@ void jffs2_get_info_from_sb(void * data, struct jffs2_fs_info * info)
info->nr_blocks = c->nr_blocks;
info->free_size = c->free_size; //fixme need test!
}
+
+int jffs2_porting_stat(cyg_mtab_entry * mte, cyg_dir dir, const char *name,
+ void * stat_buf)
+{
+ return jffs2_fste.stat(mte, mte->root, name, (struct stat *)stat_buf);
+}
diff --git a/components/dfs/filesystems/jffs2/porting.h b/components/dfs/filesystems/jffs2/porting.h
index bd30adfd86..3a8f3a8719 100644
--- a/components/dfs/filesystems/jffs2/porting.h
+++ b/components/dfs/filesystems/jffs2/porting.h
@@ -1,18 +1,18 @@
-#ifndef _PORTING_H
-#define _PORTING_H
-
-/* the following should be same with os_sys_stat.h */
-#define JFFS2_S_IFMT 0x000003FF
-#define JFFS2_S_IFDIR (1<<0)
-#define JFFS2_S_IFREG (1<<3)
-
-struct jffs2_fs_info
-{
- unsigned sector_size; /* a erasing block size*/
- unsigned nr_blocks; /* number of blocks in flash */
- unsigned free_size;
-};
-
+#ifndef _PORTING_H
+#define _PORTING_H
+
+/* the following should be same with os_sys_stat.h */
+#define JFFS2_S_IFMT 0x000003FF
+#define JFFS2_S_IFDIR (1<<0)
+#define JFFS2_S_IFREG (1<<3)
+
+struct jffs2_fs_info
+{
+ unsigned sector_size; /* a erasing block size*/
+ unsigned nr_blocks; /* number of blocks in flash */
+ unsigned free_size;
+};
+
struct jffs2_stat {
unsigned long st_mode; /* File mode */
unsigned int st_ino; /* File serial number */
@@ -24,9 +24,11 @@ struct jffs2_stat {
long st_atime; /* Last access time */
long st_mtime; /* Last data modification time */
long st_ctime; /* Last file status change time */
-};
-
-#define NAME_MAX 14
+};
+#ifndef NAME_MAX
+#define NAME_MAX 14
+#endif
+
struct jffs2_dirent
{
unsigned long d_type; // Only supported with FATFS, RAMFS, ROMFS,
@@ -34,5 +36,14 @@ struct jffs2_dirent
// d_type is not part of POSIX so
// should be used with caution.
char d_name[NAME_MAX+1];
-};
-#endif
+};
+
+extern cyg_fileops jffs2_fileops;
+extern cyg_fileops jffs2_dirops;
+extern struct cyg_fstab_entry jffs2_fste;
+
+extern void jffs2_get_info_from_sb(void * data, struct jffs2_fs_info * info);
+extern int jffs2_porting_stat(cyg_mtab_entry * mte, cyg_dir dir, const char *name,
+ void * stat_buf);
+
+#endif
diff --git a/components/dfs/filesystems/jffs2/src/compr_rubin.c b/components/dfs/filesystems/jffs2/src/compr_rubin.c
index 98f7443156..e1030d6778 100644
--- a/components/dfs/filesystems/jffs2/src/compr_rubin.c
+++ b/components/dfs/filesystems/jffs2/src/compr_rubin.c
@@ -195,7 +195,7 @@ static int rubin_do_compress(int bit_divider, int *bits, unsigned char *data_in,
int pos=0;
struct rubin_state rs;
- init_pushpull(&rs.pp, cpage_out, *dstlen * 8, 0, 32);
+ init_pushpull(&rs.pp, (char *)cpage_out, *dstlen * 8, 0, 32);
init_rubin(&rs, bit_divider, bits);
@@ -299,7 +299,7 @@ static void rubin_do_decompress(int bit_divider, int *bits, unsigned char *cdata
int outpos = 0;
struct rubin_state rs;
- init_pushpull(&rs.pp, cdata_in, srclen, 0, 0);
+ init_pushpull(&rs.pp, (char *)cdata_in, srclen, 0, 0);
init_decode(&rs, bit_divider, bits);
while (outpos < destlen) {
diff --git a/components/dfs/filesystems/jffs2/src/compr_zlib.c b/components/dfs/filesystems/jffs2/src/compr_zlib.c
index 8b0cb22e15..7fe18e088c 100644
--- a/components/dfs/filesystems/jffs2/src/compr_zlib.c
+++ b/components/dfs/filesystems/jffs2/src/compr_zlib.c
@@ -10,7 +10,7 @@
* $Id: compr_zlib.c,v 1.31 2005/05/20 19:30:06 gleixner Exp $
*
*/
-
+#include "jffs2_config.h"
#if !defined(__KERNEL__) && !defined(__ECOS)
#error "The userspace support got too messy and was removed. Update your mkfs.jffs2"
#endif
diff --git a/components/dfs/filesystems/jffs2/src/debug.h b/components/dfs/filesystems/jffs2/src/debug.h
index 3b9f2a6ddb..652f59068d 100644
--- a/components/dfs/filesystems/jffs2/src/debug.h
+++ b/components/dfs/filesystems/jffs2/src/debug.h
@@ -12,9 +12,9 @@
*/
#ifndef _JFFS2_DEBUG_H_
#define _JFFS2_DEBUG_H_
-
+#include "jffs2_config.h"
#include <linux/config.h>
-#include <linux/slab.h> //prife
+
#ifndef CONFIG_JFFS2_FS_DEBUG
#define CONFIG_JFFS2_FS_DEBUG 0
#endif
diff --git a/components/dfs/filesystems/jffs2/src/erase.c b/components/dfs/filesystems/jffs2/src/erase.c
index eabc544591..3844e1d389 100644
--- a/components/dfs/filesystems/jffs2/src/erase.c
+++ b/components/dfs/filesystems/jffs2/src/erase.c
@@ -333,7 +333,7 @@ static int jffs2_block_check_erase(struct jffs2_sb_info *c, struct jffs2_erasebl
}
for (i=0; i<readlen; i += sizeof(unsigned long)) {
/* It's OK. We know it's properly aligned */
- unsigned long *datum = (char *)ebuf + i;
+ unsigned long *datum = (unsigned long *)((char *)ebuf + i);
if (*datum + 1) {
*bad_offset += i;
printk(KERN_WARNING "Newly-erased block contained word 0x%lx at offset 0x%08x\n", *datum, *bad_offset);
diff --git a/components/dfs/filesystems/jffs2/src/flashio.c b/components/dfs/filesystems/jffs2/src/flashio.c
index d89480c990..fb0d967983 100644
--- a/components/dfs/filesystems/jffs2/src/flashio.c
+++ b/components/dfs/filesystems/jffs2/src/flashio.c
@@ -25,8 +25,8 @@
//#include <io.h>
//#include <fcntl.h>
// #include <string.h>
-//#include <sys/stat.h>
-
+//#include <sys/stat.h>
+
#include <rtthread.h>
cyg_bool jffs2_flash_read(struct jffs2_sb_info * c,
@@ -128,7 +128,7 @@ jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct iovec *vecs,
}
ret =
jffs2_flash_write(c, to, sizetomalloc,
- &thislen, cbuf);
+ &thislen, (unsigned char *)cbuf);
if (thislen > totvecsize) // in case it was aligned up
thislen = totvecsize;
totlen += thislen;
@@ -147,7 +147,7 @@ jffs2_flash_direct_writev(struct jffs2_sb_info *c, const struct iovec *vecs,
ret =
jffs2_flash_write(c, to, lentowrite,
- &thislen, (char *) &buf);
+ &thislen, (unsigned char *) &buf);
if (thislen > vecs[i].iov_len)
thislen = vecs[i].iov_len;
} // else
@@ -180,7 +180,7 @@ cyg_bool jffs2_flash_erase(struct jffs2_sb_info * c,
// err = cyg_io_get_config(sb->s_dev, CYG_IO_GET_CONFIG_FLASH_ERASE,
// &e, &len);
- res = rt_device_control(sb->s_dev, RT_DEVICE_CTRL_BLK_ERASE, jeb->offset);
+ res = rt_device_control(sb->s_dev, RT_DEVICE_CTRL_BLK_ERASE, (void *)(jeb->offset));
return ((res == RT_EOK) ? ENOERR : -EIO);
//���� jeb���ݽṹ
diff --git a/components/dfs/filesystems/jffs2/src/fs-ecos.c b/components/dfs/filesystems/jffs2/src/fs-ecos.c
index 364d2bbbae..d40955a670 100644
--- a/components/dfs/filesystems/jffs2/src/fs-ecos.c
+++ b/components/dfs/filesystems/jffs2/src/fs-ecos.c
@@ -10,7 +10,7 @@
*
* $Id: fs-ecos.c,v 1.44 2005/07/24 15:29:57 dedekind Exp $
*
- */
+ */
#include <stdio.h> //prife for SEEK_SET SEEK_CUR SEEK_END
#include <linux/kernel.h>
@@ -491,6 +491,10 @@ static int jffs2_read_super(struct super_block *sb)
struct rt_device_blk_geometry geometry; //fixme need a new struct type!
c = JFFS2_SB_INFO(sb);
+
+//init some block
+ init_MUTEX(&c->alloc_sem);
+ init_MUTEX(&c->erase_free_sem);
rt_memset(&geometry, 0, sizeof(geometry));
rt_device_control(sb->s_dev, RT_DEVICE_CTRL_BLK_GETGEOME, &geometry);
@@ -552,7 +556,7 @@ int jffs2_mount(cyg_fstab_entry * fste, cyg_mtab_entry * mte)
// }
// }
jffs2_sb = NULL;
- t = mte->data; //get from dfs_jffs2;
+ t = (cyg_io_handle_t)mte->data; //get from dfs_jffs2;
if (jffs2_sb == NULL) {
jffs2_sb = malloc(sizeof (struct super_block));
@@ -1637,8 +1641,6 @@ static int jffs2_fo_getinfo(struct CYG_FILE_TAG *fp, int key, void *buf,
err = EINVAL;
}
return err;
-
- return ENOERR;
}
// -------------------------------------------------------------------------
diff --git a/components/dfs/filesystems/jffs2/src/gc.c b/components/dfs/filesystems/jffs2/src/gc.c
index 67c05302a2..34ad6ca547 100644
--- a/components/dfs/filesystems/jffs2/src/gc.c
+++ b/components/dfs/filesystems/jffs2/src/gc.c
@@ -126,8 +126,8 @@ int jffs2_garbage_collect_pass(struct jffs2_sb_info *c)
struct jffs2_raw_node_ref *raw;
int ret = 0, inum, nlink;
-// if (down_interruptible(&c->alloc_sem)) //fixme prife !!
-// return -EINTR;
+ if (down_interruptible(&c->alloc_sem))
+ return -EINTR;
for (;;) {
spin_lock(&c->erase_completion_lock);
@@ -527,7 +527,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
if (!node)
return -ENOMEM;
- ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (char *)node);
+ ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (unsigned char *)node);
if (!ret && retlen != rawlen)
ret = -EIO;
if (ret)
@@ -594,7 +594,7 @@ static int jffs2_garbage_collect_pristine(struct jffs2_sb_info *c,
nraw->__totlen = rawlen;
nraw->next_phys = NULL;
- ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (char *)node);
+ ret = jffs2_flash_write(c, phys_ofs, rawlen, &retlen, (unsigned char *)node);
if (ret || (retlen != rawlen)) {
printk(KERN_NOTICE "Write of %d bytes at 0x%08x failed. returned %d, retlen %zd\n",
@@ -691,7 +691,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_
printk(KERN_WARNING "kmalloc of mdata failed in jffs2_garbage_collect_metadata()\n");
return -ENOMEM;
}
- ret = jffs2_read_dnode(c, f, fn, mdata, 0, mdatalen);
+ ret = jffs2_read_dnode(c, f, fn, (unsigned char *)mdata, 0, mdatalen);
if (ret) {
printk(KERN_WARNING "read of old metadata failed in jffs2_garbage_collect_metadata(): %d\n", ret);
kfree(mdata);
@@ -738,7 +738,7 @@ static int jffs2_garbage_collect_metadata(struct jffs2_sb_info *c, struct jffs2_
ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri)-8));
ri.data_crc = cpu_to_je32(crc32(0, mdata, mdatalen));
- new_fn = jffs2_write_dnode(c, f, &ri, mdata, mdatalen, phys_ofs, ALLOC_GC);
+ new_fn = jffs2_write_dnode(c, f, &ri, (const unsigned char *)mdata, mdatalen, phys_ofs, ALLOC_GC);
if (IS_ERR(new_fn)) {
printk(KERN_WARNING "Error writing new dnode: %ld\n", PTR_ERR(new_fn));
@@ -764,7 +764,7 @@ static int jffs2_garbage_collect_dirent(struct jffs2_sb_info *c, struct jffs2_er
rd.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
rd.nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT);
- rd.nsize = strlen(fd->name);
+ rd.nsize = strlen((const char *)fd->name);
rd.totlen = cpu_to_je32(sizeof(rd) + rd.nsize);
rd.hdr_crc = cpu_to_je32(crc32(0, &rd, sizeof(struct jffs2_unknown_node)-4));
@@ -808,7 +808,7 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct
struct jffs2_raw_node_ref *raw;
int ret;
size_t retlen;
- int name_len = strlen(fd->name);
+ int name_len = strlen((const char *)fd->name);
uint32_t name_crc = crc32(0, fd->name, name_len);
uint32_t rawlen = ref_totlen(c, jeb, fd->raw);
@@ -840,7 +840,7 @@ static int jffs2_garbage_collect_deletion_dirent(struct jffs2_sb_info *c, struct
/* This is an obsolete node belonging to the same directory, and it's of the right
length. We need to take a closer look...*/
- ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (char *)rd);
+ ret = jffs2_flash_read(c, ref_offset(raw), rawlen, &retlen, (unsigned char *)rd);
if (ret) {
printk(KERN_WARNING "jffs2_g_c_deletion_dirent(): Read error (%d) reading obsolete node at %08x\n", ret, ref_offset(raw));
/* If we can't read it, we don't need to continue to obsolete it. Continue */
@@ -920,7 +920,7 @@ static int jffs2_garbage_collect_hole(struct jffs2_sb_info *c, struct jffs2_eras
uint32_t crc;
/* It's partially obsoleted by a later write. So we have to
write it out again with the _same_ version as before */
- ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(ri), &readlen, (char *)&ri);
+ ret = jffs2_flash_read(c, ref_offset(fn->raw), sizeof(ri), &readlen, (unsigned char *)&ri);
if (readlen != sizeof(ri) || ret) {
printk(KERN_WARNING "Node read failed in jffs2_garbage_collect_hole. Ret %d, retlen %zd. Data will be lost by writing new hole node\n", ret, readlen);
goto fill;
diff --git a/components/dfs/filesystems/jffs2/src/gcthread.c b/components/dfs/filesystems/jffs2/src/gcthread.c
index b37cb2380d..4005ec4788 100644
--- a/components/dfs/filesystems/jffs2/src/gcthread.c
+++ b/components/dfs/filesystems/jffs2/src/gcthread.c
@@ -14,6 +14,8 @@
#include "nodelist.h"
//#include <cyg/kernel/kapi.h> prife
+#if defined(CYGOPT_FS_JFFS2_GCTHREAD)
+
#define GC_THREAD_FLAG_TRIG 1
#define GC_THREAD_FLAG_STOP 2
#define GC_THREAD_FLAG_HAS_EXIT 4
@@ -133,10 +135,6 @@ rt_uint32_t cyg_current_time(void)
static void
jffs2_garbage_collect_thread(unsigned long data);
-#define CYGNUM_JFFS2_GC_THREAD_PRIORITY 20
-#define CYGNUM_JFFS2_GS_THREAD_TICKS 20
-#define CYGNUM_JFFS2_GC_THREAD_TICKS 20
-
void jffs2_garbage_collect_trigger(struct jffs2_sb_info *c)
{
struct super_block *sb=OFNI_BS_2SFFJ(c);
@@ -251,3 +249,4 @@ jffs2_garbage_collect_thread(unsigned long data)
D1(printk("jffs2_garbage_collect_thread EXIT\n"));
rt_event_send(&sb->s_gc_thread_flags,GC_THREAD_FLAG_HAS_EXIT);
}
+#endif
diff --git a/components/dfs/filesystems/jffs2/src/nodelist.c b/components/dfs/filesystems/jffs2/src/nodelist.c
index 7997f526c9..aee9d88cff 100644
--- a/components/dfs/filesystems/jffs2/src/nodelist.c
+++ b/components/dfs/filesystems/jffs2/src/nodelist.c
@@ -28,7 +28,7 @@ void jffs2_add_fd_to_list(struct jffs2_sb_info *c, struct jffs2_full_dirent *new
JFFS2_DBG_DENTLIST("add dirent \"%s\", ino #%u\n", new->name, new->ino);
while ((*prev) && (*prev)->nhash <= new->nhash) {
- if ((*prev)->nhash == new->nhash && !strcmp((*prev)->name, new->name)) {
+ if ((*prev)->nhash == new->nhash && !strcmp((const char *)((*prev)->name), (const char *)new->name)) {
/* Duplicate. Free one */
if (new->version < (*prev)->version) {
JFFS2_DBG_DENTLIST("Eep! Marking new dirent node is obsolete, old is \"%s\", ino #%u\n",
diff --git a/components/dfs/filesystems/jffs2/src/nodelist.h b/components/dfs/filesystems/jffs2/src/nodelist.h
index 710e1b9be4..7f029f8741 100644
--- a/components/dfs/filesystems/jffs2/src/nodelist.h
+++ b/components/dfs/filesystems/jffs2/src/nodelist.h
@@ -12,8 +12,9 @@
*/
#ifndef __JFFS2_NODELIST_H__
-#define __JFFS2_NODELIST_H__
+#define __JFFS2_NODELIST_H__
+#include "jffs2_config.h"
#include <linux/config.h>
#include <linux/fs.h>
#include <linux/types.h>
diff --git a/components/dfs/filesystems/jffs2/src/nodemgmt.c b/components/dfs/filesystems/jffs2/src/nodemgmt.c
index fe7e70a405..ef2167aadc 100644
--- a/components/dfs/filesystems/jffs2/src/nodemgmt.c
+++ b/components/dfs/filesystems/jffs2/src/nodemgmt.c
@@ -541,7 +541,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
by jffs2_free_all_node_refs() in erase.c. Which is nice. */
D1(printk(KERN_DEBUG "obliterating obsoleted node at 0x%08x\n", ref_offset(ref)));
- ret = jffs2_flash_read(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n);
+ ret = jffs2_flash_read(c, ref_offset(ref), sizeof(n), &retlen, (unsigned char *)&n);
if (ret) {
printk(KERN_WARNING "Read error reading from obsoleted node at 0x%08x: %d\n", ref_offset(ref), ret);
goto out_erase_sem;
@@ -560,7 +560,7 @@ void jffs2_mark_node_obsolete(struct jffs2_sb_info *c, struct jffs2_raw_node_ref
}
/* XXX FIXME: This is ugly now */
n.nodetype = cpu_to_je16(je16_to_cpu(n.nodetype) & ~JFFS2_NODE_ACCURATE);
- ret = jffs2_flash_write(c, ref_offset(ref), sizeof(n), &retlen, (char *)&n);
+ ret = jffs2_flash_write(c, ref_offset(ref), sizeof(n), &retlen, (unsigned char *)&n);
if (ret) {
printk(KERN_WARNING "Write error in obliterating obsoleted node at 0x%08x: %d\n", ref_offset(ref), ret);
goto out_erase_sem;
diff --git a/components/dfs/filesystems/jffs2/src/os-ecos.h b/components/dfs/filesystems/jffs2/src/os-ecos.h
index b60961fb81..0a04233126 100644
--- a/components/dfs/filesystems/jffs2/src/os-ecos.h
+++ b/components/dfs/filesystems/jffs2/src/os-ecos.h
@@ -13,9 +13,11 @@
#ifndef __JFFS2_OS_ECOS_H__
#define __JFFS2_OS_ECOS_H__
-
+#include "jffs2_config.h"
#include <rtthread.h>
-#define printf rt_kprintf
+#define malloc rt_malloc
+#define free rt_free
+#define printf rt_kprintf
//#include <pkgconf/fs_jffs2.h>
//#include <cyg/io/io.h>
@@ -43,7 +45,7 @@
//#include <errno.h> //fixme
//#include <dirent.h>
-#define CYGPKG_FILEIO_DIRENT_DTYPE
+
struct dirent
{
#ifdef CYGPKG_FILEIO_DIRENT_DTYPE
@@ -57,7 +59,7 @@ struct dirent
};
-#include <stdlib.h>
+//#include <stdlib.h>
#include <string.h>
#include <cyg/fileio/fileio.h> //prife
@@ -161,8 +163,8 @@ struct super_block {
// char s_gc_thread_stack[CYGNUM_HAL_STACK_SIZE_MINIMUM];
//#endif
// cyg_mtab_entry *mte;
-//#endif
-
+//#endif
+
#ifdef CYGOPT_FS_JFFS2_GCTHREAD
struct rt_mutex s_lock; // Lock the inode cache
struct rt_event s_gc_thread_flags; // Communication with the gcthread
@@ -172,12 +174,12 @@ struct super_block {
// char s_gc_thread_stack[CYGNUM_JFFS2_GC_THREAD_STACK_SIZE];
//#else
// char s_gc_thread_stack[CYGNUM_HAL_STACK_SIZE_MINIMUM];
-//#endif
+//#endif
#define CYGNUM_JFFS2_GC_THREAD_STACK_SIZE (1024*4)
- char s_gc_thread_stack[CYGNUM_JFFS2_GC_THREAD_STACK_SIZE];
+ char s_gc_thread_stack[CYGNUM_JFFS2_GC_THREAD_STACK_SIZE];
cyg_mtab_entry *mte;
-#endif
+#endif
};
@@ -260,6 +262,6 @@ static inline void jffs2_erase_pending_trigger(struct jffs2_sb_info *c)
#define BUG_ON(x) do { if (unlikely(x)) BUG(); } while(0)
#endif
-#define __init
+#define __init
#endif /* __JFFS2_OS_ECOS_H__ */
diff --git a/components/dfs/filesystems/jffs2/src/os-rtthread.h b/components/dfs/filesystems/jffs2/src/os-rtthread.h
index 02eabf8434..e1c4d55a5f 100644
--- a/components/dfs/filesystems/jffs2/src/os-rtthread.h
+++ b/components/dfs/filesystems/jffs2/src/os-rtthread.h
@@ -13,8 +13,10 @@
#ifndef __JFFS2_OS_RTTHREAD_H__
#define __JFFS2_OS_RTTHREAD_H__
-
+#include "jffs2_config.h"
#include <rtthread.h>
+#define free rt_free
+#define printf rt_kprintf
#define printf rt_kprintf
//#include <pkgconf/fs_jffs2.h>
@@ -56,8 +58,6 @@ struct dirent
char d_name[NAME_MAX+1];
};
-
-#include <stdlib.h>
#include <string.h>
#include <cyg/fileio/fileio.h> //prife
diff --git a/components/dfs/filesystems/jffs2/src/pushpull.h b/components/dfs/filesystems/jffs2/src/pushpull.h
index c0c2a9158d..4e84ee38a8 100644
--- a/components/dfs/filesystems/jffs2/src/pushpull.h
+++ b/components/dfs/filesystems/jffs2/src/pushpull.h
@@ -26,7 +26,7 @@ struct pushpull {
static inline void init_pushpull(struct pushpull *pp, char *buf, unsigned buflen, unsigned ofs, unsigned reserve)
{
- pp->buf = buf;
+ pp->buf = (unsigned char *)buf;
pp->buflen = buflen;
pp->ofs = ofs;
pp->reserve = reserve;
diff --git a/components/dfs/filesystems/jffs2/src/read.c b/components/dfs/filesystems/jffs2/src/read.c
index 4cd641c837..845ae73006 100644
--- a/components/dfs/filesystems/jffs2/src/read.c
+++ b/components/dfs/filesystems/jffs2/src/read.c
@@ -35,7 +35,7 @@ int jffs2_read_dnode(struct jffs2_sb_info *c, struct jffs2_inode_info *f,
if (!ri)
return -ENOMEM;
- ret = jffs2_flash_read(c, ref_offset(fd->raw), sizeof(*ri), &readlen, (char *)ri);
+ ret = jffs2_flash_read(c, ref_offset(fd->raw), sizeof(*ri), &readlen, (unsigned char *)ri);
if (ret) {
jffs2_free_raw_inode(ri);
printk(KERN_WARNING "Error reading node from 0x%08x: %d\n", ref_offset(fd->raw), ret);
diff --git a/components/dfs/filesystems/jffs2/src/readinode.c b/components/dfs/filesystems/jffs2/src/readinode.c
index 6a5b71cd56..d6596058bc 100644
--- a/components/dfs/filesystems/jffs2/src/readinode.c
+++ b/components/dfs/filesystems/jffs2/src/readinode.c
@@ -477,7 +477,7 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf
goto free_out;
}
- err = read_direntry(c, ref, &node.d, retlen, &ret_fd, latest_mctime, mctime_ver);
+ err = read_direntry(c, ref, &node.d, retlen, &ret_fd, (int32_t *)latest_mctime, mctime_ver);
if (err == 1) {
jffs2_mark_node_obsolete(c, ref);
break;
@@ -498,7 +498,7 @@ static int jffs2_get_inode_nodes(struct jffs2_sb_info *c, struct jffs2_inode_inf
goto free_out;
}
- err = read_dnode(c, ref, &node.i, retlen, &ret_tn, latest_mctime, mctime_ver);
+ err = read_dnode(c, ref, &node.i, retlen, &ret_tn, (int32_t *)latest_mctime, mctime_ver);
if (err == 1) {
jffs2_mark_node_obsolete(c, ref);
break;
diff --git a/components/dfs/filesystems/jffs2/src/write.c b/components/dfs/filesystems/jffs2/src/write.c
index 4c418e69cf..dcfc3a49c1 100644
--- a/components/dfs/filesystems/jffs2/src/write.c
+++ b/components/dfs/filesystems/jffs2/src/write.c
@@ -249,7 +249,7 @@ struct jffs2_full_dirent *jffs2_write_dirent(struct jffs2_sb_info *c, struct jff
fd->version = je32_to_cpu(rd->version);
fd->ino = je32_to_cpu(rd->ino);
- fd->nhash = full_name_hash(name, strlen(name));
+ fd->nhash = full_name_hash(name, strlen((const char *)name));
fd->type = rd->type;
memcpy(fd->name, name, namelen);
fd->name[namelen]=0;
@@ -509,7 +509,7 @@ int jffs2_do_create(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, str
rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
rd->name_crc = cpu_to_je32(crc32(0, name, namelen));
- fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_NORMAL);
+ fd = jffs2_write_dirent(c, dir_f, rd, (const unsigned char *)name, namelen, phys_ofs, ALLOC_NORMAL);
jffs2_free_raw_dirent(rd);
@@ -571,7 +571,7 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
rd->name_crc = cpu_to_je32(crc32(0, name, namelen));
- fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_DELETION);
+ fd = jffs2_write_dirent(c, dir_f, rd, (const unsigned char *)name, namelen, phys_ofs, ALLOC_DELETION);
jffs2_free_raw_dirent(rd);
@@ -586,7 +586,7 @@ int jffs2_do_unlink(struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f,
up(&dir_f->sem);
} else {
struct jffs2_full_dirent **prev = &dir_f->dents;
- uint32_t nhash = full_name_hash(name, namelen);
+ uint32_t nhash = full_name_hash((const unsigned char *)name, namelen);
down(&dir_f->sem);
@@ -682,7 +682,7 @@ int jffs2_do_link (struct jffs2_sb_info *c, struct jffs2_inode_info *dir_f, uint
rd->node_crc = cpu_to_je32(crc32(0, rd, sizeof(*rd)-8));
rd->name_crc = cpu_to_je32(crc32(0, name, namelen));
- fd = jffs2_write_dirent(c, dir_f, rd, name, namelen, phys_ofs, ALLOC_NORMAL);
+ fd = jffs2_write_dirent(c, dir_f, rd, (const unsigned char *)name, namelen, phys_ofs, ALLOC_NORMAL);
jffs2_free_raw_dirent(rd);
diff --git a/include/rtdef.h b/include/rtdef.h
index 0847db737d..0b1b2e4640 100644
--- a/include/rtdef.h
+++ b/include/rtdef.h
@@ -620,6 +620,7 @@ enum rt_device_class_type
#define RT_DEVICE_CTRL_MTD_FORMAT 0x10 /**< format a MTD device */
#define RT_DEVICE_CTRL_RTC_GET_TIME 0x10 /**< get time */
#define RT_DEVICE_CTRL_RTC_SET_TIME 0x11 /**< set time */
+#define RT_DEVICE_CTRL_BLK_ERASE 0x12 /**< erase */
typedef struct rt_device *rt_device_t;
/**