summaryrefslogtreecommitdiff
path: root/nuttx
diff options
context:
space:
mode:
Diffstat (limited to 'nuttx')
-rw-r--r--nuttx/fs/vfs/fs_unlink.c20
-rw-r--r--nuttx/include/nuttx/fs/fs.h7
2 files changed, 24 insertions, 3 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
diff --git a/nuttx/include/nuttx/fs/fs.h b/nuttx/include/nuttx/fs/fs.h
index 20b318033..6a1c591ab 100644
--- a/nuttx/include/nuttx/fs/fs.h
+++ b/nuttx/include/nuttx/fs/fs.h
@@ -91,11 +91,13 @@ struct file_operations
ssize_t (*write)(FAR struct file *filep, FAR const char *buffer, size_t buflen);
off_t (*seek)(FAR struct file *filep, off_t offset, int whence);
int (*ioctl)(FAR struct file *filep, int cmd, unsigned long arg);
+
+ /* The two structures need not be common after this point */
+
#ifndef CONFIG_DISABLE_POLL
int (*poll)(FAR struct file *filep, struct pollfd *fds, bool setup);
#endif
-
- /* The two structures need not be common after this point */
+ int (*unlink)(FAR void *priv);
};
/* This structure provides information about the state of a block driver */
@@ -234,7 +236,6 @@ union inode_ops_u
#ifndef CONFIG_DISABLE_MQUEUE
FAR struct mqueue_inode_s *i_mqueue; /* POSIX message queue */
#endif
-
};
/* This structure represents one inode in the Nuttx pseudo-file system */