NFS update

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4829 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo
2012-06-11 21:16:35 +00:00
parent 48de4a98fc
commit 8eeb48d78c
7 changed files with 423 additions and 361 deletions
+1 -1
View File
@@ -88,7 +88,7 @@ struct nfsmount
uint32_t nm_sent; /* Request send count */
uint32_t nm_cwnd; /* Request send window */
uint32_t nm_timeouts; /* Request timeouts */
uint32_t nm_deadthresh; /* Threshold of timeouts-->dead server */
//uint32_t nm_deadthresh; /* Threshold of timeouts-->dead server */
uint32_t nm_rsize; /* Max size of read rpc */
uint32_t nm_wsize; /* Max size of write rpc */
uint32_t nm_readdirsize; /* Size of a readdir rpc */
+5 -5
View File
@@ -334,7 +334,6 @@ struct nfsfh
typedef struct nfsfh nfsfh_t;
#define SIZEOF_nfsfh_t(n) (n)
struct nfsv3_time
{
uint32_t nfsv3_sec;
@@ -590,14 +589,15 @@ struct RENAME3resok
struct MKDIR3args
{
struct diropargs3 where;
struct nfsv3_sattr attributes;
struct nfsv3_sattr how;
};
struct MKDIR3resok
{
struct file_handle fhandle;
uint32_t obj_attributesfalse;
struct nfs_fattr obj_attributes;
uint32_t handle_follows; /* True, handle follows */
struct file_handle fhandle; /* Variable length */
uint32_t attributes_follows; /* True, attributes follows */
struct nfs_fattr attributes; /* Directory attributes */
struct wcc_data dir_wcc;
};
+35 -22
View File
@@ -141,28 +141,24 @@ int nfs_connect(struct nfsmount *nmp)
nfsmnt_to_rpcclnt(nmp->nm_flag, rpc->rc_flag, NOCONN);
nfsmnt_to_rpcclnt(nmp->nm_flag, rpc->rc_flag, DUMBTIMR);
//rpc->rc_flag |= RPCCLNT_REDIRECT; /* Make this a mount option. */
rpc->rc_authtype = RPCAUTH_NULL; /* for now */
rpc->rc_path = nmp->nm_path;
rpc->rc_name = &nmp->nm_nam;
//rpc->rc_authtype = RPCAUTH_NULL; /* for now */
rpc->rc_path = nmp->nm_path;
rpc->rc_name = &nmp->nm_nam;
//rpc->rc_fh = nmp->nm_fh;
rpc->rc_sotype = nmp->nm_sotype;
rpc->rc_soproto = nmp->nm_soproto;
rpc->rc_rsize = (nmp->nm_rsize > nmp->nm_readdirsize) ?
nmp->nm_rsize : nmp->nm_readdirsize;
rpc->rc_wsize = nmp->nm_wsize;
rpc->rc_sotype = nmp->nm_sotype;
rpc->rc_soproto = nmp->nm_soproto;
rpc->rc_rsize = (nmp->nm_rsize > nmp->nm_readdirsize) ? nmp->nm_rsize : nmp->nm_readdirsize;
rpc->rc_wsize = nmp->nm_wsize;
//rpc->rc_deadthresh = nmp->nm_deadthresh;
rpc->rc_timeo = nmp->nm_timeo;
rpc->rc_retry = nmp->nm_retry;
rpc->rc_timeo = nmp->nm_timeo;
rpc->rc_retry = nmp->nm_retry;
/* v3 need to use this */
/* v3 needs to use this */
rpc->rc_proctlen = 0;
rpc->rc_proct = NULL;
rpc->rc_proctlen = 0;
rpc->rc_proct = NULL;
nmp->nm_rpcclnt = rpc;
nmp->nm_rpcclnt = rpc;
return rpcclnt_connect(rpc);
}
@@ -185,14 +181,14 @@ int nfs_request(struct nfsmount *nmp, int procnum,
FAR const void *request, size_t reqlen,
FAR void *response, size_t resplen)
{
struct rpcclnt *clnt= nmp->nm_rpcclnt;
struct rpc_reply_header replyh;
struct rpcclnt *clnt = nmp->nm_rpcclnt;
struct nfs_reply_header replyh;
int trylater_delay;
int error;
tryagain:
memset(&replyh, 0, sizeof(struct rpc_reply_header));
memset(&replyh, 0, sizeof(struct nfs_reply_header));
error = rpcclnt_request(clnt, procnum, nmp->nm_rpcclnt->rc_prog->prog_id,
nmp->nm_rpcclnt->rc_prog->prog_version, request, reqlen,
@@ -203,7 +199,23 @@ tryagain:
goto out;
}
memcpy(&replyh, response, sizeof(struct rpc_reply_header));
memcpy(&replyh, response, sizeof(struct nfs_reply_header));
if (replyh.nfs_status != 0)
{
if (fxdr_unsigned(uint32_t, replyh.nfs_status) > 32)
{
error = EOPNOTSUPP;
}
else
{
/* NFS_ERRORS are the same as NuttX errno values */
error = fxdr_unsigned(uint32_t, replyh.nfs_status);
}
goto out;
}
if (replyh.rpc_verfi.authtype != 0)
{
@@ -239,7 +251,8 @@ tryagain:
goto out;
}
return 0;
fvdbg("NFS_SUCCESS\n");
return OK;
out:
return error;
+3 -3
View File
@@ -380,7 +380,7 @@ int nfs_lookup(struct nfsmount *nmp, FAR const char *filename,
value = *ptr++;
value = fxdr_unsigned(uint32_t, value);
if (value > NFSX_V2FH)
if (value > NFSX_V3FHMAX)
{
fdbg("ERROR: Bad file handle length: %d\n", value);
return EIO;
@@ -444,7 +444,7 @@ int nfs_findnode(struct nfsmount *nmp, FAR const char *relpath,
/* Start with the file handle of the root directory. */
fhandle->length = nmp->nm_fhsize;
memcpy(&fhandle->handle, &nmp->nm_fh, sizeof(nfsfh_t));
memcpy(&fhandle->handle, &nmp->nm_fh, nmp->nm_fhsize);
/* If no path was provided, then the root directory must be exactly what
* the caller is looking for.
@@ -560,7 +560,7 @@ int nfs_finddir(struct nfsmount *nmp, FAR const char *relpath,
/* Start with the file handle of the root directory. */
fhandle->length = nmp->nm_fhsize;
memcpy(&fhandle->handle, &nmp->nm_fh, sizeof(nfsfh_t));
memcpy(&fhandle->handle, &nmp->nm_fh, nmp->nm_fhsize);
memcpy(attributes, &nmp->nm_fattr, sizeof(struct nfs_fattr));
/* Loop until the directory entry containing the path is found. */
+340 -289
View File
File diff suppressed because it is too large Load Diff
+16 -10
View File
@@ -281,7 +281,7 @@ enum auth_flavor
struct rpc_auth_info
{
enum auth_flavor authtype; /* auth type */
uint32_t authtype; /* auth type */
uint32_t authlen; /* auth length */
};
@@ -394,6 +394,16 @@ struct rpc_reply_header
uint32_t status;
};
struct nfs_reply_header
{
uint32_t rp_xid; /* Request transaction id */
uint32_t rp_direction; /* Call direction (1) */
uint32_t type;
struct rpc_auth_info rpc_verfi;
uint32_t status;
uint32_t nfs_status;
};
struct rpc_reply_pmap
{
struct rpc_reply_header rh;
@@ -538,27 +548,23 @@ struct rpcclnt
int rc_sent; /* Request send count */
int rc_cwnd; /* Request send window */
int rc_timeouts; /* Request timeouts */
int rc_authtype; /* Authenticator type */
//int rc_deadthresh; /* Threshold of timeouts-->dead server*/
/* authentication: */
/* currently can be RPCAUTH_NULL, RPCAUTH_KERBV4, RPCAUTH_UNIX */
/* should be kept in XDR form */
// int rc_authtype; /* Authenticator type */
/* RPCAUTH_UNIX */
#ifdef CONFIG_NFS_UNIX_AUTH
/* RPCAUTH_UNIX*/
struct rpc_auth_info rc_oldauth; /* authentication */
void *rc_auth;
#endif
//void *rc_auth;
struct rpc_program *rc_prog;
//char *rc_servername;
int rc_proctlen; /* if == 0 then rc_proct == NULL */
int *rc_proct;
int rc_proctlen; /* if == 0 then rc_proct == NULL */
int *rc_proct;
};
/****************************************************************************
+23 -31
View File
@@ -1206,15 +1206,18 @@ static int rpcclnt_buildheader(struct rpcclnt *rpc, int procid, int prog, int ve
case NFSPROC_REMOVE:
{
/* Copy the variable, caller-provided data into the call message structure */
/* Copy the variable length, caller-provided data into the call
* message structure.
*/
struct rpc_call_remove *callmsg = (struct rpc_call_remove *)msgbuf;
memcpy(&callmsg->remove, request, *reqlen);
/* Return the full size of the message (including messages headers) */
/* Return the full size of the message (the size of variable data
* plus the size of the messages header).
*/
DEBUGASSERT(*reqlen == sizeof(struct REMOVE3args));
*reqlen = sizeof(struct rpc_call_remove);
*reqlen += sizeof(struct rpc_call_header);
/* Format the message header */
@@ -1244,15 +1247,18 @@ static int rpcclnt_buildheader(struct rpcclnt *rpc, int procid, int prog, int ve
case NFSPROC_MKDIR:
{
/* Copy the variable, caller-provided data into the call message structure */
/* Copy the variable length, caller-provided data into the call
* message structure.
*/
struct rpc_call_mkdir *callmsg = (struct rpc_call_mkdir *)msgbuf;
memcpy(&callmsg->mkdir, request, *reqlen);
/* Return the full size of the message (including messages headers) */
/* Return the full size of the message (the size of variable data
* plus the size of the messages header).
*/
DEBUGASSERT(*reqlen == sizeof(struct MKDIR3args));
*reqlen = sizeof(struct rpc_call_mkdir);
*reqlen += sizeof(struct rpc_call_header);
/* Format the message header */
@@ -1263,15 +1269,18 @@ static int rpcclnt_buildheader(struct rpcclnt *rpc, int procid, int prog, int ve
case NFSPROC_RMDIR:
{
/* Copy the variable, caller-provided data into the call message structure */
/* Copy the variable length, caller-provided data into the call
* message structure.
*/
struct rpc_call_rmdir *callmsg = (struct rpc_call_rmdir *)msgbuf;
memcpy(&callmsg->rmdir, request, *reqlen);
/* Return the full size of the message (including messages headers) */
/* Return the full size of the message (the size of variable data
* plus the size of the messages header).
*/
DEBUGASSERT(*reqlen == sizeof(struct RMDIR3args));
*reqlen = sizeof(struct rpc_call_rmdir);
*reqlen += sizeof(struct rpc_call_header);
/* Format the message header */
@@ -1922,6 +1931,7 @@ int rpcclnt_request(FAR struct rpcclnt *rpc, int procnum, int prog,
memset(&replymgs, 0, sizeof(replymgs));
memcpy(&replyheader, response, sizeof(struct rpc_reply_header));
replymgs.type = fxdr_unsigned(uint32_t, replyheader.type);
if (replymgs.type == RPC_MSGDENIED)
{
@@ -1929,16 +1939,11 @@ int rpcclnt_request(FAR struct rpcclnt *rpc, int procnum, int prog,
switch (replymgs.status)
{
case RPC_MISMATCH:
/*replymgs.stat.mismatch_info.low =
fxdr_unsigned(uint32_t, replyheader.stat.mismatch_info.low);
replymgs.stat.mismatch_info.high =
fxdr_unsigned(uint32_t, replyheader.stat.mismatch_info.high);*/
fdbg("RPC_MSGDENIED: RPC_MISMATCH error\n");
error = EOPNOTSUPP;
break;
case RPC_AUTHERR:
//replymgs.stat.autherr = fxdr_unsigned(uint32_t, replyheader.stat.autherr);
fdbg("RPC_MSGDENIED: RPC_AUTHERR error\n");
error = EACCES;
break;
@@ -1947,6 +1952,7 @@ int rpcclnt_request(FAR struct rpcclnt *rpc, int procnum, int prog,
error = EOPNOTSUPP;
break;
}
goto rpcmout;
}
else if (replymgs.type != RPC_MSGACCEPTED)
@@ -1955,24 +1961,12 @@ int rpcclnt_request(FAR struct rpcclnt *rpc, int procnum, int prog,
goto rpcmout;
}
/* Verifier */
/*replymgs.rpc_verfi.authtype =
fxdr_unsigned(enum auth_flavor, replyheader.rpc_verfi.authtype);
replymgs.rpc_verfi.authlen =
fxdr_unsigned(uint32_t, replyheader.rpc_verfi.authlen);*/
if (replymgs.status == RPC_SUCCESS)
{
fvdbg("RPC_SUCCESS\n");
}
else if (replymgs.status == RPC_PROGMISMATCH)
{
/*replymgs.stat.mismatch_info.low =
fxdr_unsigned(uint32_t, replyheader.stat.mismatch_info.low);
replymgs.stat.mismatch_info.high =
fxdr_unsigned(uint32_t, replyheader.stat.mismatch_info.high);*/
fdbg("RPC_MSGACCEPTED: RPC_PROGMISMATCH error\n");
error = EOPNOTSUPP;
}
@@ -2123,9 +2117,7 @@ void rpcclnt_timer(void *arg, struct rpc_call *call)
// rpcclnt_timer_handle = timeout(rpcclnt_timer, NULL, rpcclnt_ticks);
}
#endif
#ifdef COMP
int rpcclnt_cancelreqs(struct rpcclnt *rpc)
{
struct rpctask *task;