[rtems commit] libblock: Add optional free at delete request
Joel Sherrill
joel at rtems.org
Thu Mar 29 14:14:29 UTC 2012
Module: rtems
Branch: master
Commit: 2f8f056e8334c25b8229d90e7b1ffb0151ce7cf8
Changeset: http://git.rtems.org/rtems/commit/?id=2f8f056e8334c25b8229d90e7b1ffb0151ce7cf8
Author: Sebastian Huber <sebastian.huber at embedded-brains.de>
Date: Mon Mar 5 10:01:37 2012 +0100
libblock: Add optional free at delete request
---
cpukit/libblock/include/rtems/ramdisk.h | 10 ++++++++++
cpukit/libblock/src/ramdisk-driver.c | 9 ++++++++-
2 files changed, 18 insertions(+), 1 deletions(-)
diff --git a/cpukit/libblock/include/rtems/ramdisk.h b/cpukit/libblock/include/rtems/ramdisk.h
index 71efc9f..a396bd6 100644
--- a/cpukit/libblock/include/rtems/ramdisk.h
+++ b/cpukit/libblock/include/rtems/ramdisk.h
@@ -136,6 +136,11 @@ typedef struct ramdisk {
* @brief Trace enable.
*/
bool trace;
+
+ /**
+ * @brief Free the RAM disk at the block device delete request.
+ */
+ bool free_at_delete_request;
} ramdisk;
extern const rtems_driver_address_table ramdisk_ops;
@@ -213,6 +218,11 @@ ramdisk *ramdisk_allocate(
void ramdisk_free(ramdisk *rd);
+static inline void ramdisk_enable_free_at_delete_request(ramdisk *rd)
+{
+ rd->free_at_delete_request = true;
+}
+
/**
* @brief Allocates, initializes and registers a RAM disk.
*
diff --git a/cpukit/libblock/src/ramdisk-driver.c b/cpukit/libblock/src/ramdisk-driver.c
index 2bc8d27..da36d79 100644
--- a/cpukit/libblock/src/ramdisk-driver.c
+++ b/cpukit/libblock/src/ramdisk-driver.c
@@ -102,12 +102,13 @@ ramdisk_write(struct ramdisk *rd, rtems_blkdev_request *req)
int
ramdisk_ioctl(rtems_disk_device *dd, uint32_t req, void *argp)
{
+ struct ramdisk *rd = rtems_disk_get_driver_data(dd);
+
switch (req)
{
case RTEMS_BLKIO_REQUEST:
{
rtems_blkdev_request *r = argp;
- struct ramdisk *rd = rtems_disk_get_driver_data(dd);
switch (r->req)
{
@@ -124,6 +125,12 @@ ramdisk_ioctl(rtems_disk_device *dd, uint32_t req, void *argp)
break;
}
+ case RTEMS_BLKIO_DELETED:
+ if (rd->free_at_delete_request) {
+ ramdisk_free(rd);
+ }
+ break;
+
default:
return rtems_blkdev_ioctl (dd, req, argp);
break;
More information about the vc
mailing list