1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @brief RTEMS File System Location Support |
---|
5 | * @ingroup LibIOInternal |
---|
6 | */ |
---|
7 | |
---|
8 | /* |
---|
9 | * COPYRIGHT (c) 1989-2008. |
---|
10 | * On-Line Applications Research Corporation (OAR). |
---|
11 | * |
---|
12 | * Modifications to support reference counting in the file system are |
---|
13 | * Copyright (c) 2012 embedded brains GmbH. |
---|
14 | * |
---|
15 | * The license and distribution terms for this file may be |
---|
16 | * found in the file LICENSE in this distribution or at |
---|
17 | * http://www.rtems.com/license/LICENSE. |
---|
18 | */ |
---|
19 | |
---|
20 | #if HAVE_CONFIG_H |
---|
21 | #include "config.h" |
---|
22 | #endif |
---|
23 | |
---|
24 | #include <sys/stat.h> |
---|
25 | |
---|
26 | #include <rtems/libio_.h> |
---|
27 | |
---|
28 | static int null_handler_open( |
---|
29 | rtems_libio_t *iop, |
---|
30 | const char *path, |
---|
31 | int oflag, |
---|
32 | mode_t mode |
---|
33 | ) |
---|
34 | { |
---|
35 | return -1; |
---|
36 | } |
---|
37 | |
---|
38 | static int null_handler_fstat( |
---|
39 | const rtems_filesystem_location_info_t *pathloc, |
---|
40 | struct stat *buf |
---|
41 | ) |
---|
42 | { |
---|
43 | return -1; |
---|
44 | } |
---|
45 | |
---|
46 | const rtems_filesystem_file_handlers_r rtems_filesystem_null_handlers = { |
---|
47 | .open_h = null_handler_open, |
---|
48 | .close_h = rtems_filesystem_default_close, |
---|
49 | .read_h = rtems_filesystem_default_read, |
---|
50 | .write_h = rtems_filesystem_default_write, |
---|
51 | .ioctl_h = rtems_filesystem_default_ioctl, |
---|
52 | .lseek_h = rtems_filesystem_default_lseek, |
---|
53 | .fstat_h = null_handler_fstat, |
---|
54 | .ftruncate_h = rtems_filesystem_default_ftruncate, |
---|
55 | .fsync_h = rtems_filesystem_default_fsync_or_fdatasync, |
---|
56 | .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync, |
---|
57 | .fcntl_h = rtems_filesystem_default_fcntl |
---|
58 | }; |
---|
59 | |
---|
60 | static void null_op_lock_or_unlock( |
---|
61 | const rtems_filesystem_mount_table_entry_t *mt_entry |
---|
62 | ) |
---|
63 | { |
---|
64 | /* Do nothing */ |
---|
65 | } |
---|
66 | |
---|
67 | static int null_op_mknod( |
---|
68 | const rtems_filesystem_location_info_t *parentloc, |
---|
69 | const char *name, |
---|
70 | size_t namelen, |
---|
71 | mode_t mode, |
---|
72 | dev_t dev |
---|
73 | ) |
---|
74 | { |
---|
75 | return -1; |
---|
76 | } |
---|
77 | |
---|
78 | static int null_op_rmnod( |
---|
79 | const rtems_filesystem_location_info_t *parentloc, |
---|
80 | const rtems_filesystem_location_info_t *loc |
---|
81 | ) |
---|
82 | { |
---|
83 | return -1; |
---|
84 | } |
---|
85 | |
---|
86 | static int null_op_link( |
---|
87 | const rtems_filesystem_location_info_t *parentloc, |
---|
88 | const rtems_filesystem_location_info_t *targetloc, |
---|
89 | const char *name, |
---|
90 | size_t namelen |
---|
91 | ) |
---|
92 | { |
---|
93 | return -1; |
---|
94 | } |
---|
95 | |
---|
96 | static int null_op_fchmod( |
---|
97 | const rtems_filesystem_location_info_t *pathloc, |
---|
98 | mode_t mode |
---|
99 | ) |
---|
100 | { |
---|
101 | return -1; |
---|
102 | } |
---|
103 | |
---|
104 | static int null_op_chown( |
---|
105 | const rtems_filesystem_location_info_t *loc, |
---|
106 | uid_t owner, |
---|
107 | gid_t group |
---|
108 | ) |
---|
109 | { |
---|
110 | return -1; |
---|
111 | } |
---|
112 | |
---|
113 | static int null_op_clonenode( |
---|
114 | rtems_filesystem_location_info_t *loc |
---|
115 | ) |
---|
116 | { |
---|
117 | return -1; |
---|
118 | } |
---|
119 | |
---|
120 | static int null_op_mount( |
---|
121 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
122 | ) |
---|
123 | { |
---|
124 | return -1; |
---|
125 | } |
---|
126 | |
---|
127 | static int null_op_fsmount_me( |
---|
128 | rtems_filesystem_mount_table_entry_t *mt_entry, |
---|
129 | const void *data |
---|
130 | ) |
---|
131 | { |
---|
132 | return -1; |
---|
133 | } |
---|
134 | |
---|
135 | static int null_op_unmount( |
---|
136 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
137 | ) |
---|
138 | { |
---|
139 | return -1; |
---|
140 | } |
---|
141 | |
---|
142 | static void null_op_fsunmount_me( |
---|
143 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
144 | ) |
---|
145 | { |
---|
146 | /* Do nothing */ |
---|
147 | } |
---|
148 | |
---|
149 | static int null_op_utime( |
---|
150 | const rtems_filesystem_location_info_t *loc, |
---|
151 | time_t actime, |
---|
152 | time_t modtime |
---|
153 | ) |
---|
154 | { |
---|
155 | return -1; |
---|
156 | } |
---|
157 | |
---|
158 | static int null_op_symlink( |
---|
159 | const rtems_filesystem_location_info_t *parentloc, |
---|
160 | const char *name, |
---|
161 | size_t namelen, |
---|
162 | const char *target |
---|
163 | ) |
---|
164 | { |
---|
165 | return -1; |
---|
166 | } |
---|
167 | |
---|
168 | static ssize_t null_op_readlink( |
---|
169 | const rtems_filesystem_location_info_t *loc, |
---|
170 | char *buf, |
---|
171 | size_t bufsize |
---|
172 | ) |
---|
173 | { |
---|
174 | return -1; |
---|
175 | } |
---|
176 | |
---|
177 | static int null_op_rename( |
---|
178 | const rtems_filesystem_location_info_t *oldparentloc, |
---|
179 | const rtems_filesystem_location_info_t *oldloc, |
---|
180 | const rtems_filesystem_location_info_t *newparentloc, |
---|
181 | const char *name, |
---|
182 | size_t namelen |
---|
183 | ) |
---|
184 | { |
---|
185 | return -1; |
---|
186 | } |
---|
187 | |
---|
188 | static int null_op_statvfs( |
---|
189 | const rtems_filesystem_location_info_t *loc, |
---|
190 | struct statvfs *buf |
---|
191 | ) |
---|
192 | { |
---|
193 | return -1; |
---|
194 | } |
---|
195 | |
---|
196 | static const rtems_filesystem_operations_table null_ops = { |
---|
197 | .lock_h = null_op_lock_or_unlock, |
---|
198 | .unlock_h = null_op_lock_or_unlock, |
---|
199 | .eval_path_h = rtems_filesystem_default_eval_path, |
---|
200 | .link_h = null_op_link, |
---|
201 | .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal, |
---|
202 | .node_type_h = rtems_filesystem_default_node_type, |
---|
203 | .mknod_h = null_op_mknod, |
---|
204 | .rmnod_h = null_op_rmnod, |
---|
205 | .fchmod_h = null_op_fchmod, |
---|
206 | .chown_h = null_op_chown, |
---|
207 | .clonenod_h = null_op_clonenode, |
---|
208 | .freenod_h = rtems_filesystem_default_freenode, |
---|
209 | .mount_h = null_op_mount, |
---|
210 | .fsmount_me_h = null_op_fsmount_me, |
---|
211 | .unmount_h = null_op_unmount, |
---|
212 | .fsunmount_me_h = null_op_fsunmount_me, |
---|
213 | .utime_h = null_op_utime, |
---|
214 | .symlink_h = null_op_symlink, |
---|
215 | .readlink_h = null_op_readlink, |
---|
216 | .rename_h = null_op_rename, |
---|
217 | .statvfs_h = null_op_statvfs |
---|
218 | }; |
---|
219 | |
---|
220 | rtems_filesystem_mount_table_entry_t rtems_filesystem_null_mt_entry = { |
---|
221 | .location_chain = RTEMS_CHAIN_INITIALIZER_ONE_NODE( |
---|
222 | &rtems_filesystem_global_location_null.location.mt_entry_node |
---|
223 | ), |
---|
224 | .ops = &null_ops, |
---|
225 | .mt_point_node = &rtems_filesystem_global_location_null, |
---|
226 | .mt_fs_root = &rtems_filesystem_global_location_null, |
---|
227 | .mounted = false, |
---|
228 | .writeable = false |
---|
229 | }; |
---|
230 | |
---|
231 | rtems_filesystem_global_location_t rtems_filesystem_global_location_null = { |
---|
232 | .location = { |
---|
233 | .mt_entry_node = RTEMS_CHAIN_NODE_INITIALIZER_ONE_NODE_CHAIN( |
---|
234 | &rtems_filesystem_null_mt_entry.location_chain |
---|
235 | ), |
---|
236 | .handlers = &rtems_filesystem_null_handlers, |
---|
237 | .mt_entry = &rtems_filesystem_null_mt_entry |
---|
238 | }, |
---|
239 | |
---|
240 | /* |
---|
241 | * The initial reference count accounts for the following references |
---|
242 | * o the root directory of the user environment, |
---|
243 | * o the current directory of the user environment, |
---|
244 | * o the root node of the null file system instance, and |
---|
245 | * o the mount point node of the null file system instance. |
---|
246 | */ |
---|
247 | .reference_count = 4 |
---|
248 | }; |
---|
249 | |
---|
250 | rtems_user_env_t rtems_global_user_env = { |
---|
251 | .current_directory = &rtems_filesystem_global_location_null, |
---|
252 | .root_directory = &rtems_filesystem_global_location_null, |
---|
253 | .umask = S_IWGRP | S_IWOTH |
---|
254 | }; |
---|
255 | |
---|
256 | rtems_user_env_t *rtems_current_user_env = &rtems_global_user_env; |
---|