summaryrefslogtreecommitdiff
path: root/nuttx/fs/vfs
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-01-31 11:31:34 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-01-31 11:31:34 -0600
commit94caaf84f9ade9cb5609f192bf26abbf54c62870 (patch)
treedb1cd822dbb1a554efd1b00ab6c90257bdb281e1 /nuttx/fs/vfs
parentd7c17e9d1b3a4eff010c482bcd3049f12753dbd2 (diff)
downloadpx4-nuttx-94caaf84f9ade9cb5609f192bf26abbf54c62870.tar.gz
px4-nuttx-94caaf84f9ade9cb5609f192bf26abbf54c62870.tar.bz2
px4-nuttx-94caaf84f9ade9cb5609f192bf26abbf54c62870.zip
VFS: Add an unlink method to the character driver interface. This is important because if the character driver inode is unlinked and there are no open references to the driver, then the driver resources will be stranded. On the unlink call, the driver has the opportunity (1) check if there an any open references, and (2) if not free the driver resources
Diffstat (limited to 'nuttx/fs/vfs')
-rw-r--r--nuttx/fs/vfs/fs_unlink.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/nuttx/fs/vfs/fs_unlink.c b/nuttx/fs/vfs/fs_unlink.c
index 6a294196b..fae0b59b0 100644
--- a/nuttx/fs/vfs/fs_unlink.c
+++ b/nuttx/fs/vfs/fs_unlink.c
@@ -161,6 +161,26 @@ int unlink(FAR const char *pathname)
goto errout_with_inode;
}
+ /* Notify the character driver that it has been unlinked. If
+ * there are no open references to the driver instance, then the
+ * driver should clean release all resources because it is no
+ * longer accessible.
+ */
+
+ if (INODE_IS_DRIVER(inode) && inode->u.i_ops->unlink)
+ {
+ /* The value passed to the driver is the same value that was
+ * provided to register_driver();
+ */
+
+ ret = inode->u.i_ops->unlink(inode->i_private);
+ if (ret < 0)
+ {
+ errcode = -ret;
+ goto errout_with_inode;
+ }
+ }
+
/* Remove the old inode. Because we hold a reference count on the
* inode, it will not be deleted now. It will be deleted when all
* of the references to to the inode have been released (perhaps