NFS... fix close() bug

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4839 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2012-06-14 01:37:10 +00:00
parent c0c2a8b2df
commit 906c5e8279
2 changed files with 25 additions and 19 deletions

View file

@ -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;
}

View file

@ -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;
}