From b33b2cd1e16be3b2592693fcd85a9fd998a3fd1c Mon Sep 17 00:00:00 2001 From: patacongo Date: Thu, 3 May 2012 23:32:53 +0000 Subject: NSF update git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4695 42af7a65-404d-4744-a932-0658087f49c3 --- apps/nshlib/nsh_fscmds.c | 48 ++++++++++++++++++++++++++++------------------- nuttx/fs/nfs/nfs_socket.c | 2 +- nuttx/fs/nfs/rpc_clnt.c | 26 ++++++++++++++----------- 3 files changed, 45 insertions(+), 31 deletions(-) diff --git a/apps/nshlib/nsh_fscmds.c b/apps/nshlib/nsh_fscmds.c index a398179c0..92d19e371 100644 --- a/apps/nshlib/nsh_fscmds.c +++ b/apps/nshlib/nsh_fscmds.c @@ -58,6 +58,7 @@ # include # include # include +# include # endif #endif #endif @@ -1224,8 +1225,8 @@ int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) struct nfs_args data; FAR char *address; FAR char *target; - FAR char *protocol = NULL; - struct sockaddr_in sin; + FAR char *protocol; + struct sockaddr_in *sin; bool badarg = false; #ifdef CONFIG_NET_IPv6 struct in6_addr inaddr; @@ -1337,26 +1338,35 @@ int cmd_nfsmount(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ERROR; } + /* Create an instance of the sockaddr_in state structure */ + + sin = (struct sockaddr_in *)kzalloc(sizeof(struct sockaddr_in)); + if (!sin) + { + nsh_output(vtbl, g_fmtcmdoutofmemory, argv[0]); + return -ENOMEM; + } + /* Place all of the NFS arguements into the nfs_args structure */ memset(&data, 0, sizeof(data)); - data.version = NFS_ARGSVERSION; - data.proto = (tcp) ? IPPROTO_TCP : IPPROTO_UDP; - data.sotype = (tcp) ? SOCK_STREAM : SOCK_DGRAM; - sin.sin_family = AF_INET; - sin.sin_port = htons(NFS_PORT); - sin.sin_addr = inaddr; - data.addr = (struct sockaddr *)&sin; - data.addrlen = sizeof(struct sockaddr); - data.flags = NFSMNT_NFSV3; - data.retrans = 3; - data.acregmin = 3; - data.acregmax = 60; - data.acdirmin = 30; - data.acdirmax = 60; - data.rsize = 0; - data.wsize = 0; - data.timeo = (tcp) ? 70 : 7; + data.version = NFS_ARGSVERSION; + data.proto = (tcp) ? IPPROTO_TCP : IPPROTO_UDP; + data.sotype = (tcp) ? SOCK_STREAM : SOCK_DGRAM; + sin->sin_family = AF_INET; + sin->sin_port = htons(NFS_PORT); + sin->sin_addr = inaddr; + data.addr = (struct sockaddr *)sin; + data.addrlen = sizeof(struct sockaddr); + data.flags = NFSMNT_NFSV3; + data.retrans = 3; + data.acregmin = 3; + data.acregmax = 60; + data.acdirmin = 30; + data.acdirmax = 60; + data.rsize = 0; + data.wsize = 0; + data.timeo = (tcp) ? 70 : 7; /* Perform the mount */ diff --git a/nuttx/fs/nfs/nfs_socket.c b/nuttx/fs/nfs/nfs_socket.c index d0f4e36b2..0dc8860a0 100644 --- a/nuttx/fs/nfs/nfs_socket.c +++ b/nuttx/fs/nfs/nfs_socket.c @@ -203,7 +203,7 @@ tryagain: goto out; } - dataout = reply->stat.where; + dataout = &reply->stat.where; if (reply->rpc_verfi.authtype != 0) { diff --git a/nuttx/fs/nfs/rpc_clnt.c b/nuttx/fs/nfs/rpc_clnt.c index 2515c1707..a7e7f5a1c 100644 --- a/nuttx/fs/nfs/rpc_clnt.c +++ b/nuttx/fs/nfs/rpc_clnt.c @@ -244,7 +244,7 @@ rpcclnt_send(struct socket *so, struct sockaddr *nam, struct rpc_call *call, struct rpctask *rep) { struct sockaddr *sendnam; - int error; + int error = 0; #ifdef CONFIG_NFS_TCPIP int soflags; #endif @@ -346,7 +346,7 @@ static int rpcclnt_receive(struct rpctask *rep, struct sockaddr *aname, uint32_t len; int sotype; #endif - int error; + int error = 0; int rcvflg; #ifdef CONFIG_NFS_TCPIP @@ -623,6 +623,8 @@ rpcclnt_reply(struct rpctask *myrep, struct rpc_call *call, /* Get the xid and check that it is an rpc reply */ rxid = reply->rp_xid; + + /* if (reply->rp_direction != rpc_reply) { rpcstats.rpcinvalid++; @@ -633,12 +635,13 @@ rpcclnt_reply(struct rpctask *myrep, struct rpc_call *call, continue; } + */ /* Loop through the request list to match up the reply Iff no * match, just drop the datagram */ - for (rep = (struct rpctask *)&rpctask_q.head; rep; + for (rep = (struct rpctask *)rpctask_q.head; rep != NULL; rep = (struct rpctask *)rep->r_chain.flink) { if (rxid == rep->r_xid) @@ -731,8 +734,6 @@ rpcclnt_sigintr( struct rpcclnt *rpc, struct rpctask *task, cthread_t *td) return 0; } - /* XXX deal with forced unmounts */ - if (task && ISSET(task->r_flags, TASK_SOFTTERM)) { RPC_RETURN(EINTR); @@ -1082,7 +1083,7 @@ int rpcclnt_reconnect(struct rpctask *rep) * requests on old socket. */ - for (rp = (struct rpctask *)&rpctask_q->head; rp != NULL; + for (rp = (struct rpctask *)rpctask_q->head; rp != NULL; rp = (struct rpctask *)rp->r_chain.blink) { if (rp->r_rpcclnt == rpc) @@ -1209,7 +1210,7 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, struct rpc_reply *reply, v * LAST so timer finds oldest requests first. */ - dq_addlast(&task->r_chain, &rpctask_q); + dq_addlast((struct dq_entry_t *)task, &rpctask_q); /* If backing off another request or avoiding congestion, don't send * this one now but let timer do it. If not timing a request, do it @@ -1259,7 +1260,7 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, struct rpc_reply *reply, v /* RPC done, unlink the request. */ - dq_rem(&task->r_chain, &rpctask_q); + dq_rem((struct dq_entry_t *)task, &rpctask_q); /* Decrement the outstanding request count. */ @@ -1354,7 +1355,7 @@ void rpcclnt_timer(void *arg, struct rpc_call *call) struct rpcclnt *rpc; int timeo, error; - for (rep = (struct rpctask *)&rpctask_q.head; rep; + for (rep = (struct rpctask *)rpctask_q.head; rep != NULL; rep = (struct rpctask *)rep->r_chain.flink) { rpc = rep->r_rpcclnt; @@ -1483,7 +1484,9 @@ void rpcclnt_timer(void *arg, struct rpc_call *call) int rpcclnt_buildheader(struct rpcclnt *rpc, int procid, int xidp, void *datain, struct rpc_call *call) { +#ifdef CONFIG_NFS_UNIX_AUTH struct timeval tv; +#endif srand(time(NULL)); /* The RPC header.*/ @@ -1519,15 +1522,16 @@ int rpcclnt_buildheader(struct rpcclnt *rpc, int procid, call->rpc_auth.authtype = rpc_auth_null; call->rpc_auth.authlen = txdr_unsigned(sizeof(NULL)); +#ifdef CONFIG_NFS_UNIX_AUTH tv.tv_sec = 1; tv.tv_usec = 0; -#ifdef CONFIG_NFS_UNIX_AUTH call->rpc_unix.ua_time = txdr_unsigned(&tv->tv_sec); call->rpc_unix.ua_hostname = 0; call->rpc_unix.ua_uid = geteuid(); call->rpc_unix.ua_gid = getegid(); call->rpc_unix.ua_gidlist = 0; #endif + /* rpc_verf part (auth_null) */ call->rpc_verf.authtype = 0; @@ -1541,7 +1545,7 @@ int rpcclnt_cancelreqs(struct rpcclnt *rpc) struct rpctask *task; int i; - for (task = (struct rpctask *)&rpctask_q.head; task; + for (task = (struct rpctask *)rpctask_q.head; task; task = (struct rpctask *)task->r_chain.flink) { if (rpc != task->r_rpcclnt || (task->r_flags & TASK_SOFTTERM)) -- cgit v1.2.3