summaryrefslogtreecommitdiff
path: root/nuttx/fs/nfs
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-05 23:17:25 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-05-05 23:17:25 +0000
commit5ec5d2ad4dc73eb8235d42f6b823754b53d7223d (patch)
tree3d90f49b12de4032eef21df067f4d2dff75a3221 /nuttx/fs/nfs
parentfffb5bd4f05cf422e06f650f4d13b40fe9675463 (diff)
downloadpx4-nuttx-5ec5d2ad4dc73eb8235d42f6b823754b53d7223d.tar.gz
px4-nuttx-5ec5d2ad4dc73eb8235d42f6b823754b53d7223d.tar.bz2
px4-nuttx-5ec5d2ad4dc73eb8235d42f6b823754b53d7223d.zip
Add GPIO support to STMPE11 driver; NFS update
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4701 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/fs/nfs')
-rw-r--r--nuttx/fs/nfs/nfs_mount.h2
-rw-r--r--nuttx/fs/nfs/nfs_socket.c21
-rw-r--r--nuttx/fs/nfs/nfs_vfsops.c198
-rw-r--r--nuttx/fs/nfs/rpc_clnt.c52
4 files changed, 125 insertions, 148 deletions
diff --git a/nuttx/fs/nfs/nfs_mount.h b/nuttx/fs/nfs/nfs_mount.h
index bfd5035bd..26b3eb2f9 100644
--- a/nuttx/fs/nfs/nfs_mount.h
+++ b/nuttx/fs/nfs/nfs_mount.h
@@ -81,7 +81,7 @@ struct nfsmount
uint8_t nm_sotype; /* Type of socket */
uint8_t nm_soproto; /* and protocol */
uint8_t nm_soflags; /* pr_flags for socket protocol */
- struct sockaddr *nm_nam; /* Addr of server */
+ struct sockaddr nm_nam; /* Addr of server */
int nm_timeo; /* Init timer for NFSMNT_DUMBTIMR */
int nm_retry; /* Max retries */
int nm_srtt[4]; /* Timers for rpcs */
diff --git a/nuttx/fs/nfs/nfs_socket.c b/nuttx/fs/nfs/nfs_socket.c
index 0dc8860a0..93e84c0e6 100644
--- a/nuttx/fs/nfs/nfs_socket.c
+++ b/nuttx/fs/nfs/nfs_socket.c
@@ -145,7 +145,7 @@ int nfs_connect(struct nfsmount *nmp)
rpc->rc_authtype = RPCAUTH_NULL; /* for now */
//rpc->rc_servername = nmp->nm_mountp->mnt_stat.f_mntfromname;
- rpc->rc_name = nmp->nm_nam;
+ rpc->rc_name = &nmp->nm_nam;
rpc->rc_sotype = nmp->nm_sotype;
rpc->rc_soproto = nmp->nm_soproto;
@@ -184,30 +184,21 @@ int nfs_request(struct nfsmount *nmp, int procnum, void *datain, void *dataout)
{
int error;
struct rpcclnt *clnt= nmp->nm_rpcclnt;
- struct rpc_reply *reply;
+ struct rpc_reply reply;
int trylater_delay;
- /* Create an instance of the reply state structure */
-
- reply = (struct rpc_reply *)kzalloc(sizeof(struct rpc_reply));
- if (!reply)
- {
- fdbg("Failed to allocate reply structure\n");
- return -ENOMEM;
- }
-
tryagain:
- if ((error = rpcclnt_request(clnt, procnum, reply, datain)) != 0)
+ if ((error = rpcclnt_request(clnt, procnum, &reply, datain)) != 0)
{
goto out;
}
- dataout = &reply->stat.where;
+ bcopy (dataout, &reply.stat.where, sizeof(reply.stat.where));
- if (reply->rpc_verfi.authtype != 0)
+ if (reply.rpc_verfi.authtype != 0)
{
- error = fxdr_unsigned(int, reply->rpc_verfi.authtype);
+ error = fxdr_unsigned(int, reply.rpc_verfi.authtype);
if ((nmp->nm_flag & NFSMNT_NFSV3) && error == NFSERR_TRYLATER)
{
diff --git a/nuttx/fs/nfs/nfs_vfsops.c b/nuttx/fs/nfs/nfs_vfsops.c
index ae5ef8585..e0e20839c 100644
--- a/nuttx/fs/nfs/nfs_vfsops.c
+++ b/nuttx/fs/nfs/nfs_vfsops.c
@@ -185,7 +185,7 @@ nfs_open(FAR struct file *filep, FAR const char *relpath,
struct nfsmount *nmp;
struct nfsnode *np;
struct CREATE3args create;
- struct CREATE3resok *resok;
+ struct CREATE3resok resok;
void *datareply;
int error = 0;
@@ -219,6 +219,8 @@ nfs_open(FAR struct file *filep, FAR const char *relpath,
DEBUGASSERT(filep->f_priv == NULL);
again:
nfsstats.rpccnt[NFSPROC_CREATE]++;
+ memset(&sp, 0, sizeof(struct nfsv3_sattr));
+ memset(&vap, 0, sizeof(struct nfs_fattr));
vap = nmp->nm_head->n_fattr;
sp.sa_modetrue = true;
sp.sa_mode = txdr_unsigned(vap.fa_mode);
@@ -230,6 +232,7 @@ again:
sp.sa_atime = vap.fa3_atime;
sp.sa_mtime = vap.fa3_mtime;
+ memset(&create, 0, sizeof(struct CREATE3args));
create.how = sp;
create.where.dir = nmp->nm_fh;
create.where.name = relpath;
@@ -253,14 +256,14 @@ again:
* non-zero elements)
*/
- resok = (struct CREATE3resok *) datareply;
+ bcopy (datareply, &resok, sizeof(struct CREATE3resok));
np->n_open = true;
np->nfsv3_type = NFREG;
- np->n_fhp = resok->handle;
- np->n_size = fxdr_hyper(&resok->attributes.fa3_size);
- np->n_fattr = resok->attributes;
- fxdr_nfsv3time(&resok->attributes.fa3_mtime, &np->n_mtime)
- np->n_ctime = fxdr_hyper(&resok->attributes.fa3_ctime);
+ np->n_fhp = resok.handle;
+ np->n_size = fxdr_hyper(&resok.attributes.fa3_size);
+ np->n_fattr = resok.attributes;
+ fxdr_nfsv3time(&resok.attributes.fa3_mtime, &np->n_mtime)
+ np->n_ctime = fxdr_hyper(&resok.attributes.fa3_ctime);
/* Attach the private date to the struct file instance */
@@ -361,7 +364,7 @@ static ssize_t nfs_read(FAR struct file *filep, char *buffer, size_t buflen)
uint64_t offset;
void *datareply;
struct READ3args read;
- struct READ3resok *resok;
+ struct READ3resok resok;
uint8_t *userbuffer = (uint8_t*)buffer;
int error = 0;
int len;
@@ -427,6 +430,7 @@ static ssize_t nfs_read(FAR struct file *filep, char *buffer, size_t buflen)
nfsstats.rpccnt[NFSPROC_READ]++;
again:
+ memset(&read, 0, sizeof(struct READ3args));
read.file = np->nfsv3_type;
read.count = buflen;
read.offset = offset;
@@ -437,13 +441,13 @@ again:
goto errout_with_semaphore;
}
- resok = (struct READ3resok *) datareply;
- eof = resok->eof;
+ bcopy (datareply, &resok, sizeof(struct READ3resok));
+ eof = resok.eof;
if (eof == true)
{
- readsize = resok->count;
- np->n_fattr = resok->file_attributes;
- memcpy(userbuffer, resok->data, readsize);
+ readsize = resok.count;
+ np->n_fattr = resok.file_attributes;
+ memcpy(userbuffer, resok.data, readsize);
}
else
{
@@ -471,7 +475,7 @@ nfs_write(FAR struct file *filep, const char *buffer, size_t buflen)
unsigned int writesize;
void *datareply;
struct WRITE3args write;
- struct WRITE3resok *resok;
+ struct WRITE3resok resok;
uint8_t *userbuffer = (uint8_t*)buffer;
int error = 0;
uint64_t offset;
@@ -518,6 +522,7 @@ nfs_write(FAR struct file *filep, const char *buffer, size_t buflen)
writesize = 0;
nfsstats.rpccnt[NFSPROC_WRITE]++;
+ memset(&write, 0, sizeof(struct WRITE3args));
write.file = np->nfsv3_type;
write.offset = offset;
write.count = buflen;
@@ -530,16 +535,16 @@ nfs_write(FAR struct file *filep, const char *buffer, size_t buflen)
goto errout_with_semaphore;
}
- resok = (struct WRITE3resok *)datareply;
- writesize = resok->count;
+ bcopy (datareply, &resok, sizeof(struct WRITE3resok));
+ writesize = resok.count;
if (writesize == 0)
{
error = NFSERR_IO;
goto errout_with_semaphore;
}
- commit = resok->committed;
- np->n_fattr = resok->file_wcc.after;
+ commit = resok.committed;
+ np->n_fattr = resok.file_wcc.after;
/* Return the lowest committment level obtained by any of the RPCs. */
@@ -555,12 +560,12 @@ nfs_write(FAR struct file *filep, const char *buffer, size_t buflen)
if ((nmp->nm_flag & NFSMNT_HASWRITEVERF) == 0)
{
- bcopy((void*) resok->verf, (void*) nmp->nm_verf, NFSX_V3WRITEVERF);
+ bcopy((void*) resok.verf, (void*) nmp->nm_verf, NFSX_V3WRITEVERF);
nmp->nm_flag |= NFSMNT_HASWRITEVERF;
}
- else if (strncmp((char*) resok->verf, (char*) nmp->nm_verf, NFSX_V3WRITEVERF))
+ else if (strncmp((char*) resok.verf, (char*) nmp->nm_verf, NFSX_V3WRITEVERF))
{
- bcopy((void*) resok->verf, (void*) nmp->nm_verf, NFSX_V3WRITEVERF);
+ bcopy((void*) resok.verf, (void*) nmp->nm_verf, NFSX_V3WRITEVERF);
}
fxdr_nfsv3time(&np->n_fattr.fa3_mtime, &np->n_mtime)
@@ -585,7 +590,7 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
int error = 0;
void *datareply = NULL;
struct READDIR3args readir;
- struct READDIR3resok *resok;
+ struct READDIR3resok resok;
/* Loop around doing readdir rpc's of size nm_readdirsize
* truncated to a multiple of NFS_READDIRBLKSIZ.
@@ -595,6 +600,7 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
while (end_of_directory == false)
{
nfsstats.rpccnt[NFSPROC_READDIR]++;
+ memset(&readir, 0, sizeof(struct READDIR3args));
readir.dir = np->n_fhp;
readir.count = nmp->nm_readdirsize;
if (nfsstats.rpccnt[NFSPROC_READDIR] == 1)
@@ -619,17 +625,17 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
goto nfsmout;
}
- resok = (struct READDIR3resok*) datareply;
- np->n_fattr = resok->dir_attributes;
- np->n_cookieverf.nfsuquad[0] = resok->cookieverf.nfsuquad[0];
- np->n_cookieverf.nfsuquad[1] = resok->cookieverf.nfsuquad[1];
- dir->fd_dir.d_type = resok->reply.entries->fileid;
- memcpy(&dir->fd_dir.d_name[NAME_MAX], &resok->reply.entries->name, NAME_MAX);
+ bcopy (datareply, &resok, sizeof(struct READDIR3resok));
+ np->n_fattr = resok.dir_attributes;
+ np->n_cookieverf.nfsuquad[0] = resok.cookieverf.nfsuquad[0];
+ np->n_cookieverf.nfsuquad[1] = resok.cookieverf.nfsuquad[1];
+ dir->fd_dir.d_type = resok.reply.entries->fileid;
+ memcpy(&dir->fd_dir.d_name[NAME_MAX], &resok.reply.entries->name, NAME_MAX);
//dir->fd_dir.d_name = resok->reply.entries->name;//
- dir->u.nfs.cookie[0] = resok->reply.entries->cookie.nfsuquad[0];
- dir->u.nfs.cookie[1] = resok->reply.entries->cookie.nfsuquad[1];
+ dir->u.nfs.cookie[0] = resok.reply.entries->cookie.nfsuquad[0];
+ dir->u.nfs.cookie[1] = resok.reply.entries->cookie.nfsuquad[1];
- if(resok->reply.eof == true)
+ if (resok.reply.eof == true)
{
end_of_directory = true;
}
@@ -661,7 +667,7 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
/* We are now either at the end of the directory */
- if (resok->reply.entries == NULL)
+ if (resok.reply.entries == NULL)
{
np->n_direofoffset = fxdr_hyper(&dir->u.nfs.cookie[0]);
@@ -1050,6 +1056,8 @@ int mountnfs(struct nfs_args *argp, void **handle)
bad:
nfs_disconnect(nmp);
sem_destroy(&nmp->nm_sem);
+ kfree(nmp->nm_so);
+ kfree(nmp->nm_rpcclnt);
kfree(nmp);
return error;
}
@@ -1152,6 +1160,8 @@ int nfs_unbind(void *handle, struct inode **blkdriver)
nfs_disconnect(nmp);
sem_destroy(&nmp->nm_sem);
+ kfree(nmp->nm_so);
+ kfree(nmp->nm_rpcclnt);
kfree(nmp);
return 0;
@@ -1170,13 +1180,12 @@ int nfs_unbind(void *handle, struct inode **blkdriver)
static int nfs_statfs(struct inode *mountpt, struct statfs *sbp)
{
- struct nfs_statfs *sfp;
+ struct nfs_statfs sfp;
struct nfsmount *nmp;
int error = 0;
uint64_t tquad;
void *datareply;
struct FSSTAT3args fsstat;
- int info_v3;
/* Sanity checks */
@@ -1185,7 +1194,6 @@ static int nfs_statfs(struct inode *mountpt, struct statfs *sbp)
/* Get the mountpoint private data from the inode structure */
nmp = (struct nfsmount*)mountpt->i_private;
- info_v3 = (nmp->nm_flag & NFSMNT_NFSV3);
/* Check if the mount is still healthy */
@@ -1202,12 +1210,13 @@ static int nfs_statfs(struct inode *mountpt, struct statfs *sbp)
memset(sbp, 0, sizeof(struct statfs));
sbp->f_type = NFS_SUPER_MAGIC;
- if (info_v3 && (nmp->nm_flag & NFSMNT_GOTFSINFO) == 0)
+ if ((nmp->nm_flag & NFSMNT_GOTFSINFO) == 0)
{
(void)nfs_fsinfo(mountpt, NULL, NULL);
}
nfsstats.rpccnt[NFSPROC_FSSTAT]++;
+ memset(&fsstat, 0, sizeof(struct FSSTAT3args));
fsstat.fsroot = nmp->nm_fh;
error = nfs_request(nmp, NFSPROC_FSSTAT, &fsstat, datareply);
if (error)
@@ -1215,33 +1224,20 @@ static int nfs_statfs(struct inode *mountpt, struct statfs *sbp)
goto errout_with_semaphore;
}
- sfp = (struct nfs_statfs *)datareply;
- nmp->nm_head->n_fattr = sfp->obj_attributes;
- if (info_v3)
- {
- sbp->f_bsize = NFS_FABLKSIZE;
- tquad = fxdr_hyper(&sfp->sf_tbytes);
- sbp->f_blocks = tquad / (uint64_t) NFS_FABLKSIZE;
- tquad = fxdr_hyper(&sfp->sf_fbytes);
- sbp->f_bfree = tquad / (uint64_t) NFS_FABLKSIZE;
- tquad = fxdr_hyper(&sfp->sf_abytes);
- sbp->f_bavail = tquad / (uint64_t) NFS_FABLKSIZE;
-
- tquad = fxdr_hyper(&sfp->sf_tfiles);
- sbp->f_files = tquad;
- tquad = fxdr_hyper(&sfp->sf_ffiles);
- sbp->f_ffree = tquad;
- sbp->f_namelen = NAME_MAX;
- }
- else
- {
- sbp->f_bsize = fxdr_unsigned(int32_t, sfp->sf_bsize);
- sbp->f_blocks = fxdr_unsigned(int32_t, sfp->sf_blocks);
- sbp->f_bfree = fxdr_unsigned(int32_t, sfp->sf_bfree);
- sbp->f_bavail = fxdr_unsigned(int32_t, sfp->sf_bavail);
- sbp->f_files = 0;
- sbp->f_ffree = 0;
- }
+ bcopy (datareply, &sfp, sizeof(struct nfs_statfs));
+ nmp->nm_head->n_fattr = sfp.obj_attributes;
+ sbp->f_bsize = NFS_FABLKSIZE;
+ tquad = fxdr_hyper(&sfp.sf_tbytes);
+ sbp->f_blocks = tquad / (uint64_t) NFS_FABLKSIZE;
+ tquad = fxdr_hyper(&sfp.sf_fbytes);
+ sbp->f_bfree = tquad / (uint64_t) NFS_FABLKSIZE;
+ tquad = fxdr_hyper(&sfp.sf_abytes);
+ sbp->f_bavail = tquad / (uint64_t) NFS_FABLKSIZE;
+ tquad = fxdr_hyper(&sfp.sf_tfiles);
+ sbp->f_files = tquad;
+ tquad = fxdr_hyper(&sfp.sf_ffiles);
+ sbp->f_ffree = tquad;
+ sbp->f_namelen = NAME_MAX;
errout_with_semaphore:
nfs_semgive(nmp);
@@ -1261,7 +1257,7 @@ static int nfs_remove(struct inode *mountpt, const char *relpath)
struct nfsnode *np;
void *datareply;
struct REMOVE3args remove;
- struct REMOVE3resok *resok;
+ struct REMOVE3resok resok;
int error = 0;
/* Sanity checks */
@@ -1295,6 +1291,7 @@ static int nfs_remove(struct inode *mountpt, const char *relpath)
/* Do the rpc */
nfsstats.rpccnt[NFSPROC_REMOVE]++;
+ memset(&remove, 0, sizeof(struct REMOVE3args));
remove.object.dir = np->n_fhp;
remove.object.name = relpath;
@@ -1316,8 +1313,8 @@ static int nfs_remove(struct inode *mountpt, const char *relpath)
goto errout_with_semaphore;
}
- resok = (struct REMOVE3resok *)datareply;
- np->n_fattr = resok->dir_wcc.after;
+ bcopy (datareply, &resok, sizeof(struct REMOVE3resok));
+ np->n_fattr = resok.dir_wcc.after;
np->n_flag |= NMODIFIED;
}
NFS_INVALIDATE_ATTRCACHE(np);
@@ -1336,12 +1333,12 @@ errout_with_semaphore:
static int nfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode)
{
- struct nfs_fattr *vap;
+//struct nfs_fattr *vap;
struct nfsv3_sattr sp;
struct nfsmount *nmp;
struct nfsnode *np;
struct MKDIR3args mkir;
- struct MKDIR3resok *resok;
+ struct MKDIR3resok resok;
void *datareply;
int error = 0;
@@ -1365,18 +1362,6 @@ static int nfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode)
goto errout_with_semaphore;
}
- /* Create an instance of the private data to describe the opened
- * file.
- */
-
- vap = (struct nfs_fattr*)kzalloc(sizeof(struct nfs_fattr));
- if (!vap)
- {
- fdbg("Failed to allocate private data\n", error);
- error = -ENOMEM;
- goto errout_with_semaphore;
- }
-
/* Check if the mount is still healthy */
nfs_semtake(nmp);
@@ -1387,19 +1372,20 @@ static int nfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode)
}
nfsstats.rpccnt[NFSPROC_MKDIR]++;
+ memset(&mkir, 0, sizeof(struct MKDIR3args));
mkir.where.dir = nmp->nm_fh;
mkir.where.name = relpath;
sp.sa_modetrue = nfs_true;
- sp.sa_mode = txdr_unsigned(vap->fa_mode);
+ sp.sa_mode = txdr_unsigned(mode);
sp.sa_uidfalse = nfs_xdrneg1;
sp.sa_gidfalse = nfs_xdrneg1;
sp.sa_sizefalse = nfs_xdrneg1;
sp.sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
sp.sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
-//fxdr_nfsv3time2(vap->fa3_atime, &sp.sa_atime);
-//fxdr_nfsv3time2(vap->fa3_mtime, &sp.sa_mtime);
+ memset(&sp.sa_atime, 0, sizeof(nfstime3));
+ memset(&sp.sa_mtime, 0, sizeof(nfstime3));
mkir.attributes = sp;
@@ -1409,10 +1395,10 @@ static int nfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode)
goto errout_with_semaphore;
}
- resok = (struct MKDIR3resok *) datareply;
+ bcopy (datareply, &resok, sizeof(struct MKDIR3resok));
np->nfsv3_type = NFDIR;
- np->n_fhp = resok->handle;
- np->n_fattr = resok->obj_attributes;
+ np->n_fhp = resok.handle;
+ np->n_fattr = resok.obj_attributes;
np->n_flag |= NMODIFIED;
nmp->nm_head = np;
@@ -1436,7 +1422,7 @@ static int nfs_rmdir(struct inode *mountpt, const char *relpath)
struct nfsmount *nmp;
struct nfsnode *np;
struct RMDIR3args rmdir;
- struct RMDIR3resok *resok;
+ struct RMDIR3resok resok;
void *datareply;
int error = 0;
@@ -1466,6 +1452,7 @@ static int nfs_rmdir(struct inode *mountpt, const char *relpath)
/* Do the rpc */
nfsstats.rpccnt[NFSPROC_RMDIR]++;
+ memset(&rmdir, 0, sizeof(struct RMDIR3args));
rmdir.object.dir = np->n_fhp;
rmdir.object.name = relpath;
error = nfs_request(nmp, NFSPROC_RMDIR, &rmdir, datareply);
@@ -1480,8 +1467,8 @@ static int nfs_rmdir(struct inode *mountpt, const char *relpath)
goto errout_with_semaphore;
}
- resok = (struct RMDIR3resok *)datareply;
- np->n_fattr = resok->dir_wcc.after;
+ bcopy (datareply, &resok, sizeof(struct RMDIR3resok));
+ np->n_fattr = resok.dir_wcc.after;
np->n_flag |= NMODIFIED;
}
@@ -1506,7 +1493,7 @@ static int nfs_rename(struct inode *mountpt, const char *oldrelpath,
struct nfsnode *np;
void *datareply;
struct RENAME3args rename;
- struct RENAME3resok *resok;
+ struct RENAME3resok resok;
int error = 0;
/* Sanity checks */
@@ -1535,6 +1522,7 @@ static int nfs_rename(struct inode *mountpt, const char *oldrelpath,
}
nfsstats.rpccnt[NFSPROC_RENAME]++;
+ memset(&rename, 0, sizeof(struct RENAME3args));
rename.from.dir = np->n_fhp;
rename.from.name = oldrelpath;
rename.to.dir = np->n_fhp;
@@ -1554,8 +1542,8 @@ static int nfs_rename(struct inode *mountpt, const char *oldrelpath,
goto errout_with_semaphore;
}
- resok = (struct RENAME3resok *) datareply;
- np->n_fattr = resok->todir_wcc.after;
+ bcopy (datareply, &resok, sizeof(struct RENAME3resok));
+ np->n_fattr = resok.todir_wcc.after;
np->n_flag |= NMODIFIED;
NFS_INVALIDATE_ATTRCACHE(np);
@@ -1573,7 +1561,7 @@ errout_with_semaphore:
static int nfs_fsinfo(struct inode *mountpt, const char *relpath, struct stat *buf)
{
- struct nfsv3_fsinfo *fsp;
+ struct nfsv3_fsinfo fsp;
struct FSINFOargs fsinfo;
struct nfsmount *nmp;
uint32_t pref, max;
@@ -1606,15 +1594,15 @@ static int nfs_fsinfo(struct inode *mountpt, const char *relpath, struct stat *b
goto errout_with_semaphore;
}
- fsp = (struct nfsv3_fsinfo *)datareply;
- nmp->nm_head->n_fattr = fsp->obj_attributes;
- pref = fxdr_unsigned(uint32_t, fsp->fs_wtpref);
+ bcopy (datareply, &fsp, sizeof(struct nfsv3_fsinfo));
+ nmp->nm_head->n_fattr = fsp.obj_attributes;
+ pref = fxdr_unsigned(uint32_t, fsp.fs_wtpref);
if (pref < nmp->nm_wsize)
{
nmp->nm_wsize = (pref + NFS_FABLKSIZE - 1) & ~(NFS_FABLKSIZE - 1);
}
- max = fxdr_unsigned(uint32_t, fsp->fs_wtmax);
+ max = fxdr_unsigned(uint32_t, fsp.fs_wtmax);
if (max < nmp->nm_wsize)
{
nmp->nm_wsize = max & ~(NFS_FABLKSIZE - 1);
@@ -1622,13 +1610,13 @@ static int nfs_fsinfo(struct inode *mountpt, const char *relpath, struct stat *b
nmp->nm_wsize = max;
}
- pref = fxdr_unsigned(uint32_t, fsp->fs_rtpref);
+ pref = fxdr_unsigned(uint32_t, fsp.fs_rtpref);
if (pref < nmp->nm_rsize)
{
nmp->nm_rsize = (pref + NFS_FABLKSIZE - 1) & ~(NFS_FABLKSIZE - 1);
}
- max = fxdr_unsigned(uint32_t, fsp->fs_rtmax);
+ max = fxdr_unsigned(uint32_t, fsp.fs_rtmax);
if (max < nmp->nm_rsize)
{
nmp->nm_rsize = max & ~(NFS_FABLKSIZE - 1);
@@ -1638,7 +1626,7 @@ static int nfs_fsinfo(struct inode *mountpt, const char *relpath, struct stat *b
}
}
- pref = fxdr_unsigned(uint32_t, fsp->fs_dtpref);
+ pref = fxdr_unsigned(uint32_t, fsp.fs_dtpref);
if (pref < nmp->nm_readdirsize)
{
nmp->nm_readdirsize = (pref + NFS_DIRBLKSIZ - 1) & ~(NFS_DIRBLKSIZ - 1);
@@ -1653,13 +1641,13 @@ static int nfs_fsinfo(struct inode *mountpt, const char *relpath, struct stat *b
}
}
- buf->st_mode = fxdr_hyper(&fsp->obj_attributes.fa_mode);
- buf->st_size = fxdr_hyper(&fsp->obj_attributes.fa3_size);
+ buf->st_mode = fxdr_hyper(&fsp.obj_attributes.fa_mode);
+ buf->st_size = fxdr_hyper(&fsp.obj_attributes.fa3_size);
buf->st_blksize = 0;
buf->st_blocks = 0;
- buf->st_mtime = fxdr_hyper(&fsp->obj_attributes.fa3_mtime);
- buf->st_atime = fxdr_hyper(&fsp->obj_attributes.fa3_atime);
- buf->st_ctime = fxdr_hyper(&fsp->obj_attributes.fa3_ctime);
+ buf->st_mtime = fxdr_hyper(&fsp.obj_attributes.fa3_mtime);
+ buf->st_atime = fxdr_hyper(&fsp.obj_attributes.fa3_atime);
+ buf->st_ctime = fxdr_hyper(&fsp.obj_attributes.fa3_ctime);
nmp->nm_flag |= NFSMNT_GOTFSINFO;
errout_with_semaphore:
diff --git a/nuttx/fs/nfs/rpc_clnt.c b/nuttx/fs/nfs/rpc_clnt.c
index a7e7f5a1c..af14d69a9 100644
--- a/nuttx/fs/nfs/rpc_clnt.c
+++ b/nuttx/fs/nfs/rpc_clnt.c
@@ -194,8 +194,8 @@ static uint32_t rpcclnt_xid = 0;
static uint32_t rpcclnt_xid_touched = 0;
int rpcclnt_ticks;
struct rpcstats rpcstats;
-struct rpc_call *callmgs;
-struct rpc_reply *replymsg;
+//struct rpc_call *callmgs;
+//struct rpc_reply *replymsg;
/* Queue head for rpctask's */
@@ -223,7 +223,7 @@ static int rpcclnt_sigintr(struct rpcclnt *, struct rpctask *, cthread_t *);
static void rpcclnt_softterm(struct rpctask *task);
static uint32_t rpcclnt_proct(struct rpcclnt *, uint32_t);
-static int rpcclnt_buildheader(struct rpcclnt *, int, int, void *, struct rpc_call *);
+static int rpcclnt_buildheader(struct rpcclnt *, int, void *, struct rpc_call *);
/****************************************************************************
* Private Functions
@@ -293,9 +293,7 @@ rpcclnt_send(struct socket *so, struct sockaddr *nam, struct rpc_call *call,
flags = 0;
}
- error =
- psock_sendto(so, call, sizeof(*call), flags, sendnam, sizeof(*sendnam));
-
+ error = psock_sendto(so, call, sizeof(*call), flags, sendnam, sizeof(*sendnam));
if (error != 0)
{
if (rep != NULL)
@@ -567,7 +565,7 @@ static int rpcclnt_receive(struct rpctask *rep, struct sockaddr *aname,
*/
static int
-rpcclnt_reply(struct rpctask *myrep, struct rpc_call *call,
+rpcclnt_reply(struct rpctask *myrep, struct rpc_call *call, //Here we need to make changes for debugging
struct rpc_reply *reply)
{
struct rpctask *rep;
@@ -624,7 +622,6 @@ rpcclnt_reply(struct rpctask *myrep, struct rpc_call *call,
rxid = reply->rp_xid;
- /*
if (reply->rp_direction != rpc_reply)
{
rpcstats.rpcinvalid++;
@@ -635,7 +632,6 @@ rpcclnt_reply(struct rpctask *myrep, struct rpc_call *call,
continue;
}
- */
/* Loop through the request list to match up the reply Iff no
* match, just drop the datagram
@@ -956,7 +952,8 @@ int rpcclnt_connect(struct rpcclnt *rpc)
/* Create the socket */
saddr = rpc->rc_name;
-
+ memset(&sin, 0, sizeof(sin));
+
/* Create an instance of the socket state structure */
so = (struct socket *)kzalloc(sizeof(struct socket));
@@ -965,7 +962,7 @@ int rpcclnt_connect(struct rpcclnt *rpc)
fdbg("Failed to allocate socket structure\n");
return -ENOMEM;
}
-
+
error =
psock_socket(saddr->sa_family, rpc->rc_sotype, rpc->rc_soproto, so);
@@ -1103,7 +1100,6 @@ void rpcclnt_disconnect(struct rpcclnt *rpc)
if (rpc->rc_so != NULL)
{
so = rpc->rc_so;
- rpc->rc_so = NULL;
(void)psock_close(so);
}
}
@@ -1126,10 +1122,7 @@ void rpcclnt_safedisconnect(struct rpcclnt *rpc)
/* Code from nfs_request - goes something like this - fill in task struct -
* links task into list - calls nfs_send() for first transmit - calls
* nfs_receive() to get reply - fills in reply (which should be initialized
- * prior to calling), which is valid when 0 is returned and is NEVER freed in
- * this function
- *
- * always frees the request header, but NEVER frees 'mrest'
+ * prior to calling), which is valid when 0.
*
* note that reply->result_* are invalid unless reply->type ==
* RPC_MSGACCEPTED and reply->status == RPC_SUCCESS and that reply->verf_*
@@ -1152,7 +1145,7 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, struct rpc_reply *reply, v
fdbg("Failed to allocate call msg structure\n");
return -ENOMEM;
}
-
+
/* Create an instance of the reply state structure */
replysvr = (struct rpc_reply *)kzalloc(sizeof(struct rpc_reply));
@@ -1161,7 +1154,7 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, struct rpc_reply *reply, v
fdbg("Failed to allocate reply msg structure\n");
return -ENOMEM;
}
-
+
/* Create an instance of the task state structure */
task = (struct rpctask *)kzalloc(sizeof(struct rpctask));
@@ -1170,16 +1163,16 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, struct rpc_reply *reply, v
fdbg("Failed to allocate reply msg structure\n");
return -ENOMEM;
}
-
- error = rpcclnt_buildheader(rpc, procnum, xid, datain, callhost);
+
+ error = rpcclnt_buildheader(rpc, procnum, datain, callhost);
if (error)
{
ndbg("building call header error");
goto rpcmout;
}
- task->r_rpcclnt = rpc;
- task->r_xid = fxdr_unsigned(uint32_t,xid);
+ task->r_rpcclnt = rpc;
+ task->r_xid = callhost->rp_xid;
task->r_procnum = procnum;
if (rpc->rc_flag & RPCCLNT_SOFT)
@@ -1210,7 +1203,7 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, struct rpc_reply *reply, v
* LAST so timer finds oldest requests first.
*/
- dq_addlast((struct dq_entry_t *)task, &rpctask_q);
+ dq_addlast(&task->r_chain, &rpctask_q);
/* If backing off another request or avoiding congestion, don't send
* this one now but let timer do it. If not timing a request, do it
@@ -1260,7 +1253,7 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, struct rpc_reply *reply, v
/* RPC done, unlink the request. */
- dq_rem((struct dq_entry_t *)task, &rpctask_q);
+ dq_rem(&task->r_chain, &rpctask_q);
/* Decrement the outstanding request count. */
@@ -1277,6 +1270,7 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, struct rpc_reply *reply, v
/* Break down the rpc header and check if ok */
+ memset(reply, 0, sizeof(rpc_reply));
reply->stat.type = fxdr_unsigned(uint32_t, replysvr->stat.type);
if (reply->stat.type == RPC_MSGDENIED)
{
@@ -1320,7 +1314,7 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, struct rpc_reply *reply, v
if (reply->stat.status == RPC_SUCCESS)
{
nvdbg("RPC_SUCCESS");
-
+
reply->stat.where = replysvr->stat.where;
}
else if (reply->stat.status == RPC_PROGMISMATCH)
@@ -1340,6 +1334,9 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, struct rpc_reply *reply, v
}
rpcmout:
+ kfree(callhost);
+ kfree(replysvr);
+ kfree(task);
RPC_RETURN(error);
}
@@ -1482,12 +1479,13 @@ void rpcclnt_timer(void *arg, struct rpc_call *call)
/* Build the RPC header and fill in the authorization info. */
int rpcclnt_buildheader(struct rpcclnt *rpc, int procid,
- int xidp, void *datain, struct rpc_call *call)
+ void *datain, struct rpc_call *call)
{
#ifdef CONFIG_NFS_UNIX_AUTH
struct timeval tv;
#endif
srand(time(NULL));
+ int xidp = 0;
/* The RPC header.*/
@@ -1509,7 +1507,7 @@ int rpcclnt_buildheader(struct rpcclnt *rpc, int procid,
rpcclnt_xid += xidp;
}
- call->rp_xid = xidp = txdr_unsigned(rpcclnt_xid);
+ call->rp_xid = txdr_unsigned(rpcclnt_xid);
call->rp_direction = rpc_call;
call->rp_rpcvers = rpc_vers;
call->rp_prog = txdr_unsigned(rpc->rc_prog->prog_id);