diff options
-rw-r--r-- | nuttx/drivers/pipes/pipe_common.c | 12 | ||||
-rw-r--r-- | nuttx/fs/vfs/fs_unlink.c | 24 | ||||
-rw-r--r-- | nuttx/include/nuttx/fs/fs.h | 5 |
3 files changed, 23 insertions, 18 deletions
diff --git a/nuttx/drivers/pipes/pipe_common.c b/nuttx/drivers/pipes/pipe_common.c index 1d584ce60..7a6d92137 100644 --- a/nuttx/drivers/pipes/pipe_common.c +++ b/nuttx/drivers/pipes/pipe_common.c @@ -707,16 +707,12 @@ int pipecommon_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * Name: pipecommon_unlink ****************************************************************************/ -int pipecommon_unlink(FAR void *priv) +int pipecommon_unlink(FAR struct inode *inode) { - /* The value passed to pipcommon_unlink is the private data pointer from - * the inode that is being unlinked. If there are no open references to - * the driver, then we must free up all resources used by the driver now. - */ - - FAR struct pipe_dev_s *dev = (FAR struct pipe_dev_s *)priv; + FAR struct pipe_dev_s *dev; - DEBUGASSERT(dev); + DEBUGASSERT(inode && inode->i_private); + dev = = (FAR struct pipe_dev_s *)inode->i_private; /* Mark the pipe unlinked */ diff --git a/nuttx/fs/vfs/fs_unlink.c b/nuttx/fs/vfs/fs_unlink.c index fae0b59b0..abd774d98 100644 --- a/nuttx/fs/vfs/fs_unlink.c +++ b/nuttx/fs/vfs/fs_unlink.c @@ -161,19 +161,27 @@ 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. + /* Notify the driver that it has been unlinked. If there are no + * open references to the driver instance, then the driver should + * 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(); - */ + /* Notify the character driver that it has been unlinked */ - ret = inode->u.i_ops->unlink(inode->i_private); + ret = inode->u.i_ops->unlink(inode); + if (ret < 0) + { + errcode = -ret; + goto errout_with_inode; + } + } + else if (INODE_IS_BLOCK(inode) && inode->u.i_bops->unlink) + { + /* Notify the block driver that it has been unlinked */ + + ret = inode->u.i_bops->unlink(inode); if (ret < 0) { errcode = -ret; diff --git a/nuttx/include/nuttx/fs/fs.h b/nuttx/include/nuttx/fs/fs.h index 6a1c591ab..3c8381190 100644 --- a/nuttx/include/nuttx/fs/fs.h +++ b/nuttx/include/nuttx/fs/fs.h @@ -97,7 +97,7 @@ struct file_operations #ifndef CONFIG_DISABLE_POLL int (*poll)(FAR struct file *filep, struct pollfd *fds, bool setup); #endif - int (*unlink)(FAR void *priv); + int (*unlink)(FAR struct inode *inode); }; /* This structure provides information about the state of a block driver */ @@ -105,7 +105,7 @@ struct file_operations #ifndef CONFIG_DISABLE_MOUNTPOINT struct geometry { - bool geo_available; /* true: The device is vailable */ + bool geo_available; /* true: The device is available */ bool geo_mediachanged; /* true: The media has changed since last query */ bool geo_writeenabled; /* true: It is okay to write to this device */ size_t geo_nsectors; /* Number of sectors on the device */ @@ -129,6 +129,7 @@ struct block_operations size_t start_sector, unsigned int nsectors); int (*geometry)(FAR struct inode *inode, FAR struct geometry *geometry); int (*ioctl)(FAR struct inode *inode, int cmd, unsigned long arg); + int (*unlink)(FAR struct inode *inode); }; /* This structure is provided by a filesystem to describe a mount point. |