diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index d60492160..6dc90caaa 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -964,4 +964,11 @@
NOTE: On initial check-in, mmcsd_sdio.c and stm32_sdio.c are merely
skeleton frameworks for the driver.
+ * fs/fs_mount.c -- Correct error handling logic. If the bind() method
+ fails, then a reserved node is left in the tree. This causes subsequent
+ attempts to mount at the location to fail (reporting that the node
+ already exists). This is a probably for block drivers for removable
+ media: The bind method could fail repeatedly until media is asserted.
+
+
diff --git a/nuttx/Documentation/NuttX.html b/nuttx/Documentation/NuttX.html
index d14a755ce..28fe87dde 100644
--- a/nuttx/Documentation/NuttX.html
+++ b/nuttx/Documentation/NuttX.html
@@ -8,7 +8,7 @@
NuttX RTOS
- Last Updated: November 11, 2009
+ Last Updated: November 18, 2009
|
@@ -1612,6 +1612,12 @@ nuttx-0.4.14 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
NOTE: On initial check-in, mmcsd_sdio.c and stm32_sdio.c are merely
skeleton frameworks for the driver.
+ * fs/fs_mount.c -- Correct error handling logic. If the bind() method
+ fails, then a reserved node is left in the tree. This causes subsequent
+ attempts to mount at the location to fail (reporting that the node
+ already exists). This is a probably for block drivers for removable
+ media: The bind method could fail repeatedly until media is asserted.
+
pascal-0.1.3 2009-xx-xx Gregory Nutt <spudmonkey@racsa.co.cr>
buildroot-0.1.8 2009-xx-xx <spudmonkey@racsa.co.cr>
diff --git a/nuttx/fs/fs_mount.c b/nuttx/fs/fs_mount.c
index 22af7a136..9dcc21238 100644
--- a/nuttx/fs/fs_mount.c
+++ b/nuttx/fs/fs_mount.c
@@ -227,9 +227,13 @@ int mount(const char *source, const char *target,
status = mops->bind(blkdrvr_inode, data, &fshandle);
if (status != 0)
{
- /* The inode is unhappy with the blkdrvr for some reason */
+ /* The inode is unhappy with the blkdrvr for some reason. Back out
+ * the count for the reference we failed to pass and exit with an
+ * error.
+ */
fdbg("Bind method failed: %d\n", status);
+ blkdrvr_inode->i_crefs--;
errcode = -status;
goto errout_with_mountpt;
}
@@ -257,6 +261,8 @@ int mount(const char *source, const char *target,
/* A lot of goto's! But they make the error handling much simpler */
errout_with_mountpt:
+ mountpt_inode->i_crefs = 0;
+ inode_remove(target);
inode_semgive();
inode_release(blkdrvr_inode);
inode_release(mountpt_inode);