mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-21 21:55:34 +08:00
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:
+128
-20
@@ -73,9 +73,9 @@
|
||||
/* Ideally, NFS_DIRBLKSIZ should be bigger, but I've seen servers with
|
||||
* broken NFS/ethernet drivers that won't work with anything bigger (Linux..)
|
||||
*/
|
||||
|
||||
#define NFS_DIRBLKSIZ 1024 /* Must be a multiple of DIRBLKSIZ */
|
||||
#define NFS_READDIRBLKSIZ 512 /* Size of read dir blocks. XXX */
|
||||
|
||||
#define NFS_DIRBLKSIZ 1024 /* Must be a multiple of DIRBLKSIZ */
|
||||
#define NFS_READDIRBLKSIZ 512 /* Size of read dir blocks. XXX */
|
||||
|
||||
/* Oddballs */
|
||||
|
||||
@@ -102,17 +102,17 @@
|
||||
* buffer cache code to say "Invalidate the block after it is written back".
|
||||
*/
|
||||
|
||||
#define B_INVAFTERWRITE B_INVAL
|
||||
#define B_INVAFTERWRITE B_INVAL
|
||||
|
||||
/* Flags for nfssvc() system call. */
|
||||
|
||||
#define NFSSVC_BIOD 0x002
|
||||
#define NFSSVC_NFSD 0x004
|
||||
#define NFSSVC_ADDSOCK 0x008
|
||||
#define NFSSVC_AUTHIN 0x010
|
||||
#define NFSSVC_GOTAUTH 0x040
|
||||
#define NFSSVC_BIOD 0x002
|
||||
#define NFSSVC_NFSD 0x004
|
||||
#define NFSSVC_ADDSOCK 0x008
|
||||
#define NFSSVC_AUTHIN 0x010
|
||||
#define NFSSVC_GOTAUTH 0x040
|
||||
#define NFSSVC_AUTHINFAIL 0x080
|
||||
#define NFSSVC_MNTD 0x100
|
||||
#define NFSSVC_MNTD 0x100
|
||||
|
||||
/* fs.nfs sysctl(3) identifiers */
|
||||
|
||||
@@ -129,8 +129,7 @@
|
||||
#define NFSINT_SIGMASK (sigmask(SIGINT)|sigmask(SIGTERM)|sigmask(SIGKILL)| \
|
||||
sigmask(SIGHUP)|sigmask(SIGQUIT))
|
||||
|
||||
/*
|
||||
* Socket errors ignored for connectionless sockets??
|
||||
/* Socket errors ignored for connectionless sockets??
|
||||
* For now, ignore them all
|
||||
*/
|
||||
|
||||
@@ -316,7 +315,7 @@ struct nfssvc_sock
|
||||
int ns_solock; /* lock for connected socket */
|
||||
int ns_cc; /* actual chars queued */
|
||||
int ns_reclen; /* length of first queued record */
|
||||
uint32_t ns_sref; /* # of refs to this struct */
|
||||
uint32_t ns_sref; /* # of refs to this struct */
|
||||
};
|
||||
|
||||
/* One of these structures is allocated for each nfsd. */
|
||||
@@ -324,19 +323,127 @@ struct nfssvc_sock
|
||||
struct nfsd
|
||||
{
|
||||
//TAILQ_ENTRY(nfsd) nfsd_chain; /* List of all nfsd's */
|
||||
int nfsd_flag; /* NFSD_ flags */
|
||||
struct nfssvc_sock *nfsd_slp; /* Current socket */
|
||||
struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
|
||||
int nfsd_flag; /* NFSD_ flags */
|
||||
struct nfssvc_sock *nfsd_slp; /* Current socket */
|
||||
struct nfsrv_descript *nfsd_nd; /* Associated nfsrv_descript */
|
||||
};
|
||||
|
||||
/* This structure is used by the server for describing each request. */
|
||||
|
||||
struct nfsrv_descript
|
||||
{
|
||||
unsigned int nd_procnum; /* RPC # */
|
||||
int nd_flag; /* nd_flag */
|
||||
int nd_repstat; /* Reply status */
|
||||
uint32_t nd_retxid; /* Reply xid */
|
||||
unsigned int nd_procnum; /* RPC # */
|
||||
int nd_flag; /* nd_flag */
|
||||
int nd_repstat; /* Reply status */
|
||||
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;
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
@@ -352,6 +459,7 @@ extern struct pool nfs_node_pool;
|
||||
extern TAILQ_HEAD(nfsdhead, nfsd) nfsd_head;
|
||||
extern int nfsd_head_flag;
|
||||
*/
|
||||
|
||||
/****************************************************************************
|
||||
* Public Function Prototypes
|
||||
****************************************************************************/
|
||||
|
||||
@@ -98,7 +98,7 @@ struct nfsmount
|
||||
int nm_acregmin; /* Reg file attr cache min lifetime */
|
||||
int nm_acregmax; /* Reg file attr cache max lifetime */
|
||||
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*/
|
||||
};
|
||||
|
||||
|
||||
@@ -115,7 +115,6 @@ struct nfsnode
|
||||
bool n_open; /* true: The file is (still) open */
|
||||
uint64_t n_size; /* Current size of file */
|
||||
struct nfs_fattr n_fattr; /* nfs file attribute cache */
|
||||
struct nfsv3_sattr n_sattr;
|
||||
nfstype nfsv3_type; /* File type */
|
||||
time_t n_attrstamp; /* Attr. cache timestamp */
|
||||
struct timespec n_mtime; /* Prev modify time. */
|
||||
|
||||
+36
-21
@@ -61,11 +61,13 @@
|
||||
|
||||
/* Flag translations */
|
||||
|
||||
#define nfsmnt_to_rpcclnt(nf, rf, name) do { \
|
||||
if (nf & NFSMNT_##name) { \
|
||||
rf |= RPCCLNT_##name; \
|
||||
} \
|
||||
} while(0)
|
||||
#define nfsmnt_to_rpcclnt(nf, rf, name) do \
|
||||
{ \
|
||||
if (nf & NFSMNT_##name) \
|
||||
{ \
|
||||
rf |= RPCCLNT_##name; \
|
||||
} \
|
||||
} while(0)
|
||||
|
||||
/****************************************************************************
|
||||
* Private Variables
|
||||
@@ -101,15 +103,18 @@ int nfsx_connect(struct nfsmount *nmp)
|
||||
int error = 0;
|
||||
|
||||
if (nmp == NULL)
|
||||
return EFAULT;
|
||||
{
|
||||
return EFAULT;
|
||||
}
|
||||
|
||||
rpc = &nmp->nm_rpcclnt;
|
||||
|
||||
rpc->rc_prog = &nfs3_program;
|
||||
|
||||
printf("nfsxconnect!\n");
|
||||
nvdbg("nfsxconnect!\n");
|
||||
|
||||
/* translate nfsmnt flags -> rpcclnt flags */
|
||||
|
||||
rpc->rc_flag = 0;
|
||||
nfsmnt_to_rpcclnt(nmp->nm_flag, rpc->rc_flag, SOFT);
|
||||
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;
|
||||
|
||||
/* XXX v2,3 need to use this */
|
||||
|
||||
rpc->rc_proctlen = 0;
|
||||
rpc->rc_proct = NULL;
|
||||
|
||||
if (error)
|
||||
return error;
|
||||
{
|
||||
return error;
|
||||
}
|
||||
|
||||
return rpcclnt_connect(rpc);
|
||||
}
|
||||
@@ -155,7 +163,7 @@ void nfsx_safedisconnect(struct nfsmount *nmp)
|
||||
}
|
||||
#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;
|
||||
struct nfsmount *nmp;
|
||||
@@ -170,10 +178,12 @@ tryagain:
|
||||
|
||||
memset(reply, 0, sizeof(struct rpc_reply));
|
||||
|
||||
if ((error = rpcclnt_request(clnt, procnum, reply)) != 0)
|
||||
goto out;
|
||||
if ((error = rpcclnt_request(clnt, procnum, reply, datain)) != 0)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
data = reply->stat.where;
|
||||
dataout = reply->stat.where;
|
||||
|
||||
if (reply->rpc_verfi.authtype != 0)
|
||||
{
|
||||
@@ -190,22 +200,27 @@ tryagain:
|
||||
goto tryagain;
|
||||
}
|
||||
|
||||
/*
|
||||
** If the File Handle was stale, invalidate the
|
||||
** lookup cache, just in case.
|
||||
**/
|
||||
/* If the File Handle was stale, invalidate the
|
||||
* lookup cache, just in case.
|
||||
*/
|
||||
|
||||
if (error == ESTALE)
|
||||
printf("%s: ESTALE on mount from server \n",
|
||||
nmp->nm_rpcclnt.rc_prog->prog_name);
|
||||
{
|
||||
ndbg("%s: ESTALE on mount from server \n",
|
||||
nmp->nm_rpcclnt.rc_prog->prog_name);
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
goto out;
|
||||
}
|
||||
return (0);
|
||||
return 0;
|
||||
|
||||
out:
|
||||
return (error);
|
||||
return error;
|
||||
}
|
||||
|
||||
/* terminate any outstanding RPCs. */
|
||||
|
||||
@@ -53,17 +53,17 @@ int nfsx_sigintr(struct nfsmount *, struct nfsreq *, cthread_t *);
|
||||
void nfsx_safedisconnect(struct nfsmount *);
|
||||
#define nfs_safedisconnect nfsx_safedisconnect
|
||||
#endif
|
||||
int nfsx_request_xx(struct nfsmount *, int, void*);
|
||||
int nfsx_request_xx(struct nfsmount *, int, void*, void*);
|
||||
int nfsx_nmcancelreqs(struct nfsmount *);
|
||||
|
||||
#define nfs_connect nfs_connect_nfsx
|
||||
#define nfs_disconnect nfs_disconnect_nfsx
|
||||
#define nfs_nmcancelreqs nfsx_nmcancelreqs
|
||||
#define nfsx_request(nmp, m, s) \
|
||||
nfsx_request_xx(nmp, m, s)
|
||||
#define nfsx_request(nmp, m, i, o) \
|
||||
nfsx_request_xx(nmp, m, i, o)
|
||||
|
||||
#ifdef CONFIG_NFS_TCPIP
|
||||
#define nfs_sigintr nfs_sigintr_nfsx
|
||||
# define nfs_sigintr nfs_sigintr_nfsx
|
||||
#endif
|
||||
|
||||
#endif /* __FS_NFS_NFS_SOCKET_H */
|
||||
|
||||
+287
-372
File diff suppressed because it is too large
Load Diff
+2
-1
@@ -144,6 +144,7 @@ struct rpc_call
|
||||
uint32_t rp_prog; /* program */
|
||||
uint32_t rp_vers; /* version */
|
||||
uint32_t rp_proc; /* procedure */
|
||||
void *data;
|
||||
struct rpc_auth_info rpc_auth;
|
||||
struct auth_unix rpc_unix;
|
||||
struct rpc_auth_info rpc_verf;
|
||||
@@ -248,7 +249,7 @@ int rpcclnt_connect(struct rpcclnt *);
|
||||
int rpcclnt_reconnect(struct rpctask *);
|
||||
void rpcclnt_disconnect(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 *);
|
||||
|
||||
#endif /* _RPCCLNT_H_ */
|
||||
|
||||
+270
-116
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user