diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-05-20 16:38:49 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-05-20 16:38:49 +0000 |
commit | 030a08da229d9c7a409c48fa7be3ff7f0177ece6 (patch) | |
tree | 760c9c5ab82fb82ac2e31cfbc5a7249ad1e588b0 /nuttx | |
parent | ae18b383ab8601fbb814c89b6b289ef6b716a1ad (diff) | |
download | px4-nuttx-030a08da229d9c7a409c48fa7be3ff7f0177ece6.tar.gz px4-nuttx-030a08da229d9c7a409c48fa7be3ff7f0177ece6.tar.bz2 px4-nuttx-030a08da229d9c7a409c48fa7be3ff7f0177ece6.zip |
fix last change
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@235 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx')
-rw-r--r-- | nuttx/fs/fs_close.c | 19 | ||||
-rw-r--r-- | nuttx/fs/fs_open.c | 5 |
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) |