mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-06-08 02:17:07 +08:00
NFS... fix close() bug
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4839 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
+10
-11
@@ -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;
|
||||
}
|
||||
|
||||
+15
-8
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user