summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nuttx/fs/fs_close.c19
-rw-r--r--nuttx/fs/fs_open.c5
2 files changed, 11 insertions, 13 deletions
diff --git a/nuttx/fs/fs_close.c b/nuttx/fs/fs_close.c
index 1d1faa009..74f5e831b 100644
--- a/nuttx/fs/fs_close.c
+++ b/nuttx/fs/fs_close.c
@@ -71,27 +71,22 @@ int close(int fd)
{
int ret = OK;
- /* Get then nullify the operations to prohibit any other
- * use of the driver while it is closing.
+ /* 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.
*/
- struct file_operations *fops = inode->u.i_ops;
- inode->u.i_ops = NULL;
-
- /* At this point, there can be no other access to the underlying
- * driver. We can safely close the driver as well.
- */
-
- if (fops && fops->close)
+ if (inode->u.i_ops && inode->u.i_ops->close)
{
/* Perform the close operation (by the driver) */
- int status = fops->close(fd);
+ int status = inode->u.i_ops->close(fd);
if (status < 0)
{
/* An error occurred while closing the driver */
- inode->u.i_ops = fops;
*get_errno_ptr() = -status;
ret = ERROR;
}
diff --git a/nuttx/fs/fs_open.c b/nuttx/fs/fs_open.c
index e954fb743..fd4462c99 100644
--- a/nuttx/fs/fs_open.c
+++ b/nuttx/fs/fs_open.c
@@ -146,7 +146,10 @@ int open(const char *path, int oflags, ...)
return ERROR;
}
- /* Perform the driver open operation */
+ /* Perform the driver open operation. NOTE that the open method may
+ * be called many times. The driver/mountpoint logic should handled this
+ * becuase it may also be closed that many times.
+ */
status = OK;
if (inode->u.i_ops && inode->u.i_ops->open)