Change NFS buffering
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4837 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
7f6145b1e1
commit
8764f673f2
@ -48,8 +48,9 @@
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include "nfs_proto.h"
|
||||
#include <sys/socket.h>
|
||||
|
||||
#include "rpc.h"
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
@ -84,6 +85,27 @@ struct nfsmount
|
||||
uint16_t nm_wsize; /* Max size of write RPC */
|
||||
uint16_t nm_readdirsize; /* Size of a readdir RPC */
|
||||
uint8_t nm_verf[NFSX_V3WRITEVERF]; /* V3 write verifier */
|
||||
|
||||
/* Set aside memory on the stack to hold the largest call message. NOTE
|
||||
* that for the case of the write call message, the reply message is in
|
||||
* this union.
|
||||
*/
|
||||
|
||||
union
|
||||
{
|
||||
struct rpc_call_pmap pmap;
|
||||
struct rpc_call_mount mountd;
|
||||
struct rpc_call_create create;
|
||||
struct rpc_call_lookup lookup;
|
||||
struct rpc_call_read read;
|
||||
struct rpc_call_remove removef;
|
||||
struct rpc_call_rename renamef;
|
||||
struct rpc_call_mkdir mkdir;
|
||||
struct rpc_call_rmdir rmdir;
|
||||
struct rpc_call_readdir readdir;
|
||||
struct rpc_call_fs fs;
|
||||
struct rpc_reply_write write;
|
||||
} nm_smallbuffer;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -146,7 +146,7 @@ void nfs_disconnect(struct nfsmount *nmp)
|
||||
}
|
||||
|
||||
int nfs_request(struct nfsmount *nmp, int procnum,
|
||||
FAR const void *request, size_t reqlen,
|
||||
FAR void *request, size_t reqlen,
|
||||
FAR void *response, size_t resplen)
|
||||
{
|
||||
struct rpcclnt *clnt = nmp->nm_rpcclnt;
|
||||
|
@ -58,7 +58,7 @@ EXTERN void nfs_init(void);
|
||||
EXTERN int nfs_connect(struct nfsmount *nmp);
|
||||
EXTERN void nfs_disconnect(struct nfsmount *nmp);
|
||||
EXTERN int nfs_request(struct nfsmount *nmp, int procnum,
|
||||
FAR const void *request, size_t reqlen,
|
||||
FAR void *request, size_t reqlen,
|
||||
FAR void *response, size_t resplen);
|
||||
|
||||
#undef EXTERN
|
||||
|
@ -212,17 +212,17 @@ int nfs_checkmount(struct nfsmount *nmp)
|
||||
|
||||
int nfs_fsinfo(FAR struct nfsmount *nmp)
|
||||
{
|
||||
struct rpc_call_fs fsinfo;
|
||||
struct rpc_reply_fsinfo fsp;
|
||||
struct FS3args fsinfo;
|
||||
uint32_t pref;
|
||||
uint32_t max;
|
||||
int error = 0;
|
||||
|
||||
memset(&fsinfo, 0, sizeof(struct FS3args));
|
||||
memset(&fsinfo, 0, sizeof(struct rpc_call_fs));
|
||||
memset(&fsp, 0, sizeof(struct rpc_reply_fsinfo));
|
||||
|
||||
fsinfo.fsroot.length = txdr_unsigned(nmp->nm_fhsize);
|
||||
fsinfo.fsroot.handle = nmp->nm_fh;
|
||||
fsinfo.fs.fsroot.length = txdr_unsigned(nmp->nm_fhsize);
|
||||
fsinfo.fs.fsroot.handle = nmp->nm_fh;
|
||||
|
||||
/* Request FSINFO from the server */
|
||||
|
||||
@ -311,7 +311,7 @@ int nfs_lookup(struct nfsmount *nmp, FAR const char *filename,
|
||||
FAR struct nfs_fattr *obj_attributes,
|
||||
FAR struct nfs_fattr *dir_attributes)
|
||||
{
|
||||
struct LOOKUP3args request;
|
||||
struct rpc_call_lookup request;
|
||||
struct rpc_reply_lookup response;
|
||||
FAR uint32_t *ptr;
|
||||
uint32_t value;
|
||||
@ -323,7 +323,7 @@ int nfs_lookup(struct nfsmount *nmp, FAR const char *filename,
|
||||
|
||||
/* Set all of the buffers to a known state */
|
||||
|
||||
memset(&request, 0, sizeof(struct LOOKUP3args));
|
||||
memset(&request, 0, sizeof(struct rpc_call_lookup));
|
||||
memset(&response, 0, sizeof(struct rpc_reply_lookup));
|
||||
|
||||
/* Get the length of the string to be sent */
|
||||
@ -337,7 +337,7 @@ int nfs_lookup(struct nfsmount *nmp, FAR const char *filename,
|
||||
|
||||
/* Initialize the request */
|
||||
|
||||
ptr = (FAR uint32_t*)&request;
|
||||
ptr = (FAR uint32_t*)&request.lookup;
|
||||
reqlen = 0;
|
||||
|
||||
/* Copy the variable length, directory file handle */
|
||||
|
@ -202,7 +202,6 @@ static int nfs_filecreate(FAR struct nfsmount *nmp, struct nfsnode *np,
|
||||
struct file_handle fhandle;
|
||||
struct nfs_fattr fattr;
|
||||
char filename[NAME_MAX + 1];
|
||||
struct CREATE3args request;
|
||||
struct rpc_reply_create resok;
|
||||
FAR uint32_t *ptr;
|
||||
uint32_t tmp;
|
||||
@ -221,7 +220,7 @@ static int nfs_filecreate(FAR struct nfsmount *nmp, struct nfsnode *np,
|
||||
|
||||
/* Create the CREATE RPC call arguments */
|
||||
|
||||
ptr = (FAR uint32_t *)&request;
|
||||
ptr = (FAR uint32_t *)&((FAR struct rpc_call_create *)np->n_iobuffer)->create;
|
||||
reqlen = 0;
|
||||
|
||||
/* Copy the variable length, directory file handle */
|
||||
@ -315,7 +314,7 @@ static int nfs_filecreate(FAR struct nfsmount *nmp, struct nfsnode *np,
|
||||
{
|
||||
nfs_statistics(NFSPROC_CREATE);
|
||||
error = nfs_request(nmp, NFSPROC_CREATE,
|
||||
(FAR const void *)&request, reqlen,
|
||||
(FAR void *)np->n_iobuffer, reqlen,
|
||||
(FAR void *)&resok, sizeof(struct rpc_reply_create));
|
||||
}
|
||||
#ifdef USE_GUARDED_CREATE
|
||||
@ -681,7 +680,7 @@ static ssize_t nfs_read(FAR struct file *filep, char *buffer, size_t buflen)
|
||||
ssize_t tmp;
|
||||
ssize_t bytesread;
|
||||
size_t reqlen;
|
||||
struct READ3args request;
|
||||
struct rpc_call_read request;
|
||||
FAR uint32_t *ptr;
|
||||
int error = 0;
|
||||
|
||||
@ -741,7 +740,7 @@ static ssize_t nfs_read(FAR struct file *filep, char *buffer, size_t buflen)
|
||||
|
||||
/* Initialize the request */
|
||||
|
||||
ptr = (FAR uint32_t*)&request;
|
||||
ptr = (FAR uint32_t*)&request.read;
|
||||
reqlen = 0;
|
||||
|
||||
/* Copy the variable length, file handle */
|
||||
@ -769,7 +768,7 @@ static ssize_t nfs_read(FAR struct file *filep, char *buffer, size_t buflen)
|
||||
fvdbg("Reading %d bytes\n", readsize);
|
||||
nfs_statistics(NFSPROC_READ);
|
||||
error = nfs_request(nmp, NFSPROC_READ,
|
||||
(FAR const void *)&request, reqlen,
|
||||
(FAR void *)&request, reqlen,
|
||||
(FAR void *)np->n_iobuffer, np->n_buflen);
|
||||
if (error)
|
||||
{
|
||||
@ -953,7 +952,7 @@ static ssize_t nfs_write(FAR struct file *filep, const char *buffer,
|
||||
|
||||
nfs_statistics(NFSPROC_WRITE);
|
||||
error = nfs_request(nmp, NFSPROC_WRITE,
|
||||
(FAR const void *)np->n_iobuffer, reqlen,
|
||||
(FAR void *)np->n_iobuffer, reqlen,
|
||||
(FAR void *)&resok, sizeof(struct rpc_reply_write));
|
||||
if (error)
|
||||
{
|
||||
@ -1131,8 +1130,7 @@ static int nfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
|
||||
{
|
||||
struct nfsmount *nmp;
|
||||
uint32_t buffer[64];
|
||||
struct READDIR3args request;
|
||||
struct rpc_reply_readdir *resok;
|
||||
struct rpc_call_readdir request;
|
||||
struct file_handle fhandle;
|
||||
struct nfs_fattr obj_attributes;
|
||||
uint32_t tmp;
|
||||
@ -1166,7 +1164,7 @@ static int nfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
|
||||
* the dirent structure.
|
||||
*/
|
||||
|
||||
ptr = (FAR uint32_t*)&request;
|
||||
ptr = (FAR uint32_t*)&request.readdir;
|
||||
reqlen = 0;
|
||||
|
||||
/* Copy the variable length, directory file handle */
|
||||
@ -1198,7 +1196,7 @@ static int nfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
|
||||
|
||||
nfs_statistics(NFSPROC_READDIR);
|
||||
error = nfs_request(nmp, NFSPROC_READDIR,
|
||||
(FAR const void *)&request, reqlen,
|
||||
(FAR void *)&request, reqlen,
|
||||
(FAR void *)buffer, sizeof(buffer));
|
||||
if (error != OK)
|
||||
{
|
||||
@ -1216,11 +1214,7 @@ static int nfs_readdir(struct inode *mountpt, struct fs_dirent_s *dir)
|
||||
* 4) Values follows indication - 4 bytes
|
||||
*/
|
||||
|
||||
resok = (struct rpc_reply_readdir *)buffer;
|
||||
|
||||
/* Start with the first entry */
|
||||
|
||||
ptr = (uint32_t*)&resok->readdir;
|
||||
ptr = (uint32_t *)&((FAR struct rpc_reply_readdir *)buffer)->readdir;
|
||||
|
||||
/* Check if attributes follow, if 0 so Skip over the attributes */
|
||||
|
||||
@ -1531,7 +1525,7 @@ int mountnfs(struct nfs_args *argp, void **handle)
|
||||
{
|
||||
FAR struct nfsmount *nmp;
|
||||
struct nfsnode *np = NULL;
|
||||
struct FS3args getattr;
|
||||
struct rpc_call_fs getattr;
|
||||
struct rpc_reply_getattr resok;
|
||||
int error = 0;
|
||||
|
||||
@ -1617,13 +1611,14 @@ int mountnfs(struct nfs_args *argp, void **handle)
|
||||
|
||||
/* Get the file attributes */
|
||||
|
||||
memset(&getattr, 0, sizeof(struct FS3args));
|
||||
memset(&getattr, 0, sizeof(struct rpc_call_fs));
|
||||
memset(&resok, 0, sizeof(struct rpc_reply_getattr));
|
||||
getattr.fsroot.length = txdr_unsigned(nmp->nm_fhsize);
|
||||
memcpy(&getattr.fsroot.handle, &nmp->nm_fh, sizeof(nfsfh_t));
|
||||
|
||||
getattr.fs.fsroot.length = txdr_unsigned(nmp->nm_fhsize);
|
||||
memcpy(&getattr.fs.fsroot.handle, &nmp->nm_fh, sizeof(nfsfh_t));
|
||||
|
||||
error = nfs_request(nmp, NFSPROC_GETATTR,
|
||||
(FAR const void *)&getattr, sizeof(struct FS3args),
|
||||
(FAR void *)&getattr, sizeof(struct FS3args),
|
||||
(FAR void*)&resok, sizeof(struct rpc_reply_getattr));
|
||||
if (error)
|
||||
{
|
||||
@ -1773,11 +1768,11 @@ int nfs_unbind(void *handle, struct inode **blkdriver)
|
||||
|
||||
static int nfs_statfs(struct inode *mountpt, struct statfs *sbp)
|
||||
{
|
||||
struct rpc_call_fs fsstat;
|
||||
struct rpc_reply_fsstat sfp;
|
||||
struct nfsmount *nmp;
|
||||
int error = 0;
|
||||
uint64_t tquad;
|
||||
struct FS3args fsstat;
|
||||
|
||||
/* Sanity checks */
|
||||
|
||||
@ -1807,14 +1802,15 @@ static int nfs_statfs(struct inode *mountpt, struct statfs *sbp)
|
||||
(void)nfs_fsinfo(nmp);
|
||||
}
|
||||
|
||||
nfs_statistics(NFSPROC_FSSTAT);
|
||||
memset(&fsstat, 0, sizeof(struct FS3args));
|
||||
memset(&fsstat, 0, sizeof(struct rpc_call_fs));
|
||||
memset(&sfp, 0, sizeof(struct rpc_reply_fsstat));
|
||||
fsstat.fsroot.length = txdr_unsigned(nmp->nm_fhsize);
|
||||
fsstat.fsroot.handle = nmp->nm_fh;
|
||||
|
||||
fsstat.fs.fsroot.length = txdr_unsigned(nmp->nm_fhsize);
|
||||
fsstat.fs.fsroot.handle = nmp->nm_fh;
|
||||
|
||||
nfs_statistics(NFSPROC_FSSTAT);
|
||||
error = nfs_request(nmp, NFSPROC_FSSTAT,
|
||||
(FAR const void *)&fsstat, sizeof(struct FS3args),
|
||||
(FAR void *)&fsstat, sizeof(struct FS3args),
|
||||
(FAR void *) &sfp, sizeof(struct rpc_reply_fsstat));
|
||||
if (error)
|
||||
{
|
||||
@ -1856,7 +1852,7 @@ static int nfs_remove(struct inode *mountpt, const char *relpath)
|
||||
struct file_handle fhandle;
|
||||
struct nfs_fattr fattr;
|
||||
char filename[NAME_MAX + 1];
|
||||
struct REMOVE3args remove;
|
||||
struct rpc_call_remove remove;
|
||||
struct rpc_reply_remove resok;
|
||||
FAR uint32_t *ptr;
|
||||
int namelen;
|
||||
@ -1892,7 +1888,7 @@ static int nfs_remove(struct inode *mountpt, const char *relpath)
|
||||
|
||||
/* Create the REMOVE RPC call arguments */
|
||||
|
||||
ptr = (FAR uint32_t *)&remove;
|
||||
ptr = (FAR uint32_t *)&remove.remove;
|
||||
reqlen = 0;
|
||||
|
||||
/* Copy the variable length, directory file handle */
|
||||
@ -1918,7 +1914,7 @@ static int nfs_remove(struct inode *mountpt, const char *relpath)
|
||||
|
||||
nfs_statistics(NFSPROC_REMOVE);
|
||||
error = nfs_request(nmp, NFSPROC_REMOVE,
|
||||
(FAR const void *)&remove, reqlen,
|
||||
(FAR void *)&remove, reqlen,
|
||||
(FAR void *)&resok, sizeof(struct rpc_reply_remove));
|
||||
|
||||
/* Check if the file removal was successful */
|
||||
@ -1957,7 +1953,7 @@ static int nfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode)
|
||||
struct file_handle fhandle;
|
||||
struct nfs_fattr fattr;
|
||||
char dirname[NAME_MAX + 1];
|
||||
struct MKDIR3args request;
|
||||
struct rpc_call_mkdir request;
|
||||
struct rpc_reply_mkdir resok;
|
||||
FAR uint32_t *ptr;
|
||||
uint32_t tmp;
|
||||
@ -1994,7 +1990,7 @@ static int nfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode)
|
||||
|
||||
/* Format the MKDIR call message arguments */
|
||||
|
||||
ptr = (FAR uint32_t *)&request;
|
||||
ptr = (FAR uint32_t *)&request.mkdir;
|
||||
reqlen = 0;
|
||||
|
||||
/* Copy the variable length, directory file handle */
|
||||
@ -2057,7 +2053,7 @@ static int nfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode)
|
||||
|
||||
nfs_statistics(NFSPROC_MKDIR);
|
||||
error = nfs_request(nmp, NFSPROC_MKDIR,
|
||||
(FAR const void *)&request, reqlen,
|
||||
(FAR void *)&request, reqlen,
|
||||
(FAR void *)&resok, sizeof(struct rpc_reply_mkdir));
|
||||
if (error)
|
||||
{
|
||||
@ -2086,7 +2082,7 @@ static int nfs_rmdir(struct inode *mountpt, const char *relpath)
|
||||
struct file_handle fhandle;
|
||||
struct nfs_fattr fattr;
|
||||
char dirname[NAME_MAX + 1];
|
||||
struct RMDIR3args request;
|
||||
struct rpc_call_rmdir request;
|
||||
struct rpc_reply_rmdir resok;
|
||||
FAR uint32_t *ptr;
|
||||
int namelen;
|
||||
@ -2122,7 +2118,7 @@ static int nfs_rmdir(struct inode *mountpt, const char *relpath)
|
||||
|
||||
/* Set up the RMDIR call message arguments */
|
||||
|
||||
ptr = (FAR uint32_t *)&request;
|
||||
ptr = (FAR uint32_t *)&request.rmdir;
|
||||
reqlen = 0;
|
||||
|
||||
/* Copy the variable length, directory file handle */
|
||||
@ -2148,7 +2144,7 @@ static int nfs_rmdir(struct inode *mountpt, const char *relpath)
|
||||
|
||||
nfs_statistics(NFSPROC_RMDIR);
|
||||
error = nfs_request(nmp, NFSPROC_RMDIR,
|
||||
(FAR const void *)&request, reqlen,
|
||||
(FAR void *)&request, reqlen,
|
||||
(FAR void *)&resok, sizeof(struct rpc_reply_rmdir));
|
||||
|
||||
/* Check if the removal was successful */
|
||||
@ -2189,7 +2185,7 @@ static int nfs_rename(struct inode *mountpt, const char *oldrelpath,
|
||||
char from_name[NAME_MAX+1];
|
||||
char to_name[NAME_MAX+1];
|
||||
struct nfs_fattr fattr;
|
||||
struct RENAME3args request;
|
||||
struct rpc_call_rename request;
|
||||
struct rpc_reply_rename resok;
|
||||
FAR uint32_t *ptr;
|
||||
int namelen;
|
||||
@ -2234,7 +2230,7 @@ static int nfs_rename(struct inode *mountpt, const char *oldrelpath,
|
||||
|
||||
/* Format the RENAME RPC arguments */
|
||||
|
||||
ptr = (FAR uint32_t *)&request;
|
||||
ptr = (FAR uint32_t *)&request.rename;
|
||||
reqlen = 0;
|
||||
|
||||
/* Copy the variable length, 'from' directory file handle */
|
||||
@ -2280,7 +2276,7 @@ static int nfs_rename(struct inode *mountpt, const char *oldrelpath,
|
||||
|
||||
nfs_statistics(NFSPROC_RENAME);
|
||||
error = nfs_request(nmp, NFSPROC_RENAME,
|
||||
(FAR const void *)&request, reqlen,
|
||||
(FAR void *)&request, reqlen,
|
||||
(FAR void *)&resok, sizeof(struct rpc_reply_rename));
|
||||
|
||||
/* Check if the rename was successful */
|
||||
|
@ -513,7 +513,7 @@ void rpcclnt_disconnect(FAR struct rpcclnt *rpc);
|
||||
int rpcclnt_umount(FAR struct rpcclnt *rpc);
|
||||
void rpcclnt_safedisconnect(FAR struct rpcclnt *rpc);
|
||||
int rpcclnt_request(FAR struct rpcclnt *rpc, int procnum, int prog, int version,
|
||||
FAR const void *request, size_t reqlen,
|
||||
FAR void *request, size_t reqlen,
|
||||
FAR void *response, size_t resplen);
|
||||
|
||||
#endif /* __FS_NFS_RPC_H */
|
||||
|
@ -165,9 +165,6 @@ static int rpcclnt_reconnect(FAR struct rpcclnt *rpc);
|
||||
static uint32_t rpcclnt_newxid(void);
|
||||
static void rpcclnt_fmtheader(FAR struct rpc_call_header *ch,
|
||||
uint32_t xid, int procid, int prog, int vers);
|
||||
static int rpcclnt_buildheader(struct rpcclnt *rpc, int procid, int prog, int vers,
|
||||
FAR const void *request, size_t *reqlen,
|
||||
FAR void *msgbuf);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@ -536,6 +533,7 @@ static void rpcclnt_fmtheader(FAR struct rpc_call_header *ch,
|
||||
/* rpc_auth part (auth_null) */
|
||||
|
||||
ch->rpc_auth.authtype = rpc_auth_null;
|
||||
ch->rpc_auth.authlen = 0;
|
||||
|
||||
#ifdef CONFIG_NFS_UNIX_AUTH
|
||||
ch->rpc_unix.stamp = txdr_unsigned(1);
|
||||
@ -548,334 +546,7 @@ static void rpcclnt_fmtheader(FAR struct rpc_call_header *ch,
|
||||
/* rpc_verf part (auth_null) */
|
||||
|
||||
ch->rpc_verf.authtype = rpc_auth_null;
|
||||
}
|
||||
|
||||
/* Build the RPC header and fill in the authorization info. */
|
||||
|
||||
static int rpcclnt_buildheader(struct rpcclnt *rpc, int procid, int prog, int vers,
|
||||
FAR const void *request, size_t *reqlen, FAR void *msgbuf)
|
||||
{
|
||||
uint32_t xid;
|
||||
|
||||
/* The RPC header.*/
|
||||
|
||||
/* Get a new (non-zero) xid */
|
||||
|
||||
xid = rpcclnt_newxid();
|
||||
|
||||
/* Perform the binding depending on the protocol type */
|
||||
|
||||
if (prog == PMAPPROG)
|
||||
{
|
||||
if (procid == PMAPPROC_GETPORT)
|
||||
{
|
||||
/* Copy the variable, caller-provided data into the call message structure */
|
||||
|
||||
struct rpc_call_pmap *callmsg = (struct rpc_call_pmap *)msgbuf;
|
||||
memcpy(&callmsg->pmap, request, *reqlen);
|
||||
|
||||
/* Return the full size of the message (including messages headers) */
|
||||
|
||||
DEBUGASSERT(*reqlen == sizeof(struct call_args_pmap));
|
||||
*reqlen = sizeof(struct rpc_call_pmap);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (prog == RPCPROG_MNT)
|
||||
{
|
||||
if (procid == RPCMNT_UMOUNT)
|
||||
{
|
||||
/* Copy the variable, caller-provided data into the call message structure */
|
||||
|
||||
struct rpc_call_mount *callmsg = (struct rpc_call_mount *)msgbuf;
|
||||
memcpy(&callmsg->mount, request, *reqlen);
|
||||
|
||||
/* Return the full size of the message (including messages headers) */
|
||||
|
||||
DEBUGASSERT(*reqlen == sizeof(struct call_args_mount));
|
||||
*reqlen = sizeof(struct rpc_call_mount);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
return 0;
|
||||
}
|
||||
else if (procid == RPCMNT_MOUNT)
|
||||
{
|
||||
/* Copy the variable, caller-provided data into the call message structure */
|
||||
|
||||
struct rpc_call_mount *callmsg = (struct rpc_call_mount *)msgbuf;
|
||||
memcpy(&callmsg->mount, request, *reqlen);
|
||||
|
||||
/* Return the full size of the message (including messages headers) */
|
||||
|
||||
DEBUGASSERT(*reqlen == sizeof(struct call_args_mount));
|
||||
*reqlen = sizeof(struct rpc_call_mount);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else if (prog == NFS_PROG)
|
||||
{
|
||||
switch (procid)
|
||||
{
|
||||
case NFSPROC_CREATE:
|
||||
{
|
||||
/* Copy the variable length, caller-provided data into the call
|
||||
* message structure.
|
||||
*/
|
||||
|
||||
struct rpc_call_create *callmsg = (struct rpc_call_create *)msgbuf;
|
||||
memcpy(&callmsg->create, request, *reqlen);
|
||||
|
||||
/* Return the full size of the message (the size of variable data
|
||||
* plus the size of the messages header).
|
||||
*/
|
||||
|
||||
*reqlen += sizeof(struct rpc_call_header);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case NFSPROC_LOOKUP:
|
||||
{
|
||||
/* Copy the variable length, caller-provided data into the call
|
||||
* message structure.
|
||||
*/
|
||||
|
||||
struct rpc_call_lookup *callmsg = (struct rpc_call_lookup *)msgbuf;
|
||||
memcpy(&callmsg->lookup, request, *reqlen);
|
||||
|
||||
/* Return the full size of the message (the size of variable data
|
||||
* plus the size of the messages header).
|
||||
*/
|
||||
|
||||
*reqlen += sizeof(struct rpc_call_header);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case NFSPROC_READ:
|
||||
{
|
||||
/* Copy the variable length, caller-provided data into the call
|
||||
* message structure.
|
||||
*/
|
||||
|
||||
struct rpc_call_read *callmsg = (struct rpc_call_read *)msgbuf;
|
||||
memcpy(&callmsg->read, request, *reqlen);
|
||||
|
||||
/* Return the full size of the message (the size of variable data
|
||||
* plus the size of the messages header).
|
||||
*/
|
||||
|
||||
*reqlen += sizeof(struct rpc_call_header);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case NFSPROC_WRITE:
|
||||
{
|
||||
/* The WRITE message is a unique case: The write data is already
|
||||
* provided in an I/O buffer at the correct offset. Here we
|
||||
* merely have to inititlized the RPC header fields.
|
||||
*/
|
||||
|
||||
struct rpc_call_write *callmsg = (struct rpc_call_write *)request;
|
||||
|
||||
/* Return the full size of the message (the size of variable data
|
||||
* plus the size of the messages header).
|
||||
*/
|
||||
|
||||
*reqlen += sizeof(struct rpc_call_header);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case NFSPROC_READDIR:
|
||||
{
|
||||
/* Copy the variable length, caller-provided data into the call
|
||||
* message structure.
|
||||
*/
|
||||
|
||||
struct rpc_call_readdir *callmsg = (struct rpc_call_readdir *)msgbuf;
|
||||
memcpy(&callmsg->readdir, request, *reqlen);
|
||||
|
||||
/* Return the full size of the message (the size of variable data
|
||||
* plus the size of the messages header).
|
||||
*/
|
||||
|
||||
*reqlen += sizeof(struct rpc_call_header);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case NFSPROC_FSSTAT:
|
||||
{
|
||||
/* Copy the variable, caller-provided data into the call message structure */
|
||||
|
||||
struct rpc_call_fs *callmsg = (struct rpc_call_fs *)msgbuf;
|
||||
memcpy(&callmsg->fs, request, *reqlen);
|
||||
|
||||
/* Return the full size of the message (including messages headers) */
|
||||
|
||||
DEBUGASSERT(*reqlen == sizeof(struct FS3args));
|
||||
*reqlen = sizeof(struct rpc_call_fs);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case NFSPROC_REMOVE:
|
||||
{
|
||||
/* 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 (the size of variable data
|
||||
* plus the size of the messages header).
|
||||
*/
|
||||
|
||||
*reqlen += sizeof(struct rpc_call_header);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case NFSPROC_GETATTR:
|
||||
{
|
||||
/* Copy the variable, caller-provided data into the call message structure */
|
||||
|
||||
struct rpc_call_fs *callmsg = (struct rpc_call_fs *)msgbuf;
|
||||
memcpy(&callmsg->fs, request, *reqlen);
|
||||
|
||||
/* Return the full size of the message (including messages headers) */
|
||||
|
||||
DEBUGASSERT(*reqlen == sizeof(struct FS3args));
|
||||
*reqlen = sizeof(struct rpc_call_fs);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case NFSPROC_MKDIR:
|
||||
{
|
||||
/* 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 (the size of variable data
|
||||
* plus the size of the messages header).
|
||||
*/
|
||||
|
||||
*reqlen += sizeof(struct rpc_call_header);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case NFSPROC_RMDIR:
|
||||
{
|
||||
/* 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 (the size of variable data
|
||||
* plus the size of the messages header).
|
||||
*/
|
||||
|
||||
*reqlen += sizeof(struct rpc_call_header);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case NFSPROC_RENAME:
|
||||
{
|
||||
/* Copy the variable length, caller-provided data into the call
|
||||
* message structure.
|
||||
*/
|
||||
|
||||
struct rpc_call_rename *callmsg = (struct rpc_call_rename *)msgbuf;
|
||||
memcpy(&callmsg->rename, request, *reqlen);
|
||||
|
||||
/* Return the full size of the message (the size of variable data
|
||||
* plus the size of the messages header).
|
||||
*/
|
||||
|
||||
*reqlen += sizeof(struct rpc_call_header);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
case NFSPROC_FSINFO:
|
||||
{
|
||||
/* Copy the variable, caller-provided data into the call message structure */
|
||||
|
||||
struct rpc_call_fs *callmsg = (struct rpc_call_fs *)msgbuf;
|
||||
memcpy(&callmsg->fs, request, *reqlen);
|
||||
|
||||
/* Return the full size of the message (including messages headers) */
|
||||
|
||||
DEBUGASSERT(*reqlen == sizeof(struct FS3args));
|
||||
*reqlen = sizeof(struct rpc_call_fs);
|
||||
|
||||
/* Format the message header */
|
||||
|
||||
rpcclnt_fmtheader(&callmsg->ch, xid, prog, vers, procid);
|
||||
return 0;
|
||||
}
|
||||
|
||||
default:
|
||||
fdbg("No support for procid %d\n", procid);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return ESRCH;
|
||||
ch->rpc_verf.authlen = 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -910,8 +581,8 @@ int rpcclnt_connect(struct rpcclnt *rpc)
|
||||
struct sockaddr *saddr;
|
||||
struct sockaddr_in sin;
|
||||
struct sockaddr_in *sa;
|
||||
struct call_args_pmap sdata;
|
||||
struct call_args_mount mountd;
|
||||
struct rpc_call_pmap sdata;
|
||||
struct rpc_call_mount mountd;
|
||||
struct rpc_reply_pmap rdata;
|
||||
struct rpc_reply_mount mdata;
|
||||
struct timeval tv;
|
||||
@ -1007,15 +678,15 @@ int rpcclnt_connect(struct rpcclnt *rpc)
|
||||
* Get port number for MOUNTD.
|
||||
*/
|
||||
|
||||
memset(&sdata, 0, sizeof(struct call_args_pmap));
|
||||
memset(&sdata, 0, sizeof(struct rpc_call_pmap));
|
||||
memset(&rdata, 0, sizeof(struct rpc_reply_pmap));
|
||||
sdata.prog = txdr_unsigned(RPCPROG_MNT);
|
||||
sdata.vers = txdr_unsigned(RPCMNT_VER1);
|
||||
sdata.proc = txdr_unsigned(IPPROTO_UDP);
|
||||
sdata.port = 0;
|
||||
sdata.pmap.prog = txdr_unsigned(RPCPROG_MNT);
|
||||
sdata.pmap.vers = txdr_unsigned(RPCMNT_VER1);
|
||||
sdata.pmap.proc = txdr_unsigned(IPPROTO_UDP);
|
||||
sdata.pmap.port = 0;
|
||||
|
||||
error = rpcclnt_request(rpc, PMAPPROC_GETPORT, PMAPPROG, PMAPVERS,
|
||||
(FAR const void *)&sdata, sizeof(struct call_args_pmap),
|
||||
(FAR void *)&sdata, sizeof(struct call_args_pmap),
|
||||
(FAR void *)&rdata, sizeof(struct rpc_reply_pmap));
|
||||
if (error != 0)
|
||||
{
|
||||
@ -1036,13 +707,13 @@ int rpcclnt_connect(struct rpcclnt *rpc)
|
||||
|
||||
/* Do RPC to mountd. */
|
||||
|
||||
memset(&mountd, 0, sizeof(struct call_args_mount));
|
||||
memset(&mountd, 0, sizeof(struct rpc_call_mount));
|
||||
memset(&mdata, 0, sizeof(struct rpc_reply_mount));
|
||||
strncpy(mountd.rpath, rpc->rc_path, 90);
|
||||
mountd.len = txdr_unsigned(sizeof(mountd.rpath));
|
||||
strncpy(mountd.mount.rpath, rpc->rc_path, 90);
|
||||
mountd.mount.len = txdr_unsigned(sizeof(mountd.mount.rpath));
|
||||
|
||||
error = rpcclnt_request(rpc, RPCMNT_MOUNT, RPCPROG_MNT, RPCMNT_VER1,
|
||||
(FAR const void *)&mountd, sizeof(struct call_args_mount),
|
||||
(FAR void *)&mountd, sizeof(struct call_args_mount),
|
||||
(FAR void *)&mdata, sizeof(struct rpc_reply_mount));
|
||||
if (error != 0)
|
||||
{
|
||||
@ -1063,7 +734,7 @@ int rpcclnt_connect(struct rpcclnt *rpc)
|
||||
* NFS port in the socket.
|
||||
*/
|
||||
|
||||
memset(&sdata, 0, sizeof(struct call_args_pmap));
|
||||
memset(&sdata, 0, sizeof(struct rpc_call_pmap));
|
||||
memset(&rdata, 0, sizeof(struct rpc_reply_pmap));
|
||||
sa->sin_port = htons(PMAPPORT);
|
||||
|
||||
@ -1075,13 +746,13 @@ int rpcclnt_connect(struct rpcclnt *rpc)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
sdata.prog = txdr_unsigned(NFS_PROG);
|
||||
sdata.vers = txdr_unsigned(NFS_VER3);
|
||||
sdata.proc = txdr_unsigned(IPPROTO_UDP);
|
||||
sdata.port = 0;
|
||||
sdata.pmap.prog = txdr_unsigned(NFS_PROG);
|
||||
sdata.pmap.vers = txdr_unsigned(NFS_VER3);
|
||||
sdata.pmap.proc = txdr_unsigned(IPPROTO_UDP);
|
||||
sdata.pmap.port = 0;
|
||||
|
||||
error = rpcclnt_request(rpc, PMAPPROC_GETPORT, PMAPPROG, PMAPVERS,
|
||||
(FAR const void *)&sdata, sizeof(struct call_args_pmap),
|
||||
(FAR void *)&sdata, sizeof(struct call_args_pmap),
|
||||
(FAR void *)&rdata, sizeof(struct rpc_reply_pmap));
|
||||
if (error != 0)
|
||||
{
|
||||
@ -1149,9 +820,9 @@ int rpcclnt_umount(struct rpcclnt *rpc)
|
||||
{
|
||||
struct sockaddr *saddr;
|
||||
struct sockaddr_in *sa;
|
||||
struct call_args_pmap sdata;
|
||||
struct rpc_call_pmap sdata;
|
||||
struct rpc_reply_pmap rdata;
|
||||
struct call_args_mount mountd;
|
||||
struct rpc_call_mount mountd;
|
||||
struct rpc_reply_mount mdata;
|
||||
int error;
|
||||
|
||||
@ -1162,7 +833,7 @@ int rpcclnt_umount(struct rpcclnt *rpc)
|
||||
* Get port number for MOUNTD.
|
||||
*/
|
||||
|
||||
memset(&sdata, 0, sizeof(struct call_args_pmap));
|
||||
memset(&sdata, 0, sizeof(struct rpc_call_pmap));
|
||||
memset(&rdata, 0, sizeof(struct rpc_reply_pmap));
|
||||
sa->sin_port = htons(PMAPPORT);
|
||||
|
||||
@ -1173,13 +844,13 @@ int rpcclnt_umount(struct rpcclnt *rpc)
|
||||
goto bad;
|
||||
}
|
||||
|
||||
sdata.prog = txdr_unsigned(RPCPROG_MNT);
|
||||
sdata.vers = txdr_unsigned(RPCMNT_VER1);
|
||||
sdata.proc = txdr_unsigned(IPPROTO_UDP);
|
||||
sdata.port = 0;
|
||||
sdata.pmap.prog = txdr_unsigned(RPCPROG_MNT);
|
||||
sdata.pmap.vers = txdr_unsigned(RPCMNT_VER1);
|
||||
sdata.pmap.proc = txdr_unsigned(IPPROTO_UDP);
|
||||
sdata.pmap.port = 0;
|
||||
|
||||
error = rpcclnt_request(rpc, PMAPPROC_GETPORT, PMAPPROG, PMAPVERS,
|
||||
(FAR const void *)&sdata, sizeof(struct call_args_pmap),
|
||||
(FAR void *)&sdata, sizeof(struct call_args_pmap),
|
||||
(FAR void *)&rdata, sizeof(struct rpc_reply_pmap));
|
||||
if (error != 0)
|
||||
{
|
||||
@ -1198,14 +869,14 @@ int rpcclnt_umount(struct rpcclnt *rpc)
|
||||
|
||||
/* Do RPC to umountd. */
|
||||
|
||||
memset(&mountd, 0, sizeof(struct call_args_mount));
|
||||
memset(&mountd, 0, sizeof(struct rpc_call_mount));
|
||||
memset(&mdata, 0, sizeof(struct rpc_reply_mount));
|
||||
|
||||
strncpy(mountd.rpath, rpc->rc_path, 92);
|
||||
mountd.len = txdr_unsigned(sizeof(mountd.rpath));
|
||||
strncpy(mountd.mount.rpath, rpc->rc_path, 92);
|
||||
mountd.mount.len = txdr_unsigned(sizeof(mountd.mount.rpath));
|
||||
|
||||
error = rpcclnt_request(rpc, RPCMNT_UMOUNT, RPCPROG_MNT, RPCMNT_VER1,
|
||||
(FAR const void *)&mountd, sizeof(struct call_args_mount),
|
||||
(FAR void *)&mountd, sizeof(struct call_args_mount),
|
||||
(FAR void *)&mdata, sizeof(struct rpc_reply_mount));
|
||||
if (error != 0)
|
||||
{
|
||||
@ -1237,75 +908,35 @@ bad:
|
||||
*/
|
||||
|
||||
int rpcclnt_request(FAR struct rpcclnt *rpc, int procnum, int prog,
|
||||
int version, FAR const void *request, size_t reqlen,
|
||||
int version, FAR void *request, size_t reqlen,
|
||||
FAR void *response, size_t resplen)
|
||||
{
|
||||
struct rpc_reply_header *replymsg;
|
||||
uint32_t tmp;
|
||||
uint32_t xid;
|
||||
int retries;
|
||||
int error = 0;
|
||||
|
||||
/* Set aside memory on the stack to hold the largest call message. NOTE
|
||||
* that the write call message does not appear in this list. It is a
|
||||
* special case because the full write call message will be provided in
|
||||
* user-provided I/O vuffer.
|
||||
/* Get a new (non-zero) xid */
|
||||
|
||||
xid = rpcclnt_newxid();
|
||||
|
||||
/* Initialize the RPC header fields */
|
||||
|
||||
rpcclnt_fmtheader((FAR struct rpc_call_header *)request,
|
||||
xid, prog, version, procnum);
|
||||
|
||||
/* Get the full size of the message (the size of variable data plus the size of
|
||||
* the messages header).
|
||||
*/
|
||||
|
||||
union
|
||||
{
|
||||
struct rpc_call_pmap pmap;
|
||||
struct rpc_call_mount mountd;
|
||||
struct rpc_call_create create;
|
||||
struct rpc_call_lookup lookup;
|
||||
struct rpc_call_read read;
|
||||
struct rpc_call_remove removef;
|
||||
struct rpc_call_rename renamef;
|
||||
struct rpc_call_mkdir mkdir;
|
||||
struct rpc_call_rmdir rmdir;
|
||||
struct rpc_call_readdir readdir;
|
||||
struct rpc_call_fs fs;
|
||||
} u;
|
||||
FAR void *callmsg;
|
||||
|
||||
/* Handle a nasty special case... the NFS WRITE call message will reside
|
||||
* in a use provided I/O buffer, not in our local call message buffer.
|
||||
*/
|
||||
|
||||
if (prog == NFS_PROG && procnum == NFSPROC_WRITE)
|
||||
{
|
||||
/* User the caller provided I/O buffer. The data to be written has
|
||||
* already been copied into the correct offset by the calling.
|
||||
* rpcclnt_buildheader will need only to initialize the header and
|
||||
* update the call messsage size.
|
||||
*/
|
||||
|
||||
callmsg = (FAR void *)request;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Clear the local call message memory. rpcclnt_buildheader will
|
||||
* need to initialie the header and copy the user RPC arguments into
|
||||
* this buffer.
|
||||
*/
|
||||
|
||||
memset(&u, 0, sizeof(u));
|
||||
callmsg = (FAR void *)&u;
|
||||
}
|
||||
|
||||
/* Construct the RPC call messasge header */
|
||||
|
||||
error = rpcclnt_buildheader(rpc, procnum, prog, version,
|
||||
request, &reqlen, callmsg);
|
||||
if (error != OK)
|
||||
{
|
||||
fdbg("ERROR: Building call header error\n");
|
||||
return error;
|
||||
}
|
||||
reqlen += sizeof(struct rpc_call_header);
|
||||
|
||||
/* Send the RPC call messsages and receive the RPC response. A limited
|
||||
* number of re-tries will be attempted, but only for the case of response
|
||||
* timeouts.
|
||||
*/
|
||||
|
||||
retries = 0;
|
||||
do
|
||||
{
|
||||
@ -1315,7 +946,7 @@ int rpcclnt_request(FAR struct rpcclnt *rpc, int procnum, int prog,
|
||||
|
||||
/* Send the RPC CALL message */
|
||||
|
||||
error = rpcclnt_send(rpc, procnum, prog, callmsg, reqlen);
|
||||
error = rpcclnt_send(rpc, procnum, prog, request, reqlen);
|
||||
if (error != OK)
|
||||
{
|
||||
fvdbg("ERROR rpcclnt_send failed: %d\n", error);
|
||||
@ -1344,7 +975,7 @@ int rpcclnt_request(FAR struct rpcclnt *rpc, int procnum, int prog,
|
||||
|
||||
/* Break down the RPC header and check if it is OK */
|
||||
|
||||
replymsg = (FAR struct rpc_reply_header*)response;
|
||||
replymsg = (FAR struct rpc_reply_header *)response;
|
||||
|
||||
tmp = fxdr_unsigned(uint32_t, replymsg->type);
|
||||
if (tmp == RPC_MSGDENIED)
|
||||
|
Loading…
Reference in New Issue
Block a user