Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Keyboard Man_俊
rt-thread
提交
41f3d1f9
R
rt-thread
项目概览
Keyboard Man_俊
/
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看板
体验新版 GitCode,发现更多精彩内容 >>
提交
41f3d1f9
编写于
10月 17, 2017
作者:
B
bernard
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'master' of
https://github.com/RT-Thread/rt-thread
上级
19aa36e8
1b070259
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
191 addition
and
169 deletion
+191
-169
bsp/lm3s8962/rtconfig.h
bsp/lm3s8962/rtconfig.h
+2
-0
bsp/ls1cdev/drivers/net/synopGMAC_network_interface.h
bsp/ls1cdev/drivers/net/synopGMAC_network_interface.h
+3
-0
bsp/sam7x/sam7x_rom.ld
bsp/sam7x/sam7x_rom.ld
+1
-1
bsp/simulator/applications/init.c
bsp/simulator/applications/init.c
+1
-1
bsp/stm32f107/rtconfig.h
bsp/stm32f107/rtconfig.h
+1
-0
components/dfs/filesystems/nfs/dfs_nfs.c
components/dfs/filesystems/nfs/dfs_nfs.c
+183
-167
未找到文件。
bsp/lm3s8962/rtconfig.h
浏览文件 @
41f3d1f9
...
...
@@ -153,4 +153,6 @@
/* the size of each pbuf in the pbuf pool. */
#define RT_LWIP_PBUF_POOL_BUFSIZE 1500
#define RT_USING_LIBC
#define RT_USING_LWIP141
#endif
bsp/ls1cdev/drivers/net/synopGMAC_network_interface.h
浏览文件 @
41f3d1f9
...
...
@@ -35,6 +35,9 @@
#ifndef SYNOP_GMAC_NETWORK_INTERFACE_H
#define SYNOP_GMAC_NETWORK_INTERFACE_H 1
#include <lwip/sys.h>
#include <netif/ethernetif.h>
#include "synopGMAC_plat.h"
#include "synopGMAC_Host.h"
#include "synopGMAC_Dev.h"
...
...
bsp/sam7x/sam7x_rom.ld
浏览文件 @
41f3d1f9
...
...
@@ -4,7 +4,7 @@ MEMORY
{
CODE (rx) : ORIGIN = 0x00100000, LENGTH = 0x00040000
/* DATA (rw) : ORIGIN = 0x00200000, LENGTH = 0x00010000 */
DATA (rw) : ORIGIN = 0x0020
4000, LENGTH = 0x0000C
000
DATA (rw) : ORIGIN = 0x0020
3000, LENGTH = 0x0000D
000
}
ENTRY(_start)
SECTIONS
...
...
bsp/simulator/applications/init.c
浏览文件 @
41f3d1f9
...
...
@@ -38,7 +38,7 @@ extern void lwip_system_init(void);
#endif
#ifdef RT_USING_DFS
#include <dfs
_init
.h>
#include <dfs.h>
#include <dfs_fs.h>
#ifdef RT_USING_DFS_ELMFAT
#include <dfs_elm.h>
...
...
bsp/stm32f107/rtconfig.h
浏览文件 @
41f3d1f9
...
...
@@ -163,4 +163,5 @@
// <bool name="RT_USING_BSP_CMSIS" description="Using CMSIS in BSP" default="true" />
// #define RT_USING_BSP_CMSIS
#define RT_USING_LIBC
#endif
components/dfs/filesystems/nfs/dfs_nfs.c
浏览文件 @
41f3d1f9
...
...
@@ -24,7 +24,8 @@
#include <stdio.h>
#include <rtthread.h>
#include <dfs_fs.h>
#include <dfs_def.h>
#include <dfs.h>
#include <dfs_file.h>
#include <rpc/rpc.h>
...
...
@@ -59,6 +60,7 @@ struct nfs_dir
#define HOST_LENGTH 32
#define EXPORT_PATH_LENGTH 32
struct
nfs_filesystem
{
nfs_fh3
root_handle
;
...
...
@@ -68,10 +70,14 @@ struct nfs_filesystem
char
host
[
HOST_LENGTH
];
char
export
[
EXPORT_PATH_LENGTH
];
void
*
data
;
/* nfs_file or nfs_dir */
};
typedef
struct
nfs_filesystem
nfs_filesystem
;
typedef
struct
nfs_file
nfs_file
;
typedef
struct
nfs_dir
nfs_dir
;
nfs_dir
*
nfs_opendir
(
struct
nfs_filesystem
*
nfs
,
const
char
*
path
);
nfs_dir
*
nfs_opendir
(
nfs_filesystem
*
nfs
,
const
char
*
path
);
static
int
nfs_parse_host_export
(
const
char
*
host_export
,
char
*
host
,
...
...
@@ -98,7 +104,7 @@ static int nfs_parse_host_export(const char *host_export,
if
(
index
==
host_len
)
return
-
1
;
/* make
RT_
NULL */
/* make NULL */
host_len
=
index
;
host
[
host_len
]
=
'\0'
;
...
...
@@ -124,7 +130,7 @@ static void copy_handle(nfs_fh3 *dest, const nfs_fh3 *source)
{
dest
->
data
.
data_len
=
source
->
data
.
data_len
;
dest
->
data
.
data_val
=
rt_malloc
(
dest
->
data
.
data_len
);
if
(
dest
->
data
.
data_val
==
RT_
NULL
)
if
(
dest
->
data
.
data_val
==
NULL
)
{
dest
->
data
.
data_len
=
0
;
...
...
@@ -134,25 +140,25 @@ static void copy_handle(nfs_fh3 *dest, const nfs_fh3 *source)
memcpy
(
dest
->
data
.
data_val
,
source
->
data
.
data_val
,
dest
->
data
.
data_len
);
}
static
nfs_fh3
*
get_handle
(
struct
nfs_filesystem
*
nfs
,
const
char
*
name
)
static
nfs_fh3
*
get_handle
(
nfs_filesystem
*
nfs
,
const
char
*
name
)
{
nfs_fh3
*
handle
=
RT_
NULL
;
nfs_fh3
*
handle
=
NULL
;
char
*
file
;
char
*
path
;
char
*
init
;
init
=
path
=
rt_malloc
(
strlen
(
name
)
+
1
);
if
(
init
==
RT_
NULL
)
return
RT_
NULL
;
if
(
init
==
NULL
)
return
NULL
;
memcpy
(
init
,
name
,
strlen
(
name
)
+
1
);
handle
=
rt_malloc
(
sizeof
(
nfs_fh3
));
if
(
handle
==
RT_
NULL
)
if
(
handle
==
NULL
)
{
rt_free
(
init
);
return
RT_
NULL
;
return
NULL
;
}
if
(
path
[
0
]
==
'/'
)
...
...
@@ -165,7 +171,7 @@ static nfs_fh3 *get_handle(struct nfs_filesystem *nfs, const char *name)
copy_handle
(
handle
,
&
nfs
->
current_handle
);
}
while
((
file
=
strtok_r
(
RT_NULL
,
"/"
,
&
path
))
!=
RT_
NULL
)
while
((
file
=
strtok_r
(
NULL
,
"/"
,
&
path
))
!=
NULL
)
{
LOOKUP3args
args
;
LOOKUP3res
res
;
...
...
@@ -181,7 +187,7 @@ static nfs_fh3 *get_handle(struct nfs_filesystem *nfs, const char *name)
rt_free
(
handle
);
xdr_free
((
xdrproc_t
)
xdr_nfs_fh3
,
(
char
*
)
&
args
.
what
.
dir
);
return
RT_
NULL
;
return
NULL
;
}
else
if
(
res
.
status
!=
NFS3_OK
)
{
...
...
@@ -191,7 +197,7 @@ static nfs_fh3 *get_handle(struct nfs_filesystem *nfs, const char *name)
xdr_free
((
xdrproc_t
)
xdr_nfs_fh3
,
(
char
*
)
&
args
.
what
.
dir
);
xdr_free
((
xdrproc_t
)
xdr_LOOKUP3res
,
(
char
*
)
&
res
);
return
RT_
NULL
;
return
NULL
;
}
copy_handle
(
handle
,
&
res
.
LOOKUP3res_u
.
resok
.
object
);
xdr_free
((
xdrproc_t
)
xdr_nfs_fh3
,
(
char
*
)
&
args
.
what
.
dir
);
...
...
@@ -203,24 +209,24 @@ static nfs_fh3 *get_handle(struct nfs_filesystem *nfs, const char *name)
return
handle
;
}
static
nfs_fh3
*
get_dir_handle
(
struct
nfs_filesystem
*
nfs
,
const
char
*
name
)
static
nfs_fh3
*
get_dir_handle
(
nfs_filesystem
*
nfs
,
const
char
*
name
)
{
nfs_fh3
*
handle
=
RT_
NULL
;
nfs_fh3
*
handle
=
NULL
;
char
*
file
;
char
*
path
;
char
*
init
;
init
=
path
=
rt_malloc
(
strlen
(
name
)
+
1
);
if
(
init
==
RT_
NULL
)
return
RT_
NULL
;
if
(
init
==
NULL
)
return
NULL
;
memcpy
(
init
,
name
,
strlen
(
name
)
+
1
);
handle
=
rt_malloc
(
sizeof
(
nfs_fh3
));
if
(
handle
==
RT_
NULL
)
if
(
handle
==
NULL
)
{
rt_free
(
init
);
return
RT_
NULL
;
return
NULL
;
}
if
(
path
[
0
]
==
'/'
)
...
...
@@ -233,7 +239,7 @@ static nfs_fh3 *get_dir_handle(struct nfs_filesystem *nfs, const char *name)
copy_handle
(
handle
,
&
nfs
->
current_handle
);
}
while
((
file
=
strtok_r
(
RT_NULL
,
"/"
,
&
path
))
!=
RT_
NULL
&&
path
[
0
]
!=
0
)
while
((
file
=
strtok_r
(
NULL
,
"/"
,
&
path
))
!=
NULL
&&
path
[
0
]
!=
0
)
{
LOOKUP3args
args
;
LOOKUP3res
res
;
...
...
@@ -249,7 +255,7 @@ static nfs_fh3 *get_dir_handle(struct nfs_filesystem *nfs, const char *name)
rt_free
(
handle
);
xdr_free
((
xdrproc_t
)
xdr_nfs_fh3
,
(
char
*
)
&
args
.
what
.
dir
);
return
RT_
NULL
;
return
NULL
;
}
else
if
(
res
.
status
!=
NFS3_OK
)
{
...
...
@@ -259,7 +265,7 @@ static nfs_fh3 *get_dir_handle(struct nfs_filesystem *nfs, const char *name)
xdr_free
((
xdrproc_t
)
xdr_nfs_fh3
,
(
char
*
)
&
args
.
what
.
dir
);
xdr_free
((
xdrproc_t
)
xdr_LOOKUP3res
,
(
char
*
)
&
res
);
return
RT_
NULL
;
return
NULL
;
}
copy_handle
(
handle
,
&
res
.
LOOKUP3res_u
.
resok
.
object
);
xdr_free
((
xdrproc_t
)
xdr_nfs_fh3
,
(
char
*
)
&
args
.
what
.
dir
);
...
...
@@ -271,7 +277,7 @@ static nfs_fh3 *get_dir_handle(struct nfs_filesystem *nfs, const char *name)
return
handle
;
}
static
size_t
nfs_get_filesize
(
struct
nfs_filesystem
*
nfs
,
nfs_fh3
*
handle
)
static
size_t
nfs_get_filesize
(
nfs_filesystem
*
nfs
,
nfs_fh3
*
handle
)
{
GETATTR3args
args
;
GETATTR3res
res
;
...
...
@@ -297,7 +303,7 @@ static size_t nfs_get_filesize(struct nfs_filesystem *nfs, nfs_fh3 *handle)
return
size
;
}
rt_bool_t
nfs_is_directory
(
struct
nfs_filesystem
*
nfs
,
const
char
*
name
)
rt_bool_t
nfs_is_directory
(
nfs_filesystem
*
nfs
,
const
char
*
name
)
{
GETATTR3args
args
;
GETATTR3res
res
;
...
...
@@ -307,7 +313,7 @@ rt_bool_t nfs_is_directory(struct nfs_filesystem *nfs, const char *name)
result
=
RT_FALSE
;
handle
=
get_handle
(
nfs
,
name
);
if
(
handle
==
RT_
NULL
)
if
(
handle
==
NULL
)
return
RT_FALSE
;
args
.
object
=
*
handle
;
...
...
@@ -339,26 +345,26 @@ rt_bool_t nfs_is_directory(struct nfs_filesystem *nfs, const char *name)
return
result
;
}
int
nfs_create
(
struct
nfs_filesystem
*
nfs
,
const
char
*
name
,
mode_t
mode
)
int
nfs_create
(
nfs_filesystem
*
nfs
,
const
char
*
name
,
mode_t
mode
)
{
CREATE3args
args
;
CREATE3res
res
;
int
ret
=
0
;
nfs_fh3
*
handle
;
if
(
nfs
->
nfs_client
==
RT_
NULL
)
if
(
nfs
->
nfs_client
==
NULL
)
{
return
-
1
;
}
handle
=
get_dir_handle
(
nfs
,
name
);
if
(
handle
==
RT_
NULL
)
if
(
handle
==
NULL
)
{
return
-
1
;
}
args
.
where
.
dir
=
*
handle
;
args
.
where
.
name
=
strrchr
(
name
,
'/'
)
+
1
;
if
(
args
.
where
.
name
==
RT_
NULL
)
if
(
args
.
where
.
name
==
NULL
)
{
args
.
where
.
name
=
(
char
*
)
name
;
}
...
...
@@ -391,23 +397,23 @@ int nfs_create(struct nfs_filesystem *nfs, const char *name, mode_t mode)
return
ret
;
}
int
nfs_mkdir
(
struct
nfs_filesystem
*
nfs
,
const
char
*
name
,
mode_t
mode
)
int
nfs_mkdir
(
nfs_filesystem
*
nfs
,
const
char
*
name
,
mode_t
mode
)
{
MKDIR3args
args
;
MKDIR3res
res
;
int
ret
=
0
;
nfs_fh3
*
handle
;
if
(
nfs
->
nfs_client
==
RT_
NULL
)
if
(
nfs
->
nfs_client
==
NULL
)
return
-
1
;
handle
=
get_dir_handle
(
nfs
,
name
);
if
(
handle
==
RT_
NULL
)
if
(
handle
==
NULL
)
return
-
1
;
args
.
where
.
dir
=
*
handle
;
args
.
where
.
name
=
strrchr
(
name
,
'/'
)
+
1
;
if
(
args
.
where
.
name
==
RT_
NULL
)
if
(
args
.
where
.
name
==
NULL
)
{
args
.
where
.
name
=
(
char
*
)
name
;
}
...
...
@@ -439,14 +445,14 @@ int nfs_mkdir(struct nfs_filesystem *nfs, const char *name, mode_t mode)
return
ret
;
}
/* mount(
RT_
NULL, "/mnt", "nfs", 0, "192.168.1.1:/export") */
/* mount(NULL, "/mnt", "nfs", 0, "192.168.1.1:/export") */
int
nfs_mount
(
struct
dfs_filesystem
*
fs
,
unsigned
long
rwflag
,
const
void
*
data
)
{
mountres3
res
;
struct
nfs_filesystem
*
nfs
;
nfs_filesystem
*
nfs
;
nfs
=
(
struct
nfs_filesystem
*
)
rt_malloc
(
sizeof
(
struct
nfs_filesystem
));
memset
(
nfs
,
0
,
sizeof
(
struct
nfs_filesystem
));
nfs
=
(
nfs_filesystem
*
)
rt_malloc
(
sizeof
(
nfs_filesystem
));
memset
(
nfs
,
0
,
sizeof
(
nfs_filesystem
));
if
(
nfs_parse_host_export
((
const
char
*
)
data
,
nfs
->
host
,
HOST_LENGTH
,
nfs
->
export
,
EXPORT_PATH_LENGTH
)
<
0
)
...
...
@@ -456,7 +462,7 @@ int nfs_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *data)
}
nfs
->
mount_client
=
clnt_create
((
char
*
)
nfs
->
host
,
MOUNT_PROGRAM
,
MOUNT_V3
,
"udp"
);
if
(
nfs
->
mount_client
==
RT_
NULL
)
if
(
nfs
->
mount_client
==
NULL
)
{
rt_kprintf
(
"create mount client failed
\n
"
);
goto
__return
;
...
...
@@ -474,7 +480,7 @@ int nfs_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *data)
goto
__return
;
}
nfs
->
nfs_client
=
clnt_create
((
char
*
)
nfs
->
host
,
NFS_PROGRAM
,
NFS_V3
,
"udp"
);
if
(
nfs
->
nfs_client
==
RT_
NULL
)
if
(
nfs
->
nfs_client
==
NULL
)
{
rt_kprintf
(
"creat nfs client failed
\n
"
);
goto
__return
;
...
...
@@ -488,15 +494,15 @@ int nfs_mount(struct dfs_filesystem *fs, unsigned long rwflag, const void *data)
return
0
;
__return:
if
(
nfs
!=
RT_
NULL
)
if
(
nfs
!=
NULL
)
{
if
(
nfs
->
mount_client
!=
RT_
NULL
)
if
(
nfs
->
mount_client
!=
NULL
)
{
clnt_destroy
(
nfs
->
mount_client
);
}
if
(
nfs
->
nfs_client
!=
RT_
NULL
)
if
(
nfs
->
nfs_client
!=
NULL
)
{
if
(
nfs
->
nfs_client
->
cl_auth
!=
RT_
NULL
)
if
(
nfs
->
nfs_client
->
cl_auth
!=
NULL
)
{
auth_destroy
(
nfs
->
nfs_client
->
cl_auth
);
}
...
...
@@ -510,73 +516,73 @@ __return:
int
nfs_unmount
(
struct
dfs_filesystem
*
fs
)
{
struct
nfs_filesystem
*
nfs
;
nfs_filesystem
*
nfs
;
RT_ASSERT
(
fs
!=
RT_
NULL
);
RT_ASSERT
(
fs
->
data
!=
RT_
NULL
);
nfs
=
(
struct
nfs_filesystem
*
)
fs
->
data
;
RT_ASSERT
(
fs
!=
NULL
);
RT_ASSERT
(
fs
->
data
!=
NULL
);
nfs
=
(
nfs_filesystem
*
)
fs
->
data
;
if
(
nfs
->
mount_client
!=
RT_NULL
&&
mountproc3_umnt_3
((
char
*
)
nfs
->
export
,
RT_
NULL
,
nfs
->
mount_client
)
!=
RPC_SUCCESS
)
if
(
nfs
->
mount_client
!=
NULL
&&
mountproc3_umnt_3
((
char
*
)
nfs
->
export
,
NULL
,
nfs
->
mount_client
)
!=
RPC_SUCCESS
)
{
rt_kprintf
(
"umount failed
\n
"
);
rt_kprintf
(
"u
n
mount failed
\n
"
);
return
-
1
;
}
/* destroy nfs client */
if
(
nfs
->
nfs_client
!=
RT_
NULL
)
if
(
nfs
->
nfs_client
!=
NULL
)
{
if
(
nfs
->
nfs_client
->
cl_auth
!=
RT_
NULL
)
if
(
nfs
->
nfs_client
->
cl_auth
!=
NULL
)
{
auth_destroy
(
nfs
->
nfs_client
->
cl_auth
);
nfs
->
nfs_client
->
cl_auth
=
RT_
NULL
;
nfs
->
nfs_client
->
cl_auth
=
NULL
;
}
clnt_destroy
(
nfs
->
nfs_client
);
nfs
->
nfs_client
=
RT_
NULL
;
nfs
->
nfs_client
=
NULL
;
}
/* destroy mount client */
if
(
nfs
->
mount_client
!=
RT_
NULL
)
if
(
nfs
->
mount_client
!=
NULL
)
{
if
(
nfs
->
mount_client
->
cl_auth
!=
RT_
NULL
)
if
(
nfs
->
mount_client
->
cl_auth
!=
NULL
)
{
auth_destroy
(
nfs
->
mount_client
->
cl_auth
);
nfs
->
mount_client
->
cl_auth
=
RT_
NULL
;
nfs
->
mount_client
->
cl_auth
=
NULL
;
}
clnt_destroy
(
nfs
->
mount_client
);
nfs
->
mount_client
=
RT_
NULL
;
nfs
->
mount_client
=
NULL
;
}
rt_free
(
nfs
);
fs
->
data
=
RT_
NULL
;
fs
->
data
=
NULL
;
return
0
;
}
int
nfs_ioctl
(
struct
dfs_fd
*
file
,
int
cmd
,
void
*
args
)
{
return
-
DFS_STATUS_
ENOSYS
;
return
-
ENOSYS
;
}
int
nfs_read
(
struct
dfs_fd
*
file
,
void
*
buf
,
rt_
size_t
count
)
int
nfs_read
(
struct
dfs_fd
*
file
,
void
*
buf
,
size_t
count
)
{
READ3args
args
;
READ3res
res
;
ssize_t
bytes
,
total
=
0
;
nfs_file
*
fd
;
struct
nfs_filesystem
*
nfs
;
nfs_filesystem
*
nfs
;
if
(
file
->
type
==
FT_DIRECTORY
)
return
-
DFS_STATUS_
EISDIR
;
return
-
EISDIR
;
fd
=
(
nfs_file
*
)(
file
->
data
);
RT_ASSERT
(
fd
!=
RT_NULL
);
RT_ASSERT
(
file
->
fs
!=
RT_NULL
);
RT_ASSERT
(
file
->
fs
->
data
!=
RT_NULL
);
nfs
=
(
struct
nfs_filesystem
*
)
file
->
fs
->
data
;
if
(
nfs
->
nfs_client
==
RT_NULL
)
RT_ASSERT
(
file
->
data
!=
NULL
);
nfs
=
(
nfs_filesystem
*
)((
struct
dfs_filesystem
*
)(
file
->
data
));
fd
=
(
nfs_file
*
)(
nfs
->
data
);
RT_ASSERT
(
fd
!=
NULL
);
if
(
nfs
->
nfs_client
==
NULL
)
return
-
1
;
/* end of file */
...
...
@@ -626,24 +632,23 @@ int nfs_read(struct dfs_fd *file, void *buf, rt_size_t count)
return
total
;
}
int
nfs_write
(
struct
dfs_fd
*
file
,
const
void
*
buf
,
rt_
size_t
count
)
int
nfs_write
(
struct
dfs_fd
*
file
,
const
void
*
buf
,
size_t
count
)
{
WRITE3args
args
;
WRITE3res
res
;
ssize_t
bytes
,
total
=
0
;
nfs_file
*
fd
;
struct
nfs_filesystem
*
nfs
;
nfs_filesystem
*
nfs
;
if
(
file
->
type
==
FT_DIRECTORY
)
return
-
DFS_STATUS_
EISDIR
;
return
-
EISDIR
;
fd
=
(
nfs_file
*
)(
file
->
data
);
RT_ASSERT
(
fd
!=
RT_NULL
);
RT_ASSERT
(
file
->
fs
!=
RT_NULL
);
RT_ASSERT
(
file
->
fs
->
data
!=
RT_NULL
);
nfs
=
(
struct
nfs_filesystem
*
)
file
->
fs
->
data
;
RT_ASSERT
(
file
->
data
!=
NULL
);
nfs
=
(
nfs_filesystem
*
)((
struct
dfs_filesystem
*
)(
file
->
data
));
fd
=
(
nfs_file
*
)(
nfs
->
data
);
RT_ASSERT
(
fd
!=
NULL
);
if
(
nfs
->
nfs_client
==
RT_
NULL
)
if
(
nfs
->
nfs_client
==
NULL
)
return
-
1
;
args
.
file
=
fd
->
handle
;
...
...
@@ -690,15 +695,18 @@ int nfs_write(struct dfs_fd *file, const void *buf, rt_size_t count)
return
total
;
}
int
nfs_lseek
(
struct
dfs_fd
*
file
,
rt_
off_t
offset
)
int
nfs_lseek
(
struct
dfs_fd
*
file
,
off_t
offset
)
{
nfs_file
*
fd
;
nfs_filesystem
*
nfs
;
if
(
file
->
type
==
FT_DIRECTORY
)
return
-
DFS_STATUS_
EISDIR
;
return
-
EISDIR
;
fd
=
(
nfs_file
*
)(
file
->
data
);
RT_ASSERT
(
fd
!=
RT_NULL
);
RT_ASSERT
(
file
->
data
!=
NULL
);
nfs
=
(
nfs_filesystem
*
)((
struct
dfs_filesystem
*
)(
file
->
data
));
fd
=
(
nfs_file
*
)(
nfs
->
data
);
RT_ASSERT
(
fd
!=
NULL
);
if
(
offset
<=
fd
->
size
)
{
...
...
@@ -707,16 +715,20 @@ int nfs_lseek(struct dfs_fd *file, rt_off_t offset)
return
offset
;
}
return
-
DFS_STATUS_
EIO
;
return
-
EIO
;
}
int
nfs_close
(
struct
dfs_fd
*
file
)
{
nfs_filesystem
*
nfs
;
RT_ASSERT
(
file
->
data
!=
NULL
);
nfs
=
(
nfs_filesystem
*
)((
struct
dfs_filesystem
*
)(
file
->
data
));
if
(
file
->
type
==
FT_DIRECTORY
)
{
struct
nfs_dir
*
dir
;
dir
=
(
struct
nfs_dir
*
)
file
->
data
;
dir
=
(
struct
nfs_dir
*
)
nfs
->
data
;
xdr_free
((
xdrproc_t
)
xdr_nfs_fh3
,
(
char
*
)
&
dir
->
handle
);
xdr_free
((
xdrproc_t
)
xdr_READDIR3res
,
(
char
*
)
&
dir
->
res
);
rt_free
(
dir
);
...
...
@@ -725,38 +737,37 @@ int nfs_close(struct dfs_fd *file)
{
struct
nfs_file
*
fd
;
fd
=
(
struct
nfs_file
*
)
file
->
data
;
fd
=
(
struct
nfs_file
*
)
nfs
->
data
;
xdr_free
((
xdrproc_t
)
xdr_nfs_fh3
,
(
char
*
)
&
fd
->
handle
);
rt_free
(
fd
);
}
file
->
data
=
RT_
NULL
;
nfs
->
data
=
NULL
;
return
0
;
}
int
nfs_open
(
struct
dfs_fd
*
file
)
{
struct
nfs_filesystem
*
nfs
;
nfs_filesystem
*
nfs
;
RT_ASSERT
(
file
->
data
!=
NULL
);
nfs
=
(
nfs_filesystem
*
)((
struct
dfs_filesystem
*
)(
file
->
data
));
RT_ASSERT
(
file
->
fs
!=
RT_NULL
);
RT_ASSERT
(
file
->
fs
->
data
!=
RT_NULL
);
nfs
=
(
struct
nfs_filesystem
*
)
file
->
fs
->
data
;
if
(
file
->
flags
&
DFS_
O_DIRECTORY
)
if
(
file
->
flags
&
O_DIRECTORY
)
{
nfs_dir
*
dir
;
if
(
file
->
flags
&
DFS_
O_CREAT
)
if
(
file
->
flags
&
O_CREAT
)
{
if
(
nfs_mkdir
(
nfs
,
file
->
path
,
0755
)
<
0
)
return
-
DFS_STATUS_
EAGAIN
;
return
-
EAGAIN
;
}
/* open directory */
dir
=
nfs_opendir
(
nfs
,
file
->
path
);
if
(
dir
==
RT_NULL
)
return
-
DFS_STATUS_
ENOENT
;
file
->
data
=
dir
;
if
(
dir
==
NULL
)
return
-
ENOENT
;
nfs
->
data
=
dir
;
}
else
{
...
...
@@ -764,23 +775,23 @@ int nfs_open(struct dfs_fd *file)
nfs_fh3
*
handle
;
/* create file */
if
(
file
->
flags
&
DFS_
O_CREAT
)
if
(
file
->
flags
&
O_CREAT
)
{
if
(
nfs_create
(
nfs
,
file
->
path
,
0664
)
<
0
)
return
-
DFS_STATUS_
EAGAIN
;
return
-
EAGAIN
;
}
/* open file (get file handle ) */
fp
=
rt_malloc
(
sizeof
(
nfs_file
));
if
(
fp
==
RT_
NULL
)
return
-
DFS_STATUS_
ENOMEM
;
if
(
fp
==
NULL
)
return
-
ENOMEM
;
handle
=
get_handle
(
nfs
,
file
->
path
);
if
(
handle
==
RT_
NULL
)
if
(
handle
==
NULL
)
{
rt_free
(
fp
);
return
-
DFS_STATUS_
ENOENT
;
return
-
ENOENT
;
}
/* get size of file */
...
...
@@ -792,13 +803,13 @@ int nfs_open(struct dfs_fd *file)
xdr_free
((
xdrproc_t
)
xdr_nfs_fh3
,
(
char
*
)
handle
);
rt_free
(
handle
);
if
(
file
->
flags
&
DFS_
O_APPEND
)
if
(
file
->
flags
&
O_APPEND
)
{
fp
->
offset
=
fp
->
size
;
}
/* set private file */
file
->
data
=
fp
;
nfs
->
data
=
fp
;
file
->
size
=
fp
->
size
;
}
...
...
@@ -811,14 +822,14 @@ int nfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
GETATTR3res
res
;
fattr3
*
info
;
nfs_fh3
*
handle
;
struct
nfs_filesystem
*
nfs
;
nfs_filesystem
*
nfs
;
RT_ASSERT
(
fs
!=
RT_
NULL
);
RT_ASSERT
(
fs
->
data
!=
RT_
NULL
);
nfs
=
(
struct
nfs_filesystem
*
)
fs
->
data
;
RT_ASSERT
(
fs
!=
NULL
);
RT_ASSERT
(
fs
->
data
!=
NULL
);
nfs
=
(
nfs_filesystem
*
)
fs
->
data
;
handle
=
get_handle
(
nfs
,
path
);
if
(
handle
==
RT_
NULL
)
if
(
handle
==
NULL
)
return
-
1
;
args
.
object
=
*
handle
;
...
...
@@ -840,12 +851,11 @@ int nfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
st
->
st_dev
=
0
;
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
;
if
(
info
->
type
==
NFS3DIR
)
{
st
->
st_mode
&=
~
DFS_
S_IFREG
;
st
->
st_mode
|=
DFS_S_IFDIR
|
DFS_S_IXUSR
|
DFS_S_IXGRP
|
DFS_
S_IXOTH
;
st
->
st_mode
&=
~
S_IFREG
;
st
->
st_mode
|=
S_IFDIR
|
S_IXUSR
|
S_IXGRP
|
S_IXOTH
;
}
st
->
st_size
=
info
->
size
;
...
...
@@ -858,23 +868,23 @@ int nfs_stat(struct dfs_filesystem *fs, const char *path, struct stat *st)
return
0
;
}
nfs_dir
*
nfs_opendir
(
struct
nfs_filesystem
*
nfs
,
const
char
*
path
)
nfs_dir
*
nfs_opendir
(
nfs_filesystem
*
nfs
,
const
char
*
path
)
{
nfs_dir
*
dir
;
nfs_fh3
*
handle
;
dir
=
rt_malloc
(
sizeof
(
nfs_dir
));
if
(
dir
==
RT_
NULL
)
if
(
dir
==
NULL
)
{
return
RT_
NULL
;
return
NULL
;
}
handle
=
get_handle
(
nfs
,
path
);
if
(
handle
==
RT_
NULL
)
if
(
handle
==
NULL
)
{
rt_free
(
dir
);
return
RT_
NULL
;
return
NULL
;
}
copy_handle
(
&
dir
->
handle
,
handle
);
...
...
@@ -883,21 +893,21 @@ nfs_dir *nfs_opendir(struct nfs_filesystem *nfs, const char *path)
dir
->
cookie
=
0
;
memset
(
&
dir
->
cookieverf
,
'\0'
,
sizeof
(
cookieverf3
));
dir
->
entry
=
RT_
NULL
;
dir
->
entry
=
NULL
;
dir
->
eof
=
FALSE
;
memset
(
&
dir
->
res
,
'\0'
,
sizeof
(
dir
->
res
));
return
dir
;
}
char
*
nfs_readdir
(
struct
nfs_filesystem
*
nfs
,
nfs_dir
*
dir
)
char
*
nfs_readdir
(
nfs_filesystem
*
nfs
,
nfs_dir
*
dir
)
{
static
char
name
[
NAME_MAX
];
if
(
nfs
->
nfs_client
==
RT_NULL
||
dir
==
RT_
NULL
)
return
RT_
NULL
;
if
(
nfs
->
nfs_client
==
NULL
||
dir
==
NULL
)
return
NULL
;
if
(
dir
->
entry
==
RT_
NULL
)
if
(
dir
->
entry
==
NULL
)
{
READDIR3args
args
;
...
...
@@ -913,21 +923,21 @@ char *nfs_readdir(struct nfs_filesystem *nfs, nfs_dir *dir)
{
rt_kprintf
(
"Readdir failed
\n
"
);
return
RT_
NULL
;
return
NULL
;
}
else
if
(
dir
->
res
.
status
!=
NFS3_OK
)
{
rt_kprintf
(
"Readdir failed: %d
\n
"
,
dir
->
res
.
status
);
return
RT_
NULL
;
return
NULL
;
}
memcpy
(
&
dir
->
cookieverf
,
&
dir
->
res
.
READDIR3res_u
.
resok
.
cookieverf
,
sizeof
(
cookieverf3
));
dir
->
eof
=
dir
->
res
.
READDIR3res_u
.
resok
.
reply
.
eof
;
dir
->
entry
=
dir
->
res
.
READDIR3res_u
.
resok
.
reply
.
entries
;
}
if
(
dir
->
eof
==
TRUE
&&
dir
->
entry
==
RT_
NULL
)
return
RT_
NULL
;
if
(
dir
->
eof
==
TRUE
&&
dir
->
entry
==
NULL
)
return
NULL
;
dir
->
cookie
=
dir
->
entry
->
cookie
;
strncpy
(
name
,
dir
->
entry
->
name
,
NAME_MAX
-
1
);
...
...
@@ -940,11 +950,11 @@ char *nfs_readdir(struct nfs_filesystem *nfs, nfs_dir *dir)
int
nfs_unlink
(
struct
dfs_filesystem
*
fs
,
const
char
*
path
)
{
int
ret
=
0
;
struct
nfs_filesystem
*
nfs
;
nfs_filesystem
*
nfs
;
RT_ASSERT
(
fs
!=
RT_
NULL
);
RT_ASSERT
(
fs
->
data
!=
RT_
NULL
);
nfs
=
(
struct
nfs_filesystem
*
)
fs
->
data
;
RT_ASSERT
(
fs
!=
NULL
);
RT_ASSERT
(
fs
->
data
!=
NULL
);
nfs
=
(
nfs_filesystem
*
)
fs
->
data
;
if
(
nfs_is_directory
(
nfs
,
path
)
==
RT_FALSE
)
{
...
...
@@ -954,12 +964,12 @@ int nfs_unlink(struct dfs_filesystem *fs, const char *path)
nfs_fh3
*
handle
;
handle
=
get_dir_handle
(
nfs
,
path
);
if
(
handle
==
RT_
NULL
)
if
(
handle
==
NULL
)
return
-
1
;
args
.
object
.
dir
=
*
handle
;
args
.
object
.
name
=
strrchr
(
path
,
'/'
)
+
1
;
if
(
args
.
object
.
name
==
RT_
NULL
)
if
(
args
.
object
.
name
==
NULL
)
{
args
.
object
.
name
=
(
char
*
)
path
;
}
...
...
@@ -988,12 +998,12 @@ int nfs_unlink(struct dfs_filesystem *fs, const char *path)
nfs_fh3
*
handle
;
handle
=
get_dir_handle
(
nfs
,
path
);
if
(
handle
==
RT_
NULL
)
if
(
handle
==
NULL
)
return
-
1
;
args
.
object
.
dir
=
*
handle
;
args
.
object
.
name
=
strrchr
(
path
,
'/'
)
+
1
;
if
(
args
.
object
.
name
==
RT_
NULL
)
if
(
args
.
object
.
name
==
NULL
)
{
args
.
object
.
name
=
(
char
*
)
path
;
}
...
...
@@ -1026,31 +1036,31 @@ int nfs_rename(struct dfs_filesystem *fs, const char *src, const char *dest)
nfs_fh3
*
sHandle
;
nfs_fh3
*
dHandle
;
int
ret
=
0
;
struct
nfs_filesystem
*
nfs
;
nfs_filesystem
*
nfs
;
RT_ASSERT
(
fs
!=
RT_
NULL
);
RT_ASSERT
(
fs
->
data
!=
RT_
NULL
);
nfs
=
(
struct
nfs_filesystem
*
)
fs
->
data
;
RT_ASSERT
(
fs
!=
NULL
);
RT_ASSERT
(
fs
->
data
!=
NULL
);
nfs
=
(
nfs_filesystem
*
)
fs
->
data
;
if
(
nfs
->
nfs_client
==
RT_
NULL
)
if
(
nfs
->
nfs_client
==
NULL
)
return
-
1
;
sHandle
=
get_dir_handle
(
nfs
,
src
);
if
(
sHandle
==
RT_
NULL
)
if
(
sHandle
==
NULL
)
return
-
1
;
dHandle
=
get_dir_handle
(
nfs
,
dest
);
if
(
dHandle
==
RT_
NULL
)
if
(
dHandle
==
NULL
)
return
-
1
;
args
.
from
.
dir
=
*
sHandle
;
args
.
from
.
name
=
strrchr
(
src
,
'/'
)
+
1
;
if
(
args
.
from
.
name
==
RT_
NULL
)
if
(
args
.
from
.
name
==
NULL
)
args
.
from
.
name
=
(
char
*
)
src
;
args
.
to
.
dir
=
*
dHandle
;
args
.
to
.
name
=
strrchr
(
src
,
'/'
)
+
1
;
if
(
args
.
to
.
name
==
RT_
NULL
)
if
(
args
.
to
.
name
==
NULL
)
args
.
to
.
name
=
(
char
*
)
dest
;
memset
(
&
res
,
'\0'
,
sizeof
(
res
));
...
...
@@ -1073,24 +1083,24 @@ int nfs_rename(struct dfs_filesystem *fs, const char *src, const char *dest)
return
ret
;
}
int
nfs_getdents
(
struct
dfs_fd
*
file
,
struct
dirent
*
dirp
,
rt_
uint32_t
count
)
int
nfs_getdents
(
struct
dfs_fd
*
file
,
struct
dirent
*
dirp
,
uint32_t
count
)
{
nfs_dir
*
dir
;
rt_uint32_t
index
;
struct
dirent
*
d
;
struct
nfs_filesystem
*
nfs
;
nfs_filesystem
*
nfs
;
char
*
name
;
dir
=
(
nfs_dir
*
)(
file
->
data
);
RT_ASSERT
(
dir
!=
RT_
NULL
);
RT_ASSERT
(
file
->
fs
!=
RT_NULL
);
RT_ASSERT
(
file
->
fs
->
data
!=
RT_NULL
);
nfs
=
(
struct
nfs_filesystem
*
)
file
->
fs
->
data
;
RT_ASSERT
(
file
->
data
!=
NULL
);
nfs
=
(
nfs_filesystem
*
)((
struct
dfs_filesystem
*
)(
file
->
data
)
);
dir
=
(
nfs_dir
*
)(
nfs
->
data
);
RT_ASSERT
(
dir
!=
NULL
)
;
/* make integer count */
count
=
(
count
/
sizeof
(
struct
dirent
))
*
sizeof
(
struct
dirent
);
if
(
count
==
0
)
return
-
DFS_STATUS_
EINVAL
;
return
-
EINVAL
;
index
=
0
;
while
(
1
)
...
...
@@ -1098,10 +1108,10 @@ int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, rt_uint32_t count)
d
=
dirp
+
index
;
name
=
nfs_readdir
(
nfs
,
dir
);
if
(
name
==
RT_
NULL
)
if
(
name
==
NULL
)
break
;
d
->
d_type
=
D
FS_D
T_REG
;
d
->
d_type
=
DT_REG
;
d
->
d_namlen
=
rt_strlen
(
name
);
d
->
d_reclen
=
(
rt_uint16_t
)
sizeof
(
struct
dirent
);
...
...
@@ -1115,22 +1125,28 @@ int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, rt_uint32_t count)
return
index
*
sizeof
(
struct
dirent
);
}
static
const
struct
dfs_file
system_operation
_nfs
=
static
const
struct
dfs_file
_ops
nfs_fops
=
{
"nfs"
,
DFS_FS_FLAG_DEFAULT
,
nfs_mount
,
nfs_unmount
,
RT_NULL
,
/* mkfs */
RT_NULL
,
/* statfs */
nfs_open
,
nfs_close
,
nfs_ioctl
,
nfs_read
,
nfs_write
,
RT_
NULL
,
/* flush */
NULL
,
/* flush */
nfs_lseek
,
nfs_getdents
,
NULL
,
/* poll */
};
static
const
struct
dfs_filesystem_ops
_nfs
=
{
"nfs"
,
DFS_FS_FLAG_DEFAULT
,
&
nfs_fops
,
nfs_mount
,
nfs_unmount
,
NULL
,
/* mkfs */
NULL
,
/* statfs */
nfs_unlink
,
nfs_stat
,
nfs_rename
,
...
...
@@ -1138,7 +1154,7 @@ static const struct dfs_filesystem_operation _nfs =
int
nfs_init
(
void
)
{
/* register
fat
fs file system */
/* register
n
fs file system */
dfs_register
(
&
_nfs
);
return
RT_EOK
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录