summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-06-14 01:37:10 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-06-14 01:37:10 +0000
commit04caa18a834d94bd469e7c78971f677d4a17a401 (patch)
treeb261f2e0c822d538df14ccbde581bdcb3fd37ed9
parent68cef09eeafdbceef358b47ca3a6817600bdfc08 (diff)
downloadpx4-nuttx-04caa18a834d94bd469e7c78971f677d4a17a401.tar.gz
px4-nuttx-04caa18a834d94bd469e7c78971f677d4a17a401.tar.bz2
px4-nuttx-04caa18a834d94bd469e7c78971f677d4a17a401.zip
NFS... fix close() bug
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4839 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/fs/nfs/nfs_vfsops.c21
-rw-r--r--nuttx/fs/nfs/rpc_clnt.c23
2 files changed, 25 insertions, 19 deletions
diff --git a/nuttx/fs/nfs/nfs_vfsops.c b/nuttx/fs/nfs/nfs_vfsops.c
index cd8a5ab7a..c2d610a76 100644
--- a/nuttx/fs/nfs/nfs_vfsops.c
+++ b/nuttx/fs/nfs/nfs_vfsops.c
@@ -596,17 +596,16 @@ static int nfs_close(FAR struct file *filep)
FAR struct nfsnode *np;
FAR struct nfsnode *prev;
FAR struct nfsnode *curr;
- int error;
/* Sanity checks */
- DEBUGASSERT(filep->f_inode != NULL);
+ DEBUGASSERT(filep->f_priv != NULL && filep->f_inode != NULL);
- /* Get the mountpoint inode reference from the file structure and the
- * mountpoint private data from the inode structure
- */
+ /* Recover our private data from the struct file instance */
+
+ nmp = (struct nfsmount*) filep->f_inode->i_private;
+ np = (struct nfsnode*) filep->f_priv;
- nmp = (struct nfsmount*)filep->f_inode->i_private;
DEBUGASSERT(nmp != NULL);
/* Get exclusive access to the mount structure. */
@@ -617,7 +616,6 @@ static int nfs_close(FAR struct file *filep)
* mount structure.
*/
- error = EINVAL;
for (prev = NULL, curr = nmp->nm_head; curr; prev = curr, curr = curr->n_next)
{
/* Check if this node is ours */
@@ -642,13 +640,14 @@ static int nfs_close(FAR struct file *filep)
/* Then deallocate the file structure and return success */
kfree(np);
- error = OK;
- break;
+ nfs_semgive(nmp);
+ return OK;
}
}
+ fdbg("ERROR: file structure not found in list: %p\n", np);
nfs_semgive(nmp);
- return error;
+ return EINVAL;
}
/****************************************************************************
@@ -1692,7 +1691,7 @@ int nfs_unbind(FAR void *handle, FAR struct inode **blkdriver)
if (nmp->nm_head != NULL)
{
- fdbg("ERROR; There are open files\n");
+ fdbg("ERROR; There are open files: %p\n", nmp->nm_head);
error = EBUSY;
goto errout_with_semaphore;
}
diff --git a/nuttx/fs/nfs/rpc_clnt.c b/nuttx/fs/nfs/rpc_clnt.c
index 0dcb7f2b7..705dad359 100644
--- a/nuttx/fs/nfs/rpc_clnt.c
+++ b/nuttx/fs/nfs/rpc_clnt.c
@@ -571,7 +571,9 @@ int rpcclnt_umount(struct rpcclnt *rpc)
struct rpc_reply_pmap rdata;
struct rpc_call_mount mountd;
struct rpc_reply_mount mdata;
+ uint32_t tmp;
int error;
+ int ret;
saddr = rpc->rc_name;
sa = (FAR struct sockaddr_in *)saddr;
@@ -582,10 +584,12 @@ int rpcclnt_umount(struct rpcclnt *rpc)
sa->sin_port = htons(PMAPPORT);
- error = psock_connect(rpc->rc_so, saddr, sizeof(*saddr));
- if (error)
+ ret = psock_connect(rpc->rc_so, saddr, sizeof(*saddr));
+ if (ret < 0)
{
- fdbg("psock_connect MOUNTD port returns %d\n", error);
+ error = errno;
+ fdbg("ERROR: psock_connect failed [port=%d]: %d\n",
+ ntohs(sa->sin_port), error);
goto bad;
}
@@ -605,10 +609,12 @@ int rpcclnt_umount(struct rpcclnt *rpc)
sa->sin_port = htons(fxdr_unsigned(uint32_t, rdata.pmap.port));
- error = psock_connect(rpc->rc_so, saddr, sizeof(*saddr));
- if (error)
+ ret = psock_connect(rpc->rc_so, saddr, sizeof(*saddr));
+ if (ret < 0)
{
- fdbg("psock_connect MOUNTD port returns %d\n", error);
+ error = errno;
+ fdbg("ERROR: psock_connect failed [port=%d]: %d\n",
+ ntohs(sa->sin_port), error);
goto bad;
}
@@ -626,9 +632,10 @@ int rpcclnt_umount(struct rpcclnt *rpc)
goto bad;
}
- if ((fxdr_unsigned(uint32_t, mdata.mount.status)) != 0)
+ tmp = fxdr_unsigned(uint32_t, mdata.mount.status);
+ if (tmp != 0)
{
- fdbg("error unmounting with the server %d\n", error);
+ fdbg("ERROR: Server returned umount status: %d\n", tmp);
goto bad;
}