summaryrefslogtreecommitdiff
path: root/nuttx/fs/nfs/rpc_clnt.c
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-06-09 15:55:10 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-06-09 15:55:10 +0000
commit41375ad4a6216e206030e71aca39c54c94e00a57 (patch)
treeb2bcdba62940f6fdedc7ba0ab8e96f6d7622ddec /nuttx/fs/nfs/rpc_clnt.c
parentcd9f8ddacbdfdcfa75938f9fb803a86a4e2bbea4 (diff)
downloadpx4-nuttx-41375ad4a6216e206030e71aca39c54c94e00a57.tar.gz
px4-nuttx-41375ad4a6216e206030e71aca39c54c94e00a57.tar.bz2
px4-nuttx-41375ad4a6216e206030e71aca39c54c94e00a57.zip
NFS update
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4820 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/fs/nfs/rpc_clnt.c')
-rw-r--r--nuttx/fs/nfs/rpc_clnt.c152
1 files changed, 60 insertions, 92 deletions
diff --git a/nuttx/fs/nfs/rpc_clnt.c b/nuttx/fs/nfs/rpc_clnt.c
index 243bbb0f0..a78bc6d78 100644
--- a/nuttx/fs/nfs/rpc_clnt.c
+++ b/nuttx/fs/nfs/rpc_clnt.c
@@ -241,10 +241,12 @@ rpcclnt_send(struct socket *so, struct sockaddr *nam, int procid, int prog,
void *call, struct rpctask *rep)
{
struct sockaddr *sendnam;
+ ssize_t nbytes;
int error = ESRCH;
#ifdef CONFIG_NFS_TCPIP
int soflags;
#endif
+ int length;
int flags;
if (rep != NULL)
@@ -290,34 +292,29 @@ rpcclnt_send(struct socket *so, struct sockaddr *nam, int procid, int prog,
flags = 0;
}
+ /* Get the length of the call messsage */
+
+ error = 0;
if (prog == PMAPPROG)
{
- if (procid == PMAPPROC_GETPORT)
+ if (procid == PMAPPROC_GETPORT || procid == PMAPPROC_UNSET)
{
- struct rpc_call_pmap *callmsg = (struct rpc_call_pmap *)call;
- error = psock_sendto(so, callmsg, sizeof(*callmsg), flags,
- sendnam, sizeof(*sendnam));
+ length = sizeof(struct rpc_call_pmap);
}
- else if (procid == PMAPPROC_UNSET)
+ else
{
- struct rpc_call_pmap *callmsg = (struct rpc_call_pmap *)call;
- error = psock_sendto(so, callmsg, sizeof(*callmsg), flags,
- sendnam, sizeof(*sendnam));
+ error = EINVAL;
}
}
else if (prog == RPCPROG_MNT)
{
- if (procid == RPCMNT_UMOUNT)
+ if (procid == RPCMNT_UMOUNT || procid == RPCMNT_MOUNT)
{
- struct rpc_call_mount *callmsg = (struct rpc_call_mount *)call;
- error = psock_sendto(so, callmsg, sizeof(*callmsg), flags,
- sendnam, sizeof(*sendnam));
+ length = sizeof(struct rpc_call_mount);
}
- else if (procid == RPCMNT_MOUNT)
+ else
{
- struct rpc_call_mount *callmsg = (struct rpc_call_mount *)call;
- error = psock_sendto(so, callmsg, sizeof(*callmsg), flags,
- sendnam, sizeof(*sendnam));
+ error = EINVAL;
}
}
else if (prog == NFS_PROG)
@@ -325,127 +322,98 @@ rpcclnt_send(struct socket *so, struct sockaddr *nam, int procid, int prog,
switch (procid)
{
case NFSPROC_CREATE:
- {
- struct rpc_call_create *callmsg = (struct rpc_call_create *)call;
- error = psock_sendto(so, callmsg, sizeof(*callmsg), flags,
- sendnam, sizeof(*sendnam));
- }
+ length = sizeof(struct rpc_call_create);
break;
case NFSPROC_READ:
- {
- struct rpc_call_read *callmsg = (struct rpc_call_read *)call;
- error = psock_sendto(so, callmsg, sizeof(*callmsg), flags,
- sendnam, sizeof(*sendnam));
- }
+ length = sizeof(struct rpc_call_read);
break;
case NFSPROC_WRITE:
- {
- struct rpc_call_write *callmsg = (struct rpc_call_write *)call;
- error = psock_sendto(so, callmsg, sizeof(*callmsg), flags,
- sendnam, sizeof(*sendnam));
- }
+ length = sizeof(struct rpc_call_write);
break;
case NFSPROC_READDIR:
- {
- struct rpc_call_readdir *callmsg = (struct rpc_call_readdir *)call;
- error = psock_sendto(so, callmsg, sizeof(*callmsg), flags,
- sendnam, sizeof(*sendnam));
- }
+ length = sizeof(struct rpc_call_readdir);
break;
case NFSPROC_FSSTAT:
- {
- struct rpc_call_fs *callmsg = (struct rpc_call_fs *)call;
- error = psock_sendto(so, callmsg, sizeof(*callmsg), flags,
- sendnam, sizeof(*sendnam));
- }
+ length = sizeof(struct rpc_call_fs);
break;
case NFSPROC_GETATTR:
- {
- struct rpc_call_fs *callmsg = (struct rpc_call_fs *)call;
- error = psock_sendto(so, callmsg, sizeof(*callmsg), flags,
- sendnam, sizeof(*sendnam));
- }
+ length = sizeof(struct rpc_call_fs);
break;
case NFSPROC_REMOVE:
- {
- struct rpc_call_remove *callmsg = (struct rpc_call_remove *)call;
- error = psock_sendto(so, callmsg, sizeof(*callmsg), flags,
- sendnam, sizeof(*sendnam));
- }
+ length = sizeof(struct rpc_call_remove);
break;
case NFSPROC_MKDIR:
- {
- struct rpc_call_mkdir *callmsg = (struct rpc_call_mkdir *)call;
- error = psock_sendto(so, callmsg, sizeof(*callmsg), flags,
- sendnam, sizeof(*sendnam));
- }
+ length = sizeof(struct rpc_call_mkdir);
break;
case NFSPROC_RMDIR:
- {
- struct rpc_call_rmdir *callmsg = (struct rpc_call_rmdir *)call;
- error = psock_sendto(so, callmsg, sizeof(*callmsg), flags,
- sendnam, sizeof(*sendnam));
- }
+ length = sizeof(struct rpc_call_rmdir);
break;
case NFSPROC_RENAME:
- {
- struct rpc_call_rename *callmsg = (struct rpc_call_rename *)call;
- error = psock_sendto(so, callmsg, sizeof(*callmsg), flags,
- sendnam, sizeof(*sendnam));
- }
+ length = sizeof(struct rpc_call_rename);
break;
case NFSPROC_FSINFO:
- {
- struct rpc_call_fs *callmsg = (struct rpc_call_fs *)call;
- error = psock_sendto(so, callmsg, sizeof(*callmsg), flags,
- sendnam, sizeof(*sendnam));
- }
+ length = sizeof(struct rpc_call_fs);
break;
default:
+ error = EINVAL;
break;
}
}
+ else
+ {
+ error = EINVAL;
+ }
- if (error < 0)
+ /* Send the call message */
+
+ if (error == 0)
{
- if (rep != NULL)
+ /* On success, psock_sendto returns the number of bytes sent;
+ * On failure, it returns -1 with the specific error in errno.
+ */
+
+ nbytes = psock_sendto(so, call, length, flags,
+ sendnam, sizeof(struct sockaddr));
+ if (nbytes < 0)
{
- fdbg("rpc send error %d for service %s\n", error,
- rep->r_rpcclnt->rc_prog->prog_name);
+ /* psock_sendto failed, Sample the error value (subsequent
+ * calls can change the errno value!
+ */
- /* Deal with errors for the client side. */
+ error = errno;
+ fdbg("ERROR: psock_sendto failed: %d\n", error);
- if (rep->r_flags & TASK_SOFTTERM)
+ if (rep != NULL)
{
- error = EINTR;
- }
- else
- {
- rep->r_flags |= TASK_MUSTRESEND;
+ fdbg("rpc send error %d for service %s\n", error,
+ rep->r_rpcclnt->rc_prog->prog_name);
+
+ /* Deal with errors for the client side. */
+
+ if (rep->r_flags & TASK_SOFTTERM)
+ {
+ error = EINTR;
+ }
+ else
+ {
+ rep->r_flags |= TASK_MUSTRESEND;
+ }
}
}
- else
- {
- fdbg("rpc service send error %d\n", error);
- }
-
- return error;
- }
- else
- {
- return 0;
}
+
+ return error;
}
/* Receive a Sun RPC Request/Reply. For SOCK_DGRAM, the work is all