4.115
Last change
on this file since b467782b was
b467782b,
checked in by Sebastian Huber <sebastian.huber@…>, on 03/26/12 at 12:58:35
|
libblock: Add rtems_bdbuf_set_block_size()
The new function rtems_bdbuf_set_block_size() must be used to set the
block size of a disk device. It will check if the block size is valid
and set the new fields block_to_media_block_shift and bds_per_group of
the rtems_disk_device structure. This helps to avoid complex arithmetic
operations in the block device buffer get and read path.
|
-
Property mode set to
100644
|
File size:
1.4 KB
|
Line | |
---|
1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup rtems_blkdev |
---|
5 | * |
---|
6 | * Block device management. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (C) 2001 OKTET Ltd., St.-Petersburg, Russia |
---|
11 | * Author: Victor V. Vengerov <vvv@oktet.ru> |
---|
12 | */ |
---|
13 | |
---|
14 | #if HAVE_CONFIG_H |
---|
15 | #include "config.h" |
---|
16 | #endif |
---|
17 | |
---|
18 | #include <errno.h> |
---|
19 | |
---|
20 | #include <rtems/blkdev.h> |
---|
21 | #include <rtems/bdbuf.h> |
---|
22 | |
---|
23 | int |
---|
24 | rtems_blkdev_ioctl(rtems_disk_device *dd, uint32_t req, void *argp) |
---|
25 | { |
---|
26 | rtems_status_code sc; |
---|
27 | int rc = 0; |
---|
28 | |
---|
29 | switch (req) |
---|
30 | { |
---|
31 | case RTEMS_BLKIO_GETMEDIABLKSIZE: |
---|
32 | *(uint32_t *) argp = dd->media_block_size; |
---|
33 | break; |
---|
34 | |
---|
35 | case RTEMS_BLKIO_GETBLKSIZE: |
---|
36 | *(uint32_t *) argp = dd->block_size; |
---|
37 | break; |
---|
38 | |
---|
39 | case RTEMS_BLKIO_SETBLKSIZE: |
---|
40 | sc = rtems_bdbuf_set_block_size(dd, *(uint32_t *) argp); |
---|
41 | if (sc != RTEMS_SUCCESSFUL) { |
---|
42 | errno = EIO; |
---|
43 | rc = -1; |
---|
44 | } |
---|
45 | break; |
---|
46 | |
---|
47 | case RTEMS_BLKIO_GETSIZE: |
---|
48 | *(rtems_blkdev_bnum *) argp = dd->size; |
---|
49 | break; |
---|
50 | |
---|
51 | case RTEMS_BLKIO_SYNCDEV: |
---|
52 | sc = rtems_bdbuf_syncdev(dd); |
---|
53 | if (sc != RTEMS_SUCCESSFUL) { |
---|
54 | errno = EIO; |
---|
55 | rc = -1; |
---|
56 | } |
---|
57 | break; |
---|
58 | |
---|
59 | case RTEMS_BLKIO_GETDISKDEV: |
---|
60 | *(rtems_disk_device **) argp = dd; |
---|
61 | break; |
---|
62 | |
---|
63 | default: |
---|
64 | errno = EINVAL; |
---|
65 | rc = -1; |
---|
66 | break; |
---|
67 | } |
---|
68 | |
---|
69 | return rc; |
---|
70 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.