1 | /* |
---|
2 | * Copyright (c) 2015 embedded brains GmbH. All rights reserved. |
---|
3 | * |
---|
4 | * embedded brains GmbH |
---|
5 | * Dornierstr. 4 |
---|
6 | * 82178 Puchheim |
---|
7 | * Germany |
---|
8 | * <rtems@embedded-brains.de> |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.rtems.org/license/LICENSE. |
---|
13 | */ |
---|
14 | |
---|
15 | #ifdef HAVE_CONFIG_H |
---|
16 | #include "config.h" |
---|
17 | #endif |
---|
18 | |
---|
19 | #define TESTS_USE_PRINTK |
---|
20 | #include "tmacros.h" |
---|
21 | |
---|
22 | #include <sys/stat.h> |
---|
23 | #include <errno.h> |
---|
24 | #include <fcntl.h> |
---|
25 | #include <stdio.h> |
---|
26 | #include <unistd.h> |
---|
27 | #include <utime.h> |
---|
28 | |
---|
29 | #include <rtems/imfs.h> |
---|
30 | #include <rtems/libio.h> |
---|
31 | |
---|
32 | const char rtems_test_name[] = "FSIMFSCONFIG 3"; |
---|
33 | |
---|
34 | static const IMFS_node_control node_control = IMFS_GENERIC_INITIALIZER( |
---|
35 | &rtems_filesystem_handlers_default, |
---|
36 | IMFS_node_initialize_generic, |
---|
37 | IMFS_node_destroy_default |
---|
38 | ); |
---|
39 | |
---|
40 | static void Init(rtems_task_argument arg) |
---|
41 | { |
---|
42 | struct utimbuf times; |
---|
43 | const char *generic = "generic"; |
---|
44 | const char *mnt = "mnt"; |
---|
45 | const char *dev = "device"; |
---|
46 | const char *file = "file"; |
---|
47 | const char *fifo = "fifo"; |
---|
48 | int rv; |
---|
49 | int fd; |
---|
50 | |
---|
51 | TEST_BEGIN(); |
---|
52 | |
---|
53 | rv = IMFS_make_generic_node( |
---|
54 | generic, |
---|
55 | S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO, |
---|
56 | &node_control, |
---|
57 | NULL |
---|
58 | ); |
---|
59 | rtems_test_assert(rv == 0); |
---|
60 | |
---|
61 | errno = 0; |
---|
62 | rv = chown(generic, 0, 0); |
---|
63 | rtems_test_assert(rv == -1); |
---|
64 | rtems_test_assert(errno == ENOTSUP); |
---|
65 | |
---|
66 | errno = 0; |
---|
67 | rv = chmod(generic, 0); |
---|
68 | rtems_test_assert(rv == -1); |
---|
69 | rtems_test_assert(errno == ENOTSUP); |
---|
70 | |
---|
71 | errno = 0; |
---|
72 | rv = link(generic, "link"); |
---|
73 | rtems_test_assert(rv == -1); |
---|
74 | rtems_test_assert(errno == ENOTSUP); |
---|
75 | |
---|
76 | rv = mkdir(mnt, S_IRWXU); |
---|
77 | rtems_test_assert(rv == 0); |
---|
78 | |
---|
79 | rv = mknod(dev, S_IFCHR | S_IRWXU, 0); |
---|
80 | rtems_test_assert(rv == 0); |
---|
81 | |
---|
82 | fd = creat(file, S_IRWXU); |
---|
83 | rtems_test_assert(fd == 0); |
---|
84 | |
---|
85 | rv = close(fd); |
---|
86 | rtems_test_assert(rv == 0); |
---|
87 | |
---|
88 | errno = 0; |
---|
89 | rv = mkfifo(fifo, S_IRWXU); |
---|
90 | rtems_test_assert(rv == -1); |
---|
91 | rtems_test_assert(errno == ENOSYS); |
---|
92 | |
---|
93 | rv = mount( |
---|
94 | "", |
---|
95 | mnt, |
---|
96 | RTEMS_FILESYSTEM_TYPE_IMFS, |
---|
97 | RTEMS_FILESYSTEM_READ_ONLY, |
---|
98 | NULL |
---|
99 | ); |
---|
100 | rtems_test_assert(rv == 0); |
---|
101 | |
---|
102 | errno = 0; |
---|
103 | rv = unmount(mnt); |
---|
104 | rtems_test_assert(rv == -1); |
---|
105 | rtems_test_assert(errno == ENOTSUP); |
---|
106 | |
---|
107 | errno = 0; |
---|
108 | rv = rename(generic, "new"); |
---|
109 | rtems_test_assert(rv == -1); |
---|
110 | rtems_test_assert(errno == ENOTSUP); |
---|
111 | |
---|
112 | errno = 0; |
---|
113 | rv = symlink(generic, "link"); |
---|
114 | rtems_test_assert(rv == -1); |
---|
115 | rtems_test_assert(errno == ENOTSUP); |
---|
116 | |
---|
117 | errno = 0; |
---|
118 | rv = utime(generic, ×); |
---|
119 | rtems_test_assert(rv == -1); |
---|
120 | rtems_test_assert(errno == ENOTSUP); |
---|
121 | |
---|
122 | rv = unlink(generic); |
---|
123 | rtems_test_assert(rv == 0); |
---|
124 | |
---|
125 | TEST_END(); |
---|
126 | rtems_test_exit(0); |
---|
127 | } |
---|
128 | |
---|
129 | #define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER |
---|
130 | |
---|
131 | #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 1 |
---|
132 | |
---|
133 | #define CONFIGURE_FILESYSTEM_IMFS |
---|
134 | |
---|
135 | #define CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM |
---|
136 | |
---|
137 | #define CONFIGURE_MAXIMUM_TASKS 1 |
---|
138 | |
---|
139 | #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION |
---|
140 | |
---|
141 | #define CONFIGURE_RTEMS_INIT_TASKS_TABLE |
---|
142 | |
---|
143 | #define CONFIGURE_INIT |
---|
144 | |
---|
145 | #include <rtems/confdefs.h> |
---|