source: rtems/testsuites/fstests/support/ramdisk_support.c @ 71cf3e9d

4.115
Last change on this file since 71cf3e9d was 71cf3e9d, checked in by Sebastian Huber <sebastian.huber@…>, on 02/20/13 at 12:30:43

libblock: Do resource allocation in one place

All resource allocations take place in rtems_bdbuf_init() now. After
rtems_bdbuf_init() no fatal errors can happen due to configuration
errors or resource limits. This makes it easier to detect
configuration errors for users.

  • Property mode set to 100644
File size: 1.2 KB
RevLine 
[7336d4af]1/*
[858e013f]2 *  COPYRIGHT (c) 1989-2011.
3 *  On-Line Applications Research Corporation (OAR).
4 *
5 *  The license and distribution terms for this file may be
6 *  found in the file LICENSE in this distribution or at
7 *  http://www.rtems.com/license/LICENSE.
[7336d4af]8 */
[d957805]9
10#ifdef HAVE_CONFIG_H
11#include "config.h"
12#endif
13
[334222f0]14#include <sys/stat.h>
15#include <fcntl.h>
16
[7336d4af]17#include <rtems/ramdisk.h>
18#include <rtems/blkdev.h>
19#include <rtems/libio.h>
20
21#include "ramdisk_support.h"
[858e013f]22#include "fstest.h"
[32448524]23#include "pmacros.h"
24
[7336d4af]25/*
[6fed43e]26 * Ramdisk information
[7336d4af]27 */
28
29dev_t dev = 0;
30
[6fed43e]31void
32init_ramdisk (void)
[7336d4af]33{
34
[6fed43e]35  int rc = 0;
36  rc = rtems_disk_io_initialize ();
37  rtems_test_assert (rc == 0);
38  rc = ramdisk_register (RAMDISK_BLOCK_SIZE, RAMDISK_BLOCK_COUNT,
39                         false, RAMDISK_PATH, &dev);
40  rtems_test_assert (rc == 0);
[7336d4af]41}
[858e013f]42
[6fed43e]43void
44del_ramdisk (void)
[7336d4af]45{
46
[6fed43e]47  int rc = 0;
48  rtems_device_major_number major = 0;
49  rtems_device_minor_number minor = 0;
[7336d4af]50
[6fed43e]51  rc = rtems_disk_delete (dev);
52  rtems_test_assert (rc == 0);
[7336d4af]53
[6fed43e]54  rtems_filesystem_split_dev_t (dev, major, minor);
[7336d4af]55
[6fed43e]56  rtems_test_assert (major >= 0);
57  rtems_test_assert (minor >= 0);
58
59  rc = rtems_io_unregister_driver (major);
60  rtems_test_assert (rc == 0);
61  rc = rtems_disk_io_done ();
62  rtems_test_assert (rc == 0);
[7336d4af]63
[6fed43e]64}
Note: See TracBrowser for help on using the repository browser.