aboutsummaryrefslogtreecommitdiff
path: root/nuttx/fs
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-16 14:14:14 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2013-01-16 14:14:14 +0000
commit77efc9f9cdd5828ab724b3355f0f0737bb15b579 (patch)
tree5c82c94b6cb8e68f1ffda9326d9cb2f108e5db86 /nuttx/fs
parentfcb316906d1741c28292e94eb7f09bd4d71ccb48 (diff)
downloadpx4-firmware-77efc9f9cdd5828ab724b3355f0f0737bb15b579.tar.gz
px4-firmware-77efc9f9cdd5828ab724b3355f0f0737bb15b579.tar.bz2
px4-firmware-77efc9f9cdd5828ab724b3355f0f0737bb15b579.zip
BINFS now supports open, close, and FIOC_FILENAME ioctl
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5522 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/fs')
-rw-r--r--nuttx/fs/nfs/nfs_vfsops.c61
-rw-r--r--nuttx/fs/nxffs/nxffs_open.c3
2 files changed, 37 insertions, 27 deletions
diff --git a/nuttx/fs/nfs/nfs_vfsops.c b/nuttx/fs/nfs/nfs_vfsops.c
index 01e999ac8..2ff4ff9d3 100644
--- a/nuttx/fs/nfs/nfs_vfsops.c
+++ b/nuttx/fs/nfs/nfs_vfsops.c
@@ -680,6 +680,7 @@ static int nfs_close(FAR struct file *filep)
FAR struct nfsnode *np;
FAR struct nfsnode *prev;
FAR struct nfsnode *curr;
+ int ret;
/* Sanity checks */
@@ -703,8 +704,7 @@ static int nfs_close(FAR struct file *filep)
if (np->n_crefs > 1)
{
np->n_crefs--;
- nfs_semgive(nmp);
- return OK;
+ ret = OK;
}
/* There are no more references to the file structure. Now we need to
@@ -714,38 +714,47 @@ static int nfs_close(FAR struct file *filep)
* containted in the mount structure.
*/
- for (prev = NULL, curr = nmp->nm_head; curr; prev = curr, curr = curr->n_next)
- {
- /* Check if this node is ours */
+ else
+ {
+ /* Assume file structure will not be found. This should never happen. */
+
+ ret = -EINVAL;
- if (np == curr)
- {
- /* Yes.. remove it from the list of file structures */
+ for (prev = NULL, curr = nmp->nm_head;
+ curr;
+ prev = curr, curr = curr->n_next)
+ {
+ /* Check if this node is ours */
+
+ if (np == curr)
+ {
+ /* Yes.. remove it from the list of file structures */
- if (prev)
- {
- /* Remove from mid-list */
+ if (prev)
+ {
+ /* Remove from mid-list */
- prev->n_next = np->n_next;
- }
- else
- {
- /* Remove from the head of the list */
+ prev->n_next = np->n_next;
+ }
+ else
+ {
+ /* Remove from the head of the list */
- nmp->nm_head = np->n_next;
- }
+ nmp->nm_head = np->n_next;
+ }
- /* Then deallocate the file structure and return success */
+ /* Then deallocate the file structure and return success */
- kfree(np);
- nfs_semgive(nmp);
- return OK;
- }
- }
+ kfree(np);
+ ret = OK;
+ break;
+ }
+ }
+ }
- fdbg("ERROR: file structure not found in list: %p\n", np);
+ filep->f_priv = NULL;
nfs_semgive(nmp);
- return EINVAL;
+ return ret;
}
/****************************************************************************
diff --git a/nuttx/fs/nxffs/nxffs_open.c b/nuttx/fs/nxffs/nxffs_open.c
index b1e99267f..9fa4ef2e0 100644
--- a/nuttx/fs/nxffs/nxffs_open.c
+++ b/nuttx/fs/nxffs/nxffs_open.c
@@ -1188,9 +1188,10 @@ int nxffs_close(FAR struct file *filep)
ofile->crefs--;
}
- filep->f_priv = NULL;
+ filep->f_priv = NULL;
sem_post(&volume->exclsem);
+
errout:
return ret;
}