source: rtems/cpukit/libcsupport/include/rtems/libio.h @ 4ec8180

4.11
Last change on this file since 4ec8180 was 96406152, checked in by Ralf Corsepius <ralf.corsepius@…>, on Oct 18, 2011 at 2:37:47 PM

2011-10-18 Ralf Corsépius <ralf.corsepius@…>

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