RTEMS CPU Kit with SuperCore  4.10.99.0
rtems/libio.h
Go to the documentation of this file.
00001 
00013 /*
00014  *  COPYRIGHT (c) 1989-2008.
00015  *  On-Line Applications Research Corporation (OAR).
00016  *
00017  *  Modifications to support reference counting in the file system are
00018  *  Copyright (c) 2012 embedded brains GmbH.
00019  *
00020  *  The license and distribution terms for this file may be
00021  *  found in the file LICENSE in this distribution or at
00022  *  http://www.rtems.org/license/LICENSE.
00023  */
00024 
00025 #ifndef _RTEMS_RTEMS_LIBIO_H
00026 #define _RTEMS_RTEMS_LIBIO_H
00027 
00028 #include <sys/types.h>
00029 #include <sys/stat.h>
00030 #include <sys/ioctl.h>
00031 #include <sys/statvfs.h>
00032 #include <sys/uio.h>
00033 
00034 #include <unistd.h>
00035 #include <termios.h>
00036 
00037 #include <rtems.h>
00038 #include <rtems/fs.h>
00039 #include <rtems/chain.h>
00040 
00041 #ifdef __cplusplus
00042 extern "C" {
00043 #endif
00044 
00045 struct knote;
00046 
00059 typedef enum {
00060   RTEMS_FILESYSTEM_DIRECTORY,
00061   RTEMS_FILESYSTEM_DEVICE,
00062   RTEMS_FILESYSTEM_HARD_LINK,
00063   RTEMS_FILESYSTEM_SYM_LINK,
00064   RTEMS_FILESYSTEM_MEMORY_FILE,
00065   RTEMS_FILESYSTEM_INVALID_NODE_TYPE
00066 } rtems_filesystem_node_types_t;
00067 
00077 typedef void (*rtems_filesystem_mt_entry_lock_t)(
00078   const rtems_filesystem_mount_table_entry_t *mt_entry
00079 );
00080 
00088 typedef void (*rtems_filesystem_mt_entry_unlock_t)(
00089   const rtems_filesystem_mount_table_entry_t *mt_entry
00090 );
00091 
00095 typedef struct {
00099   const char *path;
00100 
00104   size_t pathlen;
00105 
00110   const char *token;
00111 
00116   size_t tokenlen;
00117 
00130   int flags;
00131 
00137   int recursionlevel;
00138 
00146   rtems_filesystem_location_info_t currentloc;
00147 
00152   rtems_filesystem_global_location_t *rootloc;
00153 
00158   rtems_filesystem_global_location_t *startloc;
00159 } rtems_filesystem_eval_path_context_t;
00160 
00168 typedef void (*rtems_filesystem_eval_path_t)(
00169   rtems_filesystem_eval_path_context_t *ctx
00170 );
00171 
00185 typedef int (*rtems_filesystem_link_t)(
00186   const rtems_filesystem_location_info_t *parentloc,
00187   const rtems_filesystem_location_info_t *targetloc,
00188   const char *name,
00189   size_t namelen
00190 );
00191 
00203 typedef int (*rtems_filesystem_fchmod_t)(
00204   const rtems_filesystem_location_info_t *loc,
00205   mode_t mode
00206 );
00207 
00220 typedef int (*rtems_filesystem_chown_t)(
00221   const rtems_filesystem_location_info_t *loc,
00222   uid_t owner,
00223   gid_t group
00224 );
00225 
00241 typedef int (*rtems_filesystem_clonenode_t)(
00242   rtems_filesystem_location_info_t *loc
00243 );
00244 
00252 typedef void (*rtems_filesystem_freenode_t)(
00253   const rtems_filesystem_location_info_t *loc
00254 );
00255 
00272 typedef int (*rtems_filesystem_mount_t) (
00273   rtems_filesystem_mount_table_entry_t *mt_entry
00274 );
00275 
00288 typedef int (*rtems_filesystem_fsmount_me_t)(
00289   rtems_filesystem_mount_table_entry_t *mt_entry,
00290   const void *data
00291 );
00292 
00307 typedef int (*rtems_filesystem_unmount_t) (
00308   rtems_filesystem_mount_table_entry_t *mt_entry
00309 );
00310 
00322 typedef void (*rtems_filesystem_fsunmount_me_t)(
00323   rtems_filesystem_mount_table_entry_t *mt_entry
00324 );
00325 
00340 typedef bool (*rtems_filesystem_are_nodes_equal_t)(
00341   const rtems_filesystem_location_info_t *a,
00342   const rtems_filesystem_location_info_t *b
00343 );
00344 
00354 typedef rtems_filesystem_node_types_t (*rtems_filesystem_node_type_t)(
00355   const rtems_filesystem_location_info_t *loc
00356 );
00357 
00374 typedef int (*rtems_filesystem_mknod_t)(
00375   const rtems_filesystem_location_info_t *parentloc,
00376   const char *name,
00377   size_t namelen,
00378   mode_t mode,
00379   dev_t dev
00380 );
00381 
00393 typedef int (*rtems_filesystem_rmnod_t)(
00394   const rtems_filesystem_location_info_t *parentloc,
00395   const rtems_filesystem_location_info_t *loc
00396 );
00397 
00410 typedef int (*rtems_filesystem_utime_t)(
00411   const rtems_filesystem_location_info_t *loc,
00412   time_t actime,
00413   time_t modtime
00414 );
00415 
00430 typedef int (*rtems_filesystem_symlink_t)(
00431   const rtems_filesystem_location_info_t *parentloc,
00432   const char *name,
00433   size_t namelen,
00434   const char *target
00435 );
00436 
00449 typedef ssize_t (*rtems_filesystem_readlink_t)(
00450   const rtems_filesystem_location_info_t *loc,
00451   char *buf,
00452   size_t bufsize
00453 );
00454 
00469 typedef int (*rtems_filesystem_rename_t)(
00470   const rtems_filesystem_location_info_t *oldparentloc,
00471   const rtems_filesystem_location_info_t *oldloc,
00472   const rtems_filesystem_location_info_t *newparentloc,
00473   const char *name,
00474   size_t namelen
00475 );
00476 
00488 typedef int (*rtems_filesystem_statvfs_t)(
00489   const rtems_filesystem_location_info_t *loc,
00490   struct statvfs *buf
00491 );
00492 
00496 struct _rtems_filesystem_operations_table {
00497   rtems_filesystem_mt_entry_lock_t lock_h;
00498   rtems_filesystem_mt_entry_unlock_t unlock_h;
00499   rtems_filesystem_eval_path_t eval_path_h;
00500   rtems_filesystem_link_t link_h;
00501   rtems_filesystem_are_nodes_equal_t are_nodes_equal_h;
00502   rtems_filesystem_node_type_t node_type_h;
00503   rtems_filesystem_mknod_t mknod_h;
00504   rtems_filesystem_rmnod_t rmnod_h;
00505   rtems_filesystem_fchmod_t fchmod_h;
00506   rtems_filesystem_chown_t chown_h;
00507   rtems_filesystem_clonenode_t clonenod_h;
00508   rtems_filesystem_freenode_t freenod_h;
00509   rtems_filesystem_mount_t mount_h;
00510   rtems_filesystem_fsmount_me_t fsmount_me_h;
00511   rtems_filesystem_unmount_t unmount_h;
00512   rtems_filesystem_fsunmount_me_t fsunmount_me_h;
00513   rtems_filesystem_utime_t utime_h;
00514   rtems_filesystem_symlink_t symlink_h;
00515   rtems_filesystem_readlink_t readlink_h;
00516   rtems_filesystem_rename_t rename_h;
00517   rtems_filesystem_statvfs_t statvfs_h;
00518 };
00519 
00523 extern const rtems_filesystem_operations_table
00524   rtems_filesystem_operations_default;
00525 
00531 void rtems_filesystem_default_lock(
00532   const rtems_filesystem_mount_table_entry_t *mt_entry
00533 );
00534 
00540 void rtems_filesystem_default_unlock(
00541   const rtems_filesystem_mount_table_entry_t *mt_entry
00542 );
00543 
00550 void rtems_filesystem_default_eval_path(
00551   rtems_filesystem_eval_path_context_t *ctx
00552 );
00553 
00559 int rtems_filesystem_default_link(
00560   const rtems_filesystem_location_info_t *parentloc,
00561   const rtems_filesystem_location_info_t *targetloc,
00562   const char *name,
00563   size_t namelen
00564 );
00565 
00578 bool rtems_filesystem_default_are_nodes_equal(
00579   const rtems_filesystem_location_info_t *a,
00580   const rtems_filesystem_location_info_t *b
00581 );
00582 
00588 rtems_filesystem_node_types_t rtems_filesystem_default_node_type(
00589   const rtems_filesystem_location_info_t *pathloc
00590 );
00591 
00597 int rtems_filesystem_default_mknod(
00598   const rtems_filesystem_location_info_t *parentloc,
00599   const char *name,
00600   size_t namelen,
00601   mode_t mode,
00602   dev_t dev
00603 );
00604 
00610 int rtems_filesystem_default_rmnod(
00611   const rtems_filesystem_location_info_t *parentloc,
00612   const rtems_filesystem_location_info_t *loc
00613 );
00614 
00620 int rtems_filesystem_default_fchmod(
00621   const rtems_filesystem_location_info_t *loc,
00622   mode_t mode
00623 );
00624 
00630 int rtems_filesystem_default_chown(
00631   const rtems_filesystem_location_info_t *loc,
00632   uid_t owner,
00633   gid_t group
00634 );
00635 
00641 int rtems_filesystem_default_clonenode(
00642   rtems_filesystem_location_info_t *loc
00643 );
00644 
00648 void rtems_filesystem_default_freenode(
00649   const rtems_filesystem_location_info_t *loc
00650 );
00651 
00657 int rtems_filesystem_default_mount (
00658    rtems_filesystem_mount_table_entry_t *mt_entry     /* IN */
00659 );
00660 
00666 int rtems_filesystem_default_fsmount(
00667   rtems_filesystem_mount_table_entry_t *mt_entry,     /* IN */
00668   const void                           *data          /* IN */
00669 );
00670 
00676 int rtems_filesystem_default_unmount(
00677   rtems_filesystem_mount_table_entry_t *mt_entry     /* IN */
00678 );
00679 
00685 void rtems_filesystem_default_fsunmount(
00686    rtems_filesystem_mount_table_entry_t *mt_entry    /* IN */
00687 );
00688 
00694 int rtems_filesystem_default_utime(
00695   const rtems_filesystem_location_info_t *loc,
00696   time_t actime,
00697   time_t modtime
00698 );
00699 
00705 int rtems_filesystem_default_symlink(
00706   const rtems_filesystem_location_info_t *parentloc,
00707   const char *name,
00708   size_t namelen,
00709   const char *target
00710 );
00711 
00717 ssize_t rtems_filesystem_default_readlink(
00718   const rtems_filesystem_location_info_t *loc,
00719   char *buf,
00720   size_t bufsize
00721 );
00722 
00728 int rtems_filesystem_default_rename(
00729   const rtems_filesystem_location_info_t *oldparentloc,
00730   const rtems_filesystem_location_info_t *oldloc,
00731   const rtems_filesystem_location_info_t *newparentloc,
00732   const char *name,
00733   size_t namelen
00734 );
00735 
00741 int rtems_filesystem_default_statvfs(
00742   const rtems_filesystem_location_info_t *loc,
00743   struct statvfs *buf
00744 );
00745 
00770 typedef int (*rtems_filesystem_open_t)(
00771   rtems_libio_t *iop,
00772   const char    *path,
00773   int            oflag,
00774   mode_t         mode
00775 );
00776 
00787 typedef int (*rtems_filesystem_close_t)(
00788   rtems_libio_t *iop
00789 );
00790 
00805 typedef ssize_t (*rtems_filesystem_read_t)(
00806   rtems_libio_t *iop,
00807   void          *buffer,
00808   size_t         count
00809 );
00810 
00827 typedef ssize_t (*rtems_filesystem_readv_t)(
00828   rtems_libio_t      *iop,
00829   const struct iovec *iov,
00830   int                 iovcnt,
00831   ssize_t             total
00832 );
00833 
00848 typedef ssize_t (*rtems_filesystem_write_t)(
00849   rtems_libio_t *iop,
00850   const void    *buffer,
00851   size_t         count
00852 );
00853 
00870 typedef ssize_t (*rtems_filesystem_writev_t)(
00871   rtems_libio_t      *iop,
00872   const struct iovec *iov,
00873   int                 iovcnt,
00874   ssize_t             total
00875 );
00876 
00889 typedef int (*rtems_filesystem_ioctl_t)(
00890   rtems_libio_t   *iop,
00891   ioctl_command_t  request,
00892   void            *buffer
00893 );
00894 
00909 typedef off_t (*rtems_filesystem_lseek_t)(
00910   rtems_libio_t *iop,
00911   off_t          offset,
00912   int            whence
00913 );
00914 
00926 typedef int (*rtems_filesystem_fstat_t)(
00927   const rtems_filesystem_location_info_t *loc,
00928   struct stat *buf
00929 );
00930 
00943 typedef int (*rtems_filesystem_ftruncate_t)(
00944   rtems_libio_t *iop,
00945   off_t length
00946 );
00947 
00959 typedef int (*rtems_filesystem_fsync_t)(
00960   rtems_libio_t *iop
00961 );
00962 
00974 typedef int (*rtems_filesystem_fdatasync_t)(
00975   rtems_libio_t *iop
00976 );
00977 
00989 typedef int (*rtems_filesystem_fcntl_t)(
00990   rtems_libio_t *iop,
00991   int cmd
00992 );
00993 
01004 typedef int (*rtems_filesystem_poll_t)(
01005   rtems_libio_t *iop,
01006   int events
01007 );
01008 
01020 typedef int (*rtems_filesystem_kqfilter_t)(
01021   rtems_libio_t *iop,
01022   struct knote *kn
01023 );
01024 
01028 struct _rtems_filesystem_file_handlers_r {
01029   rtems_filesystem_open_t open_h;
01030   rtems_filesystem_close_t close_h;
01031   rtems_filesystem_read_t read_h;
01032   rtems_filesystem_write_t write_h;
01033   rtems_filesystem_ioctl_t ioctl_h;
01034   rtems_filesystem_lseek_t lseek_h;
01035   rtems_filesystem_fstat_t fstat_h;
01036   rtems_filesystem_ftruncate_t ftruncate_h;
01037   rtems_filesystem_fsync_t fsync_h;
01038   rtems_filesystem_fdatasync_t fdatasync_h;
01039   rtems_filesystem_fcntl_t fcntl_h;
01040   rtems_filesystem_poll_t poll_h;
01041   rtems_filesystem_kqfilter_t kqfilter_h;
01042   rtems_filesystem_readv_t readv_h;
01043   rtems_filesystem_writev_t writev_h;
01044 };
01045 
01049 extern const rtems_filesystem_file_handlers_r
01050   rtems_filesystem_handlers_default;
01051 
01057 int rtems_filesystem_default_open(
01058   rtems_libio_t *iop,
01059   const char    *path,
01060   int            oflag,
01061   mode_t         mode
01062 );
01063 
01069 int rtems_filesystem_default_close(
01070   rtems_libio_t *iop
01071 );
01072 
01078 ssize_t rtems_filesystem_default_read(
01079   rtems_libio_t *iop,
01080   void          *buffer,
01081   size_t         count
01082 );
01083 
01089 ssize_t rtems_filesystem_default_readv(
01090   rtems_libio_t      *iop,
01091   const struct iovec *iov,
01092   int                 iovcnt,
01093   ssize_t             total
01094 );
01095 
01101 ssize_t rtems_filesystem_default_write(
01102   rtems_libio_t *iop,
01103   const void    *buffer,
01104   size_t         count
01105 );
01106 
01112 ssize_t rtems_filesystem_default_writev(
01113   rtems_libio_t      *iop,
01114   const struct iovec *iov,
01115   int                 iovcnt,
01116   ssize_t             total
01117 );
01118 
01124 int rtems_filesystem_default_ioctl(
01125   rtems_libio_t   *iop,
01126   ioctl_command_t  request,
01127   void            *buffer
01128 );
01129 
01135 off_t rtems_filesystem_default_lseek(
01136   rtems_libio_t *iop,
01137   off_t          offset,
01138   int            whence
01139 );
01140 
01152 off_t rtems_filesystem_default_lseek_directory(
01153   rtems_libio_t *iop,
01154   off_t offset,
01155   int whence
01156 );
01157 
01175 off_t rtems_filesystem_default_lseek_file(
01176   rtems_libio_t *iop,
01177   off_t offset,
01178   int whence
01179 );
01180 
01188 int rtems_filesystem_default_fstat(
01189   const rtems_filesystem_location_info_t *loc,
01190   struct stat *buf
01191 );
01192 
01198 int rtems_filesystem_default_ftruncate(
01199   rtems_libio_t *iop,
01200   off_t length
01201 );
01202 
01208 int rtems_filesystem_default_ftruncate_directory(
01209   rtems_libio_t *iop,
01210   off_t length
01211 );
01212 
01218 int rtems_filesystem_default_fsync_or_fdatasync(
01219   rtems_libio_t *iop
01220 );
01221 
01227 int rtems_filesystem_default_fsync_or_fdatasync_success(
01228   rtems_libio_t *iop
01229 );
01230 
01236 int rtems_filesystem_default_fcntl(
01237   rtems_libio_t *iop,
01238   int cmd
01239 );
01240 
01248 int rtems_filesystem_default_poll(
01249   rtems_libio_t *iop,
01250   int events
01251 );
01252 
01260 int rtems_filesystem_default_kqfilter(
01261   rtems_libio_t *iop,
01262   struct knote *kn
01263 );
01264 
01279 typedef off_t rtems_off64_t __attribute__((deprecated));
01280 
01287 rtems_filesystem_fsmount_me_t
01288 rtems_filesystem_get_mount_handler(
01289   const char *type
01290 );
01291 
01296 typedef struct {
01297   int    link_max;                 /* count */
01298   int    max_canon;                /* max formatted input line size */
01299   int    max_input;                /* max input line size */
01300   int    name_max;                 /* max name length */
01301   int    path_max;                 /* max path */
01302   int    pipe_buf;                 /* pipe buffer size */
01303   int    posix_async_io;           /* async IO supported on fs, 0=no, 1=yes */
01304   int    posix_chown_restrictions; /* can chown: 0=no, 1=yes */
01305   int    posix_no_trunc;           /* error on names > max name, 0=no, 1=yes */
01306   int    posix_prio_io;            /* priority IO, 0=no, 1=yes */
01307   int    posix_sync_io;            /* file can be sync'ed, 0=no, 1=yes */
01308   int    posix_vdisable;           /* special char processing, 0=no, 1=yes */
01309 } rtems_filesystem_limits_and_options_t;
01310 
01316 extern const rtems_filesystem_limits_and_options_t
01317   rtems_filesystem_default_pathconf;
01318 
01327 struct rtems_libio_tt {
01328   rtems_driver_name_t                    *driver;
01329   off_t                                   offset;    /* current offset into file */
01330   uint32_t                                flags;
01331   rtems_filesystem_location_info_t        pathinfo;
01332   uint32_t                                data0;     /* private to "driver" */
01333   void                                   *data1;     /* ... */
01334 };
01335 
01342 typedef struct {
01343   rtems_libio_t          *iop;
01344   off_t                   offset;
01345   char                   *buffer;
01346   uint32_t                count;
01347   uint32_t                flags;
01348   uint32_t                bytes_moved;
01349 } rtems_libio_rw_args_t;
01350 
01354 typedef struct {
01355   rtems_libio_t          *iop;
01356   uint32_t                flags;
01357   uint32_t                mode;
01358 } rtems_libio_open_close_args_t;
01359 
01363 typedef struct {
01364   rtems_libio_t          *iop;
01365   ioctl_command_t         command;
01366   void                   *buffer;
01367   int                     ioctl_return;
01368 } rtems_libio_ioctl_args_t;
01369 
01375 #define LIBIO_FLAGS_NO_DELAY      0x0001U  /* return immediately if no data */
01376 #define LIBIO_FLAGS_READ          0x0002U  /* reading */
01377 #define LIBIO_FLAGS_WRITE         0x0004U  /* writing */
01378 #define LIBIO_FLAGS_OPEN          0x0100U  /* device is open */
01379 #define LIBIO_FLAGS_APPEND        0x0200U  /* all writes append */
01380 #define LIBIO_FLAGS_CREATE        0x0400U  /* create file */
01381 #define LIBIO_FLAGS_CLOSE_ON_EXEC 0x0800U  /* close on process exec() */
01382 #define LIBIO_FLAGS_READ_WRITE    (LIBIO_FLAGS_READ | LIBIO_FLAGS_WRITE)
01383 
01391 void rtems_libio_init(void);
01392 
01398 typedef int (*rtems_libio_open_t)(
01399   const char  *pathname,
01400   uint32_t    flag,
01401   uint32_t    mode
01402 );
01403 
01404 typedef int (*rtems_libio_close_t)(
01405   int  fd
01406 );
01407 
01408 typedef ssize_t (*rtems_libio_read_t)(
01409   int         fd,
01410   void       *buffer,
01411   size_t    count
01412 );
01413 
01414 typedef ssize_t (*rtems_libio_write_t)(
01415   int         fd,
01416   const void *buffer,
01417   size_t      count
01418 );
01419 
01420 typedef int (*rtems_libio_ioctl_t)(
01421   int         fd,
01422   uint32_t    command,
01423   void       *buffer
01424 );
01425 
01426 typedef off_t (*rtems_libio_lseek_t)(
01427   int           fd,
01428   off_t         offset,
01429   int           whence
01430 );
01431 
01439 /*
01440  *  The following macros are used to build up the permissions sets
01441  *  used to check permissions.  These are similar in style to the
01442  *  mode_t bits and should stay compatible with them.
01443  */
01444 #define RTEMS_FS_PERMS_READ 0x4
01445 #define RTEMS_FS_PERMS_WRITE 0x2
01446 #define RTEMS_FS_PERMS_EXEC 0x1
01447 #define RTEMS_FS_PERMS_RWX \
01448   (RTEMS_FS_PERMS_READ | RTEMS_FS_PERMS_WRITE | RTEMS_FS_PERMS_EXEC)
01449 #define RTEMS_FS_FOLLOW_HARD_LINK 0x8
01450 #define RTEMS_FS_FOLLOW_SYM_LINK 0x10
01451 #define RTEMS_FS_FOLLOW_LINK \
01452   (RTEMS_FS_FOLLOW_HARD_LINK | RTEMS_FS_FOLLOW_SYM_LINK)
01453 #define RTEMS_FS_MAKE 0x20
01454 #define RTEMS_FS_EXCLUSIVE 0x40
01455 #define RTEMS_FS_ACCEPT_RESIDUAL_DELIMITERS 0x80
01456 #define RTEMS_FS_REJECT_TERMINAL_DOT 0x100
01457 
01460 union __rtems_dev_t {
01461   dev_t device;
01462   struct {
01463      rtems_device_major_number major;
01464      rtems_device_minor_number minor;
01465   } __overlay;
01466 };
01467 
01468 static inline dev_t rtems_filesystem_make_dev_t(
01469   rtems_device_major_number _major,
01470   rtems_device_minor_number _minor
01471 )
01472 {
01473   union __rtems_dev_t temp;
01474 
01475   temp.__overlay.major = _major;
01476   temp.__overlay.minor = _minor;
01477   return temp.device;
01478 }
01479 
01480 static inline rtems_device_major_number rtems_filesystem_dev_major_t(
01481   dev_t device
01482 )
01483 {
01484   union __rtems_dev_t temp;
01485 
01486   temp.device = device;
01487   return temp.__overlay.major;
01488 }
01489 
01490 
01491 static inline rtems_device_minor_number rtems_filesystem_dev_minor_t(
01492   dev_t device
01493 )
01494 {
01495   union __rtems_dev_t temp;
01496 
01497   temp.device = device;
01498   return temp.__overlay.minor;
01499 }
01500 
01501 #define rtems_filesystem_split_dev_t( _dev, _major, _minor ) \
01502   do { \
01503     (_major) = rtems_filesystem_dev_major_t ( _dev ); \
01504     (_minor) = rtems_filesystem_dev_minor_t( _dev ); \
01505   } while(0)
01506 
01507 /*
01508  *  Prototypes for filesystem
01509  */
01510 
01519 void rtems_filesystem_initialize( void );
01520 
01521 typedef void (*rtems_libio_helper)(void);
01522 
01523 extern const rtems_libio_helper rtems_libio_init_helper;
01524 
01525 extern const rtems_libio_helper rtems_libio_post_driver_helper;
01526 
01527 extern const rtems_libio_helper rtems_libio_exit_helper;
01528 
01529 extern const rtems_libio_helper rtems_fs_init_helper;
01530 
01531 void rtems_libio_helper_null(void);
01532 
01533 void rtems_libio_post_driver(void);
01534 
01535 void rtems_libio_exit(void);
01536 
01546 extern int rtems_mkdir(const char *path, mode_t mode);
01547 
01564 #define RTEMS_FILESYSTEM_TYPE_IMFS "imfs"
01565 #define RTEMS_FILESYSTEM_TYPE_MINIIMFS "mimfs"
01566 #define RTEMS_FILESYSTEM_TYPE_DEVFS "devfs"
01567 #define RTEMS_FILESYSTEM_TYPE_FTPFS "ftpfs"
01568 #define RTEMS_FILESYSTEM_TYPE_TFTPFS "tftpfs"
01569 #define RTEMS_FILESYSTEM_TYPE_NFS "nfs"
01570 #define RTEMS_FILESYSTEM_TYPE_DOSFS "dosfs"
01571 #define RTEMS_FILESYSTEM_TYPE_RFS "rfs"
01572 #define RTEMS_FILESYSTEM_TYPE_JFFS2 "jffs2"
01573 
01579 struct rtems_filesystem_mount_table_entry_tt {
01580   rtems_chain_node                       mt_node;
01581   void                                  *fs_info;
01582   const rtems_filesystem_operations_table *ops;
01583   const void                            *immutable_fs_info;
01584   rtems_chain_control                    location_chain;
01585   rtems_filesystem_global_location_t    *mt_point_node;
01586   rtems_filesystem_global_location_t    *mt_fs_root;
01587   bool                                   mounted;
01588   bool                                   writeable;
01589   const rtems_filesystem_limits_and_options_t *pathconf_limits_and_options;
01590 
01591   /*
01592    * The target or mount point of the file system.
01593    */
01594   const char                            *target;
01595 
01596   /*
01597    * The type of filesystem or the name of the filesystem.
01598    */
01599   const char                            *type;
01600 
01601   /*
01602    *  When someone adds a mounted filesystem on a real device,
01603    *  this will need to be used.
01604    *
01605    *  The lower layers can manage how this is managed. Leave as a
01606    *  string.
01607    */
01608   char                                  *dev;
01609 
01616   rtems_id                               unmount_task;
01617 };
01618 
01622 typedef enum {
01623   RTEMS_FILESYSTEM_READ_ONLY,
01624   RTEMS_FILESYSTEM_READ_WRITE,
01625   RTEMS_FILESYSTEM_BAD_OPTIONS
01626 } rtems_filesystem_options_t;
01627 
01631 typedef struct rtems_filesystem_table_t {
01632   const char                    *type;
01633   rtems_filesystem_fsmount_me_t  mount_h;
01634 } rtems_filesystem_table_t;
01635 
01641 extern const rtems_filesystem_table_t rtems_filesystem_table [];
01642 
01643 extern rtems_chain_control rtems_filesystem_mount_table;
01644 
01653 int rtems_filesystem_register(
01654   const char                    *type,
01655   rtems_filesystem_fsmount_me_t  mount_h
01656 );
01657 
01664 int rtems_filesystem_unregister(
01665   const char *type
01666 );
01667 
01690 int unmount(
01691   const char *mount_path
01692 );
01693 
01745 int mount(
01746   const char                 *source,
01747   const char                 *target,
01748   const char                 *filesystemtype,
01749   rtems_filesystem_options_t options,
01750   const void                 *data
01751 );
01752 
01764 int mount_and_make_target_path(
01765   const char                 *source,
01766   const char                 *target,
01767   const char                 *filesystemtype,
01768   rtems_filesystem_options_t options,
01769   const void                 *data
01770 );
01771 
01780 typedef bool (*rtems_per_filesystem_routine)(
01781   const rtems_filesystem_table_t *fs_entry,
01782   void *arg
01783 );
01784 
01798 bool rtems_filesystem_iterate(
01799   rtems_per_filesystem_routine routine,
01800   void *routine_arg
01801 );
01802 
01811 typedef bool (*rtems_filesystem_mt_entry_visitor)(
01812   const rtems_filesystem_mount_table_entry_t *mt_entry,
01813   void *arg
01814 );
01815 
01829 bool rtems_filesystem_mount_iterate(
01830   rtems_filesystem_mt_entry_visitor visitor,
01831   void *visitor_arg
01832 );
01833 
01834 typedef struct {
01835   const char *source;
01836   const char *target;
01837   const char *filesystemtype;
01838   rtems_filesystem_options_t options;
01839   const void *data;
01840 } rtems_filesystem_mount_configuration;
01841 
01842 extern const rtems_filesystem_mount_configuration
01843   rtems_filesystem_root_configuration;
01844 
01856 typedef struct rtems_termios_callbacks {
01857   int    (*firstOpen)(int major, int minor, void *arg);
01858   int    (*lastClose)(int major, int minor, void *arg);
01859   int    (*pollRead)(int minor);
01860   ssize_t (*write)(int minor, const char *buf, size_t len);
01861   int    (*setAttributes)(int minor, const struct termios *t);
01862   int    (*stopRemoteTx)(int minor);
01863   int    (*startRemoteTx)(int minor);
01864   int    outputUsesInterrupts;
01865 } rtems_termios_callbacks;
01866 
01867 void rtems_termios_initialize (void);
01868 
01869 /*
01870  * CCJ: Change before opening a tty. Newer code from Eric is coming
01871  * so extra work to handle an open tty is not worth it. If the tty
01872  * is open, close then open it again.
01873  */
01874 rtems_status_code rtems_termios_bufsize (
01875   size_t cbufsize,     /* cooked buffer size */
01876   size_t raw_input,    /* raw input buffer size */
01877   size_t raw_output    /* raw output buffer size */
01878 );
01879 
01880 rtems_status_code rtems_termios_open (
01881   rtems_device_major_number      major,
01882   rtems_device_minor_number      minor,
01883   void                          *arg,
01884   const rtems_termios_callbacks *callbacks
01885 );
01886 
01887 rtems_status_code rtems_termios_close(
01888   void *arg
01889 );
01890 
01891 rtems_status_code rtems_termios_read(
01892   void *arg
01893 );
01894 
01895 rtems_status_code rtems_termios_write(
01896   void *arg
01897 );
01898 
01899 rtems_status_code rtems_termios_ioctl(
01900   void *arg
01901 );
01902 
01903 int rtems_termios_enqueue_raw_characters(
01904   void *ttyp,
01905   const char *buf,
01906   int   len
01907 );
01908 
01909 int rtems_termios_dequeue_characters(
01910   void *ttyp,
01911   int   len
01912 );
01913 
01919 #define rtems_filesystem_pathconf(_mte) ((_mte)->pathconf_limits_and_options)
01920 
01924 #define rtems_filesystem_type(_mte) ((_mte)->type)
01925 
01929 #define rtems_filesystem_mount_point(_mte) ((_mte)->target)
01930 
01934 #define rtems_filesystem_mount_device(_mte) ((_mte)->dev)
01935 
01936 #ifdef __cplusplus
01937 }
01938 #endif
01939 
01940 #endif /* _RTEMS_LIBIO_H */