summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/dosfs/msdos_format.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/libfs/src/dosfs/msdos_format.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/libfs/src/dosfs/msdos_format.c')
-rw-r--r--cpukit/libfs/src/dosfs/msdos_format.c32
1 files changed, 13 insertions, 19 deletions
diff --git a/cpukit/libfs/src/dosfs/msdos_format.c b/cpukit/libfs/src/dosfs/msdos_format.c
index 1394f811c4..2a9d09048f 100644
--- a/cpukit/libfs/src/dosfs/msdos_format.c
+++ b/cpukit/libfs/src/dosfs/msdos_format.c
@@ -370,7 +370,7 @@ static int msdos_format_determine_fmt_params
+---------------------------------------------------------------------------+
| Input Parameters: |
\*-------------------------------------------------------------------------*/
- const rtems_disk_device *dd, /* disk device structure */
+ int fd, /* disk file descriptor */
const msdos_format_request_param_t *rqdata, /* requested fmt parameters */
msdos_format_param_t *fmt_params/* computed fmt parameters */
)
@@ -386,18 +386,24 @@ static int msdos_format_determine_fmt_params
uint64_t total_size = 0;
memset(fmt_params,0,sizeof(*fmt_params));
+
/*
* this one is fixed in this implementation.
* At least one thing we don't have to magically guess...
*/
if (ret_val == 0) {
- fmt_params->bytes_per_sector = dd->block_size;
- fmt_params->totl_sector_cnt = dd->size;
- total_size = dd->block_size * dd->size;
+ ret_val = rtems_disk_fd_get_block_size(fd, &fmt_params->bytes_per_sector);
+ }
+ if (ret_val == 0) {
+ ret_val = rtems_disk_fd_get_block_count(fd, &fmt_params->totl_sector_cnt);
+ }
+ if (ret_val == 0) {
+ total_size = fmt_params->bytes_per_sector * fmt_params->totl_sector_cnt;
msdos_format_printf (rqdata, MSDOS_FMT_INFO_LEVEL_DETAIL,
"bytes per sector: %d\ntotal sectors: %d\ntotal size: %lu\n",
- dd->block_size, dd->size, total_size);
+ fmt_params->bytes_per_sector, fmt_params->totl_sector_cnt, total_size);
}
+
/*
* determine number of FATs
*/
@@ -889,7 +895,6 @@ int msdos_format
{
char tmp_sec[FAT_TOTAL_MBR_SIZE];
int rc;
- rtems_disk_device *dd = NULL;
struct stat stat_buf;
int ret_val = 0;
int fd = -1;
@@ -923,20 +928,11 @@ int msdos_format
ret_val = -1;
}
- /* check that device is registered as block device and lock it */
- if (ret_val == 0) {
- dd = rtems_disk_obtain(stat_buf.st_rdev);
- if (dd == NULL) {
- errno = ENOTTY;
- ret_val = -1;
- }
- }
-
/*
* compute formatting parameters
*/
if (ret_val == 0) {
- ret_val = msdos_format_determine_fmt_params(dd,rqdata,&fmt_params);
+ ret_val = msdos_format_determine_fmt_params(fd,rqdata,&fmt_params);
}
/*
* if requested, write whole disk/partition with 0xe5
@@ -1120,8 +1116,6 @@ int msdos_format
if (fd != -1) {
close(fd);
}
- if (dd != NULL) {
- rtems_disk_release(dd);
- }
+
return ret_val;
}