mirror of
https://github.com/apache/nuttx.git
synced 2026-06-06 08:36:24 +08:00
Add an unlink method to block driver interface. Same motivataion as for the same modification to the character driver interface
This commit is contained in:
@@ -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 *dev = (FAR struct pipe_dev_s *)priv;
|
||||
|
||||
DEBUGASSERT(dev);
|
||||
DEBUGASSERT(inode && inode->i_private);
|
||||
dev = = (FAR struct pipe_dev_s *)inode->i_private;
|
||||
|
||||
/* Mark the pipe unlinked */
|
||||
|
||||
|
||||
+16
-8
@@ -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;
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user