未验证 提交 3ea1ce9e 编写于 作者: G geniusgogo 提交者: GitHub

Fix nfs (#7194)

* fixed nfs 64bit arch fault

* change mount cmd support nfs.
上级 e45d9c4a
...@@ -562,8 +562,8 @@ int nfs_read(struct dfs_fd *file, void *buf, size_t count) ...@@ -562,8 +562,8 @@ int nfs_read(struct dfs_fd *file, void *buf, size_t count)
if (file->vnode->type == FT_DIRECTORY) if (file->vnode->type == FT_DIRECTORY)
return -EISDIR; return -EISDIR;
RT_ASSERT(file->vnode->data != NULL); RT_ASSERT(file->vnode->fs != NULL);
struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->data)); struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->fs));
nfs = (struct nfs_filesystem *)(dfs_nfs->data); nfs = (struct nfs_filesystem *)(dfs_nfs->data);
fd = (nfs_file *)(nfs->data); fd = (nfs_file *)(nfs->data);
RT_ASSERT(fd != NULL); RT_ASSERT(fd != NULL);
...@@ -631,8 +631,8 @@ int nfs_write(struct dfs_fd *file, const void *buf, size_t count) ...@@ -631,8 +631,8 @@ int nfs_write(struct dfs_fd *file, const void *buf, size_t count)
if (file->vnode->type == FT_DIRECTORY) if (file->vnode->type == FT_DIRECTORY)
return -EISDIR; return -EISDIR;
RT_ASSERT(file->vnode->data != NULL); RT_ASSERT(file->vnode->fs != NULL);
struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->data)); struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->fs));
nfs = (struct nfs_filesystem *)(dfs_nfs->data); nfs = (struct nfs_filesystem *)(dfs_nfs->data);
fd = (nfs_file *)(nfs->data); fd = (nfs_file *)(nfs->data);
RT_ASSERT(fd != NULL); RT_ASSERT(fd != NULL);
...@@ -693,8 +693,8 @@ int nfs_lseek(struct dfs_fd *file, off_t offset) ...@@ -693,8 +693,8 @@ int nfs_lseek(struct dfs_fd *file, off_t offset)
if (file->vnode->type == FT_DIRECTORY) if (file->vnode->type == FT_DIRECTORY)
return -EISDIR; return -EISDIR;
RT_ASSERT(file->vnode->data != NULL); RT_ASSERT(file->vnode->fs != NULL);
struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->data)); struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->fs));
nfs = (struct nfs_filesystem *)(dfs_nfs->data); nfs = (struct nfs_filesystem *)(dfs_nfs->data);
fd = (nfs_file *)(nfs->data); fd = (nfs_file *)(nfs->data);
RT_ASSERT(fd != NULL); RT_ASSERT(fd != NULL);
...@@ -712,8 +712,8 @@ int nfs_lseek(struct dfs_fd *file, off_t offset) ...@@ -712,8 +712,8 @@ int nfs_lseek(struct dfs_fd *file, off_t offset)
int nfs_close(struct dfs_fd *file) int nfs_close(struct dfs_fd *file)
{ {
nfs_filesystem *nfs; nfs_filesystem *nfs;
RT_ASSERT(file->vnode->data != NULL); RT_ASSERT(file->vnode->fs != NULL);
struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->data)); struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->fs));
RT_ASSERT(file->vnode->ref_count > 0); RT_ASSERT(file->vnode->ref_count > 0);
if (file->vnode->ref_count > 1) if (file->vnode->ref_count > 1)
...@@ -749,7 +749,7 @@ int nfs_close(struct dfs_fd *file) ...@@ -749,7 +749,7 @@ int nfs_close(struct dfs_fd *file)
int nfs_open(struct dfs_fd *file) int nfs_open(struct dfs_fd *file)
{ {
nfs_filesystem *nfs; nfs_filesystem *nfs;
RT_ASSERT(file->vnode->data != NULL); RT_ASSERT(file->vnode->fs != NULL);
struct dfs_filesystem *dfs_nfs = file->vnode->fs; struct dfs_filesystem *dfs_nfs = file->vnode->fs;
nfs = (struct nfs_filesystem *)(dfs_nfs->data); nfs = (struct nfs_filesystem *)(dfs_nfs->data);
RT_ASSERT(nfs != NULL); RT_ASSERT(nfs != NULL);
...@@ -1111,8 +1111,8 @@ int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count) ...@@ -1111,8 +1111,8 @@ int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
nfs_filesystem *nfs; nfs_filesystem *nfs;
char *name; char *name;
RT_ASSERT(file->vnode->data != NULL); RT_ASSERT(file->vnode->fs != NULL);
struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->data)); struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->fs));
nfs = (struct nfs_filesystem *)(dfs_nfs->data); nfs = (struct nfs_filesystem *)(dfs_nfs->data);
dir = (nfs_dir *)(nfs->data); dir = (nfs_dir *)(nfs->data);
RT_ASSERT(dir != NULL); RT_ASSERT(dir != NULL);
......
...@@ -150,6 +150,7 @@ CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr, ...@@ -150,6 +150,7 @@ CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr,
if ((port = if ((port =
pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) { pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) {
rt_kprintf("pmap_getport failure\n");
goto fooy; goto fooy;
} }
raddr->sin_port = htons(port); raddr->sin_port = htons(port);
...@@ -164,7 +165,7 @@ CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr, ...@@ -164,7 +165,7 @@ CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr,
cu->cu_total.tv_usec = -1; cu->cu_total.tv_usec = -1;
cu->cu_sendsz = sendsz; cu->cu_sendsz = sendsz;
cu->cu_recvsz = recvsz; cu->cu_recvsz = recvsz;
call_msg.rm_xid = ((unsigned long)rt_thread_self()) ^ ((unsigned long)rt_tick_get()) ^ (xid_count++); call_msg.rm_xid = (uint32_t)(((unsigned long)rt_thread_self()) ^ ((unsigned long)rt_tick_get()) ^ (xid_count++));
call_msg.rm_direction = CALL; call_msg.rm_direction = CALL;
call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
call_msg.rm_call.cb_prog = program; call_msg.rm_call.cb_prog = program;
...@@ -172,6 +173,7 @@ CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr, ...@@ -172,6 +173,7 @@ CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr,
xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE); xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE);
if (!xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) if (!xdr_callhdr(&(cu->cu_outxdrs), &call_msg))
{ {
rt_kprintf("xdr_callhdr failure\n");
goto fooy; goto fooy;
} }
cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs)); cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs));
......
...@@ -57,9 +57,6 @@ typedef unsigned long u_long; ...@@ -57,9 +57,6 @@ typedef unsigned long u_long;
#include <stdint.h> #include <stdint.h>
#endif #endif
typedef long long int64_t;
typedef unsigned long long uint64_t;
typedef int bool_t; typedef int bool_t;
typedef int enum_t; typedef int enum_t;
...@@ -67,9 +64,6 @@ typedef int enum_t; ...@@ -67,9 +64,6 @@ typedef int enum_t;
typedef unsigned long dev_t; typedef unsigned long dev_t;
#endif #endif
#if !defined(RT_USING_NEWLIB) && !defined(RT_USING_MINILIBC) && !defined(RT_USING_MUSL)
typedef rt_int32_t ssize_t;
#endif
/* This needs to be changed to uint32_t in the future */ /* This needs to be changed to uint32_t in the future */
typedef unsigned long rpcprog_t; typedef unsigned long rpcprog_t;
......
...@@ -196,7 +196,7 @@ bool_t xdr_u_long(XDR* xdrs, unsigned long* ulp) ...@@ -196,7 +196,7 @@ bool_t xdr_u_long(XDR* xdrs, unsigned long* ulp)
/* /*
* XDR long long integers * XDR long long integers
*/ */
bool_t xdr_longlong_t (XDR * xdrs, long long* llp) bool_t xdr_longlong_t (XDR * xdrs, int64_t* llp)
{ {
int32_t t1, t2; int32_t t1, t2;
...@@ -223,7 +223,7 @@ bool_t xdr_longlong_t (XDR * xdrs, long long* llp) ...@@ -223,7 +223,7 @@ bool_t xdr_longlong_t (XDR * xdrs, long long* llp)
/* /*
* XDR unsigned long long integers * XDR unsigned long long integers
*/ */
bool_t xdr_u_longlong_t (XDR * xdrs, unsigned long long* ullp) bool_t xdr_u_longlong_t (XDR * xdrs, uint64_t* ullp)
{ {
uint32_t t1, t2; uint32_t t1, t2;
...@@ -363,10 +363,20 @@ bool_t xdr_bool(XDR *xdrs, bool_t *bp) ...@@ -363,10 +363,20 @@ bool_t xdr_bool(XDR *xdrs, bool_t *bp)
*/ */
bool_t xdr_enum(XDR *xdrs, enum_t *ep) bool_t xdr_enum(XDR *xdrs, enum_t *ep)
{ {
enum sizecheck { SIZEVAL }; /* used to find the size of an enum */
/* /*
* enums are treated as ints * enums are treated as ints
*/ */
return (xdr_long(xdrs, (long *) ep)); /* LINTED */ if (sizeof (enum sizecheck) == sizeof (long)) {
return (xdr_long(xdrs, (long *)(void *)ep));
} else /* LINTED */ if (sizeof (enum sizecheck) == sizeof (int)) {
return (xdr_int(xdrs, (int *)(void *)ep));
} else /* LINTED */ if (sizeof (enum sizecheck) == sizeof (short)) {
return (xdr_short(xdrs, (short *)(void *)ep));
} else {
return (FALSE);
}
} }
/* /*
......
...@@ -562,8 +562,8 @@ int nfs_read(struct dfs_fd *file, void *buf, size_t count) ...@@ -562,8 +562,8 @@ int nfs_read(struct dfs_fd *file, void *buf, size_t count)
if (file->vnode->type == FT_DIRECTORY) if (file->vnode->type == FT_DIRECTORY)
return -EISDIR; return -EISDIR;
RT_ASSERT(file->vnode->data != NULL); RT_ASSERT(file->vnode->fs != NULL);
struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->data)); struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->fs));
nfs = (struct nfs_filesystem *)(dfs_nfs->data); nfs = (struct nfs_filesystem *)(dfs_nfs->data);
fd = (nfs_file *)(nfs->data); fd = (nfs_file *)(nfs->data);
RT_ASSERT(fd != NULL); RT_ASSERT(fd != NULL);
...@@ -631,8 +631,8 @@ int nfs_write(struct dfs_fd *file, const void *buf, size_t count) ...@@ -631,8 +631,8 @@ int nfs_write(struct dfs_fd *file, const void *buf, size_t count)
if (file->vnode->type == FT_DIRECTORY) if (file->vnode->type == FT_DIRECTORY)
return -EISDIR; return -EISDIR;
RT_ASSERT(file->vnode->data != NULL); RT_ASSERT(file->vnode->fs != NULL);
struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->data)); struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->fs));
nfs = (struct nfs_filesystem *)(dfs_nfs->data); nfs = (struct nfs_filesystem *)(dfs_nfs->data);
fd = (nfs_file *)(nfs->data); fd = (nfs_file *)(nfs->data);
RT_ASSERT(fd != NULL); RT_ASSERT(fd != NULL);
...@@ -693,8 +693,8 @@ int nfs_lseek(struct dfs_fd *file, off_t offset) ...@@ -693,8 +693,8 @@ int nfs_lseek(struct dfs_fd *file, off_t offset)
if (file->vnode->type == FT_DIRECTORY) if (file->vnode->type == FT_DIRECTORY)
return -EISDIR; return -EISDIR;
RT_ASSERT(file->vnode->data != NULL); RT_ASSERT(file->vnode->fs != NULL);
struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->data)); struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->fs));
nfs = (struct nfs_filesystem *)(dfs_nfs->data); nfs = (struct nfs_filesystem *)(dfs_nfs->data);
fd = (nfs_file *)(nfs->data); fd = (nfs_file *)(nfs->data);
RT_ASSERT(fd != NULL); RT_ASSERT(fd != NULL);
...@@ -712,8 +712,8 @@ int nfs_lseek(struct dfs_fd *file, off_t offset) ...@@ -712,8 +712,8 @@ int nfs_lseek(struct dfs_fd *file, off_t offset)
int nfs_close(struct dfs_fd *file) int nfs_close(struct dfs_fd *file)
{ {
nfs_filesystem *nfs; nfs_filesystem *nfs;
RT_ASSERT(file->vnode->data != NULL); RT_ASSERT(file->vnode->fs != NULL);
struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->data)); struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->fs));
RT_ASSERT(file->vnode->ref_count > 0); RT_ASSERT(file->vnode->ref_count > 0);
if (file->vnode->ref_count > 1) if (file->vnode->ref_count > 1)
...@@ -749,7 +749,7 @@ int nfs_close(struct dfs_fd *file) ...@@ -749,7 +749,7 @@ int nfs_close(struct dfs_fd *file)
int nfs_open(struct dfs_fd *file) int nfs_open(struct dfs_fd *file)
{ {
nfs_filesystem *nfs; nfs_filesystem *nfs;
RT_ASSERT(file->vnode->data != NULL); RT_ASSERT(file->vnode->fs != NULL);
struct dfs_filesystem *dfs_nfs = file->vnode->fs; struct dfs_filesystem *dfs_nfs = file->vnode->fs;
nfs = (struct nfs_filesystem *)(dfs_nfs->data); nfs = (struct nfs_filesystem *)(dfs_nfs->data);
RT_ASSERT(nfs != NULL); RT_ASSERT(nfs != NULL);
...@@ -1111,8 +1111,8 @@ int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count) ...@@ -1111,8 +1111,8 @@ int nfs_getdents(struct dfs_fd *file, struct dirent *dirp, uint32_t count)
nfs_filesystem *nfs; nfs_filesystem *nfs;
char *name; char *name;
RT_ASSERT(file->vnode->data != NULL); RT_ASSERT(file->vnode->fs != NULL);
struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->data)); struct dfs_filesystem *dfs_nfs = ((struct dfs_filesystem *)(file->vnode->fs));
nfs = (struct nfs_filesystem *)(dfs_nfs->data); nfs = (struct nfs_filesystem *)(dfs_nfs->data);
dir = (nfs_dir *)(nfs->data); dir = (nfs_dir *)(nfs->data);
RT_ASSERT(dir != NULL); RT_ASSERT(dir != NULL);
......
...@@ -150,6 +150,7 @@ CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr, ...@@ -150,6 +150,7 @@ CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr,
if ((port = if ((port =
pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) { pmap_getport(raddr, program, version, IPPROTO_UDP)) == 0) {
rt_kprintf("pmap_getport failure\n");
goto fooy; goto fooy;
} }
raddr->sin_port = htons(port); raddr->sin_port = htons(port);
...@@ -164,7 +165,7 @@ CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr, ...@@ -164,7 +165,7 @@ CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr,
cu->cu_total.tv_usec = -1; cu->cu_total.tv_usec = -1;
cu->cu_sendsz = sendsz; cu->cu_sendsz = sendsz;
cu->cu_recvsz = recvsz; cu->cu_recvsz = recvsz;
call_msg.rm_xid = ((unsigned long)rt_thread_self()) ^ ((unsigned long)rt_tick_get()) ^ (xid_count++); call_msg.rm_xid = (uint32_t)(((unsigned long)rt_thread_self()) ^ ((unsigned long)rt_tick_get()) ^ (xid_count++));
call_msg.rm_direction = CALL; call_msg.rm_direction = CALL;
call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION; call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
call_msg.rm_call.cb_prog = program; call_msg.rm_call.cb_prog = program;
...@@ -172,6 +173,7 @@ CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr, ...@@ -172,6 +173,7 @@ CLIENT *clntudp_bufcreate(struct sockaddr_in *raddr,
xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE); xdrmem_create(&(cu->cu_outxdrs), cu->cu_outbuf, sendsz, XDR_ENCODE);
if (!xdr_callhdr(&(cu->cu_outxdrs), &call_msg)) if (!xdr_callhdr(&(cu->cu_outxdrs), &call_msg))
{ {
rt_kprintf("xdr_callhdr failure\n");
goto fooy; goto fooy;
} }
cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs)); cu->cu_xdrpos = XDR_GETPOS(&(cu->cu_outxdrs));
......
...@@ -57,9 +57,6 @@ typedef unsigned long u_long; ...@@ -57,9 +57,6 @@ typedef unsigned long u_long;
#include <stdint.h> #include <stdint.h>
#endif #endif
typedef long long int64_t;
typedef unsigned long long uint64_t;
typedef int bool_t; typedef int bool_t;
typedef int enum_t; typedef int enum_t;
...@@ -67,9 +64,6 @@ typedef int enum_t; ...@@ -67,9 +64,6 @@ typedef int enum_t;
typedef unsigned long dev_t; typedef unsigned long dev_t;
#endif #endif
#if !defined(RT_USING_NEWLIB) && !defined(RT_USING_MINILIBC) && !defined(RT_USING_MUSL)
typedef rt_int32_t ssize_t;
#endif
/* This needs to be changed to uint32_t in the future */ /* This needs to be changed to uint32_t in the future */
typedef unsigned long rpcprog_t; typedef unsigned long rpcprog_t;
......
...@@ -196,7 +196,7 @@ bool_t xdr_u_long(XDR* xdrs, unsigned long* ulp) ...@@ -196,7 +196,7 @@ bool_t xdr_u_long(XDR* xdrs, unsigned long* ulp)
/* /*
* XDR long long integers * XDR long long integers
*/ */
bool_t xdr_longlong_t (XDR * xdrs, long long* llp) bool_t xdr_longlong_t (XDR * xdrs, int64_t* llp)
{ {
int32_t t1, t2; int32_t t1, t2;
...@@ -223,7 +223,7 @@ bool_t xdr_longlong_t (XDR * xdrs, long long* llp) ...@@ -223,7 +223,7 @@ bool_t xdr_longlong_t (XDR * xdrs, long long* llp)
/* /*
* XDR unsigned long long integers * XDR unsigned long long integers
*/ */
bool_t xdr_u_longlong_t (XDR * xdrs, unsigned long long* ullp) bool_t xdr_u_longlong_t (XDR * xdrs, uint64_t* ullp)
{ {
uint32_t t1, t2; uint32_t t1, t2;
...@@ -363,10 +363,20 @@ bool_t xdr_bool(XDR *xdrs, bool_t *bp) ...@@ -363,10 +363,20 @@ bool_t xdr_bool(XDR *xdrs, bool_t *bp)
*/ */
bool_t xdr_enum(XDR *xdrs, enum_t *ep) bool_t xdr_enum(XDR *xdrs, enum_t *ep)
{ {
enum sizecheck { SIZEVAL }; /* used to find the size of an enum */
/* /*
* enums are treated as ints * enums are treated as ints
*/ */
return (xdr_long(xdrs, (long *) ep)); /* LINTED */ if (sizeof (enum sizecheck) == sizeof (long)) {
return (xdr_long(xdrs, (long *)(void *)ep));
} else /* LINTED */ if (sizeof (enum sizecheck) == sizeof (int)) {
return (xdr_int(xdrs, (int *)(void *)ep));
} else /* LINTED */ if (sizeof (enum sizecheck) == sizeof (short)) {
return (xdr_short(xdrs, (short *)(void *)ep));
} else {
return (FALSE);
}
} }
/* /*
......
...@@ -104,7 +104,7 @@ int msh_exec_script(const char *cmd_line, int size) ...@@ -104,7 +104,7 @@ int msh_exec_script(const char *cmd_line, int size)
int length; int length;
line_buf = (char *) rt_malloc(RT_CONSOLEBUF_SIZE); line_buf = (char *) rt_malloc(RT_CONSOLEBUF_SIZE);
if (line_buf == RT_NULL) if (line_buf == RT_NULL)
{ {
close(fd); close(fd);
return -RT_ENOMEM; return -RT_ENOMEM;
...@@ -514,10 +514,17 @@ static int cmd_mount(int argc, char **argv) ...@@ -514,10 +514,17 @@ static int cmd_mount(int argc, char **argv)
char *device = argv[1]; char *device = argv[1];
char *path = argv[2]; char *path = argv[2];
char *fstype = argv[3]; char *fstype = argv[3];
char *data = 0;
/* mount a filesystem to the specified directory */ /* mount a filesystem to the specified directory */
rt_kprintf("mount device %s(%s) onto %s ... ", device, fstype, path); rt_kprintf("mount device %s(%s) onto %s ... ", device, fstype, path);
if (dfs_mount(device, path, fstype, 0, 0) == 0) if (strcmp(fstype, "nfs") == 0)
{
data = argv[1];
device = 0;
}
if (dfs_mount(device, path, fstype, 0, data) == 0)
{ {
rt_kprintf("succeed!\n"); rt_kprintf("succeed!\n");
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册