diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-02-28 17:19:49 +0100 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2012-03-13 12:24:18 +0100 |
commit | 796967c3df40a51a9028bc83d1a4b6dbeae07c3f (patch) | |
tree | edd7251883f74506a69f76e6e9fbf173de195f50 /cpukit/libblock/src/media.c | |
parent | libblock: Documentation (diff) | |
download | rtems-796967c3df40a51a9028bc83d1a4b6dbeae07c3f.tar.bz2 |
libblock: Change bdbuf API
The functions
o rtems_bdbuf_get(),
o rtems_bdbuf_read(),
o rtems_bdbuf_syncdev(), and
o rtems_bdbuf_purge_dev(),
use now the disk device instead of the device identifier. This makes
bdbuf independent of rtems_disk_obtain() and rtems_disk_release(). It
is the responsiblity of the file system to obtain the disk device. This
also reduces the overhead to get a buffer.
The key for the AVL tree uses now the disk device instead of the device
identifier. The pointer is interpreted as an unsigned integer. This
reduces the memory overhead and makes the comparison operation a bit
faster.
Removed function rtems_bdbuf_purge_major(). This function was too
destructive and could have unpredictable side effects.
Diffstat (limited to 'cpukit/libblock/src/media.c')
-rw-r--r-- | cpukit/libblock/src/media.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/cpukit/libblock/src/media.c b/cpukit/libblock/src/media.c index b4ddd6ad7c..989f80ded2 100644 --- a/cpukit/libblock/src/media.c +++ b/cpukit/libblock/src/media.c @@ -812,15 +812,19 @@ static rtems_status_code disk_detach_worker( if (state == RTEMS_MEDIA_STATE_READY) { dev_t dev = 0; + rtems_disk_device *dd = NULL; sc = rtems_media_get_device_identifier(src, &dev); if (sc != RTEMS_SUCCESSFUL) { return RTEMS_IO_ERROR; } - sc = rtems_bdbuf_syncdev(dev); - if (sc != RTEMS_SUCCESSFUL) { - rsc = RTEMS_IO_ERROR; + dd = rtems_disk_obtain(dev); + if (dd != NULL) { + sc = rtems_bdbuf_syncdev(dd); + if (sc != RTEMS_SUCCESSFUL) { + rsc = RTEMS_IO_ERROR; + } } sc = rtems_disk_delete(dev); @@ -828,7 +832,10 @@ static rtems_status_code disk_detach_worker( rsc = RTEMS_IO_ERROR; } - rtems_bdbuf_purge_dev(dev); + if (dd != NULL) { + rtems_bdbuf_purge_dev(dd); + rtems_disk_release(dd); + } if (rtems_filesystem_dev_minor_t(dev) == 0) { sc = rtems_io_unregister_driver(rtems_filesystem_dev_major_t(dev)); |