1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2010. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * Modifications to support reference counting in the file system are |
---|
6 | * Copyright (c) 2012 embedded brains GmbH. |
---|
7 | * |
---|
8 | * The license and distribution terms for this file may be |
---|
9 | * found in the file LICENSE in this distribution or at |
---|
10 | * http://www.rtems.com/license/LICENSE. |
---|
11 | */ |
---|
12 | |
---|
13 | #ifdef HAVE_CONFIG_H |
---|
14 | #include "config.h" |
---|
15 | #endif |
---|
16 | |
---|
17 | #include "test_support.h" |
---|
18 | |
---|
19 | #include <tmacros.h> |
---|
20 | #include <errno.h> |
---|
21 | #include <unistd.h> |
---|
22 | #include <sys/types.h> |
---|
23 | #include <sys/stat.h> |
---|
24 | #include <fcntl.h> |
---|
25 | |
---|
26 | #include <rtems/devfs.h> |
---|
27 | #include <rtems/malloc.h> |
---|
28 | |
---|
29 | rtems_task Init( |
---|
30 | rtems_task_argument argument |
---|
31 | ) |
---|
32 | { |
---|
33 | int status; |
---|
34 | rtems_filesystem_location_info_t *rootloc = &rtems_filesystem_root->location; |
---|
35 | const devFS_data *data = rootloc->mt_entry->immutable_fs_info; |
---|
36 | devFS_data zero_count_data = { |
---|
37 | .nodes = data->nodes, |
---|
38 | .count = 0 |
---|
39 | }; |
---|
40 | void *opaque; |
---|
41 | |
---|
42 | puts( "\n\n*** TEST DEVFS02 ***" ); |
---|
43 | |
---|
44 | puts( "Init - attempt to create a fifo - expect ENOTSUP" ); |
---|
45 | status = mkfifo( "/fifo01", 0 ); |
---|
46 | rtems_test_assert( status == -1 ); |
---|
47 | rtems_test_assert( errno == ENOTSUP ); |
---|
48 | |
---|
49 | /* Manipulate the device table size */ |
---|
50 | puts( "Init - set device table size to zero" ); |
---|
51 | rootloc->mt_entry->immutable_fs_info = &zero_count_data; |
---|
52 | |
---|
53 | puts( "Init - attempt to create a node - expect ENOSPC" ); |
---|
54 | status = mknod( "/node", S_IFBLK, 0LL ); |
---|
55 | rtems_test_assert( status == -1 ); |
---|
56 | rtems_test_assert( errno == ENOSPC ); |
---|
57 | |
---|
58 | /* Now restore */ |
---|
59 | puts( "Init - restore device table size" ); |
---|
60 | rootloc->mt_entry->immutable_fs_info = data; |
---|
61 | |
---|
62 | opaque = rtems_heap_greedy_allocate( 0 ); |
---|
63 | |
---|
64 | puts( "Init - attempt to create a node - expect ENOMEM" ); |
---|
65 | status = mknod( "/node", S_IFBLK, 0LL ); |
---|
66 | rtems_test_assert( status == -1 ); |
---|
67 | rtems_test_assert( errno == ENOMEM ); |
---|
68 | |
---|
69 | rtems_heap_greedy_free( opaque ); |
---|
70 | |
---|
71 | puts( "Init - attempt to create /node -- OK" ); |
---|
72 | status = mknod( "/node", S_IFBLK, 0LL ); |
---|
73 | rtems_test_assert( status == 0 ); |
---|
74 | |
---|
75 | puts( "Init - attempt to create /node - expect EEXIST" ); |
---|
76 | status = mknod( "/node", S_IFBLK, 0LL ); |
---|
77 | rtems_test_assert( status == -1 ); |
---|
78 | rtems_test_assert( errno == EEXIST ); |
---|
79 | |
---|
80 | puts( "*** END OF TEST DEVFS02 ***" ); |
---|
81 | |
---|
82 | rtems_test_exit(0); |
---|
83 | } |
---|
84 | |
---|
85 | /* configuration information */ |
---|
86 | |
---|
87 | #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER |
---|
88 | #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER |
---|
89 | |
---|
90 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
91 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
92 | |
---|
93 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 5 |
---|
94 | |
---|
95 | #define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM |
---|
96 | |
---|
97 | #define CONFIGURE_INIT |
---|
98 | #include <rtems/confdefs.h> |
---|
99 | /* end of file */ |
---|