NFS client update

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4605 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo
2012-04-14 00:27:44 +00:00
parent 8133934480
commit df5c47bfae
8 changed files with 728 additions and 536 deletions
+110 -2
View File
@@ -129,8 +129,7 @@
#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \ #define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
sigmask(SIGHUP)|sigmask(SIGQUIT)) sigmask(SIGHUP)|sigmask(SIGQUIT))
/* /* Socket errors ignored for connectionless sockets??
* Socket errors ignored for connectionless sockets??
* For now, ignore them all * For now, ignore them all
*/ */
@@ -339,6 +338,114 @@ struct nfsrv_descript
uint32_t nd_retxid; /* Reply xid */ uint32_t nd_retxid; /* Reply xid */
}; };
/* NFS procedures args */
struct wcc_attr
{
nfsuint64 size;
nfstime3 mtime;
nfstime3 ctime;
}
struct wcc_data
{
wcc_attr before;
nfs_fattr after;
};
struct diropargs3
{
nfsfh_t dir;
const char name;
};
struct CREATE3args
{
diropargs3 where;
nfsv3_sattr how;
};
struct CREATE3resok
{
const char handle;
nfs_fattr attributes;
wcc_data dir_wcc;
};
struct READ3args
{
nfstype file;
uint64_t offset;
uint32_t count;
};
struct READ3resok
{
nfs_fattr file_attributes;
uint32_t count;
bool eof;
const char data;
};
enum stable_how
{
UNSTABLE = 0,
DATA_SYNC = 1,
FILE_SYNC = 2
};
struct WRITE3args
{
nfstype file;
uint64_t offset;
uint32_t count;
stable_how stable;
const char data;
};
struct WRITE3resok
{
wcc_data file_wcc;
count3 count;
stable_how committed;
unsigned char verf;
};
struct REMOVE3args
{
diropargs3 object;
};
struct REMOVE3resok
{
wcc_data dir_wcc;
};
struct RENAME3args
{
diropargs3 from;
diropargs3 to;
};
struct RENAME3resok
{
wcc_data fromdir_wcc;
wcc_data todir_wcc;
};
struct MKDIR3args
{
diropargs3 where;
nfsv3_sattr attributes;
};
struct MKDIR3resok
{
const char handle;
nfs_fattr obj_attributes;
wcc_data dir_wcc;
};
/**************************************************************************** /****************************************************************************
* Public Data * Public Data
****************************************************************************/ ****************************************************************************/
@@ -352,6 +459,7 @@ extern struct pool nfs_node_pool;
extern TAILQ_HEAD(nfsdhead, nfsd) nfsd_head; extern TAILQ_HEAD(nfsdhead, nfsd) nfsd_head;
extern int nfsd_head_flag; extern int nfsd_head_flag;
*/ */
/**************************************************************************** /****************************************************************************
* Public Function Prototypes * Public Function Prototypes
****************************************************************************/ ****************************************************************************/
+1 -1
View File
@@ -98,7 +98,7 @@ struct nfsmount
int nm_acregmin; /* Reg file attr cache min lifetime */ int nm_acregmin; /* Reg file attr cache min lifetime */
int nm_acregmax; /* Reg file attr cache max lifetime */ int nm_acregmax; /* Reg file attr cache max lifetime */
unsigned char nm_verf[NFSX_V3WRITEVERF]; /* V3 write verifier */ unsigned char nm_verf[NFSX_V3WRITEVERF]; /* V3 write verifier */
char nm_mntonname[90]; /* directory on which mounted */ //char nm_mntonname[90]; /* directory on which mounted */
uint8_t *nm_buffer; /* This is an allocated buffer to hold one sector*/ uint8_t *nm_buffer; /* This is an allocated buffer to hold one sector*/
}; };
-1
View File
@@ -115,7 +115,6 @@ struct nfsnode
bool n_open; /* true: The file is (still) open */ bool n_open; /* true: The file is (still) open */
uint64_t n_size; /* Current size of file */ uint64_t n_size; /* Current size of file */
struct nfs_fattr n_fattr; /* nfs file attribute cache */ struct nfs_fattr n_fattr; /* nfs file attribute cache */
struct nfsv3_sattr n_sattr;
nfstype nfsv3_type; /* File type */ nfstype nfsv3_type; /* File type */
time_t n_attrstamp; /* Attr. cache timestamp */ time_t n_attrstamp; /* Attr. cache timestamp */
struct timespec n_mtime; /* Prev modify time. */ struct timespec n_mtime; /* Prev modify time. */
+30 -15
View File
@@ -61,11 +61,13 @@
/* Flag translations */ /* Flag translations */
#define nfsmnt_to_rpcclnt(nf, rf, name) do { \ #define nfsmnt_to_rpcclnt(nf, rf, name) do \
if (nf & NFSMNT_##name) { \ { \
if (nf & NFSMNT_##name) \
{ \
rf |= RPCCLNT_##name; \ rf |= RPCCLNT_##name; \
} \ } \
} while(0) } while(0)
/**************************************************************************** /****************************************************************************
* Private Variables * Private Variables
@@ -101,15 +103,18 @@ int nfsx_connect(struct nfsmount *nmp)
int error = 0; int error = 0;
if (nmp == NULL) if (nmp == NULL)
{
return EFAULT; return EFAULT;
}
rpc = &nmp->nm_rpcclnt; rpc = &nmp->nm_rpcclnt;
rpc->rc_prog = &nfs3_program; rpc->rc_prog = &nfs3_program;
printf("nfsxconnect!\n"); nvdbg("nfsxconnect!\n");
/* translate nfsmnt flags -> rpcclnt flags */ /* translate nfsmnt flags -> rpcclnt flags */
rpc->rc_flag = 0; rpc->rc_flag = 0;
nfsmnt_to_rpcclnt(nmp->nm_flag, rpc->rc_flag, SOFT); nfsmnt_to_rpcclnt(nmp->nm_flag, rpc->rc_flag, SOFT);
nfsmnt_to_rpcclnt(nmp->nm_flag, rpc->rc_flag, INT); nfsmnt_to_rpcclnt(nmp->nm_flag, rpc->rc_flag, INT);
@@ -132,11 +137,14 @@ int nfsx_connect(struct nfsmount *nmp)
rpc->rc_retry = nmp->nm_retry; rpc->rc_retry = nmp->nm_retry;
/* XXX v2,3 need to use this */ /* XXX v2,3 need to use this */
rpc->rc_proctlen = 0; rpc->rc_proctlen = 0;
rpc->rc_proct = NULL; rpc->rc_proct = NULL;
if (error) if (error)
{
return error; return error;
}
return rpcclnt_connect(rpc); return rpcclnt_connect(rpc);
} }
@@ -155,7 +163,7 @@ void nfsx_safedisconnect(struct nfsmount *nmp)
} }
#endif #endif
int nfsx_request_xx(struct nfsmount *nm, int procnum, void *data) int nfsx_request_xx(struct nfsmount *nm, int procnum,void *datain, void *dataout)
{ {
int error; int error;
struct nfsmount *nmp; struct nfsmount *nmp;
@@ -170,10 +178,12 @@ tryagain:
memset(reply, 0, sizeof(struct rpc_reply)); memset(reply, 0, sizeof(struct rpc_reply));
if ((error = rpcclnt_request(clnt, procnum, reply)) != 0) if ((error = rpcclnt_request(clnt, procnum, reply, datain)) != 0)
{
goto out; goto out;
}
data = reply->stat.where; dataout = reply->stat.where;
if (reply->rpc_verfi.authtype != 0) if (reply->rpc_verfi.authtype != 0)
{ {
@@ -190,22 +200,27 @@ tryagain:
goto tryagain; goto tryagain;
} }
/* /* If the File Handle was stale, invalidate the
** If the File Handle was stale, invalidate the * lookup cache, just in case.
** lookup cache, just in case. */
**/
if (error == ESTALE) if (error == ESTALE)
printf("%s: ESTALE on mount from server \n", {
ndbg("%s: ESTALE on mount from server \n",
nmp->nm_rpcclnt.rc_prog->prog_name); nmp->nm_rpcclnt.rc_prog->prog_name);
}
else else
printf("%s: unknown error %d from server \n", {
ndbg("%s: unknown error %d from server \n",
nmp->nm_rpcclnt.rc_prog->prog_name, error); nmp->nm_rpcclnt.rc_prog->prog_name, error);
}
goto out; goto out;
} }
return (0); return 0;
out: out:
return (error); return error;
} }
/* terminate any outstanding RPCs. */ /* terminate any outstanding RPCs. */
+4 -4
View File
@@ -53,17 +53,17 @@ int nfsx_sigintr(struct nfsmount *, struct nfsreq *, cthread_t *);
void nfsx_safedisconnect(struct nfsmount *); void nfsx_safedisconnect(struct nfsmount *);
#define nfs_safedisconnect nfsx_safedisconnect #define nfs_safedisconnect nfsx_safedisconnect
#endif #endif
int nfsx_request_xx(struct nfsmount *, int, void*); int nfsx_request_xx(struct nfsmount *, int, void*, void*);
int nfsx_nmcancelreqs(struct nfsmount *); int nfsx_nmcancelreqs(struct nfsmount *);
#define nfs_connect nfs_connect_nfsx #define nfs_connect nfs_connect_nfsx
#define nfs_disconnect nfs_disconnect_nfsx #define nfs_disconnect nfs_disconnect_nfsx
#define nfs_nmcancelreqs nfsx_nmcancelreqs #define nfs_nmcancelreqs nfsx_nmcancelreqs
#define nfsx_request(nmp, m, s) \ #define nfsx_request(nmp, m, i, o) \
nfsx_request_xx(nmp, m, s) nfsx_request_xx(nmp, m, i, o)
#ifdef CONFIG_NFS_TCPIP #ifdef CONFIG_NFS_TCPIP
#define nfs_sigintr nfs_sigintr_nfsx # define nfs_sigintr nfs_sigintr_nfsx
#endif #endif
#endif /* __FS_NFS_NFS_SOCKET_H */ #endif /* __FS_NFS_NFS_SOCKET_H */
+234 -319
View File
File diff suppressed because it is too large Load Diff
+2 -1
View File
@@ -144,6 +144,7 @@ struct rpc_call
uint32_t rp_prog; /* program */ uint32_t rp_prog; /* program */
uint32_t rp_vers; /* version */ uint32_t rp_vers; /* version */
uint32_t rp_proc; /* procedure */ uint32_t rp_proc; /* procedure */
void *data;
struct rpc_auth_info rpc_auth; struct rpc_auth_info rpc_auth;
struct auth_unix rpc_unix; struct auth_unix rpc_unix;
struct rpc_auth_info rpc_verf; struct rpc_auth_info rpc_verf;
@@ -248,7 +249,7 @@ int rpcclnt_connect(struct rpcclnt *);
int rpcclnt_reconnect(struct rpctask *); int rpcclnt_reconnect(struct rpctask *);
void rpcclnt_disconnect(struct rpcclnt *); void rpcclnt_disconnect(struct rpcclnt *);
void rpcclnt_safedisconnect(struct rpcclnt *); void rpcclnt_safedisconnect(struct rpcclnt *);
int rpcclnt_request(struct rpcclnt *, int, struct rpc_reply *); int rpcclnt_request(struct rpcclnt *, int, struct rpc_reply *, void *);
int rpcclnt_cancelreqs(struct rpcclnt *); int rpcclnt_cancelreqs(struct rpcclnt *);
#endif /* _RPCCLNT_H_ */ #endif /* _RPCCLNT_H_ */
+209 -55
View File
File diff suppressed because it is too large Load Diff