Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
rt-thread
提交
8e430738
R
rt-thread
项目概览
BaiXuePrincess
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
8e430738
编写于
12月 30, 2017
作者:
B
bernard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[DFS] update JFFS2 with RT-Thread 3.0.x.
上级
f6a95087
变更
13
显示空白变更内容
内联
并排
Showing
13 changed file
with
593 addition
and
822 deletion
+593
-822
components/dfs/Kconfig
components/dfs/Kconfig
+5
-0
components/dfs/filesystems/jffs2/cyg/compress/src/zutil.h
components/dfs/filesystems/jffs2/cyg/compress/src/zutil.h
+1
-1
components/dfs/filesystems/jffs2/cyg/compress/zconf.h
components/dfs/filesystems/jffs2/cyg/compress/zconf.h
+8
-3
components/dfs/filesystems/jffs2/cyg/fileio/fileio.h
components/dfs/filesystems/jffs2/cyg/fileio/fileio.h
+4
-4
components/dfs/filesystems/jffs2/dfs_jffs2.c
components/dfs/filesystems/jffs2/dfs_jffs2.c
+554
-583
components/dfs/filesystems/jffs2/include/linux/jffs2.h
components/dfs/filesystems/jffs2/include/linux/jffs2.h
+2
-0
components/dfs/filesystems/jffs2/include/port/codes.h
components/dfs/filesystems/jffs2/include/port/codes.h
+2
-87
components/dfs/filesystems/jffs2/include/port/fcntl.h
components/dfs/filesystems/jffs2/include/port/fcntl.h
+13
-62
components/dfs/filesystems/jffs2/include/port/sys/stat.h
components/dfs/filesystems/jffs2/include/port/sys/stat.h
+0
-61
components/dfs/filesystems/jffs2/kernel/linux/fs.h
components/dfs/filesystems/jffs2/kernel/linux/fs.h
+0
-7
components/dfs/filesystems/jffs2/kernel/linux/types.h
components/dfs/filesystems/jffs2/kernel/linux/types.h
+0
-10
components/dfs/filesystems/jffs2/src/flashio.c
components/dfs/filesystems/jffs2/src/flashio.c
+2
-2
components/dfs/filesystems/jffs2/src/readinode.c
components/dfs/filesystems/jffs2/src/readinode.c
+2
-2
未找到文件。
components/dfs/Kconfig
浏览文件 @
8e430738
...
...
@@ -157,6 +157,11 @@ if RT_USING_DFS
endif
config RT_USING_DFS_JFFS2
bool "Enable JFFS2 file system"
select RT_USING_MTD_NOR
default n
config RT_USING_DFS_NFS
bool "Using NFS v3 client file system"
select RT_USING_LWIP
...
...
components/dfs/filesystems/jffs2/cyg/compress/src/zutil.h
浏览文件 @
8e430738
...
...
@@ -28,7 +28,7 @@
# include <stddef.h>
# endif
# include <string.h>
//# include <stdlib.h> //remove by prife @ 2012/1/30
# include <stdlib.h>
#endif
#ifdef NO_ERRNO_H
# ifdef _WIN32_WCE
...
...
components/dfs/filesystems/jffs2/cyg/compress/zconf.h
浏览文件 @
8e430738
...
...
@@ -12,11 +12,16 @@
#undef __ECOS__
#define __ECOS__
#include <rtthread.h>
#ifndef RT_USING_LIBC
#define malloc rt_malloc
#define free rt_free
#define printf rt_kprintf
#endif
//#define Z_PREFIX //by prife
//#include <pkgconf/compress_zlib.h> //prife no such file.
#if CYGINT_COMPRESS_ZLIB_LOCAL_ALLOC != 0
#define MY_ZCALLOC
#endif
...
...
components/dfs/filesystems/jffs2/cyg/fileio/fileio.h
浏览文件 @
8e430738
components/dfs/filesystems/jffs2/dfs_jffs2.c
浏览文件 @
8e430738
/*
* File :
rtthread.h
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006-201
2
, RT-Thread Development Team
* File :
dfs_jffs2.c
* This file is part of
Device File System in
RT-Thread RTOS
* COPYRIGHT (C) 2006-201
7
, RT-Thread Development Team
*
* The license and distribution terms for this file may be
* found in the file LICENSE in this distribution or at
* http://www.rt-thread.org/license/LICENSE.
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2012-1-7 prife the first version
*/
*/
#include <rtthread.h>
#include <rtdevice.h>
...
...
@@ -21,7 +32,7 @@
#undef mode_t
#include <dfs_fs.h>
#include <dfs_
def
.h>
#include <dfs_
file
.h>
#include "dfs_jffs2.h"
#include "jffs2_config.h"
...
...
@@ -39,7 +50,6 @@ struct device_part
struct
rt_mtd_nor_device
*
dev
;
};
static
struct
device_part
device_partition
[
DEVICE_PART_MAX
]
=
{
0
};
static
struct
rt_mutex
jffs2_lock
;
#define jffs2_mount jffs2_fste.mount
...
...
@@ -85,58 +95,10 @@ static struct rt_mutex jffs2_lock;
/* these code is in src/flashio.c */
static
int
jffs2_result_to_dfs
(
int
result
)
{
int
status
=
-
1
;
if
(
result
<
0
)
result
=
-
result
;
if
(
result
<
0
)
return
result
;
if
(
result
>
0
)
return
-
result
;
switch
(
result
)
{
case
ENOERR
:
/** no error */
break
;
case
EACCES
:
/** Tried to open read-only file for writing, or files sharing mode
does not allow specified operations, or given path is directory */
status
=
-
DFS_STATUS_EINVAL
;
break
;
/* no suitable */
case
EEXIST
:
/** _O_CREAT and _O_EXCL flags specified, but filename already exists */
status
=
-
DFS_STATUS_EEXIST
;
break
;
case
EINVAL
:
/** Invalid oflag or pmode argument */
status
=
-
DFS_STATUS_EINVAL
;
break
;
case
EMFILE
:
/** No more file handles available(too many open files) */
rt_kprintf
(
"dfs_jffs2.c error: no more file handles available
\r\n
"
);
status
=
-
1
;
break
;
//fixme
case
ENOENT
:
/** file or path not found */
status
=
-
DFS_STATUS_ENOENT
;
break
;
case
EBADF
:
/** invalid file handle */
status
=
-
DFS_STATUS_EBADF
;
break
;
case
ENOMEM
:
/** no enough memory */
status
=
-
DFS_STATUS_ENOMEM
;
break
;
case
EIO
:
/** I/O error from lower level flash operation */
status
=
-
DFS_STATUS_EIO
;
break
;
case
ENOTDIR
:
/** Not a directory */
status
=
-
DFS_STATUS_ENOTDIR
;
break
;
case
EISDIR
:
/** Is a directory */
status
=
-
DFS_STATUS_EISDIR
;
break
;
case
ENOSPC
:
/**//* No space left on device */
status
=
-
DFS_STATUS_ENOSPC
;
break
;
default:
rt_kprintf
(
"dfs_jffs2.c error: %d
\r\n
"
,
result
);
status
=
-
1
;
break
;
/* unknown error! */
}
return
status
;
return
0
;
}
/*
...
...
@@ -157,11 +119,11 @@ static int dfs_jffs2_mount(struct dfs_filesystem* fs,
break
;
}
if
(
index
==
DEVICE_PART_MAX
)
return
-
DFS_STATUS_
ENOSPC
;
return
-
ENOSPC
;
mte
=
rt_malloc
(
sizeof
(
struct
cyg_mtab_entry
));
if
(
mte
==
RT_NULL
)
return
-
DFS_STATUS_
ENOMEM
;
return
-
ENOMEM
;
mte
->
name
=
fs
->
path
;
mte
->
fsname
=
"jffs2"
;
...
...
@@ -181,6 +143,7 @@ static int dfs_jffs2_mount(struct dfs_filesystem* fs,
device_partition
[
index
].
dev
=
NULL
;
return
jffs2_result_to_dfs
(
result
);
}
/* save this pointer */
device_partition
[
index
].
mte
=
mte
;
return
0
;
...
...
@@ -189,6 +152,7 @@ static int dfs_jffs2_mount(struct dfs_filesystem* fs,
static
int
_find_fs
(
struct
cyg_mtab_entry
**
mte
,
rt_device_t
dev_id
)
{
unsigned
index
;
/* find device index */
for
(
index
=
0
;
index
<
DEVICE_PART_MAX
;
index
++
)
{
...
...
@@ -198,6 +162,7 @@ static int _find_fs(struct cyg_mtab_entry ** mte, rt_device_t dev_id)
return
0
;
}
}
rt_kprintf
(
"error, could not found the fs!"
);
return
-
1
;
}
...
...
@@ -206,27 +171,29 @@ static int dfs_jffs2_unmount(struct dfs_filesystem* fs)
{
int
result
;
unsigned
index
;
/* find device index, then umount it */
for
(
index
=
0
;
index
<
DEVICE_PART_MAX
;
index
++
)
{
if
(
device_partition
[
index
].
dev
==
RT_MTD_NOR_DEVICE
(
fs
->
dev_id
))
{
result
=
jffs2_umount
(
device_partition
[
index
].
mte
);
if
(
result
)
return
jffs2_result_to_dfs
(
result
);
if
(
result
)
return
jffs2_result_to_dfs
(
result
);
rt_free
(
device_partition
[
index
].
mte
);
device_partition
[
index
].
dev
=
NULL
;
device_partition
[
index
].
mte
=
NULL
;
return
DFS_STATUS_
OK
;
return
RT_E
OK
;
}
}
return
-
DFS_STATUS_ENOENT
;
return
-
ENOENT
;
}
static
int
dfs_jffs2_mkfs
(
rt_device_t
dev_id
)
{
/* just erase all blocks on this nand partition */
return
-
DFS_STATUS_ENOSYS
;
return
-
ENOSYS
;
}
static
int
dfs_jffs2_statfs
(
struct
dfs_filesystem
*
fs
,
...
...
@@ -239,9 +206,9 @@ static int dfs_jffs2_statfs(struct dfs_filesystem* fs,
result
=
_find_fs
(
&
mte
,
fs
->
dev_id
);
if
(
result
)
return
-
DFS_STATUS_
ENOENT
;
return
-
ENOENT
;
RT_ASSERT
(
mte
->
data
!=
NULL
);
RT_ASSERT
(
mte
->
data
!=
0
);
jffs2_get_info_from_sb
((
void
*
)
mte
->
data
,
&
info
);
buf
->
f_bsize
=
info
.
sector_size
;
...
...
@@ -255,17 +222,20 @@ static const char jffs2_root_path[] = ".";
static
int
dfs_jffs2_open
(
struct
dfs_fd
*
file
)
{
int
oflag
,
mode
;
int
result
;
int
oflag
,
mode
;
const
char
*
name
;
cyg_file
*
jffs2_file
;
struct
dfs_filesystem
*
fs
;
struct
cyg_mtab_entry
*
mte
;
const
char
*
name
;
oflag
=
file
->
flags
;
fs
=
(
struct
dfs_filesystem
*
)
file
->
data
;
RT_ASSERT
(
fs
!=
RT_NULL
);
jffs2_file
=
rt_malloc
(
sizeof
(
cyg_file
));
if
(
jffs2_file
==
RT_NULL
)
return
-
DFS_STATUS_
ENOMEM
;
return
-
ENOMEM
;
/* just escape '/' provided by dfs code */
name
=
file
->
path
;
...
...
@@ -274,17 +244,20 @@ static int dfs_jffs2_open(struct dfs_fd* file)
else
/* name[0] still will be '/' */
name
++
;
result
=
_find_fs
(
&
mte
,
file
->
fs
->
dev_id
);
result
=
_find_fs
(
&
mte
,
fs
->
dev_id
);
if
(
result
)
{
rt_free
(
jffs2_file
);
return
-
DFS_STATUS_
ENOENT
;
return
-
ENOENT
;
}
if
(
oflag
&
DFS_O_DIRECTORY
)
/* operations about dir */
/* set mount table */
jffs2_file
->
f_mte
=
mte
;
if
(
oflag
&
O_DIRECTORY
)
/* operations about dir */
{
rt_mutex_take
(
&
jffs2_lock
,
RT_WAITING_FOREVER
);
if
(
oflag
&
DFS_
O_CREAT
)
/* create a dir*/
if
(
oflag
&
O_CREAT
)
/* create a dir*/
{
/* fixme, should test file->path can end with '/' */
result
=
jffs2_mkdir
(
mte
,
mte
->
root
,
name
);
...
...
@@ -295,6 +268,7 @@ static int dfs_jffs2_open(struct dfs_fd* file)
return
jffs2_result_to_dfs
(
result
);
}
}
/* open dir */
result
=
jffs2_opendir
(
mte
,
mte
->
root
,
name
,
jffs2_file
);
rt_mutex_release
(
&
jffs2_lock
);
...
...
@@ -311,17 +285,16 @@ static int dfs_jffs2_open(struct dfs_fd* file)
return
0
;
}
/* regular file operations */
mode
=
0
;
if
(
oflag
&
DFS_O_RDONLY
)
mode
|=
JFFS2_O_RDONLY
;
if
(
oflag
&
DFS_O_WRONLY
)
mode
|=
JFFS2_O_WRONLY
;
if
(
oflag
&
DFS_O_RDWR
)
mode
|=
JFFS2_O_RDWR
;
mode
=
JFFS2_O_RDONLY
;
if
(
oflag
&
O_WRONLY
)
mode
|=
JFFS2_O_WRONLY
;
if
(
oflag
&
O_RDWR
)
mode
|=
JFFS2_O_RDWR
;
/* Opens the file, if it is existing. If not, a new file is created. */
if
(
oflag
&
DFS_
O_CREAT
)
mode
|=
JFFS2_O_CREAT
;
if
(
oflag
&
O_CREAT
)
mode
|=
JFFS2_O_CREAT
;
/* Creates a new file. If the file is existing, it is truncated and overwritten. */
if
(
oflag
&
DFS_
O_TRUNC
)
mode
|=
JFFS2_O_TRUNC
;
if
(
oflag
&
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
&
O_EXCL
)
mode
|=
JFFS2_O_EXCL
;
rt_mutex_take
(
&
jffs2_lock
,
RT_WAITING_FOREVER
);
result
=
jffs2_open
(
mte
,
0
,
name
,
mode
,
jffs2_file
);
if
(
result
!=
0
)
...
...
@@ -336,15 +309,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
,
(
off_t
*
)(
&
(
file
->
size
)),
DFS_
SEEK_END
);
jffs2_file_lseek
(
jffs2_file
,
(
off_t
*
)(
&
(
file
->
size
)),
SEEK_END
);
jffs2_file
->
f_offset
=
(
off_t
)
file
->
pos
;
rt_mutex_release
(
&
jffs2_lock
);
if
(
oflag
&
DFS_
O_APPEND
)
if
(
oflag
&
O_APPEND
)
{
file
->
pos
=
file
->
size
;
jffs2_file
->
f_offset
=
file
->
size
;
}
return
0
;
}
...
...
@@ -356,7 +330,7 @@ static int dfs_jffs2_close(struct dfs_fd* file)
RT_ASSERT
(
file
->
data
!=
NULL
);
jffs2_file
=
(
cyg_file
*
)(
file
->
data
);
if
(
file
->
flags
&
DFS_
O_DIRECTORY
)
/* operations about dir */
if
(
file
->
flags
&
O_DIRECTORY
)
/* operations about dir */
{
rt_mutex_take
(
&
jffs2_lock
,
RT_WAITING_FOREVER
);
result
=
jffs2_dir_colse
(
jffs2_file
);
...
...
@@ -381,10 +355,10 @@ static int dfs_jffs2_close(struct dfs_fd* file)
static
int
dfs_jffs2_ioctl
(
struct
dfs_fd
*
file
,
int
cmd
,
void
*
args
)
{
return
-
DFS_STATUS_
ENOSYS
;
return
-
ENOSYS
;
}
static
int
dfs_jffs2_read
(
struct
dfs_fd
*
file
,
void
*
buf
,
rt_
size_t
len
)
static
int
dfs_jffs2_read
(
struct
dfs_fd
*
file
,
void
*
buf
,
size_t
len
)
{
cyg_file
*
jffs2_file
;
struct
CYG_UIO_TAG
uio_s
;
...
...
@@ -416,7 +390,7 @@ static int dfs_jffs2_read(struct dfs_fd* file, void* buf, rt_size_t len)
static
int
dfs_jffs2_write
(
struct
dfs_fd
*
file
,
const
void
*
buf
,
rt_
size_t
len
)
size_t
len
)
{
cyg_file
*
jffs2_file
;
struct
CYG_UIO_TAG
uio_s
;
...
...
@@ -449,7 +423,7 @@ static int dfs_jffs2_write(struct dfs_fd* file,
static
int
dfs_jffs2_flush
(
struct
dfs_fd
*
file
)
{
/* infact, jffs2 not support, jffs2_fo_sync just return ok */
return
-
DFS_STATUS_
ENOSYS
;
return
-
ENOSYS
;
}
/* fixme warning: the offset is rt_off_t, so maybe the size of a file is must <= 2G*/
...
...
@@ -464,7 +438,7 @@ static int dfs_jffs2_lseek(struct dfs_fd* file,
/* set offset as current offset */
rt_mutex_take
(
&
jffs2_lock
,
RT_WAITING_FOREVER
);
result
=
jffs2_file_lseek
(
jffs2_file
,
&
offset
,
DFS_
SEEK_SET
);
result
=
jffs2_file_lseek
(
jffs2_file
,
&
offset
,
SEEK_SET
);
rt_mutex_release
(
&
jffs2_lock
);
if
(
result
)
return
jffs2_result_to_dfs
(
result
);
...
...
@@ -493,6 +467,7 @@ static int dfs_jffs2_getdents(struct dfs_fd* file,
RT_ASSERT
(
file
->
data
!=
RT_NULL
);
jffs2_file
=
(
cyg_file
*
)(
file
->
data
);
mte
=
jffs2_file
->
f_mte
;
//set jffs2_d
memset
(
&
jffs2_d
,
0
,
sizeof
(
struct
jffs2_dirent
));
...
...
@@ -504,17 +479,9 @@ static int dfs_jffs2_getdents(struct dfs_fd* file,
uio_s
.
uio_offset
=
0
;
//not used...
uio_s
.
uio_resid
=
uio_s
.
uio_iov
->
iov_len
;
//seem no use in jffs2;
#if !defined (CYGPKG_FS_JFFS2_RET_DIRENT_DTYPE)
result
=
_find_fs
(
&
mte
,
file
->
fs
->
dev_id
);
if
(
result
)
return
-
DFS_STATUS_ENOENT
;
#endif
/* make integer count, usually count is 1 */
count
=
(
count
/
sizeof
(
struct
dirent
))
*
sizeof
(
struct
dirent
);
if
(
count
==
0
)
return
-
DFS_STATUS_EINVAL
;
if
(
count
==
0
)
return
-
EINVAL
;
index
=
0
;
/* usually, the while loop should only be looped only once! */
...
...
@@ -531,14 +498,14 @@ static int dfs_jffs2_getdents(struct dfs_fd* file,
#if defined (CYGPKG_FS_JFFS2_RET_DIRENT_DTYPE)
switch
(
jffs2_d
.
d_type
&
JFFS2_S_IFMT
)
{
case
JFFS2_S_IFREG
:
d
->
d_type
=
DFS_DT_REG
;
break
;
case
JFFS2_S_IFDIR
:
d
->
d_type
=
DFS_DT_DIR
;
break
;
default:
d
->
d_type
=
DFS_DT_UNKNOWN
;
break
;
case
JFFS2_S_IFREG
:
d
->
d_type
=
DT_REG
;
break
;
case
JFFS2_S_IFDIR
:
d
->
d_type
=
DT_DIR
;
break
;
default:
d
->
d_type
=
DT_UNKNOWN
;
break
;
}
#else
fullname
=
rt_malloc
(
FILE_PATH_MAX
);
if
(
fullname
==
RT_NULL
)
return
-
DFS_STATUS_
ENOMEM
;
return
-
ENOMEM
;
/* make a right entry */
if
((
file
->
path
[
0
]
==
'/'
)
)
...
...
@@ -560,9 +527,9 @@ static int dfs_jffs2_getdents(struct dfs_fd* file,
/* convert to dfs stat structure */
switch
(
s
.
st_mode
&
JFFS2_S_IFMT
)
{
case
JFFS2_S_IFREG
:
d
->
d_type
=
DFS_
DT_REG
;
break
;
case
JFFS2_S_IFDIR
:
d
->
d_type
=
DFS_
DT_DIR
;
break
;
default:
d
->
d_type
=
DFS_
DT_UNKNOWN
;
break
;
case
JFFS2_S_IFREG
:
d
->
d_type
=
DT_REG
;
break
;
case
JFFS2_S_IFDIR
:
d
->
d_type
=
DT_DIR
;
break
;
default:
d
->
d_type
=
DT_UNKNOWN
;
break
;
}
#endif
/* write the rest fields of struct dirent* dirp */
...
...
@@ -587,7 +554,7 @@ static int dfs_jffs2_unlink(struct dfs_filesystem* fs, const char* path)
result
=
_find_fs
(
&
mte
,
fs
->
dev_id
);
if
(
result
)
return
-
DFS_STATUS_
ENOENT
;
return
-
ENOENT
;
/* deal path */
if
(
path
[
0
]
==
'/'
)
...
...
@@ -630,7 +597,7 @@ static int dfs_jffs2_rename(struct dfs_filesystem* fs,
result
=
_find_fs
(
&
mte
,
fs
->
dev_id
);
if
(
result
)
return
-
DFS_STATUS_
ENOENT
;
return
-
ENOENT
;
if
(
*
oldpath
==
'/'
)
oldpath
+=
1
;
...
...
@@ -658,7 +625,7 @@ static int dfs_jffs2_stat(struct dfs_filesystem* fs, const char *path, struct st
result
=
_find_fs
(
&
mte
,
fs
->
dev_id
);
if
(
result
)
return
-
DFS_STATUS_
ENOENT
;
return
-
ENOENT
;
rt_mutex_take
(
&
jffs2_lock
,
RT_WAITING_FOREVER
);
result
=
jffs2_porting_stat
(
mte
,
mte
->
root
,
path
,
(
void
*
)
&
s
);
...
...
@@ -670,16 +637,16 @@ static int dfs_jffs2_stat(struct dfs_filesystem* fs, const char *path, struct st
switch
(
s
.
st_mode
&
JFFS2_S_IFMT
)
{
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
;
st
->
st_mode
=
S_IFREG
|
S_IRUSR
|
S_IRGRP
|
S_IROTH
|
S_IWUSR
|
S_IWGRP
|
S_IWOTH
;
break
;
case
JFFS2_S_IFDIR
:
st
->
st_mode
=
DFS_S_IFDIR
|
DFS_S_IXUSR
|
DFS_S_IXGRP
|
DFS_
S_IXOTH
;
st
->
st_mode
=
S_IFDIR
|
S_IXUSR
|
S_IXGRP
|
S_IXOTH
;
break
;
default:
st
->
st_mode
=
DFS_
DT_UNKNOWN
;
//fixme
st
->
st_mode
=
DT_UNKNOWN
;
//fixme
break
;
}
...
...
@@ -690,17 +657,8 @@ static int dfs_jffs2_stat(struct dfs_filesystem* fs, const char *path, struct st
return
0
;
}
static
const
struct
dfs_file
system_operation
dfs_jffs2_ops
=
static
const
struct
dfs_file
_ops
_jffs2_fops
=
{
"jffs2"
,
/* file system type: jffs2 */
#if RTTHREAD_VERSION >= 10100
DFS_FS_FLAG_DEFAULT
,
/* use Relative Path */
#endif
dfs_jffs2_mount
,
dfs_jffs2_unmount
,
dfs_jffs2_mkfs
,
dfs_jffs2_statfs
,
dfs_jffs2_open
,
dfs_jffs2_close
,
dfs_jffs2_ioctl
,
...
...
@@ -709,6 +667,19 @@ static const struct dfs_filesystem_operation dfs_jffs2_ops =
dfs_jffs2_flush
,
dfs_jffs2_lseek
,
dfs_jffs2_getdents
,
};
static
const
struct
dfs_filesystem_ops
_jffs2_ops
=
{
"jffs2"
,
DFS_FS_FLAG_DEFAULT
,
&
_jffs2_fops
,
dfs_jffs2_mount
,
dfs_jffs2_unmount
,
dfs_jffs2_mkfs
,
dfs_jffs2_statfs
,
dfs_jffs2_unlink
,
dfs_jffs2_stat
,
dfs_jffs2_rename
,
...
...
@@ -717,7 +688,8 @@ static const struct dfs_filesystem_operation dfs_jffs2_ops =
int
dfs_jffs2_init
(
void
)
{
/* register fatfs file system */
dfs_register
(
&
dfs_jffs2_ops
);
dfs_register
(
&
_jffs2_ops
);
/* initialize mutex */
if
(
rt_mutex_init
(
&
jffs2_lock
,
"jffs2lock"
,
RT_IPC_FLAG_FIFO
)
!=
RT_EOK
)
{
...
...
@@ -727,4 +699,3 @@ int dfs_jffs2_init(void)
return
0
;
}
INIT_COMPONENT_EXPORT
(
dfs_jffs2_init
);
components/dfs/filesystems/jffs2/include/linux/jffs2.h
浏览文件 @
8e430738
...
...
@@ -74,6 +74,8 @@
/* These can go once we've made sure we've caught all uses without
byteswapping */
#include <stdint.h>
#if defined(__GNUC__) || (__CC_ARM)
typedef
struct
{
uint32_t
v32
;
...
...
components/dfs/filesystems/jffs2/include/port/codes.h
浏览文件 @
8e430738
...
...
@@ -86,94 +86,9 @@ extern "C" {
typedef
int
Cyg_ErrNo
;
#include <rtthread.h>
/* CONSTANT DEFINITIONS */
/* If adding to this list, you must also update strerror() with its text
* If there is a common error of the same purpose on Unix, try and use its
* name and number. If not, use one above 200 to prevent future conflicts
*
* Do not use negative numbers, so that functions can return positive on
* success and -ESOMETHING on error, and it all works consistently.
*/
#define ENOERR 0
/* No error */
#define EPERM 1
/* Not permitted */
#define ENOENT 2
/* No such entity */
#define ESRCH 3
/* No such process */
#define EINTR 4
/* Operation interrupted */
#define EIO 5
/* I/O error */
#define EBADF 9
/* Bad file handle */
#define EAGAIN 11
/* Try again later */
#define EWOULDBLOCK EAGAIN
#define ENOMEM 12
/* Out of memory */
#define EBUSY 16
/* Resource busy */
#define EXDEV 18
/* Cross-device link */
#define ENODEV 19
/* No such device */
#define ENOTDIR 20
/* Not a directory */
#define EISDIR 21
/* Is a directory */
#define EINVAL 22
/* Invalid argument */
#define ENFILE 23
/* Too many open files in system */
#define EMFILE 24
/* Too many open files */
#define EFBIG 27
/* File too large */
#define ENOSPC 28
/* No space left on device */
#define ESPIPE 29
/* Illegal seek */
#define EROFS 30
/* Read-only file system */
#define EDOM 33
/* Argument to math function outside valid */
/* domain */
#define ERANGE 34
/* Math result cannot be represented */
#define EDEADLK 35
/* Resource deadlock would occur */
#define EDEADLOCK EDEADLK
#define ENOSYS 38
/* Function not implemented */
#define ENAMETOOLONG 60
/* File name too long */
#define ENOTEMPTY 66
/* Directory not empty */
#define ENOTSUP 95
/* Not supported error */
#define EEOF 200
/* End of file reached */
#define ENOSUPP 201
/* Operation not supported */
#define EDEVNOSUPP 202
/* Device does not support this operation */
/* Additional errors used by networking */
#define ENXIO 300
/* Device not configured */
#define EACCES 301
/* Permission denied */
#define EEXIST 302
/* File exists */
#define ENOTTY 303
/* Inappropriate ioctl for device */
#define EPIPE 304
/* Broken pipe */
/* non-blocking and interrupt i/o */
#define EINPROGRESS 310
/* Operation now in progress */
#define EALREADY 311
/* Operation already in progress */
/* ipc/network software -- argument errors */
#define ENOTSOCK 320
/* Socket operation on non-socket */
#define EDESTADDRREQ 321
/* Destination address required */
#define EMSGSIZE 322
/* Message too long */
#define EPROTOTYPE 323
/* Protocol wrong type for socket */
#define ENOPROTOOPT 324
/* Protocol not available */
#define EPROTONOSUPPORT 325
/* Protocol not supported */
#define ESOCKTNOSUPPORT 326
/* Socket type not supported */
#define EOPNOTSUPP 327
/* Operation not supported */
#define EPFNOSUPPORT 328
/* Protocol family not supported */
#define EAFNOSUPPORT 329
/* Address family not supported by */
/* protocol family */
#define EADDRINUSE 330
/* Address already in use */
#define EADDRNOTAVAIL 331
/* Can't assign requested address */
/* ipc/network software -- operational errors */
#define ENETDOWN 350
/* Network is down */
#define ENETUNREACH 351
/* Network is unreachable */
#define ENETRESET 352
/* Network dropped connection on reset */
#define ECONNABORTED 353
/* Software caused connection abort */
#define ECONNRESET 354
/* Connection reset by peer */
#define ENOBUFS 355
/* No buffer space available */
#define EISCONN 356
/* Socket is already connected */
#define ENOTCONN 357
/* Socket is not connected */
#define ESHUTDOWN 358
/* Can't send after socket shutdown */
#define ETOOMANYREFS 359
/* Too many references: can't splice */
#define ETIMEDOUT 360
/* Operation timed out */
#define ECONNREFUSED 361
/* Connection refused */
#define EHOSTDOWN 364
/* Host is down */
#define EHOSTUNREACH 365
/* No route to host */
#define ENOERR RT_EOK
#ifdef __cplusplus
}
/* extern "C" */
...
...
components/dfs/filesystems/jffs2/include/port/fcntl.h
浏览文件 @
8e430738
#ifndef CYGONCE_ISO_FCNTL_H
#define CYGONCE_ISO_FCNTL_H
#if defined(__CC_ARM) || defined(MSVC)
/* File access modes used for open() and fnctl() */
#define O_RDONLY (1<<0)
/* Open for reading only */
#define O_WRONLY (1<<1)
/* Open for writing only */
#define O_RDWR (O_RDONLY|O_WRONLY)
/* Open for reading and writing */
/* File access mode mask */
#define O_ACCMODE (O_RDONLY|O_RDWR|O_WRONLY)
/* open() mode flags */
#define O_CREAT (1<<3)
/* Create file it it does not exist */
#define O_EXCL (1<<4)
/* Exclusive use */
#define O_NOCTTY (1<<5)
/* Do not assign a controlling terminal */
#define O_TRUNC (1<<6)
/* Truncate */
/* File status flags used for open() and fcntl() */
#define O_APPEND (1<<7)
/* Set append mode */
#define O_DSYNC (1<<8)
/* Synchronized I/O data integrity writes */
#define O_NONBLOCK (1<<9)
/* No delay */
#define O_RSYNC (1<<10)
/* Synchronized read I/O */
#define O_SYNC (1<<11)
/* Synchronized I/O file integrity writes */
/*------------------------------------------------------------------------*/
/* for dfs_jffs2.c */
/*------------------------------------------------------------------------*/
/* File access modes used for open() and fnctl() */
#define JFFS2_O_RDONLY (
1<<0
)
/* Open for reading only */
#define JFFS2_O_WRONLY (
1<<1
)
/* Open for writing only */
#define JFFS2_O_RDONLY (
O_RDONLY
)
/* Open for reading only */
#define JFFS2_O_WRONLY (
O_WRONLY
)
/* Open for writing only */
#define JFFS2_O_RDWR (O_RDONLY|O_WRONLY)
/* Open for reading and writing */
/* File access mode mask */
...
...
@@ -36,45 +14,18 @@
/* open() mode flags */
#define JFFS2_O_CREAT (
1<<3)
/* Create file it it does not exist */
#define JFFS2_O_EXCL (
1<<4
)
/* Exclusive use */
#define JFFS2_O_NOCTTY (
1<<5)
/* Do not assign a controlling terminal */
#define JFFS2_O_TRUNC (
1<<6)
/* Truncate */
#define JFFS2_O_CREAT (
O_CREAT)
/* Create file it it does not exist */
#define JFFS2_O_EXCL (
O_EXCL
)
/* Exclusive use */
#define JFFS2_O_NOCTTY (
O_NOCTTY)
/* Do not assign a controlling terminal */
#define JFFS2_O_TRUNC (
O_TRUNC)
/* Truncate */
/* File status flags used for open() and fcntl() */
#define JFFS2_O_APPEND (1<<7)
/* Set append mode */
#define JFFS2_O_DSYNC (1<<8)
/* Synchronized I/O data integrity writes */
#define JFFS2_O_NONBLOCK (1<<9)
/* No delay */
#define JFFS2_O_RSYNC (1<<10)
/* Synchronized read I/O */
#define JFFS2_O_SYNC (1<<11)
/* Synchronized I/O file integrity writes */
#elif defined(__GNUC__)
/*------------------------------------------------------------------------*/
/* for dfs_jffs2.c */
/*------------------------------------------------------------------------*/
/* File access modes used for open() and fnctl() */
#define JFFS2_O_RDONLY (DFS_O_RDONLY)
/* Open for reading only */
#define JFFS2_O_WRONLY (DFS_O_WRONLY)
/* Open for writing only */
#define JFFS2_O_RDWR (DFS_O_RDONLY|DFS_O_WRONLY)
/* Open for reading and writing */
/* File access mode mask */
#define JFFS2_O_ACCMODE (DFS_O_RDONLY|DFS_O_RDWR|DFS_O_WRONLY)
/* open() mode flags */
#define JFFS2_O_CREAT (DFS_O_CREAT)
/* Create file it it does not exist */
#define JFFS2_O_EXCL (DFS_O_EXCL)
/* Exclusive use */
#define JFFS2_O_NOCTTY (DFS_O_NOCTTY)
/* Do not assign a controlling terminal */
#define JFFS2_O_TRUNC (DFS_O_TRUNC)
/* Truncate */
/* File status flags used for open() and fcntl() */
#define JFFS2_O_APPEND (DFS_O_APPEND)
/* Set append mode */
#define JFFS2_O_DSYNC (DFS_O_DSYNC)
/* Synchronized I/O data integrity writes */
#define JFFS2_O_NONBLOCK (DFS_O_NONBLOCK)
/* No delay */
#define JFFS2_O_RSYNC (DFS_O_RSYNC)
/* Synchronized read I/O */
#define JFFS2_O_SYNC (DFS_O_SYNC)
/* Synchronized I/O file integrity writes */
#define JFFS2_O_APPEND (O_APPEND)
/* Set append mode */
#define JFFS2_O_DSYNC (O_DSYNC)
/* Synchronized I/O data integrity writes */
#define JFFS2_O_NONBLOCK (O_NONBLOCK)
/* No delay */
#define JFFS2_O_RSYNC (O_RSYNC)
/* Synchronized read I/O */
#define JFFS2_O_SYNC (O_SYNC)
/* Synchronized I/O file integrity writes */
#endif
#endif
/* EOF fcntl.h */
components/dfs/filesystems/jffs2/include/port/sys/stat.h
浏览文件 @
8e430738
...
...
@@ -271,51 +271,6 @@ typedef void *cyg_io_handle_t;
#define __stat_mode_LNK (1<<8)
#define __stat_mode_SOCK (1<<9)
#if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE >= 200112L)
#define S_IFDIR (__stat_mode_DIR)
#define S_IFCHR (__stat_mode_CHR)
#define S_IFBLK (__stat_mode_BLK)
#define S_IFREG (__stat_mode_REG)
#define S_IFIFO (__stat_mode_FIFO)
#define S_IFLNK (__stat_mode_LNK)
#define S_IFSOCK (__stat_mode_SOCK)
#define S_IFMT (S_IFDIR|S_IFCHR|S_IFBLK|S_IFREG| \
S_IFIFO|S_IFLNK|S_IFSOCK)
#endif
#define S_ISDIR(__mode) ((__mode) & __stat_mode_DIR )
#define S_ISCHR(__mode) ((__mode) & __stat_mode_CHR )
#define S_ISBLK(__mode) ((__mode) & __stat_mode_BLK )
#define S_ISREG(__mode) ((__mode) & __stat_mode_REG )
#define S_ISFIFO(__mode) ((__mode) & __stat_mode_FIFO )
#if !defined(_POSIX_C_SOURCE) || (_POSIX_C_SOURCE >= 200112L)
#define S_ISLNK(__mode) ((__mode) & __stat_mode_LNK )
#define S_ISSOCK(__mode) ((__mode) & __stat_mode_SOCK )
#endif
#define S_TYPEISMQ(__buf) ((__buf)->st_mode & __stat_mode_MQ )
#define S_TYPEISSEM(__buf) ((__buf)->st_mode & __stat_mode_SEM )
#define S_TYPEISSHM(__buf) ((__buf)->st_mode & __stat_mode_SHM )
#define S_IRUSR (1<<16)
#define S_IWUSR (1<<17)
#define S_IXUSR (1<<18)
#define S_IRWXU (S_IRUSR|S_IWUSR|S_IXUSR)
#define S_IRGRP (1<<19)
#define S_IWGRP (1<<20)
#define S_IXGRP (1<<21)
#define S_IRWXG (S_IRGRP|S_IWGRP|S_IXGRP)
#define S_IROTH (1<<22)
#define S_IWOTH (1<<23)
#define S_IXOTH (1<<24)
#define S_IRWXO (S_IROTH|S_IWOTH|S_IXOTH)
#define S_ISUID (1<<25)
#define S_ISGID (1<<26)
#if defined(MSVC)
/* for time_t */
#include <time.h>
...
...
@@ -333,22 +288,6 @@ typedef long time_t;
#include <sys/types.h>
#endif
struct
stat
{
mode_t
st_mode
;
/* File mode */
ino_t
st_ino
;
/* File serial number */
dev_t
st_dev
;
/* ID of device containing file */
nlink_t
st_nlink
;
/* Number of hard links */
uid_t
st_uid
;
/* User ID of the file owner */
gid_t
st_gid
;
/* Group ID of the file's group */
off_t
st_size
;
/* File size (regular files only) */
time_t
st_atime
;
/* Last access time */
time_t
st_mtime
;
/* Last data modification time */
time_t
st_ctime
;
/* Last file status change time */
};
//fcntl.h
#define O_NONBLOCK (1<<9)
/* No delay */
#endif
/* CYGONCE_ISO_SYS_TYPES_H multiple inclusion protection */
/* EOF sys/types.h */
...
...
components/dfs/filesystems/jffs2/kernel/linux/fs.h
浏览文件 @
8e430738
...
...
@@ -2,12 +2,5 @@
#define __LINUX_FS_H__
#include <linux/stat.h>
/*
* File types
*/
#define DT_UNKNOWN 0
#define DT_DIR 4
#define DT_REG 8
#endif
/* __LINUX_FS_H__ */
components/dfs/filesystems/jffs2/kernel/linux/types.h
浏览文件 @
8e430738
...
...
@@ -3,17 +3,7 @@
#include "cyg/infra/cyg_type.h"
#define uint8_t cyg_uint8
#define uint16_t cyg_uint16
#define uint32_t cyg_uint32
#define int8_t cyg_int8
#define int16_t cyg_int16
#define int32_t cyg_int32
#define loff_t off_t
#define kvec iovec
#endif
/* __LINUX_TYPES_H__ */
components/dfs/filesystems/jffs2/src/flashio.c
浏览文件 @
8e430738
...
...
@@ -16,7 +16,7 @@
#include "nodelist.h"
#include <rtdevice.h>
int
jffs2_flash_read
(
struct
jffs2_sb_info
*
c
,
uint32_t
offset
,
int
jffs2_flash_read
(
struct
jffs2_sb_info
*
c
,
cyg_uint32
offset
,
const
size_t
size
,
size_t
*
return_size
,
unsigned
char
*
buffer
)
...
...
@@ -33,7 +33,7 @@ int jffs2_flash_read(struct jffs2_sb_info * c, uint32_t offset,
}
int
jffs2_flash_write
(
struct
jffs2_sb_info
*
c
,
uint32_t
offset
,
const
size_t
size
,
cyg_uint32
offset
,
const
size_t
size
,
size_t
*
return_size
,
unsigned
char
*
buffer
)
{
uint32_t
len
;
...
...
components/dfs/filesystems/jffs2/src/readinode.c
浏览文件 @
8e430738
...
...
@@ -188,7 +188,7 @@ read_direntry(struct jffs2_sb_info *c,
int
already
=
read
-
sizeof
(
*
rd
);
err
=
jffs2_flash_read
(
c
,
(
ref_offset
(
ref
))
+
read
,
rd
->
nsize
-
already
,
&
read
,
&
fd
->
name
[
already
]);
rd
->
nsize
-
already
,
(
size_t
*
)
&
read
,
&
fd
->
name
[
already
]);
if
(
unlikely
(
read
!=
rd
->
nsize
-
already
)
&&
likely
(
!
err
))
return
-
EIO
;
...
...
@@ -278,7 +278,7 @@ read_dnode(struct jffs2_sb_info *c,
return
-
ENOMEM
;
err
=
jffs2_flash_read
(
c
,
ref_offset
(
ref
)
+
sizeof
(
*
rd
),
je32_to_cpu
(
rd
->
csize
),
&
read
,
buf
);
(
size_t
*
)
&
read
,
buf
);
if
(
unlikely
(
read
!=
je32_to_cpu
(
rd
->
csize
))
&&
likely
(
!
err
))
err
=
-
EIO
;
if
(
err
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录