From 030a08da229d9c7a409c48fa7be3ff7f0177ece6 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 20 May 2007 16:38:49 +0000 Subject: fix last change git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@235 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/fs/fs_close.c | 19 +++++++------------ nuttx/fs/fs_open.c | 5 ++++- 2 files changed, 11 insertions(+), 13 deletions(-) (limited to 'nuttx') 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) -- cgit v1.2.3