fixes
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@236 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
36e02def6b
commit
505f5bd35c
@ -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;
|
||||
|
@ -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;
|
||||
|
25
fs/fs_read.c
25
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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user