From 77efc9f9cdd5828ab724b3355f0f0737bb15b579 Mon Sep 17 00:00:00 2001 From: patacongo Date: Wed, 16 Jan 2013 14:14:14 +0000 Subject: 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 --- nuttx/fs/nfs/nfs_vfsops.c | 61 ++++++++++++++++++++++++++------------------- nuttx/fs/nxffs/nxffs_open.c | 3 ++- 2 files changed, 37 insertions(+), 27 deletions(-) (limited to 'nuttx/fs') 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; } -- cgit v1.2.3