1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup LibIO |
---|
5 | * |
---|
6 | * @brief Basic IO API |
---|
7 | * |
---|
8 | * This file contains the support infrastructure used to manage the |
---|
9 | * table of integer style file descriptors used by the low level |
---|
10 | * POSIX system calls like open(), read, fstat(), etc. |
---|
11 | */ |
---|
12 | |
---|
13 | /* |
---|
14 | * COPYRIGHT (c) 1989-2008. |
---|
15 | * On-Line Applications Research Corporation (OAR). |
---|
16 | * |
---|
17 | * Modifications to support reference counting in the file system are |
---|
18 | * Copyright (c) 2012 embedded brains GmbH. |
---|
19 | * |
---|
20 | * The license and distribution terms for this file may be |
---|
21 | * found in the file LICENSE in this distribution or at |
---|
22 | * http://www.rtems.org/license/LICENSE. |
---|
23 | */ |
---|
24 | |
---|
25 | #ifndef _RTEMS_RTEMS_LIBIO_H |
---|
26 | #define _RTEMS_RTEMS_LIBIO_H |
---|
27 | |
---|
28 | #include <sys/types.h> |
---|
29 | #include <sys/stat.h> |
---|
30 | #include <sys/ioccom.h> |
---|
31 | #include <sys/statvfs.h> |
---|
32 | #include <sys/uio.h> |
---|
33 | |
---|
34 | #include <unistd.h> |
---|
35 | #include <termios.h> |
---|
36 | |
---|
37 | #include <rtems.h> |
---|
38 | #include <rtems/fs.h> |
---|
39 | #include <rtems/chain.h> |
---|
40 | |
---|
41 | #ifdef __cplusplus |
---|
42 | extern "C" { |
---|
43 | #endif |
---|
44 | |
---|
45 | struct knote; |
---|
46 | |
---|
47 | /** |
---|
48 | * @defgroup LibIOFSOps File System Operations |
---|
49 | * |
---|
50 | * @ingroup LibIO |
---|
51 | * |
---|
52 | * @brief File system operations. |
---|
53 | */ |
---|
54 | /**@{**/ |
---|
55 | |
---|
56 | /** |
---|
57 | * @brief Locks a file system instance. |
---|
58 | * |
---|
59 | * This lock must allow nesting. |
---|
60 | * |
---|
61 | * @param[in, out] mt_entry The mount table entry of the file system instance. |
---|
62 | * |
---|
63 | * @see rtems_filesystem_default_lock(). |
---|
64 | */ |
---|
65 | typedef void (*rtems_filesystem_mt_entry_lock_t)( |
---|
66 | const rtems_filesystem_mount_table_entry_t *mt_entry |
---|
67 | ); |
---|
68 | |
---|
69 | /** |
---|
70 | * @brief Unlocks a file system instance. |
---|
71 | * |
---|
72 | * @param[in, out] mt_entry The mount table entry of the file system instance. |
---|
73 | * |
---|
74 | * @see rtems_filesystem_default_unlock(). |
---|
75 | */ |
---|
76 | typedef void (*rtems_filesystem_mt_entry_unlock_t)( |
---|
77 | const rtems_filesystem_mount_table_entry_t *mt_entry |
---|
78 | ); |
---|
79 | |
---|
80 | /** |
---|
81 | * @brief Path evaluation context. |
---|
82 | */ |
---|
83 | typedef struct { |
---|
84 | /** |
---|
85 | * The contents of the remaining path to be evaluated. |
---|
86 | */ |
---|
87 | const char *path; |
---|
88 | |
---|
89 | /** |
---|
90 | * The length of the remaining path to be evaluated. |
---|
91 | */ |
---|
92 | size_t pathlen; |
---|
93 | |
---|
94 | /** |
---|
95 | * The contents of the token to be evaluated with respect to the current |
---|
96 | * location. |
---|
97 | */ |
---|
98 | const char *token; |
---|
99 | |
---|
100 | /** |
---|
101 | * The length of the token to be evaluated with respect to the current |
---|
102 | * location. |
---|
103 | */ |
---|
104 | size_t tokenlen; |
---|
105 | |
---|
106 | /** |
---|
107 | * The path evaluation is controlled by the following flags |
---|
108 | * - RTEMS_FS_PERMS_READ, |
---|
109 | * - RTEMS_FS_PERMS_WRITE, |
---|
110 | * - RTEMS_FS_PERMS_EXEC, |
---|
111 | * - RTEMS_FS_FOLLOW_HARD_LINK, |
---|
112 | * - RTEMS_FS_FOLLOW_SYM_LINK, |
---|
113 | * - RTEMS_FS_MAKE, |
---|
114 | * - RTEMS_FS_EXCLUSIVE, |
---|
115 | * - RTEMS_FS_ACCEPT_RESIDUAL_DELIMITERS, and |
---|
116 | * - RTEMS_FS_REJECT_TERMINAL_DOT. |
---|
117 | */ |
---|
118 | int flags; |
---|
119 | |
---|
120 | /** |
---|
121 | * Symbolic link evaluation is a recursive operation. This field helps to |
---|
122 | * limit the recursion level and thus prevents a stack overflow. The |
---|
123 | * recursion level is limited by RTEMS_FILESYSTEM_SYMLOOP_MAX. |
---|
124 | */ |
---|
125 | int recursionlevel; |
---|
126 | |
---|
127 | /** |
---|
128 | * This is the current file system location of the evaluation process. |
---|
129 | * Tokens are evaluated with respect to the current location. The token |
---|
130 | * interpretation may change the current location. The purpose of the path |
---|
131 | * evaluation is to change the start location into a final current location |
---|
132 | * according to the path. |
---|
133 | */ |
---|
134 | rtems_filesystem_location_info_t currentloc; |
---|
135 | |
---|
136 | /** |
---|
137 | * The location of the root directory of the user environment during the |
---|
138 | * evaluation start. |
---|
139 | */ |
---|
140 | rtems_filesystem_global_location_t *rootloc; |
---|
141 | |
---|
142 | /** |
---|
143 | * The start location of the evaluation process. The start location my |
---|
144 | * change during symbolic link evaluation. |
---|
145 | */ |
---|
146 | rtems_filesystem_global_location_t *startloc; |
---|
147 | } rtems_filesystem_eval_path_context_t; |
---|
148 | |
---|
149 | /** |
---|
150 | * @brief Path evaluation. |
---|
151 | * |
---|
152 | * @param[in, out] ctx The path evaluation context. |
---|
153 | * |
---|
154 | * @see rtems_filesystem_default_eval_path(). |
---|
155 | */ |
---|
156 | typedef void (*rtems_filesystem_eval_path_t)( |
---|
157 | rtems_filesystem_eval_path_context_t *ctx |
---|
158 | ); |
---|
159 | |
---|
160 | /** |
---|
161 | * @brief Creates a new link for the existing file. |
---|
162 | * |
---|
163 | * @param[in] parentloc The location of the parent of the new link. |
---|
164 | * @param[in] targetloc The location of the target file. |
---|
165 | * @param[in] name Name for the new link. |
---|
166 | * @param[in] namelen Length of the name for the new link in characters. |
---|
167 | * |
---|
168 | * @retval 0 Successful operation. |
---|
169 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
170 | * |
---|
171 | * @see rtems_filesystem_default_link(). |
---|
172 | */ |
---|
173 | typedef int (*rtems_filesystem_link_t)( |
---|
174 | const rtems_filesystem_location_info_t *parentloc, |
---|
175 | const rtems_filesystem_location_info_t *targetloc, |
---|
176 | const char *name, |
---|
177 | size_t namelen |
---|
178 | ); |
---|
179 | |
---|
180 | /** |
---|
181 | * @brief Changes the mode of a node. |
---|
182 | * |
---|
183 | * @param[in] loc The location of the node. |
---|
184 | * @param[in] mode The new mode of the node |
---|
185 | * |
---|
186 | * @retval 0 Successful operation. |
---|
187 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
188 | * |
---|
189 | * @see rtems_filesystem_default_fchmod(). |
---|
190 | */ |
---|
191 | typedef int (*rtems_filesystem_fchmod_t)( |
---|
192 | const rtems_filesystem_location_info_t *loc, |
---|
193 | mode_t mode |
---|
194 | ); |
---|
195 | |
---|
196 | /** |
---|
197 | * @brief Changes owner and group of a node. |
---|
198 | * |
---|
199 | * @param[in] loc The location of the node. |
---|
200 | * @param[in] owner User ID for the node. |
---|
201 | * @param[in] group Group ID for the node. |
---|
202 | * |
---|
203 | * @retval 0 Successful operation. |
---|
204 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
205 | * |
---|
206 | * @see rtems_filesystem_default_chown(). |
---|
207 | */ |
---|
208 | typedef int (*rtems_filesystem_chown_t)( |
---|
209 | const rtems_filesystem_location_info_t *loc, |
---|
210 | uid_t owner, |
---|
211 | gid_t group |
---|
212 | ); |
---|
213 | |
---|
214 | /** |
---|
215 | * @brief Clones a location. |
---|
216 | * |
---|
217 | * The location is initialized with a bitwise copy of an existing location. |
---|
218 | * The caller must ensure that this location is protected from a release during |
---|
219 | * the clone operation. After a successful clone operation the clone will be |
---|
220 | * added to the location chain of the corresponding mount table entry. |
---|
221 | * |
---|
222 | * @param[in, out] loc Location to clone. |
---|
223 | * |
---|
224 | * @retval 0 Successful operation. |
---|
225 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
226 | * |
---|
227 | * @see rtems_filesystem_default_clonenode(). |
---|
228 | */ |
---|
229 | typedef int (*rtems_filesystem_clonenode_t)( |
---|
230 | rtems_filesystem_location_info_t *loc |
---|
231 | ); |
---|
232 | |
---|
233 | /** |
---|
234 | * @brief Frees the location of a node. |
---|
235 | * |
---|
236 | * @param[in] loc The location of the node. |
---|
237 | * |
---|
238 | * @see rtems_filesystem_default_freenode(). |
---|
239 | */ |
---|
240 | typedef void (*rtems_filesystem_freenode_t)( |
---|
241 | const rtems_filesystem_location_info_t *loc |
---|
242 | ); |
---|
243 | |
---|
244 | /** |
---|
245 | * @brief Mounts a file system instance in a mount point (directory). |
---|
246 | * |
---|
247 | * The mount point belongs to the file system instance of the handler and is |
---|
248 | * specified by a field of the mount table entry. The handler must check that |
---|
249 | * the mount point is capable of mounting a file system instance. This is the |
---|
250 | * last step during the mount process. The file system instance is fully |
---|
251 | * initialized at this point. |
---|
252 | * |
---|
253 | * @param[in] mt_entry The mount table entry. |
---|
254 | * |
---|
255 | * @retval 0 Successful operation. |
---|
256 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
257 | * |
---|
258 | * @see rtems_filesystem_default_mount(). |
---|
259 | */ |
---|
260 | typedef int (*rtems_filesystem_mount_t) ( |
---|
261 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
262 | ); |
---|
263 | |
---|
264 | /** |
---|
265 | * @brief Initializes a file system instance. |
---|
266 | * |
---|
267 | * This function must initialize the file system root node in the mount table |
---|
268 | * entry. |
---|
269 | * |
---|
270 | * @param[in] mt_entry The mount table entry. |
---|
271 | * @param[in] data The data provided by the user. |
---|
272 | * |
---|
273 | * @retval 0 Successful operation. |
---|
274 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
275 | */ |
---|
276 | typedef int (*rtems_filesystem_fsmount_me_t)( |
---|
277 | rtems_filesystem_mount_table_entry_t *mt_entry, |
---|
278 | const void *data |
---|
279 | ); |
---|
280 | |
---|
281 | /** |
---|
282 | * @brief Unmounts a file system instance in a mount point (directory). |
---|
283 | * |
---|
284 | * In case this function is successful the file system instance will be marked |
---|
285 | * as unmounted. The file system instance will be destroyed when the last |
---|
286 | * reference to it vanishes. |
---|
287 | * |
---|
288 | * @param[in] mt_entry The mount table entry. |
---|
289 | * |
---|
290 | * @retval 0 Successful operation. |
---|
291 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
292 | * |
---|
293 | * @see rtems_filesystem_default_unmount(). |
---|
294 | */ |
---|
295 | typedef int (*rtems_filesystem_unmount_t) ( |
---|
296 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
297 | ); |
---|
298 | |
---|
299 | /** |
---|
300 | * @brief Destroys a file system instance. |
---|
301 | * |
---|
302 | * The mount point node location of the mount table entry is invalid. This |
---|
303 | * handler must free the file system root location and all remaining resources |
---|
304 | * of the file system instance. |
---|
305 | * |
---|
306 | * @param[in] mt_entry The mount table entry. |
---|
307 | * |
---|
308 | * @see rtems_filesystem_default_fsunmount(). |
---|
309 | */ |
---|
310 | typedef void (*rtems_filesystem_fsunmount_me_t)( |
---|
311 | rtems_filesystem_mount_table_entry_t *mt_entry |
---|
312 | ); |
---|
313 | |
---|
314 | /** |
---|
315 | * @brief Tests if the node of one location is equal to the node of the other |
---|
316 | * location. |
---|
317 | * |
---|
318 | * The caller ensures that both nodes are within the same file system instance. |
---|
319 | * |
---|
320 | * @param[in] a The one location. |
---|
321 | * @param[in] b The other location. |
---|
322 | * |
---|
323 | * @retval true The nodes of the locations are equal. |
---|
324 | * @retval false Otherwise. |
---|
325 | * |
---|
326 | * @see rtems_filesystem_default_are_nodes_equal(). |
---|
327 | */ |
---|
328 | typedef bool (*rtems_filesystem_are_nodes_equal_t)( |
---|
329 | const rtems_filesystem_location_info_t *a, |
---|
330 | const rtems_filesystem_location_info_t *b |
---|
331 | ); |
---|
332 | |
---|
333 | /** |
---|
334 | * @brief Creates a new node. |
---|
335 | * |
---|
336 | * This handler should create a new node according to the parameters. |
---|
337 | * |
---|
338 | * @param[in] parentloc The location of the parent of the new node. |
---|
339 | * @param[in] name Name for the new node. |
---|
340 | * @param[in] namelen Length of the name for the new node in characters. |
---|
341 | * @param[in] mode Mode for the new node. |
---|
342 | * @param[in] dev Optional device identifier for the new node. |
---|
343 | * |
---|
344 | * @retval 0 Successful operation. |
---|
345 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
346 | * |
---|
347 | * @see rtems_filesystem_default_mknod(). |
---|
348 | */ |
---|
349 | typedef int (*rtems_filesystem_mknod_t)( |
---|
350 | const rtems_filesystem_location_info_t *parentloc, |
---|
351 | const char *name, |
---|
352 | size_t namelen, |
---|
353 | mode_t mode, |
---|
354 | dev_t dev |
---|
355 | ); |
---|
356 | |
---|
357 | /** |
---|
358 | * @brief Removes a node. |
---|
359 | * |
---|
360 | * @param[in] parentloc The location of the parent of the node. |
---|
361 | * @param[in] loc The location of the node. |
---|
362 | * |
---|
363 | * @retval 0 Successful operation. |
---|
364 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
365 | * |
---|
366 | * @see rtems_filesystem_default_rmnod(). |
---|
367 | */ |
---|
368 | typedef int (*rtems_filesystem_rmnod_t)( |
---|
369 | const rtems_filesystem_location_info_t *parentloc, |
---|
370 | const rtems_filesystem_location_info_t *loc |
---|
371 | ); |
---|
372 | |
---|
373 | /** |
---|
374 | * @brief Set node access and modification times. |
---|
375 | * |
---|
376 | * @param[in] loc The location of the node. |
---|
377 | * @param[in] actime Access time for the node. |
---|
378 | * @param[in] modtime Modification for the node. |
---|
379 | * |
---|
380 | * @retval 0 Successful operation. |
---|
381 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
382 | * |
---|
383 | * @see rtems_filesystem_default_utime(). |
---|
384 | */ |
---|
385 | typedef int (*rtems_filesystem_utime_t)( |
---|
386 | const rtems_filesystem_location_info_t *loc, |
---|
387 | time_t actime, |
---|
388 | time_t modtime |
---|
389 | ); |
---|
390 | |
---|
391 | /** |
---|
392 | * @brief Makes a symbolic link to a node. |
---|
393 | * |
---|
394 | * @param[in] parentloc The location of the parent of the new symbolic link. |
---|
395 | * @param[in] name Name for the new symbolic link. |
---|
396 | * @param[in] namelen Length of the name for the new symbolic link in |
---|
397 | * characters. |
---|
398 | * @param[in] target Contents for the symbolic link. |
---|
399 | * |
---|
400 | * @retval 0 Successful operation. |
---|
401 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
402 | * |
---|
403 | * @see rtems_filesystem_default_symlink(). |
---|
404 | */ |
---|
405 | typedef int (*rtems_filesystem_symlink_t)( |
---|
406 | const rtems_filesystem_location_info_t *parentloc, |
---|
407 | const char *name, |
---|
408 | size_t namelen, |
---|
409 | const char *target |
---|
410 | ); |
---|
411 | |
---|
412 | /** |
---|
413 | * @brief Reads the contents of a symbolic link. |
---|
414 | * |
---|
415 | * @param[in] loc The location of the symbolic link. |
---|
416 | * @param[out] buf The buffer for the contents. |
---|
417 | * @param[in] bufsize The size of the buffer in characters. |
---|
418 | * |
---|
419 | * @retval non-negative Size of the actual contents in characters. |
---|
420 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
421 | * |
---|
422 | * @see rtems_filesystem_default_readlink(). |
---|
423 | */ |
---|
424 | typedef ssize_t (*rtems_filesystem_readlink_t)( |
---|
425 | const rtems_filesystem_location_info_t *loc, |
---|
426 | char *buf, |
---|
427 | size_t bufsize |
---|
428 | ); |
---|
429 | |
---|
430 | /** |
---|
431 | * @brief Renames a node. |
---|
432 | * |
---|
433 | * @param[in] oldparentloc The location of the parent of the old node. |
---|
434 | * @param[in] oldloc The location of the old node. |
---|
435 | * @param[in] newparentloc The location of the parent of the new node. |
---|
436 | * @param[in] name Name for the new node. |
---|
437 | * @param[in] namelen Length of the name for the new node in characters. |
---|
438 | * |
---|
439 | * @retval 0 Successful operation. |
---|
440 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
441 | * |
---|
442 | * @see rtems_filesystem_default_rename(). |
---|
443 | */ |
---|
444 | typedef int (*rtems_filesystem_rename_t)( |
---|
445 | const rtems_filesystem_location_info_t *oldparentloc, |
---|
446 | const rtems_filesystem_location_info_t *oldloc, |
---|
447 | const rtems_filesystem_location_info_t *newparentloc, |
---|
448 | const char *name, |
---|
449 | size_t namelen |
---|
450 | ); |
---|
451 | |
---|
452 | /** |
---|
453 | * @brief Gets file system information. |
---|
454 | * |
---|
455 | * @param[in] loc The location of a node. |
---|
456 | * @param[out] buf Buffer for file system information. |
---|
457 | * |
---|
458 | * @retval 0 Successful operation. |
---|
459 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
460 | * |
---|
461 | * @see rtems_filesystem_default_statvfs(). |
---|
462 | */ |
---|
463 | typedef int (*rtems_filesystem_statvfs_t)( |
---|
464 | const rtems_filesystem_location_info_t *loc, |
---|
465 | struct statvfs *buf |
---|
466 | ); |
---|
467 | |
---|
468 | /** |
---|
469 | * @brief File system operations table. |
---|
470 | */ |
---|
471 | struct _rtems_filesystem_operations_table { |
---|
472 | rtems_filesystem_mt_entry_lock_t lock_h; |
---|
473 | rtems_filesystem_mt_entry_unlock_t unlock_h; |
---|
474 | rtems_filesystem_eval_path_t eval_path_h; |
---|
475 | rtems_filesystem_link_t link_h; |
---|
476 | rtems_filesystem_are_nodes_equal_t are_nodes_equal_h; |
---|
477 | rtems_filesystem_mknod_t mknod_h; |
---|
478 | rtems_filesystem_rmnod_t rmnod_h; |
---|
479 | rtems_filesystem_fchmod_t fchmod_h; |
---|
480 | rtems_filesystem_chown_t chown_h; |
---|
481 | rtems_filesystem_clonenode_t clonenod_h; |
---|
482 | rtems_filesystem_freenode_t freenod_h; |
---|
483 | rtems_filesystem_mount_t mount_h; |
---|
484 | rtems_filesystem_unmount_t unmount_h; |
---|
485 | rtems_filesystem_fsunmount_me_t fsunmount_me_h; |
---|
486 | rtems_filesystem_utime_t utime_h; |
---|
487 | rtems_filesystem_symlink_t symlink_h; |
---|
488 | rtems_filesystem_readlink_t readlink_h; |
---|
489 | rtems_filesystem_rename_t rename_h; |
---|
490 | rtems_filesystem_statvfs_t statvfs_h; |
---|
491 | }; |
---|
492 | |
---|
493 | /** |
---|
494 | * @brief File system operations table with default operations. |
---|
495 | */ |
---|
496 | extern const rtems_filesystem_operations_table |
---|
497 | rtems_filesystem_operations_default; |
---|
498 | |
---|
499 | /** |
---|
500 | * @brief Obtains the IO library mutex. |
---|
501 | * |
---|
502 | * @see rtems_filesystem_mt_entry_lock_t. |
---|
503 | */ |
---|
504 | void rtems_filesystem_default_lock( |
---|
505 | const rtems_filesystem_mount_table_entry_t *mt_entry |
---|
506 | ); |
---|
507 | |
---|
508 | /** |
---|
509 | * @brief Releases the IO library mutex. |
---|
510 | * |
---|
511 | * @see rtems_filesystem_mt_entry_unlock_t. |
---|
512 | */ |
---|
513 | void rtems_filesystem_default_unlock( |
---|
514 | const rtems_filesystem_mount_table_entry_t *mt_entry |
---|
515 | ); |
---|
516 | |
---|
517 | /** |
---|
518 | * @brief Terminates the path evaluation and replaces the current location with |
---|
519 | * the null location. |
---|
520 | * |
---|
521 | * @see rtems_filesystem_eval_path_t. |
---|
522 | */ |
---|
523 | void rtems_filesystem_default_eval_path( |
---|
524 | rtems_filesystem_eval_path_context_t *ctx |
---|
525 | ); |
---|
526 | |
---|
527 | /** |
---|
528 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
529 | * |
---|
530 | * @see rtems_filesystem_link_t. |
---|
531 | */ |
---|
532 | int rtems_filesystem_default_link( |
---|
533 | const rtems_filesystem_location_info_t *parentloc, |
---|
534 | const rtems_filesystem_location_info_t *targetloc, |
---|
535 | const char *name, |
---|
536 | size_t namelen |
---|
537 | ); |
---|
538 | |
---|
539 | /** |
---|
540 | * @brief Tests if the node access pointer of one location is equal to |
---|
541 | * the node access pointer of the other location. |
---|
542 | * |
---|
543 | * @param[in] a The one location. |
---|
544 | * @param[in] b The other location. |
---|
545 | * |
---|
546 | * @retval true The node access pointers of the locations are equal. |
---|
547 | * @retval false Otherwise. |
---|
548 | * |
---|
549 | * @see rtems_filesystem_are_nodes_equal_t. |
---|
550 | */ |
---|
551 | bool rtems_filesystem_default_are_nodes_equal( |
---|
552 | const rtems_filesystem_location_info_t *a, |
---|
553 | const rtems_filesystem_location_info_t *b |
---|
554 | ); |
---|
555 | |
---|
556 | /** |
---|
557 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
558 | * |
---|
559 | * @see rtems_filesystem_mknod_t. |
---|
560 | */ |
---|
561 | int rtems_filesystem_default_mknod( |
---|
562 | const rtems_filesystem_location_info_t *parentloc, |
---|
563 | const char *name, |
---|
564 | size_t namelen, |
---|
565 | mode_t mode, |
---|
566 | dev_t dev |
---|
567 | ); |
---|
568 | |
---|
569 | /** |
---|
570 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
571 | * |
---|
572 | * @see rtems_filesystem_rmnod_t. |
---|
573 | */ |
---|
574 | int rtems_filesystem_default_rmnod( |
---|
575 | const rtems_filesystem_location_info_t *parentloc, |
---|
576 | const rtems_filesystem_location_info_t *loc |
---|
577 | ); |
---|
578 | |
---|
579 | /** |
---|
580 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
581 | * |
---|
582 | * @see rtems_filesystem_fchmod_t. |
---|
583 | */ |
---|
584 | int rtems_filesystem_default_fchmod( |
---|
585 | const rtems_filesystem_location_info_t *loc, |
---|
586 | mode_t mode |
---|
587 | ); |
---|
588 | |
---|
589 | /** |
---|
590 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
591 | * |
---|
592 | * @see rtems_filesystem_chown_t. |
---|
593 | */ |
---|
594 | int rtems_filesystem_default_chown( |
---|
595 | const rtems_filesystem_location_info_t *loc, |
---|
596 | uid_t owner, |
---|
597 | gid_t group |
---|
598 | ); |
---|
599 | |
---|
600 | /** |
---|
601 | * @retval 0 Always. |
---|
602 | * |
---|
603 | * @see rtems_filesystem_clonenode_t. |
---|
604 | */ |
---|
605 | int rtems_filesystem_default_clonenode( |
---|
606 | rtems_filesystem_location_info_t *loc |
---|
607 | ); |
---|
608 | |
---|
609 | /** |
---|
610 | * @see rtems_filesystem_freenode_t. |
---|
611 | */ |
---|
612 | void rtems_filesystem_default_freenode( |
---|
613 | const rtems_filesystem_location_info_t *loc |
---|
614 | ); |
---|
615 | |
---|
616 | /** |
---|
617 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
618 | * |
---|
619 | * @see rtems_filesystem_mount_t. |
---|
620 | */ |
---|
621 | int rtems_filesystem_default_mount ( |
---|
622 | rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ |
---|
623 | ); |
---|
624 | |
---|
625 | /** |
---|
626 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
627 | * |
---|
628 | * @see rtems_filesystem_unmount_t. |
---|
629 | */ |
---|
630 | int rtems_filesystem_default_unmount( |
---|
631 | rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ |
---|
632 | ); |
---|
633 | |
---|
634 | /** |
---|
635 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
636 | * |
---|
637 | * @see rtems_filesystem_fsunmount_me_t. |
---|
638 | */ |
---|
639 | void rtems_filesystem_default_fsunmount( |
---|
640 | rtems_filesystem_mount_table_entry_t *mt_entry /* IN */ |
---|
641 | ); |
---|
642 | |
---|
643 | /** |
---|
644 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
645 | * |
---|
646 | * @see rtems_filesystem_utime_t. |
---|
647 | */ |
---|
648 | int rtems_filesystem_default_utime( |
---|
649 | const rtems_filesystem_location_info_t *loc, |
---|
650 | time_t actime, |
---|
651 | time_t modtime |
---|
652 | ); |
---|
653 | |
---|
654 | /** |
---|
655 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
656 | * |
---|
657 | * @see rtems_filesystem_symlink_t. |
---|
658 | */ |
---|
659 | int rtems_filesystem_default_symlink( |
---|
660 | const rtems_filesystem_location_info_t *parentloc, |
---|
661 | const char *name, |
---|
662 | size_t namelen, |
---|
663 | const char *target |
---|
664 | ); |
---|
665 | |
---|
666 | /** |
---|
667 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
668 | * |
---|
669 | * @see rtems_filesystem_readlink_t. |
---|
670 | */ |
---|
671 | ssize_t rtems_filesystem_default_readlink( |
---|
672 | const rtems_filesystem_location_info_t *loc, |
---|
673 | char *buf, |
---|
674 | size_t bufsize |
---|
675 | ); |
---|
676 | |
---|
677 | /** |
---|
678 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
679 | * |
---|
680 | * @see rtems_filesystem_rename_t. |
---|
681 | */ |
---|
682 | int rtems_filesystem_default_rename( |
---|
683 | const rtems_filesystem_location_info_t *oldparentloc, |
---|
684 | const rtems_filesystem_location_info_t *oldloc, |
---|
685 | const rtems_filesystem_location_info_t *newparentloc, |
---|
686 | const char *name, |
---|
687 | size_t namelen |
---|
688 | ); |
---|
689 | |
---|
690 | /** |
---|
691 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
692 | * |
---|
693 | * @see rtems_filesystem_statvfs_t. |
---|
694 | */ |
---|
695 | int rtems_filesystem_default_statvfs( |
---|
696 | const rtems_filesystem_location_info_t *loc, |
---|
697 | struct statvfs *buf |
---|
698 | ); |
---|
699 | |
---|
700 | /** @} */ |
---|
701 | |
---|
702 | /** |
---|
703 | * @defgroup LibIOFSHandler File System Node Handler |
---|
704 | * |
---|
705 | * @ingroup LibIO |
---|
706 | * |
---|
707 | * @brief File system node handler. |
---|
708 | */ |
---|
709 | /**@{**/ |
---|
710 | |
---|
711 | /** |
---|
712 | * @brief Opens a node. |
---|
713 | * |
---|
714 | * @param[in, out] iop The IO pointer. |
---|
715 | * @param[in] path The path. |
---|
716 | * @param[in] oflag The open flags. |
---|
717 | * @param[in] mode Optional mode for node creation. |
---|
718 | * |
---|
719 | * @retval 0 Successful operation. |
---|
720 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
721 | * |
---|
722 | * @see rtems_filesystem_default_open(). |
---|
723 | */ |
---|
724 | typedef int (*rtems_filesystem_open_t)( |
---|
725 | rtems_libio_t *iop, |
---|
726 | const char *path, |
---|
727 | int oflag, |
---|
728 | mode_t mode |
---|
729 | ); |
---|
730 | |
---|
731 | /** |
---|
732 | * @brief Closes a node. |
---|
733 | * |
---|
734 | * @param[in, out] iop The IO pointer. |
---|
735 | * |
---|
736 | * @retval 0 Successful operation. |
---|
737 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
738 | * |
---|
739 | * @see rtems_filesystem_default_close(). |
---|
740 | */ |
---|
741 | typedef int (*rtems_filesystem_close_t)( |
---|
742 | rtems_libio_t *iop |
---|
743 | ); |
---|
744 | |
---|
745 | /** |
---|
746 | * @brief Reads from a node. |
---|
747 | * |
---|
748 | * This handler is responsible to update the offset field of the IO descriptor. |
---|
749 | * |
---|
750 | * @param[in, out] iop The IO pointer. |
---|
751 | * @param[out] buffer The buffer for read data. |
---|
752 | * @param[in] count The size of the buffer in characters. |
---|
753 | * |
---|
754 | * @retval non-negative Count of read characters. |
---|
755 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
756 | * |
---|
757 | * @see rtems_filesystem_default_read(). |
---|
758 | */ |
---|
759 | typedef ssize_t (*rtems_filesystem_read_t)( |
---|
760 | rtems_libio_t *iop, |
---|
761 | void *buffer, |
---|
762 | size_t count |
---|
763 | ); |
---|
764 | |
---|
765 | /** |
---|
766 | * @brief Reads an IO vector from a node. |
---|
767 | * |
---|
768 | * This handler is responsible to update the offset field of the IO descriptor. |
---|
769 | * |
---|
770 | * @param[in, out] iop The IO pointer. |
---|
771 | * @param[in] iov The IO vector with buffer for read data. The caller must |
---|
772 | * ensure that the IO vector values are valid. |
---|
773 | * @param[in] iovcnt The count of buffers in the IO vector. |
---|
774 | * @param[in] total The total count of bytes in the buffers in the IO vector. |
---|
775 | * |
---|
776 | * @retval non-negative Count of read characters. |
---|
777 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
778 | * |
---|
779 | * @see rtems_filesystem_default_readv(). |
---|
780 | */ |
---|
781 | typedef ssize_t (*rtems_filesystem_readv_t)( |
---|
782 | rtems_libio_t *iop, |
---|
783 | const struct iovec *iov, |
---|
784 | int iovcnt, |
---|
785 | ssize_t total |
---|
786 | ); |
---|
787 | |
---|
788 | /** |
---|
789 | * @brief Writes to a node. |
---|
790 | * |
---|
791 | * This handler is responsible to update the offset field of the IO descriptor. |
---|
792 | * |
---|
793 | * @param[in, out] iop The IO pointer. |
---|
794 | * @param[out] buffer The buffer for write data. |
---|
795 | * @param[in] count The size of the buffer in characters. |
---|
796 | * |
---|
797 | * @retval non-negative Count of written characters. |
---|
798 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
799 | * |
---|
800 | * @see rtems_filesystem_default_write(). |
---|
801 | */ |
---|
802 | typedef ssize_t (*rtems_filesystem_write_t)( |
---|
803 | rtems_libio_t *iop, |
---|
804 | const void *buffer, |
---|
805 | size_t count |
---|
806 | ); |
---|
807 | |
---|
808 | /** |
---|
809 | * @brief Writes an IO vector to a node. |
---|
810 | * |
---|
811 | * This handler is responsible to update the offset field of the IO descriptor. |
---|
812 | * |
---|
813 | * @param[in, out] iop The IO pointer. |
---|
814 | * @param[in] iov The IO vector with buffer for write data. The caller must |
---|
815 | * ensure that the IO vector values are valid. |
---|
816 | * @param[in] iovcnt The count of buffers in the IO vector. |
---|
817 | * @param[in] total The total count of bytes in the buffers in the IO vector. |
---|
818 | * |
---|
819 | * @retval non-negative Count of written characters. |
---|
820 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
821 | * |
---|
822 | * @see rtems_filesystem_default_writev(). |
---|
823 | */ |
---|
824 | typedef ssize_t (*rtems_filesystem_writev_t)( |
---|
825 | rtems_libio_t *iop, |
---|
826 | const struct iovec *iov, |
---|
827 | int iovcnt, |
---|
828 | ssize_t total |
---|
829 | ); |
---|
830 | |
---|
831 | /** |
---|
832 | * @brief IO control of a node. |
---|
833 | * |
---|
834 | * @param[in, out] iop The IO pointer. |
---|
835 | * @param[in] request The IO control request. |
---|
836 | * @param[in, out] buffer The buffer for IO control request data. |
---|
837 | * |
---|
838 | * @retval 0 Successful operation. |
---|
839 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
840 | * |
---|
841 | * @see rtems_filesystem_default_ioctl(). |
---|
842 | */ |
---|
843 | typedef int (*rtems_filesystem_ioctl_t)( |
---|
844 | rtems_libio_t *iop, |
---|
845 | ioctl_command_t request, |
---|
846 | void *buffer |
---|
847 | ); |
---|
848 | |
---|
849 | /** |
---|
850 | * @brief Moves the read/write file offset. |
---|
851 | * |
---|
852 | * @param[in, out] iop The IO pointer. |
---|
853 | * @param[in] offset The offset. |
---|
854 | * @param[in] whence The reference position for the offset. |
---|
855 | * |
---|
856 | * @retval non-negative The new offset from the beginning of the file. |
---|
857 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
858 | * |
---|
859 | * @see rtems_filesystem_default_lseek(), |
---|
860 | * rtems_filesystem_default_lseek_file(), and |
---|
861 | * rtems_filesystem_default_lseek_directory(). |
---|
862 | */ |
---|
863 | typedef off_t (*rtems_filesystem_lseek_t)( |
---|
864 | rtems_libio_t *iop, |
---|
865 | off_t offset, |
---|
866 | int whence |
---|
867 | ); |
---|
868 | |
---|
869 | /** |
---|
870 | * @brief Gets a node status. |
---|
871 | * |
---|
872 | * @param[in, out] iop The IO pointer. |
---|
873 | * @param[out] stat The buffer to status information. |
---|
874 | * |
---|
875 | * @retval 0 Successful operation. |
---|
876 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
877 | * |
---|
878 | * @see rtems_filesystem_default_fstat(). |
---|
879 | */ |
---|
880 | typedef int (*rtems_filesystem_fstat_t)( |
---|
881 | const rtems_filesystem_location_info_t *loc, |
---|
882 | struct stat *buf |
---|
883 | ); |
---|
884 | |
---|
885 | /** |
---|
886 | * @brief Truncates a file to a specified length. |
---|
887 | * |
---|
888 | * @param[in, out] iop The IO pointer. |
---|
889 | * @param[in] length The new length in characters. |
---|
890 | * |
---|
891 | * @retval 0 Successful operation. |
---|
892 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
893 | * |
---|
894 | * @see rtems_filesystem_default_ftruncate() and |
---|
895 | * rtems_filesystem_default_ftruncate_directory(). |
---|
896 | */ |
---|
897 | typedef int (*rtems_filesystem_ftruncate_t)( |
---|
898 | rtems_libio_t *iop, |
---|
899 | off_t length |
---|
900 | ); |
---|
901 | |
---|
902 | /** |
---|
903 | * @brief Synchronizes changes to a file. |
---|
904 | * |
---|
905 | * @param[in, out] iop The IO pointer. |
---|
906 | * |
---|
907 | * @retval 0 Successful operation. |
---|
908 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
909 | * |
---|
910 | * @see rtems_filesystem_default_fsync_or_fdatasync() and |
---|
911 | * rtems_filesystem_default_fsync_or_fdatasync_success(). |
---|
912 | */ |
---|
913 | typedef int (*rtems_filesystem_fsync_t)( |
---|
914 | rtems_libio_t *iop |
---|
915 | ); |
---|
916 | |
---|
917 | /** |
---|
918 | * @brief Synchronizes the data of a file. |
---|
919 | * |
---|
920 | * @param[in, out] iop The IO pointer. |
---|
921 | * |
---|
922 | * @retval 0 Successful operation. |
---|
923 | * @retval -1 An error occurred. The errno is set to indicate the error. |
---|
924 | * |
---|
925 | * @see rtems_filesystem_default_fsync_or_fdatasync() and |
---|
926 | * rtems_filesystem_default_fsync_or_fdatasync_success(). |
---|
927 | */ |
---|
928 | typedef int (*rtems_filesystem_fdatasync_t)( |
---|
929 | rtems_libio_t *iop |
---|
930 | ); |
---|
931 | |
---|
932 | /** |
---|
933 | * @brief File control. |
---|
934 | * |
---|
935 | * @param[in, out] iop The IO pointer. |
---|
936 | * @param[in] cmd Control command. |
---|
937 | * |
---|
938 | * @retval 0 Successful operation. |
---|
939 | * @retval errno An error occurred. This value is assigned to errno. |
---|
940 | * |
---|
941 | * @see rtems_filesystem_default_fcntl(). |
---|
942 | */ |
---|
943 | typedef int (*rtems_filesystem_fcntl_t)( |
---|
944 | rtems_libio_t *iop, |
---|
945 | int cmd |
---|
946 | ); |
---|
947 | |
---|
948 | /** |
---|
949 | * @brief Poll and select support. |
---|
950 | * |
---|
951 | * @param[in, out] iop The IO pointer. |
---|
952 | * @param[in] events The poll events. |
---|
953 | * |
---|
954 | * @return The poll return events. |
---|
955 | * |
---|
956 | * @see rtems_filesystem_default_poll(). |
---|
957 | */ |
---|
958 | typedef int (*rtems_filesystem_poll_t)( |
---|
959 | rtems_libio_t *iop, |
---|
960 | int events |
---|
961 | ); |
---|
962 | |
---|
963 | /** |
---|
964 | * @brief Kernel event filter support. |
---|
965 | * |
---|
966 | * @param[in, out] iop The IO pointer. |
---|
967 | * @param[in] kn The kernel event note. |
---|
968 | * |
---|
969 | * @retval 0 Successful operation. |
---|
970 | * @retval error An error occurred. This is usually EINVAL. |
---|
971 | * |
---|
972 | * @see rtems_filesystem_default_kqfilter(). |
---|
973 | */ |
---|
974 | typedef int (*rtems_filesystem_kqfilter_t)( |
---|
975 | rtems_libio_t *iop, |
---|
976 | struct knote *kn |
---|
977 | ); |
---|
978 | |
---|
979 | /** |
---|
980 | * @brief MMAP support. |
---|
981 | * |
---|
982 | * @param[in, out] iop The IO pointer. |
---|
983 | * @param[in, out] addr The starting address of the mapped memory. |
---|
984 | * @param[in] len The maximum number of bytes to map. |
---|
985 | * @param[in] prot The desired memory protection. |
---|
986 | * @param[in] off The offset within the file descriptor to map. |
---|
987 | * |
---|
988 | * @retval 0 Successful operation. |
---|
989 | * @retval error An error occurred. This is usually EINVAL. |
---|
990 | * |
---|
991 | * @see rtems_filesystem_default_mmap(). |
---|
992 | */ |
---|
993 | typedef int (*rtems_filesystem_mmap_t)( |
---|
994 | rtems_libio_t *iop, |
---|
995 | void **addr, |
---|
996 | size_t len, |
---|
997 | int prot, |
---|
998 | off_t off |
---|
999 | ); |
---|
1000 | |
---|
1001 | /** |
---|
1002 | * @brief File system node operations table. |
---|
1003 | */ |
---|
1004 | struct _rtems_filesystem_file_handlers_r { |
---|
1005 | rtems_filesystem_open_t open_h; |
---|
1006 | rtems_filesystem_close_t close_h; |
---|
1007 | rtems_filesystem_read_t read_h; |
---|
1008 | rtems_filesystem_write_t write_h; |
---|
1009 | rtems_filesystem_ioctl_t ioctl_h; |
---|
1010 | rtems_filesystem_lseek_t lseek_h; |
---|
1011 | rtems_filesystem_fstat_t fstat_h; |
---|
1012 | rtems_filesystem_ftruncate_t ftruncate_h; |
---|
1013 | rtems_filesystem_fsync_t fsync_h; |
---|
1014 | rtems_filesystem_fdatasync_t fdatasync_h; |
---|
1015 | rtems_filesystem_fcntl_t fcntl_h; |
---|
1016 | rtems_filesystem_poll_t poll_h; |
---|
1017 | rtems_filesystem_kqfilter_t kqfilter_h; |
---|
1018 | rtems_filesystem_readv_t readv_h; |
---|
1019 | rtems_filesystem_writev_t writev_h; |
---|
1020 | rtems_filesystem_mmap_t mmap_h; |
---|
1021 | }; |
---|
1022 | |
---|
1023 | /** |
---|
1024 | * @brief File system node handler table with default node handlers. |
---|
1025 | */ |
---|
1026 | extern const rtems_filesystem_file_handlers_r |
---|
1027 | rtems_filesystem_handlers_default; |
---|
1028 | |
---|
1029 | /** |
---|
1030 | * @retval 0 Always. |
---|
1031 | * |
---|
1032 | * @see rtems_filesystem_open_t. |
---|
1033 | */ |
---|
1034 | int rtems_filesystem_default_open( |
---|
1035 | rtems_libio_t *iop, |
---|
1036 | const char *path, |
---|
1037 | int oflag, |
---|
1038 | mode_t mode |
---|
1039 | ); |
---|
1040 | |
---|
1041 | /** |
---|
1042 | * @retval 0 Always. |
---|
1043 | * |
---|
1044 | * @see rtems_filesystem_close_t. |
---|
1045 | */ |
---|
1046 | int rtems_filesystem_default_close( |
---|
1047 | rtems_libio_t *iop |
---|
1048 | ); |
---|
1049 | |
---|
1050 | /** |
---|
1051 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
1052 | * |
---|
1053 | * @see rtems_filesystem_read_t. |
---|
1054 | */ |
---|
1055 | ssize_t rtems_filesystem_default_read( |
---|
1056 | rtems_libio_t *iop, |
---|
1057 | void *buffer, |
---|
1058 | size_t count |
---|
1059 | ); |
---|
1060 | |
---|
1061 | /** |
---|
1062 | * @brief Calls the read handler for each IO vector entry. |
---|
1063 | * |
---|
1064 | * @see rtems_filesystem_readv_t. |
---|
1065 | */ |
---|
1066 | ssize_t rtems_filesystem_default_readv( |
---|
1067 | rtems_libio_t *iop, |
---|
1068 | const struct iovec *iov, |
---|
1069 | int iovcnt, |
---|
1070 | ssize_t total |
---|
1071 | ); |
---|
1072 | |
---|
1073 | /** |
---|
1074 | * @retval -1 Always. The errno is set to ENOTSUP. |
---|
1075 | * |
---|
1076 | * @see rtems_filesystem_write_t. |
---|
1077 | */ |
---|
1078 | ssize_t rtems_filesystem_default_write( |
---|
1079 | rtems_libio_t *iop, |
---|
1080 | const void *buffer, |
---|
1081 | size_t count |
---|
1082 | ); |
---|
1083 | |
---|
1084 | /** |
---|
1085 | * @brief Calls the write handler for each IO vector entry. |
---|
1086 | * |
---|
1087 | * @see rtems_filesystem_write_t. |
---|
1088 | */ |
---|
1089 | ssize_t rtems_filesystem_default_writev( |
---|
1090 | rtems_libio_t *iop, |
---|
1091 | const struct iovec *iov, |
---|
1092 | int iovcnt, |
---|
1093 | ssize_t total |
---|
1094 | ); |
---|
1095 | |
---|
1096 | /** |
---|
1097 | * @retval -1 Always. The errno is set to ENOTTY. |
---|
1098 | * |
---|
1099 | * @see rtems_filesystem_ioctl_t. |
---|
1100 | */ |
---|
1101 | int rtems_filesystem_default_ioctl( |
---|
1102 | rtems_libio_t *iop, |
---|
1103 | ioctl_command_t request, |
---|
1104 | void *buffer |
---|
1105 | ); |
---|
1106 | |
---|
1107 | /** |
---|
1108 | * @retval -1 Always. The errno is set to ESPIPE. |
---|
1109 | * |
---|
1110 | * @see rtems_filesystem_lseek_t. |
---|
1111 | */ |
---|
1112 | off_t rtems_filesystem_default_lseek( |
---|
1113 | rtems_libio_t *iop, |
---|
1114 | off_t offset, |
---|
1115 | int whence |
---|
1116 | ); |
---|
1117 | |
---|
1118 | /** |
---|
1119 | * @brief An offset 0 with a whence of SEEK_SET will perform a directory rewind |
---|
1120 | * operation. |
---|
1121 | * |
---|
1122 | * This function has no protection against concurrent access. |
---|
1123 | * |
---|
1124 | * @retval -1 The offset is not zero or the whence is not SEEK_SET. |
---|
1125 | * @retval 0 Successful rewind operation. |
---|
1126 | * |
---|
1127 | * @see rtems_filesystem_lseek_t. |
---|
1128 | */ |
---|
1129 | off_t rtems_filesystem_default_lseek_directory( |
---|
1130 | rtems_libio_t *iop, |
---|
1131 | off_t offset, |
---|
1132 | int whence |
---|
1133 | ); |
---|
1134 | |
---|
1135 | /** |
---|
1136 | * @brief Default lseek() handler for files. |
---|
1137 | * |
---|
1138 | * The fstat() handler will be used to obtain the file size in case whence is |
---|
1139 | * SEEK_END. |
---|
1140 | * |
---|
1141 | * This function has no protection against concurrent access. |
---|
1142 | * |
---|
1143 | * @retval -1 An error occurred. In case an integer overflow occurred, then the |
---|
1144 | * errno will be set to EOVERFLOW. In case the new offset is negative, then |
---|
1145 | * the errno will be set to EINVAL. In case the whence is SEEK_END and the |
---|
1146 | * fstat() handler to obtain the current file size returned an error status, |
---|
1147 | * then the errno will be set by the fstat() handler. |
---|
1148 | * @retval offset The new offset. |
---|
1149 | * |
---|
1150 | * @see rtems_filesystem_lseek_t. |
---|
1151 | */ |
---|
1152 | off_t rtems_filesystem_default_lseek_file( |
---|
1153 | rtems_libio_t *iop, |
---|
1154 | off_t offset, |
---|
1155 | int whence |
---|
1156 | ); |
---|
1157 | |
---|
1158 | /** |
---|
1159 | * @brief Sets the mode to S_IRWXU | S_IRWXG | S_IRWXO. |
---|
1160 | * |
---|
1161 | * @retval 0 Always. |
---|
1162 | * |
---|
1163 | * @see rtems_filesystem_fstat_t. |
---|
1164 | */ |
---|
1165 | int rtems_filesystem_default_fstat( |
---|
1166 | const rtems_filesystem_location_info_t *loc, |
---|
1167 | struct stat *buf |
---|
1168 | ); |
---|
1169 | |
---|
1170 | /** |
---|
1171 | * @retval -1 Always. The errno is set to EINVAL. |
---|
1172 | * |
---|
1173 | * @see rtems_filesystem_ftruncate_t. |
---|
1174 | */ |
---|
1175 | int rtems_filesystem_default_ftruncate( |
---|
1176 | rtems_libio_t *iop, |
---|
1177 | off_t length |
---|
1178 | ); |
---|
1179 | |
---|
1180 | /** |
---|
1181 | * @retval -1 Always. The errno is set to EISDIR. |
---|
1182 | * |
---|
1183 | * @see rtems_filesystem_ftruncate_t. |
---|
1184 | */ |
---|
1185 | int rtems_filesystem_default_ftruncate_directory( |
---|
1186 | rtems_libio_t *iop, |
---|
1187 | off_t length |
---|
1188 | ); |
---|
1189 | |
---|
1190 | /** |
---|
1191 | * @retval -1 Always. The errno is set to EINVAL. |
---|
1192 | * |
---|
1193 | * @see rtems_filesystem_fsync_t and rtems_filesystem_fdatasync_t. |
---|
1194 | */ |
---|
1195 | int rtems_filesystem_default_fsync_or_fdatasync( |
---|
1196 | rtems_libio_t *iop |
---|
1197 | ); |
---|
1198 | |
---|
1199 | /** |
---|
1200 | * @retval 0 Always. |
---|
1201 | * |
---|
1202 | * @see rtems_filesystem_fsync_t and rtems_filesystem_fdatasync_t. |
---|
1203 | */ |
---|
1204 | int rtems_filesystem_default_fsync_or_fdatasync_success( |
---|
1205 | rtems_libio_t *iop |
---|
1206 | ); |
---|
1207 | |
---|
1208 | /** |
---|
1209 | * @retval 0 Always. |
---|
1210 | * |
---|
1211 | * @see rtems_filesystem_fcntl_t. |
---|
1212 | */ |
---|
1213 | int rtems_filesystem_default_fcntl( |
---|
1214 | rtems_libio_t *iop, |
---|
1215 | int cmd |
---|
1216 | ); |
---|
1217 | |
---|
1218 | /** |
---|
1219 | * @brief Default poll handler. |
---|
1220 | * |
---|
1221 | * @retval POLLERR Always. |
---|
1222 | * |
---|
1223 | * @see rtems_filesystem_poll_t. |
---|
1224 | */ |
---|
1225 | int rtems_filesystem_default_poll( |
---|
1226 | rtems_libio_t *iop, |
---|
1227 | int events |
---|
1228 | ); |
---|
1229 | |
---|
1230 | /** |
---|
1231 | * @brief Default kernel event filter handler. |
---|
1232 | * |
---|
1233 | * @retval EINVAL Always. |
---|
1234 | * |
---|
1235 | * @see rtems_filesystem_kqfilter_t. |
---|
1236 | */ |
---|
1237 | int rtems_filesystem_default_kqfilter( |
---|
1238 | rtems_libio_t *iop, |
---|
1239 | struct knote *kn |
---|
1240 | ); |
---|
1241 | |
---|
1242 | /** |
---|
1243 | * @brief Default MMAP handler. |
---|
1244 | * |
---|
1245 | * @retval ENOTSUP Always. |
---|
1246 | * |
---|
1247 | * @see rtems_filesystem_mmap_t. |
---|
1248 | */ |
---|
1249 | int rtems_filesystem_default_mmap( |
---|
1250 | rtems_libio_t *iop, |
---|
1251 | void **addr, |
---|
1252 | size_t len, |
---|
1253 | int prot, |
---|
1254 | off_t off |
---|
1255 | ); |
---|
1256 | |
---|
1257 | /** @} */ |
---|
1258 | |
---|
1259 | /** |
---|
1260 | * @defgroup LibIO IO Library |
---|
1261 | * |
---|
1262 | * @brief Provides system call and file system interface definitions. |
---|
1263 | * |
---|
1264 | * General purpose communication channel for RTEMS to allow UNIX/POSIX |
---|
1265 | * system call behavior under RTEMS. Initially this supported only |
---|
1266 | * IO to devices but has since been enhanced to support networking |
---|
1267 | * and support for mounted file systems. |
---|
1268 | */ |
---|
1269 | /**@{**/ |
---|
1270 | |
---|
1271 | typedef off_t rtems_off64_t __attribute__((deprecated)); |
---|
1272 | |
---|
1273 | /** |
---|
1274 | * @brief Gets the mount handler for the file system @a type. |
---|
1275 | * |
---|
1276 | * @return The file system mount handler associated with the @a type, or |
---|
1277 | * @c NULL if no such association exists. |
---|
1278 | */ |
---|
1279 | rtems_filesystem_fsmount_me_t |
---|
1280 | rtems_filesystem_get_mount_handler( |
---|
1281 | const char *type |
---|
1282 | ); |
---|
1283 | |
---|
1284 | /** |
---|
1285 | * @brief Contain file system specific information which is required to support |
---|
1286 | * fpathconf(). |
---|
1287 | */ |
---|
1288 | typedef struct { |
---|
1289 | int link_max; /* count */ |
---|
1290 | int max_canon; /* max formatted input line size */ |
---|
1291 | int max_input; /* max input line size */ |
---|
1292 | int name_max; /* max name length */ |
---|
1293 | int path_max; /* max path */ |
---|
1294 | int pipe_buf; /* pipe buffer size */ |
---|
1295 | int posix_async_io; /* async IO supported on fs, 0=no, 1=yes */ |
---|
1296 | int posix_chown_restrictions; /* can chown: 0=no, 1=yes */ |
---|
1297 | int posix_no_trunc; /* error on names > max name, 0=no, 1=yes */ |
---|
1298 | int posix_prio_io; /* priority IO, 0=no, 1=yes */ |
---|
1299 | int posix_sync_io; /* file can be sync'ed, 0=no, 1=yes */ |
---|
1300 | int posix_vdisable; /* special char processing, 0=no, 1=yes */ |
---|
1301 | } rtems_filesystem_limits_and_options_t; |
---|
1302 | |
---|
1303 | /** |
---|
1304 | * @brief Default pathconf settings. |
---|
1305 | * |
---|
1306 | * Override in a filesystem. |
---|
1307 | */ |
---|
1308 | extern const rtems_filesystem_limits_and_options_t |
---|
1309 | rtems_filesystem_default_pathconf; |
---|
1310 | |
---|
1311 | /** |
---|
1312 | * @brief An open file data structure. |
---|
1313 | * |
---|
1314 | * It will be indexed by 'fd'. |
---|
1315 | * |
---|
1316 | * @todo Should really have a separate per/file data structure that this points |
---|
1317 | * to (eg: offset, driver, pathname should be in that) |
---|
1318 | */ |
---|
1319 | struct rtems_libio_tt { |
---|
1320 | rtems_driver_name_t *driver; |
---|
1321 | off_t offset; /* current offset into file */ |
---|
1322 | uint32_t flags; |
---|
1323 | rtems_filesystem_location_info_t pathinfo; |
---|
1324 | uint32_t data0; /* private to "driver" */ |
---|
1325 | void *data1; /* ... */ |
---|
1326 | }; |
---|
1327 | |
---|
1328 | /** |
---|
1329 | * @brief Paramameter block for read/write. |
---|
1330 | * |
---|
1331 | * It must include 'offset' instead of using iop's offset since we can have |
---|
1332 | * multiple outstanding i/o's on a device. |
---|
1333 | */ |
---|
1334 | typedef struct { |
---|
1335 | rtems_libio_t *iop; |
---|
1336 | off_t offset; |
---|
1337 | char *buffer; |
---|
1338 | uint32_t count; |
---|
1339 | uint32_t flags; |
---|
1340 | uint32_t bytes_moved; |
---|
1341 | } rtems_libio_rw_args_t; |
---|
1342 | |
---|
1343 | /** |
---|
1344 | * @brief Parameter block for open/close. |
---|
1345 | */ |
---|
1346 | typedef struct { |
---|
1347 | rtems_libio_t *iop; |
---|
1348 | uint32_t flags; |
---|
1349 | uint32_t mode; |
---|
1350 | } rtems_libio_open_close_args_t; |
---|
1351 | |
---|
1352 | /** |
---|
1353 | * @brief Parameter block for ioctl. |
---|
1354 | */ |
---|
1355 | typedef struct { |
---|
1356 | rtems_libio_t *iop; |
---|
1357 | ioctl_command_t command; |
---|
1358 | void *buffer; |
---|
1359 | int ioctl_return; |
---|
1360 | } rtems_libio_ioctl_args_t; |
---|
1361 | |
---|
1362 | /** |
---|
1363 | * @name Flag Values |
---|
1364 | */ |
---|
1365 | /**@{**/ |
---|
1366 | |
---|
1367 | #define LIBIO_FLAGS_NO_DELAY 0x0001U /* return immediately if no data */ |
---|
1368 | #define LIBIO_FLAGS_READ 0x0002U /* reading */ |
---|
1369 | #define LIBIO_FLAGS_WRITE 0x0004U /* writing */ |
---|
1370 | #define LIBIO_FLAGS_OPEN 0x0100U /* device is open */ |
---|
1371 | #define LIBIO_FLAGS_APPEND 0x0200U /* all writes append */ |
---|
1372 | #define LIBIO_FLAGS_CLOSE_ON_EXEC 0x0800U /* close on process exec() */ |
---|
1373 | #define LIBIO_FLAGS_READ_WRITE (LIBIO_FLAGS_READ | LIBIO_FLAGS_WRITE) |
---|
1374 | |
---|
1375 | /** @} */ |
---|
1376 | |
---|
1377 | /** |
---|
1378 | * @name External I/O Handlers |
---|
1379 | */ |
---|
1380 | /**@{**/ |
---|
1381 | |
---|
1382 | typedef int (*rtems_libio_open_t)( |
---|
1383 | const char *pathname, |
---|
1384 | uint32_t flag, |
---|
1385 | uint32_t mode |
---|
1386 | ); |
---|
1387 | |
---|
1388 | typedef int (*rtems_libio_close_t)( |
---|
1389 | int fd |
---|
1390 | ); |
---|
1391 | |
---|
1392 | typedef ssize_t (*rtems_libio_read_t)( |
---|
1393 | int fd, |
---|
1394 | void *buffer, |
---|
1395 | size_t count |
---|
1396 | ); |
---|
1397 | |
---|
1398 | typedef ssize_t (*rtems_libio_write_t)( |
---|
1399 | int fd, |
---|
1400 | const void *buffer, |
---|
1401 | size_t count |
---|
1402 | ); |
---|
1403 | |
---|
1404 | typedef int (*rtems_libio_ioctl_t)( |
---|
1405 | int fd, |
---|
1406 | uint32_t command, |
---|
1407 | void *buffer |
---|
1408 | ); |
---|
1409 | |
---|
1410 | typedef off_t (*rtems_libio_lseek_t)( |
---|
1411 | int fd, |
---|
1412 | off_t offset, |
---|
1413 | int whence |
---|
1414 | ); |
---|
1415 | |
---|
1416 | /** @} */ |
---|
1417 | |
---|
1418 | /** |
---|
1419 | * @name Permission Macros |
---|
1420 | */ |
---|
1421 | /**@{**/ |
---|
1422 | |
---|
1423 | /* |
---|
1424 | * The following macros are used to build up the permissions sets |
---|
1425 | * used to check permissions. These are similar in style to the |
---|
1426 | * mode_t bits and should stay compatible with them. |
---|
1427 | */ |
---|
1428 | #define RTEMS_FS_PERMS_READ 0x4 |
---|
1429 | #define RTEMS_FS_PERMS_WRITE 0x2 |
---|
1430 | #define RTEMS_FS_PERMS_EXEC 0x1 |
---|
1431 | #define RTEMS_FS_PERMS_RWX \ |
---|
1432 | (RTEMS_FS_PERMS_READ | RTEMS_FS_PERMS_WRITE | RTEMS_FS_PERMS_EXEC) |
---|
1433 | #define RTEMS_FS_FOLLOW_HARD_LINK 0x8 |
---|
1434 | #define RTEMS_FS_FOLLOW_SYM_LINK 0x10 |
---|
1435 | #define RTEMS_FS_FOLLOW_LINK \ |
---|
1436 | (RTEMS_FS_FOLLOW_HARD_LINK | RTEMS_FS_FOLLOW_SYM_LINK) |
---|
1437 | #define RTEMS_FS_MAKE 0x20 |
---|
1438 | #define RTEMS_FS_EXCLUSIVE 0x40 |
---|
1439 | #define RTEMS_FS_ACCEPT_RESIDUAL_DELIMITERS 0x80 |
---|
1440 | #define RTEMS_FS_REJECT_TERMINAL_DOT 0x100 |
---|
1441 | |
---|
1442 | /** @} */ |
---|
1443 | |
---|
1444 | union __rtems_dev_t { |
---|
1445 | dev_t device; |
---|
1446 | struct { |
---|
1447 | rtems_device_major_number major; |
---|
1448 | rtems_device_minor_number minor; |
---|
1449 | } __overlay; |
---|
1450 | }; |
---|
1451 | |
---|
1452 | static inline dev_t rtems_filesystem_make_dev_t( |
---|
1453 | rtems_device_major_number _major, |
---|
1454 | rtems_device_minor_number _minor |
---|
1455 | ) |
---|
1456 | { |
---|
1457 | union __rtems_dev_t temp; |
---|
1458 | |
---|
1459 | temp.__overlay.major = _major; |
---|
1460 | temp.__overlay.minor = _minor; |
---|
1461 | return temp.device; |
---|
1462 | } |
---|
1463 | |
---|
1464 | static inline dev_t rtems_filesystem_make_dev_t_from_pointer( |
---|
1465 | const void *pointer |
---|
1466 | ) |
---|
1467 | { |
---|
1468 | uint64_t temp = (((uint64_t) 1) << 63) | (((uintptr_t) pointer) >> 1); |
---|
1469 | |
---|
1470 | return rtems_filesystem_make_dev_t((uint32_t) (temp >> 32), (uint32_t) temp); |
---|
1471 | } |
---|
1472 | |
---|
1473 | static inline rtems_device_major_number rtems_filesystem_dev_major_t( |
---|
1474 | dev_t device |
---|
1475 | ) |
---|
1476 | { |
---|
1477 | union __rtems_dev_t temp; |
---|
1478 | |
---|
1479 | temp.device = device; |
---|
1480 | return temp.__overlay.major; |
---|
1481 | } |
---|
1482 | |
---|
1483 | |
---|
1484 | static inline rtems_device_minor_number rtems_filesystem_dev_minor_t( |
---|
1485 | dev_t device |
---|
1486 | ) |
---|
1487 | { |
---|
1488 | union __rtems_dev_t temp; |
---|
1489 | |
---|
1490 | temp.device = device; |
---|
1491 | return temp.__overlay.minor; |
---|
1492 | } |
---|
1493 | |
---|
1494 | #define rtems_filesystem_split_dev_t( _dev, _major, _minor ) \ |
---|
1495 | do { \ |
---|
1496 | (_major) = rtems_filesystem_dev_major_t ( _dev ); \ |
---|
1497 | (_minor) = rtems_filesystem_dev_minor_t( _dev ); \ |
---|
1498 | } while(0) |
---|
1499 | |
---|
1500 | /* |
---|
1501 | * Prototypes for filesystem |
---|
1502 | */ |
---|
1503 | |
---|
1504 | /** |
---|
1505 | * @brief Base File System Initialization |
---|
1506 | * |
---|
1507 | * Initialize the foundation of the file system. This is specified |
---|
1508 | * by the structure rtems_filesystem_mount_table. The usual |
---|
1509 | * configuration is a single instantiation of the IMFS or miniIMFS with |
---|
1510 | * a single "/dev" directory in it. |
---|
1511 | */ |
---|
1512 | void rtems_filesystem_initialize( void ); |
---|
1513 | |
---|
1514 | void rtems_libio_post_driver(void); |
---|
1515 | |
---|
1516 | void rtems_libio_exit(void); |
---|
1517 | |
---|
1518 | /** |
---|
1519 | * @brief Creates a directory and all its parent directories according to |
---|
1520 | * @a path. |
---|
1521 | * |
---|
1522 | * The @a mode value selects the access permissions of the directory. |
---|
1523 | * |
---|
1524 | * @retval 0 Successful operation. |
---|
1525 | * @retval -1 An error occurred. The @c errno indicates the error. |
---|
1526 | */ |
---|
1527 | extern int rtems_mkdir(const char *path, mode_t mode); |
---|
1528 | |
---|
1529 | /** @} */ |
---|
1530 | |
---|
1531 | /** |
---|
1532 | * @defgroup FileSystemTypesAndMount File System Types and Mount |
---|
1533 | * |
---|
1534 | * @ingroup LibIO |
---|
1535 | * |
---|
1536 | * @brief File system types and mount. |
---|
1537 | */ |
---|
1538 | /**@{**/ |
---|
1539 | |
---|
1540 | /** |
---|
1541 | * @name File System Types |
---|
1542 | */ |
---|
1543 | /**@{**/ |
---|
1544 | |
---|
1545 | #define RTEMS_FILESYSTEM_TYPE_IMFS "imfs" |
---|
1546 | #define RTEMS_FILESYSTEM_TYPE_MINIIMFS "mimfs" |
---|
1547 | #define RTEMS_FILESYSTEM_TYPE_DEVFS "devfs" |
---|
1548 | #define RTEMS_FILESYSTEM_TYPE_FTPFS "ftpfs" |
---|
1549 | #define RTEMS_FILESYSTEM_TYPE_TFTPFS "tftpfs" |
---|
1550 | #define RTEMS_FILESYSTEM_TYPE_NFS "nfs" |
---|
1551 | #define RTEMS_FILESYSTEM_TYPE_DOSFS "dosfs" |
---|
1552 | #define RTEMS_FILESYSTEM_TYPE_RFS "rfs" |
---|
1553 | #define RTEMS_FILESYSTEM_TYPE_JFFS2 "jffs2" |
---|
1554 | |
---|
1555 | /** @} */ |
---|
1556 | |
---|
1557 | /** |
---|
1558 | * @brief Mount table entry. |
---|
1559 | */ |
---|
1560 | struct rtems_filesystem_mount_table_entry_tt { |
---|
1561 | rtems_chain_node mt_node; |
---|
1562 | void *fs_info; |
---|
1563 | const rtems_filesystem_operations_table *ops; |
---|
1564 | const void *immutable_fs_info; |
---|
1565 | rtems_chain_control location_chain; |
---|
1566 | rtems_filesystem_global_location_t *mt_point_node; |
---|
1567 | rtems_filesystem_global_location_t *mt_fs_root; |
---|
1568 | bool mounted; |
---|
1569 | bool writeable; |
---|
1570 | const rtems_filesystem_limits_and_options_t *pathconf_limits_and_options; |
---|
1571 | |
---|
1572 | /* |
---|
1573 | * The target or mount point of the file system. |
---|
1574 | */ |
---|
1575 | const char *target; |
---|
1576 | |
---|
1577 | /* |
---|
1578 | * The type of filesystem or the name of the filesystem. |
---|
1579 | */ |
---|
1580 | const char *type; |
---|
1581 | |
---|
1582 | /* |
---|
1583 | * When someone adds a mounted filesystem on a real device, |
---|
1584 | * this will need to be used. |
---|
1585 | * |
---|
1586 | * The lower layers can manage how this is managed. Leave as a |
---|
1587 | * string. |
---|
1588 | */ |
---|
1589 | char *dev; |
---|
1590 | |
---|
1591 | /** |
---|
1592 | * The task that initiated the unmount process. After unmount process |
---|
1593 | * completion this task will be notified via the transient event. |
---|
1594 | * |
---|
1595 | * @see ClassicEventTransient. |
---|
1596 | */ |
---|
1597 | rtems_id unmount_task; |
---|
1598 | }; |
---|
1599 | |
---|
1600 | /** |
---|
1601 | * @brief File system options. |
---|
1602 | */ |
---|
1603 | typedef enum { |
---|
1604 | RTEMS_FILESYSTEM_READ_ONLY, |
---|
1605 | RTEMS_FILESYSTEM_READ_WRITE, |
---|
1606 | RTEMS_FILESYSTEM_BAD_OPTIONS |
---|
1607 | } rtems_filesystem_options_t; |
---|
1608 | |
---|
1609 | /** |
---|
1610 | * @brief File system table entry. |
---|
1611 | */ |
---|
1612 | typedef struct rtems_filesystem_table_t { |
---|
1613 | const char *type; |
---|
1614 | rtems_filesystem_fsmount_me_t mount_h; |
---|
1615 | } rtems_filesystem_table_t; |
---|
1616 | |
---|
1617 | /** |
---|
1618 | * @brief Static table of file systems. |
---|
1619 | * |
---|
1620 | * Externally defined by confdefs.h or the user. |
---|
1621 | */ |
---|
1622 | extern const rtems_filesystem_table_t rtems_filesystem_table []; |
---|
1623 | |
---|
1624 | extern rtems_chain_control rtems_filesystem_mount_table; |
---|
1625 | |
---|
1626 | /** |
---|
1627 | * @brief Registers a file system @a type. |
---|
1628 | * |
---|
1629 | * The @a mount_h handler will be used to mount a file system of this @a type. |
---|
1630 | * |
---|
1631 | * @retval 0 Successful operation. |
---|
1632 | * @retval -1 An error occurred. The @c errno indicates the error. |
---|
1633 | */ |
---|
1634 | int rtems_filesystem_register( |
---|
1635 | const char *type, |
---|
1636 | rtems_filesystem_fsmount_me_t mount_h |
---|
1637 | ); |
---|
1638 | |
---|
1639 | /** |
---|
1640 | * @brief Unregisters a file system @a type. |
---|
1641 | * |
---|
1642 | * @retval 0 Successful operation. |
---|
1643 | * @retval -1 An error occurred. The @c errno indicates the error. |
---|
1644 | */ |
---|
1645 | int rtems_filesystem_unregister( |
---|
1646 | const char *type |
---|
1647 | ); |
---|
1648 | |
---|
1649 | /** |
---|
1650 | * @brief Unmounts the file system instance at the specified mount path. |
---|
1651 | * |
---|
1652 | * The function waits for the unmount process completion. In case the calling |
---|
1653 | * thread uses resources of the unmounted file system the function may never |
---|
1654 | * return. In case the calling thread has its root or current directory in the |
---|
1655 | * unmounted file system the function returns with an error status and errno is |
---|
1656 | * set to EBUSY. |
---|
1657 | * |
---|
1658 | * The unmount process completion notification uses the transient event. It is |
---|
1659 | * a fatal error to terminate the calling thread while waiting for this event. |
---|
1660 | * |
---|
1661 | * A concurrent unmount request for the same file system instance has |
---|
1662 | * unpredictable effects. |
---|
1663 | * |
---|
1664 | * @param[in] mount_path The path to the file system instance mount point. |
---|
1665 | * |
---|
1666 | * @retval 0 Successful operation. |
---|
1667 | * @retval -1 An error occurred. The @c errno indicates the error. |
---|
1668 | * |
---|
1669 | * @see ClassicEventTransient. |
---|
1670 | */ |
---|
1671 | int unmount( |
---|
1672 | const char *mount_path |
---|
1673 | ); |
---|
1674 | |
---|
1675 | /** |
---|
1676 | * @brief Mounts a file system instance at the specified target path. |
---|
1677 | * |
---|
1678 | * To mount a standard file system instance one of the following defines should |
---|
1679 | * be used to select the file system type |
---|
1680 | * - RTEMS_FILESYSTEM_TYPE_DEVFS, |
---|
1681 | * - RTEMS_FILESYSTEM_TYPE_DOSFS, |
---|
1682 | * - RTEMS_FILESYSTEM_TYPE_FTPFS, |
---|
1683 | * - RTEMS_FILESYSTEM_TYPE_IMFS, |
---|
1684 | * - RTEMS_FILESYSTEM_TYPE_JFFS2, |
---|
1685 | * - RTEMS_FILESYSTEM_TYPE_MINIIMFS, |
---|
1686 | * - RTEMS_FILESYSTEM_TYPE_NFS, |
---|
1687 | * - RTEMS_FILESYSTEM_TYPE_RFS, or |
---|
1688 | * - RTEMS_FILESYSTEM_TYPE_TFTPFS. |
---|
1689 | * |
---|
1690 | * Only configured or registered file system types are available. You can add |
---|
1691 | * file system types to your application configuration with the following |
---|
1692 | * configuration options |
---|
1693 | * - CONFIGURE_FILESYSTEM_DEVFS, |
---|
1694 | * - CONFIGURE_FILESYSTEM_DOSFS, |
---|
1695 | * - CONFIGURE_FILESYSTEM_FTPFS, |
---|
1696 | * - CONFIGURE_FILESYSTEM_IMFS, |
---|
1697 | * - CONFIGURE_FILESYSTEM_JFFS2, |
---|
1698 | * - CONFIGURE_FILESYSTEM_MINIIMFS, |
---|
1699 | * - CONFIGURE_FILESYSTEM_NFS, |
---|
1700 | * - CONFIGURE_FILESYSTEM_RFS, and |
---|
1701 | * - CONFIGURE_FILESYSTEM_TFTPFS. |
---|
1702 | * |
---|
1703 | * In addition to these configuration options file system types can be |
---|
1704 | * registered with rtems_filesystem_register(). |
---|
1705 | * |
---|
1706 | * @param[in] source The source parameter will be forwarded to the file system |
---|
1707 | * initialization handler. Usually the source is a path to the corresponding |
---|
1708 | * device file, or @c NULL in case the file system does not use a device file. |
---|
1709 | * @param[in] target The target path must lead to an existing directory, or |
---|
1710 | * must be @c NULL. In case the target is @c NULL, the root file system will |
---|
1711 | * be mounted. |
---|
1712 | * @param[in] filesystemtype This string selects the file system type. |
---|
1713 | * @param[in] options The options specify if the file system instance allows |
---|
1714 | * read-write or read-only access. |
---|
1715 | * @param[in] data The data parameter will be forwarded to the file system |
---|
1716 | * initialization handler. It can be used to pass file system specific mount |
---|
1717 | * options. The data structure for mount options is file system specific. See |
---|
1718 | * also in the corresponding file system documentation. |
---|
1719 | * |
---|
1720 | * @retval 0 Successful operation. |
---|
1721 | * @retval -1 An error occurred. The @c errno indicates the error. |
---|
1722 | * |
---|
1723 | * @see rtems_filesystem_register(), mount_and_make_target_path(), @ref DOSFS |
---|
1724 | * and @ref JFFS2. |
---|
1725 | */ |
---|
1726 | int mount( |
---|
1727 | const char *source, |
---|
1728 | const char *target, |
---|
1729 | const char *filesystemtype, |
---|
1730 | rtems_filesystem_options_t options, |
---|
1731 | const void *data |
---|
1732 | ); |
---|
1733 | |
---|
1734 | /** |
---|
1735 | * @brief Mounts a file system and makes the @a target path. |
---|
1736 | * |
---|
1737 | * The @a target path will be created with rtems_mkdir() and must not be |
---|
1738 | * @c NULL. |
---|
1739 | * |
---|
1740 | * @see mount(). |
---|
1741 | * |
---|
1742 | * @retval 0 Successful operation. |
---|
1743 | * @retval -1 An error occurred. The @c errno indicates the error. |
---|
1744 | */ |
---|
1745 | int mount_and_make_target_path( |
---|
1746 | const char *source, |
---|
1747 | const char *target, |
---|
1748 | const char *filesystemtype, |
---|
1749 | rtems_filesystem_options_t options, |
---|
1750 | const void *data |
---|
1751 | ); |
---|
1752 | |
---|
1753 | /** |
---|
1754 | * @brief Per file system type routine. |
---|
1755 | * |
---|
1756 | * @see rtems_filesystem_iterate(). |
---|
1757 | * |
---|
1758 | * @retval true Stop the iteration. |
---|
1759 | * @retval false Continue the iteration. |
---|
1760 | */ |
---|
1761 | typedef bool (*rtems_per_filesystem_routine)( |
---|
1762 | const rtems_filesystem_table_t *fs_entry, |
---|
1763 | void *arg |
---|
1764 | ); |
---|
1765 | |
---|
1766 | /** |
---|
1767 | * @brief Iterates over all file system types. |
---|
1768 | * |
---|
1769 | * For each file system type the @a routine will be called with the entry and |
---|
1770 | * the @a routine_arg parameter. |
---|
1771 | * |
---|
1772 | * Do not register or unregister file system types in @a routine. |
---|
1773 | * |
---|
1774 | * The iteration is protected by the IO library mutex. |
---|
1775 | * |
---|
1776 | * @retval true Iteration stopped due to @a routine return status. |
---|
1777 | * @retval false Iteration through all entries. |
---|
1778 | */ |
---|
1779 | bool rtems_filesystem_iterate( |
---|
1780 | rtems_per_filesystem_routine routine, |
---|
1781 | void *routine_arg |
---|
1782 | ); |
---|
1783 | |
---|
1784 | /** |
---|
1785 | * @brief Mount table entry visitor. |
---|
1786 | * |
---|
1787 | * @retval true Stop the iteration. |
---|
1788 | * @retval false Continue the iteration. |
---|
1789 | * |
---|
1790 | * @see rtems_filesystem_mount_iterate(). |
---|
1791 | */ |
---|
1792 | typedef bool (*rtems_filesystem_mt_entry_visitor)( |
---|
1793 | const rtems_filesystem_mount_table_entry_t *mt_entry, |
---|
1794 | void *arg |
---|
1795 | ); |
---|
1796 | |
---|
1797 | /** |
---|
1798 | * @brief Iterates over all file system mount entries. |
---|
1799 | * |
---|
1800 | * The iteration is protected by the IO library mutex. Do not mount or unmount |
---|
1801 | * file systems in the visitor function. |
---|
1802 | * |
---|
1803 | * @param[in] visitor For each file system mount entry the visitor function |
---|
1804 | * will be called with the entry and the visitor argument as parameters. |
---|
1805 | * @param[in] visitor_arg The second parameter for the visitor function. |
---|
1806 | * |
---|
1807 | * @retval true Iteration stopped due to visitor function return status. |
---|
1808 | * @retval false Iteration through all entries. |
---|
1809 | */ |
---|
1810 | bool rtems_filesystem_mount_iterate( |
---|
1811 | rtems_filesystem_mt_entry_visitor visitor, |
---|
1812 | void *visitor_arg |
---|
1813 | ); |
---|
1814 | |
---|
1815 | typedef struct { |
---|
1816 | const char *source; |
---|
1817 | const char *target; |
---|
1818 | const char *filesystemtype; |
---|
1819 | rtems_filesystem_options_t options; |
---|
1820 | const void *data; |
---|
1821 | } rtems_filesystem_mount_configuration; |
---|
1822 | |
---|
1823 | extern const rtems_filesystem_mount_configuration |
---|
1824 | rtems_filesystem_root_configuration; |
---|
1825 | |
---|
1826 | /** @} */ |
---|
1827 | |
---|
1828 | /** |
---|
1829 | * @defgroup Termios Termios |
---|
1830 | * |
---|
1831 | * @ingroup LibIO |
---|
1832 | * |
---|
1833 | * @brief Termios |
---|
1834 | */ |
---|
1835 | /**@{**/ |
---|
1836 | |
---|
1837 | typedef struct rtems_termios_callbacks { |
---|
1838 | int (*firstOpen)(int major, int minor, void *arg); |
---|
1839 | int (*lastClose)(int major, int minor, void *arg); |
---|
1840 | int (*pollRead)(int minor); |
---|
1841 | ssize_t (*write)(int minor, const char *buf, size_t len); |
---|
1842 | int (*setAttributes)(int minor, const struct termios *t); |
---|
1843 | int (*stopRemoteTx)(int minor); |
---|
1844 | int (*startRemoteTx)(int minor); |
---|
1845 | int outputUsesInterrupts; |
---|
1846 | } rtems_termios_callbacks; |
---|
1847 | |
---|
1848 | void rtems_termios_initialize (void); |
---|
1849 | |
---|
1850 | /* |
---|
1851 | * CCJ: Change before opening a tty. Newer code from Eric is coming |
---|
1852 | * so extra work to handle an open tty is not worth it. If the tty |
---|
1853 | * is open, close then open it again. |
---|
1854 | */ |
---|
1855 | rtems_status_code rtems_termios_bufsize ( |
---|
1856 | size_t cbufsize, /* cooked buffer size */ |
---|
1857 | size_t raw_input, /* raw input buffer size */ |
---|
1858 | size_t raw_output /* raw output buffer size */ |
---|
1859 | ); |
---|
1860 | |
---|
1861 | rtems_status_code rtems_termios_open ( |
---|
1862 | rtems_device_major_number major, |
---|
1863 | rtems_device_minor_number minor, |
---|
1864 | void *arg, |
---|
1865 | const rtems_termios_callbacks *callbacks |
---|
1866 | ); |
---|
1867 | |
---|
1868 | rtems_status_code rtems_termios_close( |
---|
1869 | void *arg |
---|
1870 | ); |
---|
1871 | |
---|
1872 | rtems_status_code rtems_termios_read( |
---|
1873 | void *arg |
---|
1874 | ); |
---|
1875 | |
---|
1876 | rtems_status_code rtems_termios_write( |
---|
1877 | void *arg |
---|
1878 | ); |
---|
1879 | |
---|
1880 | rtems_status_code rtems_termios_ioctl( |
---|
1881 | void *arg |
---|
1882 | ); |
---|
1883 | |
---|
1884 | int rtems_termios_enqueue_raw_characters( |
---|
1885 | void *ttyp, |
---|
1886 | const char *buf, |
---|
1887 | int len |
---|
1888 | ); |
---|
1889 | |
---|
1890 | int rtems_termios_dequeue_characters( |
---|
1891 | void *ttyp, |
---|
1892 | int len |
---|
1893 | ); |
---|
1894 | |
---|
1895 | /** @} */ |
---|
1896 | |
---|
1897 | /** |
---|
1898 | * @brief The pathconf setting for a file system. |
---|
1899 | */ |
---|
1900 | #define rtems_filesystem_pathconf(_mte) ((_mte)->pathconf_limits_and_options) |
---|
1901 | |
---|
1902 | /** |
---|
1903 | * @brief The type of file system. Its name. |
---|
1904 | */ |
---|
1905 | #define rtems_filesystem_type(_mte) ((_mte)->type) |
---|
1906 | |
---|
1907 | /** |
---|
1908 | * @brief The mount point of a file system. |
---|
1909 | */ |
---|
1910 | #define rtems_filesystem_mount_point(_mte) ((_mte)->target) |
---|
1911 | |
---|
1912 | /** |
---|
1913 | * @brief The device entry of a file system. |
---|
1914 | */ |
---|
1915 | #define rtems_filesystem_mount_device(_mte) ((_mte)->dev) |
---|
1916 | |
---|
1917 | #ifdef __cplusplus |
---|
1918 | } |
---|
1919 | #endif |
---|
1920 | |
---|
1921 | #endif /* _RTEMS_LIBIO_H */ |
---|