source: rtems/cpukit/libcsupport/include/rtems/libio.h @ 9b4422a2

4.115
Last change on this file since 9b4422a2 was 9b4422a2, checked in by Joel Sherrill <joel.sherrill@…>, on 05/03/12 at 15:09:24

Remove All CVS Id Strings Possible Using a Script

Script does what is expected and tries to do it as
smartly as possible.

+ remove occurrences of two blank comment lines

next to each other after Id string line removed.

+ remove entire comment blocks which only exited to

contain CVS Ids

+ If the processing left a blank line at the top of

a file, it was removed.

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