summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-05-20 16:54:09 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-05-20 16:54:09 +0000
commit80c8fab4acd3dcdd301d39db7d16d2e5993c76af (patch)
tree354938cc1e1fe6a272a1832c8167cbe93947f656
parent030a08da229d9c7a409c48fa7be3ff7f0177ece6 (diff)
downloadnuttx-80c8fab4acd3dcdd301d39db7d16d2e5993c76af.tar.gz
nuttx-80c8fab4acd3dcdd301d39db7d16d2e5993c76af.tar.bz2
nuttx-80c8fab4acd3dcdd301d39db7d16d2e5993c76af.zip
fixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@236 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/fs/fs_close.c31
-rw-r--r--nuttx/fs/fs_mount.c7
-rw-r--r--nuttx/fs/fs_read.c25
3 files changed, 38 insertions, 25 deletions
diff --git a/nuttx/fs/fs_close.c b/nuttx/fs/fs_close.c
index 74f5e831b..97444c2f2 100644
--- a/nuttx/fs/fs_close.c
+++ b/nuttx/fs/fs_close.c
@@ -1,4 +1,4 @@
-/************************************************************
+/****************************************************************************
* fs_close.c
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
@@ -31,11 +31,11 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Included Files
- ************************************************************/
+ ****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
@@ -45,9 +45,9 @@
#include <nuttx/fs.h>
#include "fs_internal.h"
-/************************************************************
+/****************************************************************************
* Global Functions
- ************************************************************/
+ ****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
@@ -71,18 +71,21 @@ int close(int fd)
{
int ret = OK;
- /* Close the driver. NOTES: (1) there is no semaphore protection
- * here, the driver must be able to handle concurrent close and
- * open operations. (2) The driver may have been opened numerous
- * times (for different file descriptors) and must also handle
- * being closed numerous times.
+ /* Close the driver or mountpoint. NOTES: (1) there is no
+ * exclusion mechanism here , the driver or mountpoint must be
+ * able to handle concurrent operations internally, (2) The driver
+ * may have been opened numerous times (for different file
+ * descriptors) and must also handle being closed numerous times.
+ * (3) for the case of the mountpoint, we depend on the close
+ * methods bing identical in signal and position in the operations
+ * vtable.
*/
if (inode->u.i_ops && inode->u.i_ops->close)
{
/* Perform the close operation (by the driver) */
- int status = inode->u.i_ops->close(fd);
+ int status = inode->u.i_ops->close(&list->fl_files[fd]);
if (status < 0)
{
/* An error occurred while closing the driver */
@@ -96,7 +99,9 @@ int close(int fd)
files_release(fd);
- /* Then remove the inode, eliminating the name from the namespace */
+ /* Decrement the reference count on the inode. This may remove the inode and
+ * eliminate the name from the namespace
+ */
inode_release(inode);
return ret;
diff --git a/nuttx/fs/fs_mount.c b/nuttx/fs/fs_mount.c
index 753f9bac3..3e6a564b2 100644
--- a/nuttx/fs/fs_mount.c
+++ b/nuttx/fs/fs_mount.c
@@ -188,8 +188,8 @@ int mount(const char *source, const char *target,
/* Make sure that the inode supports the requested access */
- if (!blkdrvr_inode->u.i_mops->read ||
- (!blkdrvr_inode->u.i_mops->write && (mountflags & MS_RDONLY) == 0))
+ if (!blkdrvr_inode->u.i_bops->read ||
+ (!blkdrvr_inode->u.i_bops->write && (mountflags & MS_RDONLY) == 0))
{
errcode = EACCES;
goto errout_with_blkdrvr;
@@ -259,10 +259,13 @@ int mount(const char *source, const char *target,
errout_with_mountpt:
inode_release(mountpt_inode);
+
errout_with_semaphore:
inode_semgive();
+
errout_with_blkdrvr:
inode_release(blkdrvr_inode);
+
errout:
*get_errno_ptr() = errcode;
return ERROR;
diff --git a/nuttx/fs/fs_read.c b/nuttx/fs/fs_read.c
index d5a97c553..4b1a2ce77 100644
--- a/nuttx/fs/fs_read.c
+++ b/nuttx/fs/fs_read.c
@@ -1,4 +1,4 @@
-/************************************************************
+/****************************************************************************
* fs_read.c
*
* Copyright (C) 2007 Gregory Nutt. All rights reserved.
@@ -31,15 +31,15 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Compilation Switches
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Included Files
- ************************************************************/
+ ****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
@@ -49,9 +49,9 @@
#include <errno.h>
#include "fs_internal.h"
-/************************************************************
+/****************************************************************************
* Global Functions
- ************************************************************/
+ ****************************************************************************/
#if CONFIG_NFILE_DESCRIPTORS > 0
@@ -81,11 +81,16 @@ int read(int fd, void *buf, unsigned int nbytes)
{
struct inode *inode = this_file->f_inode;
- /* Is a driver registered? Does it support the read method? */
+ /* Is a driver or mountpoint registered? If so, does it support
+ * the read method?
+ */
if (inode && inode->u.i_ops && inode->u.i_ops->read)
{
- /* Yes, then let it perform the read */
+ /* Yes, then let it perform the read. NOTE that for the case
+ * of the mountpoint, we depend on the read methods bing
+ * identical in signal and position in the operations vtable.
+ */
ret = (int)inode->u.i_ops->read(this_file, (char*)buf, (size_t)nbytes);
}