source: rtems/cpukit/libcsupport/include/rtems/libio.h @ b697bc6

4.115
Last change on this file since b697bc6 was b697bc6, checked in by Joel Sherrill <joel.sherrill@…>, on 01/10/13 at 21:06:42

cpukit: Use Consistent Beginning of Doxygen Group Notation

This is the result of a sed script which converts all uses
of @{ into a consistent form.

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