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

4.115
Last change on this file since b637dbb was b637dbb, checked in by Joel Sherrill <joel.sherrill@…>, on 07/03/10 at 19:13:25

2010-07-03 Joel Sherrill <joel.sherrill@…>

  • libcsupport/include/rtems/libio.h, libfs/src/defaults/default_read.c, libfs/src/defaults/default_readlink.c, libfs/src/rfs/rtems-rfs-rtems.c: Correct types and prototypes to eliminate warnings.
  • Property mode set to 100644
File size: 45.6 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 * @name File System Node Types
60 *
61 * @{
62 */
63
64#define RTEMS_FILESYSTEM_DIRECTORY   1
65#define RTEMS_FILESYSTEM_DEVICE      2
66#define RTEMS_FILESYSTEM_HARD_LINK   3
67#define RTEMS_FILESYSTEM_SYM_LINK    4
68#define RTEMS_FILESYSTEM_MEMORY_FILE 5
69
70/** @} */
71
72typedef int rtems_filesystem_node_types_t;
73
74/**
75 * @name File System Node Operations
76 *
77 * @{
78 */
79
80/**
81 *  This type defines the interface to the open(2) system call
82 *  support which is provided by a file system implementation.
83 */
84typedef int (*rtems_filesystem_open_t)(
85  rtems_libio_t *iop,
86  const char    *pathname,
87  uint32_t       flag,
88  uint32_t       mode
89);
90
91/**
92 *  This type defines the interface to the close(2) system call
93 *  support which is provided by a file system implementation.
94 */
95typedef int (*rtems_filesystem_close_t)(
96  rtems_libio_t *iop
97);
98
99/**
100 *  This type defines the interface to the read(2) system call
101 *  support which is provided by a file system implementation.
102 */
103typedef ssize_t (*rtems_filesystem_read_t)(
104  rtems_libio_t *iop,
105  void          *buffer,
106  size_t         count
107);
108
109/**
110 *  This type defines the interface to the write(2) system call
111 *  support which is provided by a file system implementation.
112 */
113typedef ssize_t (*rtems_filesystem_write_t)(
114  rtems_libio_t *iop,
115  const void    *buffer,
116  size_t         count
117);
118
119/**
120 *  This type defines the interface to the ioctl(2) system call
121 *  support which is provided by a file system implementation.
122 */
123typedef int (*rtems_filesystem_ioctl_t)(
124  rtems_libio_t *iop,
125  uint32_t       command,
126  void          *buffer
127);
128
129/**
130 *  This type defines the interface to the lseek(2) system call
131 *  support which is provided by a file system implementation.
132 */
133typedef rtems_off64_t (*rtems_filesystem_lseek_t)(
134  rtems_libio_t *iop,
135  rtems_off64_t  length,
136  int            whence
137);
138
139/**
140 *  This type defines the interface to the fstat(2) system call
141 *  support which is provided by a file system implementation.
142 */
143typedef int (*rtems_filesystem_fstat_t)(
144  rtems_filesystem_location_info_t *loc,
145  struct stat                      *buf
146);
147
148/**
149 *  This type defines the interface to the fchmod(2) system call
150 *  support which is provided by a file system implementation.
151 */
152typedef int (*rtems_filesystem_fchmod_t)(
153  rtems_filesystem_location_info_t *loc,
154  mode_t                            mode
155);
156
157/**
158 *  This type defines the interface to the ftruncate(2) system call
159 *  support which is provided by a file system implementation.
160 */
161typedef int (*rtems_filesystem_ftruncate_t)(
162  rtems_libio_t *iop,
163  rtems_off64_t  length
164);
165
166/**
167 *  This type defines the interface to the fpathconf(2) system call
168 *  support which is provided by a file system implementation.
169 */
170typedef int (*rtems_filesystem_fpathconf_t)(
171  rtems_libio_t *iop,
172  int name
173);
174
175/**
176 *  This type defines the interface to the fsync(2) system call
177 *  support which is provided by a file system implementation.
178 */
179typedef int (*rtems_filesystem_fsync_t)(
180  rtems_libio_t *iop
181);
182
183/**
184 *  This type defines the interface to the fdatasync(2) system call
185 *  support which is provided by a file system implementation.
186 */
187typedef int (*rtems_filesystem_fdatasync_t)(
188  rtems_libio_t *iop
189);
190
191/**
192 *  This type defines the interface to the fnctl(2) system call
193 *  support which is provided by a file system implementation.
194 */
195typedef int (*rtems_filesystem_fcntl_t)(
196  int            cmd,
197  rtems_libio_t *iop
198);
199
200typedef int (*rtems_filesystem_rmnod_t)(
201 rtems_filesystem_location_info_t      *parent_loc,   /* IN */
202 rtems_filesystem_location_info_t      *pathloc       /* IN */
203);
204
205/** @} */
206
207/**
208 * @brief File system node operations table.
209 */
210struct _rtems_filesystem_file_handlers_r {
211  /**
212   *  This field points to the file system specific implementation
213   *  of the support routine for the open(2) system call
214   *
215   *  @note This method must have a filesystem specific implementation.
216   *
217   *  @note There is no default implementation.
218   */
219  rtems_filesystem_open_t         open_h;
220
221  /**
222   *  This field points to the file system specific implementation
223   *  of the support routine for the close(2) system call
224   *
225   *  @note This method is REQUIRED by all file systems.
226   *
227   *  @note There is no default implementation.
228   */
229  rtems_filesystem_close_t        close_h;
230
231  /**
232   *  This field points to the file system specific implementation
233   *  of the support routine for the read(2) system call
234   *
235   *  @note This method must have a filesystem specific implementation.
236   *
237   *  @note The default implementation returns -1 and sets
238   *  errno to ENOTSUP.
239   */
240  rtems_filesystem_read_t         read_h;
241
242  /**
243   *  This field points to the file system specific implementation
244   *  of the support routine for the write(2) system call
245   *
246   *  @note This method may use a default implementation.
247   *
248   *  @note The default implementation returns -1 and sets
249   *  errno to ENOTSUP.
250   */
251  rtems_filesystem_write_t        write_h;
252
253  /**
254   *  This field points to the file system specific implementation
255   *  of the support routine for the ioctl(2) system call
256   *
257   *  @note This method may use a default implementation.
258   *
259   *  @note The default implementation returns -1 and sets
260   *  errno to ENOTSUP.
261   */
262  rtems_filesystem_ioctl_t        ioctl_h;
263
264  /**
265   *  This field points to the file system specific implementation
266   *  of the support routine for the lseek(2) system call
267   *
268   *  @note This method may use a default implementation.
269   *
270   *  @note The default implementation returns -1 and sets
271   *  errno to ENOTSUP.
272   */
273  rtems_filesystem_lseek_t        lseek_h;
274
275  /**
276   *  This field points to the file system specific implementation
277   *  of the support routine for the fstat(2) system call
278   *
279   *  @note This method may use a default implementation.
280   *
281   *  @note The default implementation returns -1 and sets
282   *  errno to ENOTSUP.
283   */
284  rtems_filesystem_fstat_t        fstat_h;
285
286  /**
287   *  This field points to the file system specific implementation
288   *  of the support routine for the fchmod(2) system call
289   *
290   *  @note This method may use a default implementation.
291   *
292   *  @note The default implementation returns -1 and sets
293   *  errno to ENOTSUP.
294   */
295  rtems_filesystem_fchmod_t       fchmod_h;
296
297  /**
298   *  This field points to the file system specific implementation
299   *  of the support routine for the ftruncate(2) system call
300   *
301   *  @note This method may use a default implementation.
302   *
303   *  @note The default implementation returns -1 and sets
304   *  errno to ENOTSUP.
305   */
306  rtems_filesystem_ftruncate_t    ftruncate_h;
307
308  /**
309   *  This field points to the file system specific implementation
310   *  of the support routine for the fpathconf(2) system call
311   *
312   *  @note This method may use a default implementation.
313   *
314   *  @note The default implementation returns -1 and sets
315   *  errno to ENOTSUP.
316   */
317  rtems_filesystem_fpathconf_t    fpathconf_h;
318
319  /**
320   *  This field points to the file system specific implementation
321   *  of the support routine for the fsync(2) system call
322   *
323   *  @note This method may use a default implementation.
324   *
325   *  @note The default implementation returns -1 and sets
326   *  errno to ENOTSUP.
327   */
328  rtems_filesystem_fsync_t        fsync_h;
329
330  /**
331   *  This field points to the file system specific implementation
332   *  of the support routine for the fdatasync(2) system call
333   *
334   *  @note This method may use a default implementation.
335   *
336   *  @note The default implementation returns -1 and sets
337   *  errno to ENOTSUP.
338   */
339  rtems_filesystem_fdatasync_t    fdatasync_h;
340
341  /**
342   *  This field points to the file system specific implementation
343   *  of the support routine for the fcntl(2) system call
344   *
345   *  @note This method may use a default implementation.
346   *
347   *  @note The default implementation returns -1 and sets
348   *  errno to ENOTSUP.
349   */
350  rtems_filesystem_fcntl_t        fcntl_h;
351
352  /**
353   *  This field points to the file system specific implementation
354   *  of the support routine for the rmnod(2) system call
355   *
356   *  @note This method may use a default implementation.
357   *
358   *  @note The default implementation returns -1 and sets
359   *  errno to ENOTSUP.
360   */
361  rtems_filesystem_rmnod_t        rmnod_h;
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
895/*
896 * @brief Default filesystem evalpath
897 */
898
899
900/**
901 * @brief Provides a defualt routine for filesystem
902 * implementation of a link command.
903 */
904int rtems_filesystem_default_link(
905 rtems_filesystem_location_info_t  *to_loc,      /* IN */
906 rtems_filesystem_location_info_t  *parent_loc,  /* IN */
907 const char                        *name         /* IN */
908);
909
910/**
911 * @brief Provides a defualt routine for filesystem
912 * implementation of a unlink command.
913 */
914int rtems_filesystem_default_unlink(
915 rtems_filesystem_location_info_t  *parent_pathloc, /* IN */
916 rtems_filesystem_location_info_t  *pathloc         /* IN */
917);
918
919/**
920 * @brief Provides a defualt routine for filesystem
921 * implementation to create a new node.
922 */
923int rtems_filesystem_default_mknod(
924   const char                        *path,       /* IN */
925   mode_t                             mode,       /* IN */
926   dev_t                              dev,        /* IN */
927   rtems_filesystem_location_info_t  *pathloc     /* IN/OUT */
928);
929
930/**
931 * @brief Provides a defualt routine for filesystem
932 * implementation of a chown command.
933 */
934int rtems_filesystem_default_chown(
935 rtems_filesystem_location_info_t  *pathloc,       /* IN */
936 uid_t                              owner,         /* IN */
937 gid_t                              group          /* IN */
938);
939
940/**
941 * @brief Provides a defualt routine for filesystem
942 * implementation of a freenode command.
943 */
944int rtems_filesystem_default_freenode(
945 rtems_filesystem_location_info_t      *pathloc       /* IN */
946);
947
948/**
949 * @brief Provides a defualt routine for filesystem
950 * implementation of a mount command.
951 */
952int rtems_filesystem_default_mount (
953   rtems_filesystem_mount_table_entry_t *mt_entry     /* IN */
954);
955
956/**
957 * @brief Provides a defualt routine for filesystem
958 * implementation of a fsmount command.
959 */
960int rtems_filesystem_default_fsmount(
961  rtems_filesystem_mount_table_entry_t *mt_entry,     /* IN */
962  const void                           *data          /* IN */
963);
964
965/**
966 * @brief Provides a defualt routine for filesystem
967 * implementation of a unmount command.
968 */
969int rtems_filesystem_default_unmount(
970  rtems_filesystem_mount_table_entry_t *mt_entry     /* IN */
971);
972
973/**
974 * @brief Provides a defualt routine for filesystem
975 * implementation of a fsunmount command.
976 */
977int rtems_filesystem_default_fsunmount(
978   rtems_filesystem_mount_table_entry_t *mt_entry    /* IN */
979);
980
981
982/**
983 * @brief Provides a defualt routine for filesystem
984 * implementation of a utime command.
985 */
986int rtems_filesystem_default_utime(
987  rtems_filesystem_location_info_t  *pathloc,       /* IN */
988  time_t                             actime,        /* IN */
989  time_t                             modtime        /* IN */
990);
991
992/**
993 * @brief Provides a defualt routine for filesystem
994 * implementation of a link command.
995 */
996int rtems_filesystem_default_evaluate_link(
997  rtems_filesystem_location_info_t *pathloc,     /* IN/OUT */
998  int                               flags        /* IN     */
999);
1000
1001/**
1002 * @brief Provides a defualt routine for filesystem
1003 * implementation of a symlink command.
1004 */
1005int rtems_filesystem_default_symlink(
1006 rtems_filesystem_location_info_t  *loc,         /* IN */
1007 const char                        *link_name,   /* IN */
1008 const char                        *node_name
1009);
1010
1011/**
1012 * @brief Provides a defualt routine for filesystem
1013 * implementation of a readlink command.
1014 */
1015ssize_t rtems_filesystem_default_readlink(
1016 rtems_filesystem_location_info_t  *loc,     /* IN  */
1017 char                              *buf,     /* OUT */
1018 size_t                             bufsize
1019);
1020
1021/**
1022 * @brief Provides a defualt routine for filesystem
1023 * implementation of a rename command.
1024 */
1025int rtems_filesystem_default_rename(
1026 rtems_filesystem_location_info_t  *old_parent_loc,  /* IN */
1027 rtems_filesystem_location_info_t  *old_loc,         /* IN */
1028 rtems_filesystem_location_info_t  *new_parent_loc,  /* IN */
1029 const char                        *name             /* IN */
1030);
1031
1032/**
1033 * @brief Provides a defualt routine for filesystem
1034 * implementation of a statvfs command.
1035 */
1036int rtems_filesystem_default_statvfs(
1037 rtems_filesystem_location_info_t  *loc,     /* IN  */
1038 struct statvfs                    *buf      /* OUT */
1039);
1040
1041/**
1042 * @brief Gets the mount handler for the file system @a type.
1043 *
1044 * @return The file system mount handler associated with the @a type, or
1045 * @c NULL if no such association exists.
1046 */
1047rtems_filesystem_fsmount_me_t
1048rtems_filesystem_get_mount_handler(
1049  const char *type
1050);
1051
1052/**
1053 * @brief Contain file system specific information which is required to support
1054 * fpathconf().
1055 */
1056typedef struct {
1057  int    link_max;                 /* count */
1058  int    max_canon;                /* max formatted input line size */
1059  int    max_input;                /* max input line size */
1060  int    name_max;                 /* max name length */
1061  int    path_max;                 /* max path */
1062  int    pipe_buf;                 /* pipe buffer size */
1063  int    posix_async_io;           /* async IO supported on fs, 0=no, 1=yes */
1064  int    posix_chown_restrictions; /* can chown: 0=no, 1=yes */
1065  int    posix_no_trunc;           /* error on names > max name, 0=no, 1=yes */
1066  int    posix_prio_io;            /* priority IO, 0=no, 1=yes */
1067  int    posix_sync_io;            /* file can be sync'ed, 0=no, 1=yes */
1068  int    posix_vdisable;           /* special char processing, 0=no, 1=yes */
1069} rtems_filesystem_limits_and_options_t;
1070
1071/**
1072 * @brief Default pathconf settings.
1073 *
1074 * Override in a filesystem.
1075 */
1076extern const rtems_filesystem_limits_and_options_t rtems_filesystem_default_pathconf;
1077
1078/**
1079 * @brief An open file data structure.
1080 *
1081 * It will be indexed by 'fd'.
1082 *
1083 * @todo Should really have a separate per/file data structure that this points
1084 * to (eg: size, offset, driver, pathname should be in that)
1085 */
1086struct rtems_libio_tt {
1087  rtems_driver_name_t                    *driver;
1088  rtems_off64_t                           size;      /* size of file */
1089  rtems_off64_t                           offset;    /* current offset into file */
1090  uint32_t                                flags;
1091  rtems_filesystem_location_info_t        pathinfo;
1092  rtems_id                                sem;
1093  uint32_t                                data0;     /* private to "driver" */
1094  void                                   *data1;     /* ... */
1095  void                                   *file_info; /* used by file handlers */
1096  const rtems_filesystem_file_handlers_r *handlers;  /* type specific handlers */
1097};
1098
1099/**
1100 * @brief Paramameter block for read/write.
1101 *
1102 * It must include 'offset' instead of using iop's offset since we can have
1103 * multiple outstanding i/o's on a device.
1104 */
1105typedef struct {
1106  rtems_libio_t          *iop;
1107  rtems_off64_t           offset;
1108  char                   *buffer;
1109  uint32_t                count;
1110  uint32_t                flags;
1111  uint32_t                bytes_moved;
1112} rtems_libio_rw_args_t;
1113
1114/**
1115 * @brief Parameter block for open/close.
1116 */
1117typedef struct {
1118  rtems_libio_t          *iop;
1119  uint32_t                flags;
1120  uint32_t                mode;
1121} rtems_libio_open_close_args_t;
1122
1123/**
1124 * @brief Parameter block for ioctl.
1125 */
1126typedef struct {
1127  rtems_libio_t          *iop;
1128  uint32_t                command;
1129  void                   *buffer;
1130  uint32_t                ioctl_return;
1131} rtems_libio_ioctl_args_t;
1132
1133/**
1134 * @name Flag Values
1135 *
1136 * @{
1137 */
1138
1139#define LIBIO_FLAGS_NO_DELAY      0x0001  /* return immediately if no data */
1140#define LIBIO_FLAGS_READ          0x0002  /* reading */
1141#define LIBIO_FLAGS_WRITE         0x0004  /* writing */
1142#define LIBIO_FLAGS_OPEN          0x0100  /* device is open */
1143#define LIBIO_FLAGS_APPEND        0x0200  /* all writes append */
1144#define LIBIO_FLAGS_CREATE        0x0400  /* create file */
1145#define LIBIO_FLAGS_CLOSE_ON_EXEC 0x0800  /* close on process exec() */
1146#define LIBIO_FLAGS_READ_WRITE    (LIBIO_FLAGS_READ | LIBIO_FLAGS_WRITE)
1147
1148/** @} */
1149
1150void rtems_libio_init(void);
1151
1152/**
1153 * @name External I/O Handlers
1154 *
1155 * @{
1156 */
1157
1158typedef int (*rtems_libio_open_t)(
1159  const char  *pathname,
1160  uint32_t    flag,
1161  uint32_t    mode
1162);
1163
1164typedef int (*rtems_libio_close_t)(
1165  int  fd
1166);
1167
1168typedef ssize_t (*rtems_libio_read_t)(
1169  int         fd,
1170  void       *buffer,
1171  size_t    count
1172);
1173
1174typedef ssize_t (*rtems_libio_write_t)(
1175  int         fd,
1176  const void *buffer,
1177  size_t      count
1178);
1179
1180typedef int (*rtems_libio_ioctl_t)(
1181  int         fd,
1182  uint32_t    command,
1183  void       *buffer
1184);
1185
1186typedef rtems_off64_t (*rtems_libio_lseek_t)(
1187  int           fd,
1188  rtems_off64_t offset,
1189  int           whence
1190);
1191
1192/** @} */
1193
1194/**
1195 * @name Permission Macros
1196 *
1197 * @{
1198 */
1199
1200/*
1201 *  The following macros are used to build up the permissions sets
1202 *  used to check permissions.  These are similar in style to the
1203 *  mode_t bits and should stay compatible with them.
1204 */
1205#define RTEMS_LIBIO_PERMS_READ   S_IROTH
1206#define RTEMS_LIBIO_PERMS_WRITE  S_IWOTH
1207#define RTEMS_LIBIO_PERMS_RDWR   (S_IROTH|S_IWOTH)
1208#define RTEMS_LIBIO_PERMS_EXEC   S_IXOTH
1209#define RTEMS_LIBIO_PERMS_SEARCH RTEMS_LIBIO_PERMS_EXEC
1210#define RTEMS_LIBIO_PERMS_RWX    S_IRWXO
1211
1212/** @} */
1213
1214union __rtems_dev_t {
1215  dev_t device;
1216  struct {
1217     rtems_device_major_number major;
1218     rtems_device_minor_number minor;
1219  } __overlay;
1220};
1221
1222static inline dev_t rtems_filesystem_make_dev_t(
1223  rtems_device_major_number _major,
1224  rtems_device_minor_number _minor
1225)
1226{
1227  union __rtems_dev_t temp;
1228
1229  temp.__overlay.major = _major;
1230  temp.__overlay.minor = _minor;
1231  return temp.device;
1232}
1233
1234static inline rtems_device_major_number rtems_filesystem_dev_major_t(
1235  dev_t device
1236)
1237{
1238  union __rtems_dev_t temp;
1239
1240  temp.device = device;
1241  return temp.__overlay.major;
1242}
1243
1244
1245static inline rtems_device_minor_number rtems_filesystem_dev_minor_t(
1246  dev_t device
1247)
1248{
1249  union __rtems_dev_t temp;
1250
1251  temp.device = device;
1252  return temp.__overlay.minor;
1253}
1254
1255#define rtems_filesystem_split_dev_t( _dev, _major, _minor ) \
1256  do { \
1257    (_major) = rtems_filesystem_dev_major_t ( _dev ); \
1258    (_minor) = rtems_filesystem_dev_minor_t( _dev ); \
1259  } while(0)
1260
1261/*
1262 * Verifies that the permission flag is valid.
1263 */
1264#define rtems_libio_is_valid_perms( _perm )     \
1265 (~ ((~RTEMS_LIBIO_PERMS_RWX) & _perm ))
1266
1267/*
1268 *  Prototypes for filesystem
1269 */
1270
1271void rtems_filesystem_initialize( void );
1272
1273typedef void (*rtems_libio_init_functions_t)(void);
1274extern  rtems_libio_init_functions_t rtems_libio_init_helper;
1275
1276void    open_dev_console(void);
1277
1278typedef void (*rtems_libio_supp_functions_t)(void);
1279extern  rtems_libio_supp_functions_t rtems_libio_supp_helper;
1280
1281typedef void (*rtems_fs_init_functions_t)(void);
1282extern  rtems_fs_init_functions_t    rtems_fs_init_helper;
1283
1284/**
1285 * @brief Creates a directory and all its parent directories according to
1286 * @a path.
1287 *
1288 * The @a mode value selects the access permissions of the directory.
1289 *
1290 * @retval 0 Successful operation.
1291 * @retval -1 An error occured.  The @c errno indicates the error.
1292 */
1293extern int rtems_mkdir(const char *path, mode_t mode);
1294
1295/** @} */
1296
1297/**
1298 * @defgroup FileSystemTypesAndMount File System Types and Mount
1299 *
1300 * @ingroup LibIO
1301 *
1302 * @brief File system types and mount.
1303 *
1304 * @{
1305 */
1306
1307/**
1308 * @name File System Types
1309 *
1310 * @{
1311 */
1312
1313#define RTEMS_FILESYSTEM_TYPE_IMFS "imfs"
1314#define RTEMS_FILESYSTEM_TYPE_MINIIMFS "mimfs"
1315#define RTEMS_FILESYSTEM_TYPE_DEVFS "devfs"
1316#define RTEMS_FILESYSTEM_TYPE_FTPFS "ftpfs"
1317#define RTEMS_FILESYSTEM_TYPE_TFTPFS "tftpfs"
1318#define RTEMS_FILESYSTEM_TYPE_NFS "nfs"
1319#define RTEMS_FILESYSTEM_TYPE_DOSFS "dosfs"
1320#define RTEMS_FILESYSTEM_TYPE_RFS "rfs"
1321
1322/** @} */
1323
1324/**
1325 * @brief Mount table entry.
1326 */
1327struct rtems_filesystem_mount_table_entry_tt {
1328  rtems_chain_node                       Node;
1329  rtems_filesystem_location_info_t       mt_point_node;
1330  rtems_filesystem_location_info_t       mt_fs_root;
1331  int                                    options;
1332  void                                  *fs_info;
1333
1334  rtems_filesystem_limits_and_options_t  pathconf_limits_and_options;
1335
1336  /*
1337   * The target or mount point of the file system.
1338   */
1339  const char                            *target;
1340
1341  /*
1342   * The type of filesystem or the name of the filesystem.
1343   */
1344  const char                            *type;
1345
1346  /*
1347   *  When someone adds a mounted filesystem on a real device,
1348   *  this will need to be used.
1349   *
1350   *  The lower layers can manage how this is managed. Leave as a
1351   *  string.
1352   */
1353  char                                  *dev;
1354};
1355
1356/**
1357 * @brief File system options.
1358 */
1359typedef enum {
1360  RTEMS_FILESYSTEM_READ_ONLY,
1361  RTEMS_FILESYSTEM_READ_WRITE,
1362  RTEMS_FILESYSTEM_BAD_OPTIONS
1363} rtems_filesystem_options_t;
1364
1365/**
1366 * @brief File system table entry.
1367 */
1368typedef struct rtems_filesystem_table_t {
1369  const char                    *type;
1370  rtems_filesystem_fsmount_me_t  mount_h;
1371} rtems_filesystem_table_t;
1372
1373/**
1374 * @brief Static table of file systems.
1375 *
1376 * Externally defined by confdefs.h or the user.
1377 */
1378extern const rtems_filesystem_table_t rtems_filesystem_table [];
1379
1380/**
1381 * @brief Registers a file system @a type.
1382 *
1383 * The @a mount_h handler will be used to mount a file system of this @a type.
1384 *
1385 * @retval 0 Successful operation.
1386 * @retval -1 An error occured.  The @c errno indicates the error.
1387 */
1388int rtems_filesystem_register(
1389  const char                    *type,
1390  rtems_filesystem_fsmount_me_t  mount_h
1391);
1392
1393/**
1394 * @brief Unregisters a file system @a type.
1395 *
1396 * @retval 0 Successful operation.
1397 * @retval -1 An error occured.  The @c errno indicates the error.
1398 */
1399int rtems_filesystem_unregister(
1400  const char *type
1401);
1402
1403/**
1404 * @brief Unmounts the file system at @a mount_path.
1405 *
1406 * @todo Due to file system implementation shortcomings it is possible to
1407 * unmount file systems in use.  This likely leads to heap corruption.  Unmount
1408 * only file systems which are not in use by the application.
1409 *
1410 * @retval 0 Successful operation.
1411 * @retval -1 An error occured.  The @c errno indicates the error.
1412 */
1413int unmount(
1414  const char *mount_path
1415);
1416
1417/**
1418 * @brief Mounts a file system at @a target.
1419 *
1420 * The @a source may be a path to the corresponding device file, or @c NULL.
1421 * The @a target path must lead to an existing directory, or @c NULL.  In case
1422 * @a target is @c NULL, the root file system will be mounted.  The @a data
1423 * parameter will be forwarded to the file system initialization handler.  The
1424 * file system type is selected by @a filesystemtype and may be one of
1425 * - RTEMS_FILESYSTEM_TYPE_DEVFS,
1426 * - RTEMS_FILESYSTEM_TYPE_DOSFS,
1427 * - RTEMS_FILESYSTEM_TYPE_FTPFS,
1428 * - RTEMS_FILESYSTEM_TYPE_IMFS,
1429 * - RTEMS_FILESYSTEM_TYPE_MINIIMFS,
1430 * - RTEMS_FILESYSTEM_TYPE_NFS,
1431 * - RTEMS_FILESYSTEM_TYPE_RFS, or
1432 * - RTEMS_FILESYSTEM_TYPE_TFTPFS.
1433 *
1434 * Only configured or registered file system types are available.  You can add
1435 * file system types to your application configuration with
1436 * - CONFIGURE_FILESYSTEM_DEVFS,
1437 * - CONFIGURE_FILESYSTEM_DOSFS,
1438 * - CONFIGURE_FILESYSTEM_FTPFS,
1439 * - CONFIGURE_FILESYSTEM_IMFS,
1440 * - CONFIGURE_FILESYSTEM_MINIIMFS,
1441 * - CONFIGURE_FILESYSTEM_NFS,
1442 * - CONFIGURE_FILESYSTEM_RFS, and
1443 * - CONFIGURE_FILESYSTEM_TFTPFS.
1444 *
1445 * @see rtems_filesystem_register() and mount_and_make_target_path().
1446 *
1447 * @retval 0 Successful operation.
1448 * @retval -1 An error occured.  The @c errno indicates the error.
1449 */
1450int mount(
1451  const char                 *source,
1452  const char                 *target,
1453  const char                 *filesystemtype,
1454  rtems_filesystem_options_t options,
1455  const void                 *data
1456);
1457
1458/**
1459 * @brief Mounts a file system and makes the @a target path.
1460 *
1461 * The @a target path will be created with rtems_mkdir() and must not be
1462 * @c NULL.
1463 *
1464 * @see mount().
1465 *
1466 * @retval 0 Successful operation.
1467 * @retval -1 An error occured.  The @c errno indicates the error.
1468 */
1469int mount_and_make_target_path(
1470  const char                 *source,
1471  const char                 *target,
1472  const char                 *filesystemtype,
1473  rtems_filesystem_options_t options,
1474  const void                 *data
1475);
1476
1477/**
1478 * @brief Per file system type routine.
1479 *
1480 * @see rtems_filesystem_iterate().
1481 *
1482 * @retval true Stop the iteration.
1483 * @retval false Continue the iteration.
1484 */
1485typedef bool (*rtems_per_filesystem_routine)(
1486  const rtems_filesystem_table_t *fs_entry,
1487  void *arg
1488);
1489
1490/**
1491 * @brief Iterates over all file system types.
1492 *
1493 * For each file system type the @a routine will be called with the entry and
1494 * the @a routine_arg parameter.
1495 *
1496 * Do not register or unregister file system types in @a routine.
1497 *
1498 * The iteration is protected by the IO library mutex.
1499 *
1500 * @retval true Iteration stopped due to @a routine return status.
1501 * @retval false Iteration through all entries.
1502 */
1503bool rtems_filesystem_iterate(
1504  rtems_per_filesystem_routine routine,
1505  void *routine_arg
1506);
1507
1508/**
1509 * @brief Per file system mount routine.
1510 *
1511 * @see rtems_filesystem_mount_iterate().
1512 *
1513 * @retval true Stop the iteration.
1514 * @retval false Continue the iteration.
1515 */
1516typedef bool (*rtems_per_filesystem_mount_routine)(
1517  const rtems_filesystem_mount_table_entry_t *mt_entry,
1518  void *arg
1519);
1520
1521/**
1522 * @brief Iterates over all file system mounts.
1523 *
1524 * For each file system mount the @a routine will be called with the entry and
1525 * the @a routine_arg parameter.
1526 *
1527 * Do not mount or unmount file systems in @a routine.
1528 *
1529 * The iteration is protected by the IO library mutex.
1530 *
1531 * @retval true Iteration stopped due to @a routine return status.
1532 * @retval false Iteration through all entries.
1533 */
1534bool
1535rtems_filesystem_mount_iterate(
1536  rtems_per_filesystem_mount_routine routine,
1537  void *routine_arg
1538);
1539
1540/**
1541 * @brief Boot time mount table entry.
1542 */
1543typedef struct {
1544  const char                              *type;
1545  rtems_filesystem_options_t               fsoptions;
1546  const char                              *device;
1547  const char                              *mount_point;
1548} rtems_filesystem_mount_table_t;
1549
1550/**
1551 * @brief Boot time mount table.
1552 *
1553 * @todo Only the first entry will be evaluated.  Why do we need a table?
1554 */
1555extern const rtems_filesystem_mount_table_t *rtems_filesystem_mount_table;
1556
1557/**
1558 * @brief Boot time mount table entry count.
1559 *
1560 * @todo Only the first entry will be evaluated.  Why do we need a table?
1561 */
1562extern const int rtems_filesystem_mount_table_size;
1563
1564/** @} */
1565
1566/**
1567 * @defgroup Termios Termios
1568 *
1569 * @ingroup LibIO
1570 *
1571 * @brief Termios
1572 *
1573 * @{
1574 */
1575
1576typedef struct rtems_termios_callbacks {
1577  int    (*firstOpen)(int major, int minor, void *arg);
1578  int    (*lastClose)(int major, int minor, void *arg);
1579  int    (*pollRead)(int minor);
1580  ssize_t (*write)(int minor, const char *buf, size_t len);
1581  int    (*setAttributes)(int minor, const struct termios *t);
1582  int    (*stopRemoteTx)(int minor);
1583  int    (*startRemoteTx)(int minor);
1584  int    outputUsesInterrupts;
1585} rtems_termios_callbacks;
1586
1587void rtems_termios_initialize (void);
1588
1589/*
1590 * CCJ: Change before opening a tty. Newer code from Eric is coming
1591 * so extra work to handle an open tty is not worth it. If the tty
1592 * is open, close then open it again.
1593 */
1594rtems_status_code rtems_termios_bufsize (
1595  int cbufsize,     /* cooked buffer size */
1596  int raw_input,    /* raw input buffer size */
1597  int raw_output    /* raw output buffer size */
1598);
1599
1600rtems_status_code rtems_termios_open (
1601  rtems_device_major_number      major,
1602  rtems_device_minor_number      minor,
1603  void                          *arg,
1604  const rtems_termios_callbacks *callbacks
1605);
1606
1607rtems_status_code rtems_termios_close(
1608  void *arg
1609);
1610
1611rtems_status_code rtems_termios_read(
1612  void *arg
1613);
1614
1615rtems_status_code rtems_termios_write(
1616  void *arg
1617);
1618
1619rtems_status_code rtems_termios_ioctl(
1620  void *arg
1621);
1622
1623int rtems_termios_enqueue_raw_characters(
1624  void *ttyp,
1625  char *buf,
1626  int   len
1627);
1628
1629int rtems_termios_dequeue_characters(
1630  void *ttyp,
1631  int   len
1632);
1633
1634/** @} */
1635
1636/**
1637 * @brief The pathconf setting for a file system.
1638 */
1639#define rtems_filesystem_pathconf(_mte) ((_mte)->pathconf_limits_and_options)
1640
1641/**
1642 * @brief The type of file system. Its name.
1643 */
1644#define rtems_filesystem_type(_mte) ((_mte)->type)
1645
1646/**
1647 * @brief The mount point of a file system.
1648 */
1649#define rtems_filesystem_mount_point(_mte) ((_mte)->target)
1650
1651/**
1652 * @brief The device entry of a file system.
1653 */
1654#define rtems_filesystem_mount_device(_mte) ((_mte)->dev)
1655
1656#ifdef __cplusplus
1657}
1658#endif
1659
1660#endif /* _RTEMS_LIBIO_H */
Note: See TracBrowser for help on using the repository browser.