source: rtems/cpukit/libcsupport/include/rtems/libio_.h @ 0eae36c7

4.104.114.84.95
Last change on this file since 0eae36c7 was 0eae36c7, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:54:13

2003-09-04 Joel Sherrill <joel@…>

  • include/chain.h, include/clockdrv.h, include/console.h, include/iosupp.h, include/rtc.h, include/spurious.h, include/timerdrv.h, include/vmeintr.h, include/motorola/mc68230.h, include/rtems/libcsupport.h, include/rtems/libio.h, include/rtems/libio_.h, include/rtems/termiostypes.h, include/sys/termios.h, include/zilog/z8036.h, include/zilog/z8530.h, include/zilog/z8536.h, src/brk.c, src/gettod.c, src/sbrk.c, src/times.c, src/access.c, src/base_fs.c, src/cfgetispeed.c, src/cfgetospeed.c, src/cfsetispeed.c, src/cfsetospeed.c, src/chdir.c, src/chmod.c, src/chown.c, src/chroot.c, src/close.c, src/ctermid.c, src/dup.c, src/dup2.c, src/eval.c, src/fchdir.c, src/fchmod.c, src/fcntl.c, src/fdatasync.c, src/fpathconf.c, src/fs_null_handlers.c, src/fstat.c, src/fsync.c, src/ftruncate.c, src/getdents.c, src/getpwent.c, src/hosterr.c, src/ioctl.c, src/isatty.c, src/libio.c, src/libio_sockets.c, src/link.c, src/lseek.c, src/lstat.c, src/malloc.c, src/mallocfreespace.c, src/mkdir.c, src/mkfifo.c, src/mknod.c, src/mount.c, src/newlibc.c, src/no_libc.c, src/no_posix.c, src/open.c, src/pathconf.c, src/pipe.c, src/privateenv.c, src/read.c, src/readlink.c, src/rewinddir.c, src/rmdir.c, src/seekdir.c, src/stat.c, src/symlink.c, src/sync.c, src/tcdrain.c, src/tcflow.c, src/tcflush.c, src/tcgetattr.c, src/tcgetprgrp.c, src/tcsendbreak.c, src/tcsetattr.c, src/tcsetpgrp.c, src/telldir.c, src/termios.c, src/termiosinitialize.c, src/truncate.c, src/umask.c, src/unixlibc.c, src/unlink.c, src/unmount.c, src/utime.c, src/write.c: URL for license changed.
  • Property mode set to 100644
File size: 6.2 KB
Line 
1/*
2 *  Libio Internal Information
3 *
4 *  COPYRIGHT (c) 1989-1999.
5 *  On-Line Applications Research Corporation (OAR).
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#ifndef __RTEMS_LIBIO_INTERNAL__h
15#define __RTEMS_LIBIO_INTERNAL__h
16
17#ifdef __cplusplus
18extern "C" {
19#endif
20
21#include <rtems.h>
22#include <rtems/libio.h>                /* include before standard IO */
23
24#include <sys/types.h>                 
25
26#include <errno.h>
27
28/*
29 *  Semaphore to protect the io table
30 */
31
32#define RTEMS_LIBIO_SEM         rtems_build_name('L', 'B', 'I', 'O')
33#define RTEMS_LIBIO_IOP_SEM(n)  rtems_build_name('L', 'B', 'I', n)
34
35extern rtems_id                          rtems_libio_semaphore;
36extern rtems_filesystem_file_handlers_r  rtems_filesystem_null_handlers;
37
38/*
39 *  File descriptor Table Information
40 */
41
42extern unsigned32      rtems_libio_number_iops;
43extern rtems_libio_t  *rtems_libio_iops;
44extern rtems_libio_t  *rtems_libio_last_iop;
45extern rtems_libio_t *rtems_libio_iop_freelist;
46
47/*
48 *  rtems_libio_iop
49 *
50 *  Macro to return the file descriptor pointer.
51 */
52
53#define rtems_libio_iop(_fd) \
54  ((((unsigned32)(_fd)) < rtems_libio_number_iops) ? \
55         &rtems_libio_iops[_fd] : 0)
56
57/* 
58 *  rtems_libio_check_is_open
59 * 
60 *  Macro to check if a file descriptor is actually open.
61 */
62
63#define rtems_libio_check_is_open(_iop) \
64  do {                                               \
65      if (((_iop)->flags & LIBIO_FLAGS_OPEN) == 0) { \
66          errno = EBADF;                             \
67          return -1;                                 \
68      }                                              \
69  } while (0)
70
71/*
72 *  rtems_libio_check_fd
73 *
74 *  Macro to check if a file descriptor number is valid.
75 */
76
77#define rtems_libio_check_fd(_fd) \
78  do {                                                     \
79      if ((unsigned32) (_fd) >= rtems_libio_number_iops) { \
80          errno = EBADF;                                   \
81          return -1;                                       \
82      }                                                    \
83  } while (0)
84
85/*
86 *  rtems_libio_check_buffer
87 *
88 *  Macro to check if a buffer pointer is valid.
89 */
90
91#define rtems_libio_check_buffer(_buffer) \
92  do {                                    \
93      if ((_buffer) == 0) {               \
94          errno = EINVAL;                 \
95          return -1;                      \
96      }                                   \
97  } while (0)
98
99/*
100 *  rtems_libio_check_count
101 *
102 *  Macro to check if a count or length is valid.
103 */
104
105#define rtems_libio_check_count(_count) \
106  do {                                  \
107      if ((_count) == 0) {              \
108          return 0;                     \
109      }                                 \
110  } while (0)
111
112/*
113 *  rtems_libio_check_permissions
114 *
115 *  Macro to check if a file descriptor is open for this operation.
116 */
117
118#define rtems_libio_check_permissions(_iop, _flag)    \
119  do {                                                \
120      if (((_iop)->flags & (_flag)) == 0) {           \
121            rtems_set_errno_and_return_minus_one( EINVAL ); \
122            return -1;                                \
123      }                                               \
124  } while (0)
125
126/*
127 *  rtems_filesystem_freenode
128 *
129 *  Macro to free a node.
130 */
131
132#define rtems_filesystem_freenode( _node ) \
133  do { \
134    if ( (_node)->ops )\
135      if ( (_node)->ops->freenod_h ) \
136        (*(_node)->ops->freenod_h)( (_node) ); \
137  } while (0)
138
139/*
140 *  rtems_filesystem_is_separator
141 *
142 *  Macro to determine if a character is a path name separator.
143 *
144 *  NOTE:  This macro handles MS-DOS and UNIX style names.
145 */
146
147#define rtems_filesystem_is_separator( _ch ) \
148   ( ((_ch) == '/') || ((_ch) == '\\') || ((_ch) == '\0'))
149
150/*
151 *  rtems_filesystem_get_start_loc
152 *
153 *  Macro to determine if path is absolute or relative.
154 */
155
156#define rtems_filesystem_get_start_loc( _path, _index, _loc )  \
157  do {                                                         \
158    if ( rtems_filesystem_is_separator( (_path)[ 0 ] ) ) {     \
159      *(_loc) = rtems_filesystem_root;                         \
160      *(_index) = 1;                                           \
161    } else {                                                   \
162      *(_loc) = rtems_filesystem_current;                      \
163      *(_index) = 0;                                           \
164    }                                                          \
165  } while (0)
166
167#define rtems_filesystem_get_sym_start_loc( _path, _index, _loc )  \
168  do {                                                         \
169    if ( rtems_filesystem_is_separator( (_path)[ 0 ] ) ) {     \
170      *(_loc) = rtems_filesystem_root;                         \
171      *(_index) = 1;                                           \
172    } else {                                                   \
173      *(_index) = 0;                                           \
174    }                                                          \
175  } while (0)
176
177
178/*
179 *  External structures
180 */
181#include <rtems/userenv.h>
182
183extern rtems_user_env_t * rtems_current_user_env;
184extern rtems_user_env_t   rtems_global_user_env;
185
186/*
187 *  Instantiate a private copy of the per user information for the calling task.
188 */
189
190rtems_status_code rtems_libio_set_private_env(void);
191rtems_status_code rtems_libio_share_private_env(rtems_id task_id) ;
192       
193/*
194 *  File Descriptor Routine Prototypes
195 */
196
197rtems_libio_t *rtems_libio_allocate(void);
198
199unsigned32 rtems_libio_fcntl_flags(
200  unsigned32 fcntl_flags
201);
202
203unsigned32 rtems_libio_to_fcntl_flags(
204  unsigned32 flags
205);
206
207void rtems_libio_free(
208  rtems_libio_t *iop
209);
210
211int rtems_libio_is_open_files_in_fs(
212  rtems_filesystem_mount_table_entry_t *mt_entry
213);
214
215int rtems_libio_is_file_open(
216  void  *node_access
217);
218
219/*
220 *  File System Routine Prototypes
221 */
222
223int rtems_filesystem_evaluate_path(
224  const char                        *pathname,
225  int                                flags,
226  rtems_filesystem_location_info_t  *pathloc,
227  int                                follow_link
228);
229
230void rtems_filesystem_initialize();
231
232int init_fs_mount_table();
233
234#ifdef __cplusplus
235}
236#endif
237
238#endif
239/* end of include file */
Note: See TracBrowser for help on using the repository browser.