summaryrefslogtreecommitdiffstats
path: root/cpukit/libblock/src/bdpart-write.c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2012-02-28 17:19:49 +0100
committerSebastian Huber <sebastian.huber@embedded-brains.de>2012-03-13 12:24:18 +0100
commit796967c3df40a51a9028bc83d1a4b6dbeae07c3f (patch)
treeedd7251883f74506a69f76e6e9fbf173de195f50 /cpukit/libblock/src/bdpart-write.c
parentlibblock: Documentation (diff)
downloadrtems-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/bdpart-write.c')
-rw-r--r--cpukit/libblock/src/bdpart-write.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/cpukit/libblock/src/bdpart-write.c b/cpukit/libblock/src/bdpart-write.c
index 92e80a24ec..9cccda5e5b 100644
--- a/cpukit/libblock/src/bdpart-write.c
+++ b/cpukit/libblock/src/bdpart-write.c
@@ -45,7 +45,7 @@ static void rtems_bdpart_write_mbr_partition(
}
static rtems_status_code rtems_bdpart_new_record(
- dev_t disk,
+ const rtems_disk_device *dd,
rtems_blkdev_bnum index,
rtems_bdbuf_buffer **block
)
@@ -61,7 +61,7 @@ static rtems_status_code rtems_bdpart_new_record(
}
/* Read the new record block (this accounts for disk block sizes > 512) */
- sc = rtems_bdbuf_read( disk, index, block);
+ sc = rtems_bdbuf_read( dd, index, block);
if (sc != RTEMS_SUCCESSFUL) {
return sc;
}
@@ -99,10 +99,11 @@ rtems_status_code rtems_bdpart_write(
rtems_blkdev_bnum disk_end = 0;
rtems_blkdev_bnum record_space =
dos_compatibility ? RTEMS_BDPART_MBR_CYLINDER_SIZE : 1;
- dev_t disk = 0;
size_t ppc = 0; /* Primary partition count */
size_t i = 0;
uint8_t *data = NULL;
+ int fd = -1;
+ const rtems_disk_device *dd = NULL;
/* Check if we have something to do */
if (count == 0) {
@@ -116,7 +117,7 @@ rtems_status_code rtems_bdpart_write(
}
/* Get disk data */
- sc = rtems_bdpart_get_disk_data( disk_name, &disk, &disk_end);
+ sc = rtems_bdpart_get_disk_data( disk_name, &fd, &dd, &disk_end);
if (sc != RTEMS_SUCCESSFUL) {
return sc;
}
@@ -211,7 +212,7 @@ rtems_status_code rtems_bdpart_write(
}
/* New MBR */
- sc = rtems_bdpart_new_record( disk, 0, &block);
+ sc = rtems_bdpart_new_record( dd, 0, &block);
if (sc != RTEMS_SUCCESSFUL) {
esc = sc;
goto cleanup;
@@ -275,7 +276,7 @@ rtems_status_code rtems_bdpart_write(
/* New EBR */
ebr = p->begin - record_space;
- sc = rtems_bdpart_new_record( disk, ebr, &block);
+ sc = rtems_bdpart_new_record( dd, ebr, &block);
if (sc != RTEMS_SUCCESSFUL) {
esc = sc;
goto cleanup;
@@ -294,6 +295,10 @@ rtems_status_code rtems_bdpart_write(
cleanup:
+ if (fd >= 0) {
+ close( fd);
+ }
+
if (block != NULL) {
rtems_bdbuf_sync( block);
}