source: rtems/cpukit/libcsupport/include/rtems/libio.h @ 6683a58

4.11
Last change on this file since 6683a58 was 6683a58, checked in by Jennifer Averett <Jennifer.Averett@…>, on Jun 30, 2010 at 1:58:56 PM

2010-06-30 Jennifer.Averett <Jennifer.Averett@…>

  • libcsupport/include/rtems/libio.h, libfs/Makefile.am: Added filesystem default mknod method.
  • libfs/src/defaults/default_mknod.c: New file.
  • Property mode set to 100644
File size: 42.5 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 */
390size_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 int (*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 */
1015int 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 File system table entry.
1043 */
1044typedef struct rtems_filesystem_table_t {
1045  const char                    *type;
1046  rtems_filesystem_fsmount_me_t  mount_h;
1047} rtems_filesystem_table_t;
1048
1049/**
1050 * @brief Static table of file systems.
1051 *
1052 * Externally defined by confdefs.h or the user.
1053 */
1054extern const rtems_filesystem_table_t rtems_filesystem_table [];
1055
1056/**
1057 * @brief Per file system table entry routine type.
1058 *
1059 * @see rtems_filesystem_iterate().
1060 *
1061 * @retval true Continue the iteration.
1062 * @retval false Stop the iteration.
1063 */
1064typedef bool (*rtems_per_filesystem_routine)(
1065  const rtems_filesystem_table_t *entry,
1066  void *arg
1067);
1068
1069/**
1070 * @brief Iterates over the file system table.
1071 *
1072 * For each file system table entry the @a routine will be called with the
1073 * table entry and the @a routine_arg parameter.
1074 */
1075void
1076rtems_filesystem_iterate(
1077  rtems_per_filesystem_routine routine,
1078  void *routine_arg
1079);
1080
1081/**
1082 * @brief Gets the mount handler for the file system @a type.
1083 *
1084 * @return The file system mount handler associated with the @a type, or
1085 * @c NULL if no such association exists.
1086 */
1087rtems_filesystem_fsmount_me_t
1088rtems_filesystem_get_mount_handler(
1089  const char *type
1090);
1091
1092/*
1093 * Get the first entry in the mount table.
1094 */
1095rtems_filesystem_mount_table_entry_t*
1096rtems_filesystem_mounts_first( void );
1097
1098/*
1099 * Get the next entry in the mount table.
1100 */
1101rtems_filesystem_mount_table_entry_t*
1102rtems_filesystem_mounts_next( rtems_filesystem_mount_table_entry_t *entry );
1103
1104/*
1105 * Register a file system.
1106 */
1107int
1108rtems_filesystem_register(
1109  const char                    *type,
1110  rtems_filesystem_fsmount_me_t  mount_h
1111);
1112
1113/*
1114 * Unregister a file system.
1115 */
1116int
1117rtems_filesystem_unregister(
1118  const char *type
1119);
1120
1121/**
1122 * @brief Contain file system specific information which is required to support
1123 * fpathconf().
1124 */
1125typedef struct {
1126  int    link_max;                 /* count */
1127  int    max_canon;                /* max formatted input line size */
1128  int    max_input;                /* max input line size */
1129  int    name_max;                 /* max name length */
1130  int    path_max;                 /* max path */
1131  int    pipe_buf;                 /* pipe buffer size */
1132  int    posix_async_io;           /* async IO supported on fs, 0=no, 1=yes */
1133  int    posix_chown_restrictions; /* can chown: 0=no, 1=yes */
1134  int    posix_no_trunc;           /* error on names > max name, 0=no, 1=yes */
1135  int    posix_prio_io;            /* priority IO, 0=no, 1=yes */
1136  int    posix_sync_io;            /* file can be sync'ed, 0=no, 1=yes */
1137  int    posix_vdisable;           /* special char processing, 0=no, 1=yes */
1138} rtems_filesystem_limits_and_options_t;
1139
1140/**
1141 * @brief Default pathconf settings.
1142 *
1143 * Override in a filesystem.
1144 */
1145extern const rtems_filesystem_limits_and_options_t rtems_filesystem_default_pathconf;
1146
1147/**
1148 * @brief Mount table entry.
1149 */
1150struct rtems_filesystem_mount_table_entry_tt {
1151  rtems_chain_node                       Node;
1152  rtems_filesystem_location_info_t       mt_point_node;
1153  rtems_filesystem_location_info_t       mt_fs_root;
1154  int                                    options;
1155  void                                  *fs_info;
1156
1157  rtems_filesystem_limits_and_options_t  pathconf_limits_and_options;
1158
1159  /*
1160   * The target or mount point of the file system.
1161   */
1162  const char                            *target;
1163
1164  /*
1165   * The type of filesystem or the name of the filesystem.
1166   */
1167  const char                            *type;
1168
1169  /*
1170   *  When someone adds a mounted filesystem on a real device,
1171   *  this will need to be used.
1172   *
1173   *  The lower layers can manage how this is managed. Leave as a
1174   *  string.
1175   */
1176  char                                  *dev;
1177};
1178
1179/**
1180 * @brief The pathconf setting for a file system.
1181 */
1182#define rtems_filesystem_pathconf(_mte) ((_mte)->pathconf_limits_and_options)
1183
1184/**
1185 * @brief The type of file system. Its name.
1186 */
1187#define rtems_filesystem_type(_mte) ((_mte)->type)
1188
1189/**
1190 * @brief The mount point of a file system.
1191 */
1192#define rtems_filesystem_mount_point(_mte) ((_mte)->target)
1193
1194/**
1195 * @brief The device entry of a file system.
1196 */
1197#define rtems_filesystem_mount_device(_mte) ((_mte)->dev)
1198
1199/**
1200 * @brief File systems options.
1201 */
1202typedef enum {
1203  RTEMS_FILESYSTEM_READ_ONLY,
1204  RTEMS_FILESYSTEM_READ_WRITE,
1205  RTEMS_FILESYSTEM_BAD_OPTIONS
1206} rtems_filesystem_options_t;
1207
1208/**
1209 * @brief An open file data structure.
1210 *
1211 * It will be indexed by 'fd'.
1212 *
1213 * @todo Should really have a separate per/file data structure that this points
1214 * to (eg: size, offset, driver, pathname should be in that)
1215 */
1216struct rtems_libio_tt {
1217  rtems_driver_name_t                    *driver;
1218  rtems_off64_t                           size;      /* size of file */
1219  rtems_off64_t                           offset;    /* current offset into file */
1220  uint32_t                                flags;
1221  rtems_filesystem_location_info_t        pathinfo;
1222  rtems_id                                sem;
1223  uint32_t                                data0;     /* private to "driver" */
1224  void                                   *data1;     /* ... */
1225  void                                   *file_info; /* used by file handlers */
1226  const rtems_filesystem_file_handlers_r *handlers;  /* type specific handlers */
1227};
1228
1229/**
1230 * @brief Paramameter block for read/write.
1231 *
1232 * It must include 'offset' instead of using iop's offset since we can have
1233 * multiple outstanding i/o's on a device.
1234 */
1235typedef struct {
1236  rtems_libio_t          *iop;
1237  rtems_off64_t           offset;
1238  char                   *buffer;
1239  uint32_t                count;
1240  uint32_t                flags;
1241  uint32_t                bytes_moved;
1242} rtems_libio_rw_args_t;
1243
1244/**
1245 * @brief Parameter block for open/close.
1246 */
1247typedef struct {
1248  rtems_libio_t          *iop;
1249  uint32_t                flags;
1250  uint32_t                mode;
1251} rtems_libio_open_close_args_t;
1252
1253/**
1254 * @brief Parameter block for ioctl.
1255 */
1256typedef struct {
1257  rtems_libio_t          *iop;
1258  uint32_t                command;
1259  void                   *buffer;
1260  uint32_t                ioctl_return;
1261} rtems_libio_ioctl_args_t;
1262
1263/**
1264 * @name Flag Values
1265 *
1266 * @{
1267 */
1268
1269#define LIBIO_FLAGS_NO_DELAY      0x0001  /* return immediately if no data */
1270#define LIBIO_FLAGS_READ          0x0002  /* reading */
1271#define LIBIO_FLAGS_WRITE         0x0004  /* writing */
1272#define LIBIO_FLAGS_OPEN          0x0100  /* device is open */
1273#define LIBIO_FLAGS_APPEND        0x0200  /* all writes append */
1274#define LIBIO_FLAGS_CREATE        0x0400  /* create file */
1275#define LIBIO_FLAGS_CLOSE_ON_EXEC 0x0800  /* close on process exec() */
1276#define LIBIO_FLAGS_READ_WRITE    (LIBIO_FLAGS_READ | LIBIO_FLAGS_WRITE)
1277
1278/** @} */
1279
1280void rtems_libio_init(void);
1281
1282/**
1283 * @name External I/O Handlers
1284 *
1285 * @{
1286 */
1287
1288typedef int (*rtems_libio_open_t)(
1289  const char  *pathname,
1290  uint32_t    flag,
1291  uint32_t    mode
1292);
1293
1294typedef int (*rtems_libio_close_t)(
1295  int  fd
1296);
1297
1298typedef int (*rtems_libio_read_t)(
1299  int         fd,
1300  void       *buffer,
1301  uint32_t    count
1302);
1303
1304typedef int (*rtems_libio_write_t)(
1305  int         fd,
1306  const void *buffer,
1307  uint32_t    count
1308);
1309
1310typedef int (*rtems_libio_ioctl_t)(
1311  int         fd,
1312  uint32_t    command,
1313  void       *buffer
1314);
1315
1316typedef rtems_off64_t (*rtems_libio_lseek_t)(
1317  int           fd,
1318  rtems_off64_t offset,
1319  int           whence
1320);
1321
1322/** @} */
1323
1324/**
1325 * @name Permission Macros
1326 *
1327 * @{
1328 */
1329
1330/*
1331 *  The following macros are used to build up the permissions sets
1332 *  used to check permissions.  These are similar in style to the
1333 *  mode_t bits and should stay compatible with them.
1334 */
1335#define RTEMS_LIBIO_PERMS_READ   S_IROTH
1336#define RTEMS_LIBIO_PERMS_WRITE  S_IWOTH
1337#define RTEMS_LIBIO_PERMS_RDWR   (S_IROTH|S_IWOTH)
1338#define RTEMS_LIBIO_PERMS_EXEC   S_IXOTH
1339#define RTEMS_LIBIO_PERMS_SEARCH RTEMS_LIBIO_PERMS_EXEC
1340#define RTEMS_LIBIO_PERMS_RWX    S_IRWXO
1341
1342/** @} */
1343
1344union __rtems_dev_t {
1345  dev_t device;
1346  struct {
1347     rtems_device_major_number major;
1348     rtems_device_minor_number minor;
1349  } __overlay;
1350};
1351
1352static inline dev_t rtems_filesystem_make_dev_t(
1353  rtems_device_major_number _major,
1354  rtems_device_minor_number _minor
1355)
1356{
1357  union __rtems_dev_t temp;
1358
1359  temp.__overlay.major = _major;
1360  temp.__overlay.minor = _minor;
1361  return temp.device;
1362}
1363
1364static inline rtems_device_major_number rtems_filesystem_dev_major_t(
1365  dev_t device
1366)
1367{
1368  union __rtems_dev_t temp;
1369
1370  temp.device = device;
1371  return temp.__overlay.major;
1372}
1373
1374
1375static inline rtems_device_minor_number rtems_filesystem_dev_minor_t(
1376  dev_t device
1377)
1378{
1379  union __rtems_dev_t temp;
1380
1381  temp.device = device;
1382  return temp.__overlay.minor;
1383}
1384
1385#define rtems_filesystem_split_dev_t( _dev, _major, _minor ) \
1386  do { \
1387    (_major) = rtems_filesystem_dev_major_t ( _dev ); \
1388    (_minor) = rtems_filesystem_dev_minor_t( _dev ); \
1389  } while(0)
1390
1391/*
1392 * Verifies that the permission flag is valid.
1393 */
1394#define rtems_libio_is_valid_perms( _perm )     \
1395 (~ ((~RTEMS_LIBIO_PERMS_RWX) & _perm ))
1396
1397/**
1398 * @name File System Types
1399 *
1400 * @{
1401 */
1402
1403#define RTEMS_FILESYSTEM_TYPE_IMFS "imfs"
1404#define RTEMS_FILESYSTEM_TYPE_MINIIMFS "mimfs"
1405#define RTEMS_FILESYSTEM_TYPE_DEVFS "devfs"
1406#define RTEMS_FILESYSTEM_TYPE_FTPFS "ftpfs"
1407#define RTEMS_FILESYSTEM_TYPE_TFTPFS "tftpfs"
1408#define RTEMS_FILESYSTEM_TYPE_NFS "nfs"
1409#define RTEMS_FILESYSTEM_TYPE_DOSFS "dosfs"
1410#define RTEMS_FILESYSTEM_TYPE_RFS "rfs"
1411
1412/** @} */
1413
1414/*
1415 *  Prototypes for filesystem
1416 */
1417
1418void rtems_filesystem_initialize( void );
1419
1420int unmount(
1421  const char *mount_path
1422);
1423
1424int mount(
1425  const char                 *source,
1426  const char                 *target,
1427  const char                 *filesystemtype,
1428  rtems_filesystem_options_t options,
1429  const void                 *data
1430);
1431
1432/**
1433 * @brief Mounts a file system and makes the @a target path.
1434 *
1435 * The @a target path will be created with rtems_mkdir() and must not be
1436 * @c NULL.
1437 *
1438 * @see mount().
1439 *
1440 * @retval 0 Successful operation.
1441 * @retval -1 An error occured.  The @c errno indicates the error.
1442 */
1443int mount_and_make_target_path(
1444  const char                 *source,
1445  const char                 *target,
1446  const char                 *filesystemtype,
1447  rtems_filesystem_options_t options,
1448  const void                 *data
1449);
1450
1451/*
1452 *  Boot Time Mount Table Structure
1453 */
1454
1455typedef struct {
1456  const char                              *type;
1457  rtems_filesystem_options_t               fsoptions;
1458  const char                              *device;
1459  const char                              *mount_point;
1460} rtems_filesystem_mount_table_t;
1461
1462extern const rtems_filesystem_mount_table_t *rtems_filesystem_mount_table;
1463extern const int                             rtems_filesystem_mount_table_size;
1464
1465typedef void (*rtems_libio_init_functions_t)(void);
1466extern  rtems_libio_init_functions_t rtems_libio_init_helper;
1467
1468void    open_dev_console(void);
1469
1470typedef void (*rtems_libio_supp_functions_t)(void);
1471extern  rtems_libio_supp_functions_t rtems_libio_supp_helper;
1472
1473typedef void (*rtems_fs_init_functions_t)(void);
1474extern  rtems_fs_init_functions_t    rtems_fs_init_helper;
1475
1476/**
1477 * @brief Creates a directory and all its parent directories according to
1478 * @a path.
1479 *
1480 * The @a mode value selects the access permissions of the directory.
1481 *
1482 * @retval 0 Successful operation.
1483 * @retval -1 An error occured.  The @c errno indicates the error.
1484 */
1485extern int rtems_mkdir(const char *path, mode_t mode);
1486
1487/** @} */
1488
1489/**
1490 * @defgroup Termios Termios
1491 *
1492 * @ingroup LibIO
1493 *
1494 * @brief Termios
1495 *
1496 * @{
1497 */
1498
1499typedef struct rtems_termios_callbacks {
1500  int    (*firstOpen)(int major, int minor, void *arg);
1501  int    (*lastClose)(int major, int minor, void *arg);
1502  int    (*pollRead)(int minor);
1503  ssize_t (*write)(int minor, const char *buf, size_t len);
1504  int    (*setAttributes)(int minor, const struct termios *t);
1505  int    (*stopRemoteTx)(int minor);
1506  int    (*startRemoteTx)(int minor);
1507  int    outputUsesInterrupts;
1508} rtems_termios_callbacks;
1509
1510void rtems_termios_initialize (void);
1511
1512/*
1513 * CCJ: Change before opening a tty. Newer code from Eric is coming
1514 * so extra work to handle an open tty is not worth it. If the tty
1515 * is open, close then open it again.
1516 */
1517rtems_status_code rtems_termios_bufsize (
1518  int cbufsize,     /* cooked buffer size */
1519  int raw_input,    /* raw input buffer size */
1520  int raw_output    /* raw output buffer size */
1521);
1522
1523rtems_status_code rtems_termios_open (
1524  rtems_device_major_number      major,
1525  rtems_device_minor_number      minor,
1526  void                          *arg,
1527  const rtems_termios_callbacks *callbacks
1528);
1529
1530rtems_status_code rtems_termios_close(
1531  void *arg
1532);
1533
1534rtems_status_code rtems_termios_read(
1535  void *arg
1536);
1537
1538rtems_status_code rtems_termios_write(
1539  void *arg
1540);
1541
1542rtems_status_code rtems_termios_ioctl(
1543  void *arg
1544);
1545
1546int rtems_termios_enqueue_raw_characters(
1547  void *ttyp,
1548  char *buf,
1549  int   len
1550);
1551
1552int rtems_termios_dequeue_characters(
1553  void *ttyp,
1554  int   len
1555);
1556
1557/** @} */
1558
1559#ifdef __cplusplus
1560}
1561#endif
1562
1563#endif /* _RTEMS_LIBIO_H */
Note: See TracBrowser for help on using the repository browser.