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

4.115
Last change on this file since bea7043c was bea7043c, checked in by Sebastian Huber <sebastian.huber@…>, on 02/24/12 at 12:42:06

Filesystem: Change node type enum values

Move the RTEMS_FILESYSTEM_INVALID_NODE_TYPE to the end. This makes it
possible to use this enum easily as an array index. Most comparisons
are made against RTEMS_FILESYSTEM_DIRECTORY. A value of zero allows on
some architectures simpler branch operations.

  • Property mode set to 100644
File size: 42.8 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup LibIO
5 *
6 * @brief Basic IO API.
7 */
8
9/*
10 *  COPYRIGHT (c) 1989-2008.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  Modifications to support reference counting in the file system are
14 *  Copyright (c) 2012 embedded brains GmbH.
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.rtems.com/license/LICENSE.
19 *
20 *  $Id$
21 */
22
23#ifndef _RTEMS_RTEMS_LIBIO_H
24#define _RTEMS_RTEMS_LIBIO_H
25
26#include <sys/types.h>
27#include <sys/stat.h>
28#include <sys/ioctl.h>
29#include <sys/statvfs.h>
30
31#include <unistd.h>
32#include <termios.h>
33
34#include <rtems.h>
35#include <rtems/fs.h>
36#include <rtems/chain.h>
37
38#ifdef __cplusplus
39extern "C" {
40#endif
41
42/**
43 * @defgroup LibIOFSOps File System Operations
44 *
45 * @ingroup LibIO
46 *
47 * @brief File system operations.
48 *
49 * @{
50 */
51
52/**
53 * @brief File system node types.
54 */
55typedef enum {
56  RTEMS_FILESYSTEM_DIRECTORY,
57  RTEMS_FILESYSTEM_DEVICE,
58  RTEMS_FILESYSTEM_HARD_LINK,
59  RTEMS_FILESYSTEM_SYM_LINK,
60  RTEMS_FILESYSTEM_MEMORY_FILE,
61  RTEMS_FILESYSTEM_INVALID_NODE_TYPE
62} rtems_filesystem_node_types_t;
63
64/**
65 * @brief Locks a file system instance.
66 *
67 * This lock must allow nesting.
68 *
69 * @param[in, out] mt_entry The mount table entry of the file system instance.
70 *
71 * @see rtems_filesystem_default_lock().
72 */
73typedef void (*rtems_filesystem_mt_entry_lock_t)(
74  rtems_filesystem_mount_table_entry_t *mt_entry
75);
76
77/**
78 * @brief Unlocks a file system instance.
79 *
80 * @param[in, out] mt_entry The mount table entry of the file system instance.
81 *
82 * @see rtems_filesystem_default_unlock().
83 */
84typedef void (*rtems_filesystem_mt_entry_unlock_t)(
85  rtems_filesystem_mount_table_entry_t *mt_entry
86);
87
88/**
89 * @brief Path evaluation context.
90 */
91typedef struct {
92  /**
93   * The contents of the remaining path to be evaluated.
94   */
95  const char *path;
96
97  /**
98   * The length of the remaining path to be evaluated.
99   */
100  size_t pathlen;
101
102  /**
103   * The contents of the token to be evaluated with respect to the current
104   * location.
105   */
106  const char *token;
107
108  /**
109   * The length of the token to be evaluated with respect to the current
110   * location.
111   */
112  size_t tokenlen;
113
114  /**
115   * The path evaluation is controlled by the following flags
116   *  - RTEMS_LIBIO_PERMS_READ,
117   *  - RTEMS_LIBIO_PERMS_WRITE,
118   *  - RTEMS_LIBIO_PERMS_EXEC,
119   *  - RTEMS_LIBIO_PERMS_SEARCH,
120   *  - RTEMS_LIBIO_FOLLOW_HARD_LINK,
121   *  - RTEMS_LIBIO_FOLLOW_SYM_LINK,
122   *  - RTEMS_LIBIO_MAKE,
123   *  - RTEMS_LIBIO_EXCLUSIVE,
124   *  - RTEMS_LIBIO_ACCEPT_RESIDUAL_DELIMITERS, and
125   *  - RTEMS_LIBIO_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 occured.  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 occured.  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 occured.  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 occured.  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 occured.  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 occured.  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 occured.  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 occured.  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 occured.  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 occured.  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 occured.  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 occured.  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 occured.  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 occured.  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  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  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/**
756 * @brief Opens a node.
757 *
758 * @param[in, out] iop The IO pointer.
759 * @param[in] path The path.
760 * @param[in] oflag The open flags.
761 * @param[in] mode Optional mode for node creation.
762 *
763 * @retval 0 Successful operation.
764 * @retval -1 An error occured.  The errno is set to indicate the error.
765 *
766 * @see rtems_filesystem_default_open().
767 */
768typedef int (*rtems_filesystem_open_t)(
769  rtems_libio_t *iop,
770  const char    *path,
771  int            oflag,
772  mode_t         mode
773);
774
775/**
776 * @brief Closes a node.
777 *
778 * @param[in, out] iop The IO pointer.
779 *
780 * @retval 0 Successful operation.
781 * @retval -1 An error occured.  The errno is set to indicate the error.
782 *
783 * @see rtems_filesystem_default_close().
784 */
785typedef int (*rtems_filesystem_close_t)(
786  rtems_libio_t *iop
787);
788
789/**
790 * @brief Reads from a node.
791 *
792 * @param[in, out] iop The IO pointer.
793 * @param[out] buffer The buffer for read data.
794 * @param[in] count The size of the buffer in characters.
795 *
796 * @retval non-negative Count of read characters.
797 * @retval -1 An error occured.  The errno is set to indicate the error.
798 *
799 * @see rtems_filesystem_default_read().
800 */
801typedef ssize_t (*rtems_filesystem_read_t)(
802  rtems_libio_t *iop,
803  void          *buffer,
804  size_t         count
805);
806
807/**
808 * @brief Writes to a node.
809 *
810 * @param[in, out] iop The IO pointer.
811 * @param[out] buffer The buffer for write data.
812 * @param[in] count The size of the buffer in characters.
813 *
814 * @retval non-negative Count of written characters.
815 * @retval -1 An error occured.  The errno is set to indicate the error.
816 *
817 * @see rtems_filesystem_default_write().
818 */
819typedef ssize_t (*rtems_filesystem_write_t)(
820  rtems_libio_t *iop,
821  const void    *buffer,
822  size_t         count
823);
824
825/**
826 * @brief IO control of a node.
827 *
828 * @param[in, out] iop The IO pointer.
829 * @param[in] request The IO control request.
830 * @param[in, out] buffer The buffer for IO control request data.
831 *
832 * @retval 0 Successful operation.
833 * @retval -1 An error occured.  The errno is set to indicate the error.
834 *
835 * @see rtems_filesystem_default_ioctl().
836 */
837typedef int (*rtems_filesystem_ioctl_t)(
838  rtems_libio_t *iop,
839  uint32_t       request,
840  void          *buffer
841);
842
843/**
844 * @brief Moves the read/write file offset.
845 *
846 * @param[in, out] iop The IO pointer.
847 * @param[in] offset The offset.
848 * @param[in] whence The reference position for the offset.
849 *
850 * @retval non-negative The new offset from the beginning of the file.
851 * @retval -1 An error occured.  The errno is set to indicate the error.
852 *
853 * @see rtems_filesystem_default_lseek() and
854 * rtems_filesystem_default_lseek_success().
855 */
856typedef off_t (*rtems_filesystem_lseek_t)(
857  rtems_libio_t *iop,
858  off_t          offset,
859  int            whence
860);
861
862/**
863 * @brief Gets a node status.
864 *
865 * @param[in, out] iop The IO pointer.
866 * @param[out] stat The buffer to status information.
867 *
868 * @retval 0 Successful operation.
869 * @retval -1 An error occured.  The errno is set to indicate the error.
870 *
871 * @see rtems_filesystem_default_fstat().
872 */
873typedef int (*rtems_filesystem_fstat_t)(
874  const rtems_filesystem_location_info_t *loc,
875  struct stat *buf
876);
877
878/**
879 * @brief Truncates a file to a specified length.
880 *
881 * @param[in, out] iop The IO pointer.
882 * @param[in] length The new length in characters.
883 *
884 * @retval 0 Successful operation.
885 * @retval -1 An error occured.  The errno is set to indicate the error.
886 *
887 * @see rtems_filesystem_default_ftruncate() and
888 * rtems_filesystem_default_ftruncate_directory().
889 */
890typedef int (*rtems_filesystem_ftruncate_t)(
891  rtems_libio_t *iop,
892  off_t length
893);
894
895/**
896 * @brief Synchronizes changes to a file.
897 *
898 * @param[in, out] iop The IO pointer.
899 *
900 * @retval 0 Successful operation.
901 * @retval -1 An error occured.  The errno is set to indicate the error.
902 *
903 * @see rtems_filesystem_default_fsync().
904 */
905typedef int (*rtems_filesystem_fsync_t)(
906  rtems_libio_t *iop
907);
908
909/**
910 * @brief Synchronizes the data of a file.
911 *
912 * @param[in, out] iop The IO pointer.
913 *
914 * @retval 0 Successful operation.
915 * @retval -1 An error occured.  The errno is set to indicate the error.
916 *
917 * @see rtems_filesystem_default_fdatasync().
918 */
919typedef int (*rtems_filesystem_fdatasync_t)(
920  rtems_libio_t *iop
921);
922
923/**
924 * @brief File control.
925 *
926 * @param[in, out] iop The IO pointer.
927 * @param[in] cmd Control command.
928 *
929 * @retval 0 Successful operation.
930 * @retval errno An error occured.  This value is assigned to errno.
931 *
932 * @see rtems_filesystem_default_fcntl().
933 */
934typedef int (*rtems_filesystem_fcntl_t)(
935  rtems_libio_t *iop,
936  int cmd
937);
938
939/**
940 * @brief File system node operations table.
941 */
942struct _rtems_filesystem_file_handlers_r {
943  rtems_filesystem_open_t open_h;
944  rtems_filesystem_close_t close_h;
945  rtems_filesystem_read_t read_h;
946  rtems_filesystem_write_t write_h;
947  rtems_filesystem_ioctl_t ioctl_h;
948  rtems_filesystem_lseek_t lseek_h;
949  rtems_filesystem_fstat_t fstat_h;
950  rtems_filesystem_ftruncate_t ftruncate_h;
951  rtems_filesystem_fsync_t fsync_h;
952  rtems_filesystem_fdatasync_t fdatasync_h;
953  rtems_filesystem_fcntl_t fcntl_h;
954};
955
956/**
957 * @brief File system node handler table with default node handlers.
958 */
959extern const rtems_filesystem_file_handlers_r
960  rtems_filesystem_handlers_default;
961
962/**
963 * @retval 0 Always.
964 *
965 * @see rtems_filesystem_open_t.
966 */
967int rtems_filesystem_default_open(
968  rtems_libio_t *iop,
969  const char    *path,
970  int            oflag,
971  mode_t         mode
972);
973
974/**
975 * @retval 0 Always.
976 *
977 * @see rtems_filesystem_close_t.
978 */
979int rtems_filesystem_default_close(
980  rtems_libio_t *iop
981);
982
983/**
984 * @retval -1 Always.  The errno is set to ENOTSUP.
985 *
986 * @see rtems_filesystem_read_t.
987 */
988ssize_t rtems_filesystem_default_read(
989  rtems_libio_t *iop,
990  void          *buffer,
991  size_t         count
992);
993
994/**
995 * @retval -1 Always.  The errno is set to ENOTSUP.
996 *
997 * @see rtems_filesystem_write_t.
998 */
999ssize_t rtems_filesystem_default_write(
1000  rtems_libio_t *iop,
1001  const void    *buffer,
1002  size_t         count
1003);
1004
1005/**
1006 * @retval -1 Always.  The errno is set to ENOTSUP.
1007 *
1008 * @see rtems_filesystem_ioctl_t.
1009 */
1010int rtems_filesystem_default_ioctl(
1011  rtems_libio_t *iop,
1012  uint32_t       command,
1013  void          *buffer
1014);
1015
1016/**
1017 * @retval -1 Always.  The errno is set to ESPIPE.
1018 *
1019 * @see rtems_filesystem_lseek_t.
1020 */
1021off_t rtems_filesystem_default_lseek(
1022  rtems_libio_t *iop,
1023  off_t          offset,
1024  int            whence
1025);
1026
1027/**
1028 * @retval 0 Always.
1029 *
1030 * @see rtems_filesystem_lseek_t.
1031 */
1032off_t rtems_filesystem_default_lseek_success(
1033  rtems_libio_t *iop,
1034  off_t          offset,
1035  int            whence
1036);
1037
1038/**
1039 * @brief Sets the mode to S_IRWXU | S_IRWXG | S_IRWXO.
1040 *
1041 * @retval 0 Always.
1042 *
1043 * @see rtems_filesystem_fstat_t.
1044 */
1045int rtems_filesystem_default_fstat(
1046  const rtems_filesystem_location_info_t *loc,
1047  struct stat *buf
1048);
1049
1050/**
1051 * @retval -1 Always.  The errno is set to ENOTSUP.
1052 *
1053 * @see rtems_filesystem_ftruncate_t.
1054 */
1055int rtems_filesystem_default_ftruncate(
1056  rtems_libio_t *iop,
1057  off_t length
1058);
1059
1060/**
1061 * @retval -1 Always.  The errno is set to EISDIR.
1062 *
1063 * @see rtems_filesystem_ftruncate_t.
1064 */
1065int rtems_filesystem_default_ftruncate_directory(
1066  rtems_libio_t *iop,
1067  off_t length
1068);
1069
1070/**
1071 * @retval -1 Always.  The errno is set to ENOTSUP.
1072 *
1073 * @see rtems_filesystem_fsync_t.
1074 */
1075int rtems_filesystem_default_fsync(
1076  rtems_libio_t *iop
1077);
1078
1079/**
1080 * @retval -1 Always.  The errno is set to ENOTSUP.
1081 *
1082 * @see rtems_filesystem_fdatasync_t.
1083 */
1084int rtems_filesystem_default_fdatasync(
1085  rtems_libio_t *iop
1086);
1087
1088/**
1089 * @retval 0 Always.
1090 *
1091 * @see rtems_filesystem_fcntl_t.
1092 */
1093int rtems_filesystem_default_fcntl(
1094  rtems_libio_t *iop,
1095  int cmd
1096);
1097
1098/** @} */
1099
1100/**
1101 * @defgroup LibIO IO Library
1102 *
1103 * @brief Provides system call and file system interface definitions.
1104 *
1105 * General purpose communication channel for RTEMS to allow UNIX/POSIX
1106 * system call behavior under RTEMS.  Initially this supported only
1107 * IO to devices but has since been enhanced to support networking
1108 * and support for mounted file systems.
1109 *
1110 * @{
1111 */
1112
1113typedef off_t rtems_off64_t __attribute__((deprecated));
1114
1115/**
1116 * @brief Gets the mount handler for the file system @a type.
1117 *
1118 * @return The file system mount handler associated with the @a type, or
1119 * @c NULL if no such association exists.
1120 */
1121rtems_filesystem_fsmount_me_t
1122rtems_filesystem_get_mount_handler(
1123  const char *type
1124);
1125
1126/**
1127 * @brief Contain file system specific information which is required to support
1128 * fpathconf().
1129 */
1130typedef struct {
1131  int    link_max;                 /* count */
1132  int    max_canon;                /* max formatted input line size */
1133  int    max_input;                /* max input line size */
1134  int    name_max;                 /* max name length */
1135  int    path_max;                 /* max path */
1136  int    pipe_buf;                 /* pipe buffer size */
1137  int    posix_async_io;           /* async IO supported on fs, 0=no, 1=yes */
1138  int    posix_chown_restrictions; /* can chown: 0=no, 1=yes */
1139  int    posix_no_trunc;           /* error on names > max name, 0=no, 1=yes */
1140  int    posix_prio_io;            /* priority IO, 0=no, 1=yes */
1141  int    posix_sync_io;            /* file can be sync'ed, 0=no, 1=yes */
1142  int    posix_vdisable;           /* special char processing, 0=no, 1=yes */
1143} rtems_filesystem_limits_and_options_t;
1144
1145/**
1146 * @brief Default pathconf settings.
1147 *
1148 * Override in a filesystem.
1149 */
1150extern const rtems_filesystem_limits_and_options_t
1151  rtems_filesystem_default_pathconf;
1152
1153/**
1154 * @brief An open file data structure.
1155 *
1156 * It will be indexed by 'fd'.
1157 *
1158 * @todo Should really have a separate per/file data structure that this points
1159 * to (eg: size, offset, driver, pathname should be in that)
1160 */
1161struct rtems_libio_tt {
1162  rtems_driver_name_t                    *driver;
1163  off_t                                   size;      /* size of file */
1164  off_t                                   offset;    /* current offset into file */
1165  uint32_t                                flags;
1166  rtems_filesystem_location_info_t        pathinfo;
1167  rtems_id                                sem;
1168  uint32_t                                data0;     /* private to "driver" */
1169  void                                   *data1;     /* ... */
1170};
1171
1172/**
1173 * @brief Paramameter block for read/write.
1174 *
1175 * It must include 'offset' instead of using iop's offset since we can have
1176 * multiple outstanding i/o's on a device.
1177 */
1178typedef struct {
1179  rtems_libio_t          *iop;
1180  off_t                   offset;
1181  char                   *buffer;
1182  uint32_t                count;
1183  uint32_t                flags;
1184  uint32_t                bytes_moved;
1185} rtems_libio_rw_args_t;
1186
1187/**
1188 * @brief Parameter block for open/close.
1189 */
1190typedef struct {
1191  rtems_libio_t          *iop;
1192  uint32_t                flags;
1193  uint32_t                mode;
1194} rtems_libio_open_close_args_t;
1195
1196/**
1197 * @brief Parameter block for ioctl.
1198 */
1199typedef struct {
1200  rtems_libio_t          *iop;
1201  uint32_t                command;
1202  void                   *buffer;
1203  uint32_t                ioctl_return;
1204} rtems_libio_ioctl_args_t;
1205
1206/**
1207 * @name Flag Values
1208 *
1209 * @{
1210 */
1211
1212#define LIBIO_FLAGS_NO_DELAY      0x0001U  /* return immediately if no data */
1213#define LIBIO_FLAGS_READ          0x0002U  /* reading */
1214#define LIBIO_FLAGS_WRITE         0x0004U  /* writing */
1215#define LIBIO_FLAGS_OPEN          0x0100U  /* device is open */
1216#define LIBIO_FLAGS_APPEND        0x0200U  /* all writes append */
1217#define LIBIO_FLAGS_CREATE        0x0400U  /* create file */
1218#define LIBIO_FLAGS_CLOSE_ON_EXEC 0x0800U  /* close on process exec() */
1219#define LIBIO_FLAGS_READ_WRITE    (LIBIO_FLAGS_READ | LIBIO_FLAGS_WRITE)
1220
1221/** @} */
1222
1223void rtems_libio_init(void);
1224
1225/**
1226 * @name External I/O Handlers
1227 *
1228 * @{
1229 */
1230
1231typedef int (*rtems_libio_open_t)(
1232  const char  *pathname,
1233  uint32_t    flag,
1234  uint32_t    mode
1235);
1236
1237typedef int (*rtems_libio_close_t)(
1238  int  fd
1239);
1240
1241typedef ssize_t (*rtems_libio_read_t)(
1242  int         fd,
1243  void       *buffer,
1244  size_t    count
1245);
1246
1247typedef ssize_t (*rtems_libio_write_t)(
1248  int         fd,
1249  const void *buffer,
1250  size_t      count
1251);
1252
1253typedef int (*rtems_libio_ioctl_t)(
1254  int         fd,
1255  uint32_t    command,
1256  void       *buffer
1257);
1258
1259typedef off_t (*rtems_libio_lseek_t)(
1260  int           fd,
1261  off_t         offset,
1262  int           whence
1263);
1264
1265/** @} */
1266
1267/**
1268 * @name Permission Macros
1269 *
1270 * @{
1271 */
1272
1273/*
1274 *  The following macros are used to build up the permissions sets
1275 *  used to check permissions.  These are similar in style to the
1276 *  mode_t bits and should stay compatible with them.
1277 */
1278#define RTEMS_LIBIO_PERMS_READ 0x4
1279#define RTEMS_LIBIO_PERMS_WRITE 0x2
1280#define RTEMS_LIBIO_PERMS_EXEC 0x1
1281#define RTEMS_LIBIO_PERMS_SEARCH RTEMS_LIBIO_PERMS_EXEC
1282#define RTEMS_LIBIO_PERMS_RDWR \
1283  (RTEMS_LIBIO_PERMS_READ | RTEMS_LIBIO_PERMS_WRITE)
1284#define RTEMS_LIBIO_PERMS_RWX \
1285  (RTEMS_LIBIO_PERMS_RDWR | RTEMS_LIBIO_PERMS_EXEC)
1286#define RTEMS_LIBIO_FOLLOW_HARD_LINK 0x8
1287#define RTEMS_LIBIO_FOLLOW_SYM_LINK 0x10
1288#define RTEMS_LIBIO_FOLLOW_LINK \
1289  (RTEMS_LIBIO_FOLLOW_HARD_LINK | RTEMS_LIBIO_FOLLOW_SYM_LINK)
1290#define RTEMS_LIBIO_MAKE 0x20
1291#define RTEMS_LIBIO_EXCLUSIVE 0x40
1292#define RTEMS_LIBIO_ACCEPT_RESIDUAL_DELIMITERS 0x80
1293#define RTEMS_LIBIO_REJECT_TERMINAL_DOT 0x100
1294
1295/** @} */
1296
1297union __rtems_dev_t {
1298  dev_t device;
1299  struct {
1300     rtems_device_major_number major;
1301     rtems_device_minor_number minor;
1302  } __overlay;
1303};
1304
1305static inline dev_t rtems_filesystem_make_dev_t(
1306  rtems_device_major_number _major,
1307  rtems_device_minor_number _minor
1308)
1309{
1310  union __rtems_dev_t temp;
1311
1312  temp.__overlay.major = _major;
1313  temp.__overlay.minor = _minor;
1314  return temp.device;
1315}
1316
1317static inline rtems_device_major_number rtems_filesystem_dev_major_t(
1318  dev_t device
1319)
1320{
1321  union __rtems_dev_t temp;
1322
1323  temp.device = device;
1324  return temp.__overlay.major;
1325}
1326
1327
1328static inline rtems_device_minor_number rtems_filesystem_dev_minor_t(
1329  dev_t device
1330)
1331{
1332  union __rtems_dev_t temp;
1333
1334  temp.device = device;
1335  return temp.__overlay.minor;
1336}
1337
1338#define rtems_filesystem_split_dev_t( _dev, _major, _minor ) \
1339  do { \
1340    (_major) = rtems_filesystem_dev_major_t ( _dev ); \
1341    (_minor) = rtems_filesystem_dev_minor_t( _dev ); \
1342  } while(0)
1343
1344/*
1345 *  Prototypes for filesystem
1346 */
1347
1348void rtems_filesystem_initialize( void );
1349
1350typedef void (*rtems_libio_init_functions_t)(void);
1351extern  rtems_libio_init_functions_t rtems_libio_init_helper;
1352
1353void    open_dev_console(void);
1354
1355typedef void (*rtems_libio_supp_functions_t)(void);
1356extern  rtems_libio_supp_functions_t rtems_libio_supp_helper;
1357
1358typedef void (*rtems_fs_init_functions_t)(void);
1359extern  rtems_fs_init_functions_t    rtems_fs_init_helper;
1360
1361/**
1362 * @brief Creates a directory and all its parent directories according to
1363 * @a path.
1364 *
1365 * The @a mode value selects the access permissions of the directory.
1366 *
1367 * @retval 0 Successful operation.
1368 * @retval -1 An error occured.  The @c errno indicates the error.
1369 */
1370extern int rtems_mkdir(const char *path, mode_t mode);
1371
1372/** @} */
1373
1374/**
1375 * @defgroup FileSystemTypesAndMount File System Types and Mount
1376 *
1377 * @ingroup LibIO
1378 *
1379 * @brief File system types and mount.
1380 *
1381 * @{
1382 */
1383
1384/**
1385 * @name File System Types
1386 *
1387 * @{
1388 */
1389
1390#define RTEMS_FILESYSTEM_TYPE_IMFS "imfs"
1391#define RTEMS_FILESYSTEM_TYPE_MINIIMFS "mimfs"
1392#define RTEMS_FILESYSTEM_TYPE_DEVFS "devfs"
1393#define RTEMS_FILESYSTEM_TYPE_FTPFS "ftpfs"
1394#define RTEMS_FILESYSTEM_TYPE_TFTPFS "tftpfs"
1395#define RTEMS_FILESYSTEM_TYPE_NFS "nfs"
1396#define RTEMS_FILESYSTEM_TYPE_DOSFS "dosfs"
1397#define RTEMS_FILESYSTEM_TYPE_RFS "rfs"
1398
1399/** @} */
1400
1401/**
1402 * @brief Mount table entry.
1403 */
1404struct rtems_filesystem_mount_table_entry_tt {
1405  rtems_chain_node                       mt_node;
1406  rtems_chain_control                    location_chain;
1407  rtems_filesystem_global_location_t    *mt_point_node;
1408  rtems_filesystem_global_location_t    *mt_fs_root;
1409  bool                                   mounted;
1410  bool                                   writeable;
1411  void                                  *fs_info;
1412  const void                            *immutable_fs_info;
1413  rtems_filesystem_limits_and_options_t  pathconf_limits_and_options;
1414
1415  /*
1416   * The target or mount point of the file system.
1417   */
1418  const char                            *target;
1419
1420  /*
1421   * The type of filesystem or the name of the filesystem.
1422   */
1423  const char                            *type;
1424
1425  /*
1426   *  When someone adds a mounted filesystem on a real device,
1427   *  this will need to be used.
1428   *
1429   *  The lower layers can manage how this is managed. Leave as a
1430   *  string.
1431   */
1432  char                                  *dev;
1433};
1434
1435/**
1436 * @brief File system options.
1437 */
1438typedef enum {
1439  RTEMS_FILESYSTEM_READ_ONLY,
1440  RTEMS_FILESYSTEM_READ_WRITE,
1441  RTEMS_FILESYSTEM_BAD_OPTIONS
1442} rtems_filesystem_options_t;
1443
1444/**
1445 * @brief File system table entry.
1446 */
1447typedef struct rtems_filesystem_table_t {
1448  const char                    *type;
1449  rtems_filesystem_fsmount_me_t  mount_h;
1450} rtems_filesystem_table_t;
1451
1452/**
1453 * @brief Static table of file systems.
1454 *
1455 * Externally defined by confdefs.h or the user.
1456 */
1457extern const rtems_filesystem_table_t rtems_filesystem_table [];
1458
1459extern rtems_chain_control rtems_filesystem_mount_table;
1460
1461/**
1462 * @brief Registers a file system @a type.
1463 *
1464 * The @a mount_h handler will be used to mount a file system of this @a type.
1465 *
1466 * @retval 0 Successful operation.
1467 * @retval -1 An error occured.  The @c errno indicates the error.
1468 */
1469int rtems_filesystem_register(
1470  const char                    *type,
1471  rtems_filesystem_fsmount_me_t  mount_h
1472);
1473
1474/**
1475 * @brief Unregisters a file system @a type.
1476 *
1477 * @retval 0 Successful operation.
1478 * @retval -1 An error occured.  The @c errno indicates the error.
1479 */
1480int rtems_filesystem_unregister(
1481  const char *type
1482);
1483
1484/**
1485 * @brief Unmounts the file system at @a mount_path.
1486 *
1487 * @todo Due to file system implementation shortcomings it is possible to
1488 * unmount file systems in use.  This likely leads to heap corruption.  Unmount
1489 * only file systems which are not in use by the application.
1490 *
1491 * @retval 0 Successful operation.
1492 * @retval -1 An error occured.  The @c errno indicates the error.
1493 */
1494int unmount(
1495  const char *mount_path
1496);
1497
1498/**
1499 * @brief Mounts a file system at @a target.
1500 *
1501 * The @a source may be a path to the corresponding device file, or @c NULL.
1502 * The @a target path must lead to an existing directory, or @c NULL.  In case
1503 * @a target is @c NULL, the root file system will be mounted.  The @a data
1504 * parameter will be forwarded to the file system initialization handler.  The
1505 * file system type is selected by @a filesystemtype and may be one of
1506 * - RTEMS_FILESYSTEM_TYPE_DEVFS,
1507 * - RTEMS_FILESYSTEM_TYPE_DOSFS,
1508 * - RTEMS_FILESYSTEM_TYPE_FTPFS,
1509 * - RTEMS_FILESYSTEM_TYPE_IMFS,
1510 * - RTEMS_FILESYSTEM_TYPE_MINIIMFS,
1511 * - RTEMS_FILESYSTEM_TYPE_NFS,
1512 * - RTEMS_FILESYSTEM_TYPE_RFS, or
1513 * - RTEMS_FILESYSTEM_TYPE_TFTPFS.
1514 *
1515 * Only configured or registered file system types are available.  You can add
1516 * file system types to your application configuration with
1517 * - CONFIGURE_FILESYSTEM_DEVFS,
1518 * - CONFIGURE_FILESYSTEM_DOSFS,
1519 * - CONFIGURE_FILESYSTEM_FTPFS,
1520 * - CONFIGURE_FILESYSTEM_IMFS,
1521 * - CONFIGURE_FILESYSTEM_MINIIMFS,
1522 * - CONFIGURE_FILESYSTEM_NFS,
1523 * - CONFIGURE_FILESYSTEM_RFS, and
1524 * - CONFIGURE_FILESYSTEM_TFTPFS.
1525 *
1526 * @see rtems_filesystem_register() and mount_and_make_target_path().
1527 *
1528 * @retval 0 Successful operation.
1529 * @retval -1 An error occured.  The @c errno indicates the error.
1530 */
1531int mount(
1532  const char                 *source,
1533  const char                 *target,
1534  const char                 *filesystemtype,
1535  rtems_filesystem_options_t options,
1536  const void                 *data
1537);
1538
1539/**
1540 * @brief Mounts a file system and makes the @a target path.
1541 *
1542 * The @a target path will be created with rtems_mkdir() and must not be
1543 * @c NULL.
1544 *
1545 * @see mount().
1546 *
1547 * @retval 0 Successful operation.
1548 * @retval -1 An error occured.  The @c errno indicates the error.
1549 */
1550int mount_and_make_target_path(
1551  const char                 *source,
1552  const char                 *target,
1553  const char                 *filesystemtype,
1554  rtems_filesystem_options_t options,
1555  const void                 *data
1556);
1557
1558/**
1559 * @brief Per file system type routine.
1560 *
1561 * @see rtems_filesystem_iterate().
1562 *
1563 * @retval true Stop the iteration.
1564 * @retval false Continue the iteration.
1565 */
1566typedef bool (*rtems_per_filesystem_routine)(
1567  const rtems_filesystem_table_t *fs_entry,
1568  void *arg
1569);
1570
1571/**
1572 * @brief Iterates over all file system types.
1573 *
1574 * For each file system type the @a routine will be called with the entry and
1575 * the @a routine_arg parameter.
1576 *
1577 * Do not register or unregister file system types in @a routine.
1578 *
1579 * The iteration is protected by the IO library mutex.
1580 *
1581 * @retval true Iteration stopped due to @a routine return status.
1582 * @retval false Iteration through all entries.
1583 */
1584bool rtems_filesystem_iterate(
1585  rtems_per_filesystem_routine routine,
1586  void *routine_arg
1587);
1588
1589/**
1590 * @brief Mount table entry visitor.
1591 *
1592 * @retval true Stop the iteration.
1593 * @retval false Continue the iteration.
1594 *
1595 * @see rtems_filesystem_mount_iterate().
1596 */
1597typedef bool (*rtems_filesystem_mt_entry_visitor)(
1598  const rtems_filesystem_mount_table_entry_t *mt_entry,
1599  void *arg
1600);
1601
1602/**
1603 * @brief Iterates over all file system mount entries.
1604 *
1605 * The iteration is protected by the IO library mutex.  Do not mount or unmount
1606 * file systems in the visitor function.
1607 *
1608 * @param[in] visitor For each file system mount entry the visitor function
1609 * will be called with the entry and the visitor argument as parameters.
1610 * @param[in] visitor_arg The second parameter for the visitor function.
1611 *
1612 * @retval true Iteration stopped due to visitor function return status.
1613 * @retval false Iteration through all entries.
1614 */
1615bool rtems_filesystem_mount_iterate(
1616  rtems_filesystem_mt_entry_visitor visitor,
1617  void *visitor_arg
1618);
1619
1620typedef struct {
1621  const char *source;
1622  const char *target;
1623  const char *filesystemtype;
1624  rtems_filesystem_options_t options;
1625  const void *data;
1626} rtems_filesystem_mount_configuration;
1627
1628extern const rtems_filesystem_mount_configuration
1629  rtems_filesystem_root_configuration;
1630
1631/** @} */
1632
1633/**
1634 * @defgroup Termios Termios
1635 *
1636 * @ingroup LibIO
1637 *
1638 * @brief Termios
1639 *
1640 * @{
1641 */
1642
1643typedef struct rtems_termios_callbacks {
1644  int    (*firstOpen)(int major, int minor, void *arg);
1645  int    (*lastClose)(int major, int minor, void *arg);
1646  int    (*pollRead)(int minor);
1647  ssize_t (*write)(int minor, const char *buf, size_t len);
1648  int    (*setAttributes)(int minor, const struct termios *t);
1649  int    (*stopRemoteTx)(int minor);
1650  int    (*startRemoteTx)(int minor);
1651  int    outputUsesInterrupts;
1652} rtems_termios_callbacks;
1653
1654void rtems_termios_initialize (void);
1655
1656/*
1657 * CCJ: Change before opening a tty. Newer code from Eric is coming
1658 * so extra work to handle an open tty is not worth it. If the tty
1659 * is open, close then open it again.
1660 */
1661rtems_status_code rtems_termios_bufsize (
1662  size_t cbufsize,     /* cooked buffer size */
1663  size_t raw_input,    /* raw input buffer size */
1664  size_t raw_output    /* raw output buffer size */
1665);
1666
1667rtems_status_code rtems_termios_open (
1668  rtems_device_major_number      major,
1669  rtems_device_minor_number      minor,
1670  void                          *arg,
1671  const rtems_termios_callbacks *callbacks
1672);
1673
1674rtems_status_code rtems_termios_close(
1675  void *arg
1676);
1677
1678rtems_status_code rtems_termios_read(
1679  void *arg
1680);
1681
1682rtems_status_code rtems_termios_write(
1683  void *arg
1684);
1685
1686rtems_status_code rtems_termios_ioctl(
1687  void *arg
1688);
1689
1690int rtems_termios_enqueue_raw_characters(
1691  void *ttyp,
1692  const char *buf,
1693  int   len
1694);
1695
1696int rtems_termios_dequeue_characters(
1697  void *ttyp,
1698  int   len
1699);
1700
1701/** @} */
1702
1703/**
1704 * @brief The pathconf setting for a file system.
1705 */
1706#define rtems_filesystem_pathconf(_mte) ((_mte)->pathconf_limits_and_options)
1707
1708/**
1709 * @brief The type of file system. Its name.
1710 */
1711#define rtems_filesystem_type(_mte) ((_mte)->type)
1712
1713/**
1714 * @brief The mount point of a file system.
1715 */
1716#define rtems_filesystem_mount_point(_mte) ((_mte)->target)
1717
1718/**
1719 * @brief The device entry of a file system.
1720 */
1721#define rtems_filesystem_mount_device(_mte) ((_mte)->dev)
1722
1723#ifdef __cplusplus
1724}
1725#endif
1726
1727#endif /* _RTEMS_LIBIO_H */
Note: See TracBrowser for help on using the repository browser.