source: rtems/cpukit/libcsupport/include/rtems/libio_.h @ de39b51

4.115
Last change on this file since de39b51 was de39b51, checked in by Sebastian Huber <sebastian.huber@…>, on 07/15/10 at 08:46:06

2010-07-16 Sebastian Huber <sebastian.huber@…>

  • libcsupport/include/rtems/libio_.h: Removed rtems_filesystem_null_handlers.
  • libcsupport/src/fs_null_handlers.c: Removed file.
  • libcsupport/Makefile.am: Reflect change above.
  • libfs/src/nfsclient/src/nfs.c, libfs/src/imfs/imfs_creat.c, libfs/src/imfs/imfs_init.c, libfs/src/imfs/miniimfs_init.c: Use rtems_filesystem_handlers_default instead of rtems_filesystem_null_handlers.
  • libnetworking/lib/ftpfs.c, libnetworking/lib/tftpDriver.c: Initialize handler and operations table with proper defaults.
  • Property mode set to 100644
File size: 5.8 KB
Line 
1/**
2 * @file rtems/libio_.h
3 */
4
5/*
6 *  Libio Internal Information
7 *
8 *  COPYRIGHT (c) 1989-1999.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.com/license/LICENSE.
14 *
15 *  $Id$
16 */
17
18#ifndef _RTEMS_RTEMS_LIBIO__H
19#define _RTEMS_RTEMS_LIBIO__H
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#ifdef __cplusplus
29extern "C" {
30#endif
31
32/*
33 *  Semaphore to protect the io table
34 */
35
36#define RTEMS_LIBIO_SEM         rtems_build_name('L', 'B', 'I', 'O')
37#define RTEMS_LIBIO_IOP_SEM(n)  rtems_build_name('L', 'B', 'I', n)
38
39extern rtems_id                          rtems_libio_semaphore;
40
41/*
42 *  File descriptor Table Information
43 */
44
45extern uint32_t        rtems_libio_number_iops;
46extern rtems_libio_t  *rtems_libio_iops;
47extern rtems_libio_t  *rtems_libio_last_iop;
48extern rtems_libio_t *rtems_libio_iop_freelist;
49
50/*
51 *  rtems_libio_iop
52 *
53 *  Macro to return the file descriptor pointer.
54 */
55
56#define rtems_libio_iop(_fd) \
57  ((((uint32_t)(_fd)) < rtems_libio_number_iops) ? \
58         &rtems_libio_iops[_fd] : 0)
59
60/*
61 *  rtems_libio_iop_to_descriptor
62 *
63 *  Macro to convert an internal file descriptor pointer (iop) into
64 *  the integer file descriptor used by the "section 2" system calls.
65 */
66
67#define rtems_libio_iop_to_descriptor(_iop) \
68   ((!(_iop)) ? -1 : (_iop - rtems_libio_iops))
69
70/*
71 *  rtems_libio_check_is_open
72 *
73 *  Macro to check if a file descriptor is actually open.
74 */
75
76#define rtems_libio_check_is_open(_iop) \
77  do {                                               \
78      if (((_iop)->flags & LIBIO_FLAGS_OPEN) == 0) { \
79          errno = EBADF;                             \
80          return -1;                                 \
81      }                                              \
82  } while (0)
83
84/*
85 *  rtems_libio_check_fd
86 *
87 *  Macro to check if a file descriptor number is valid.
88 */
89
90#define rtems_libio_check_fd(_fd) \
91  do {                                                     \
92      if ((uint32_t) (_fd) >= rtems_libio_number_iops) {   \
93          errno = EBADF;                                   \
94          return -1;                                       \
95      }                                                    \
96  } while (0)
97
98/*
99 *  rtems_libio_check_buffer
100 *
101 *  Macro to check if a buffer pointer is valid.
102 */
103
104#define rtems_libio_check_buffer(_buffer) \
105  do {                                    \
106      if ((_buffer) == 0) {               \
107          errno = EINVAL;                 \
108          return -1;                      \
109      }                                   \
110  } while (0)
111
112/*
113 *  rtems_libio_check_count
114 *
115 *  Macro to check if a count or length is valid.
116 */
117
118#define rtems_libio_check_count(_count) \
119  do {                                  \
120      if ((_count) == 0) {              \
121          return 0;                     \
122      }                                 \
123  } while (0)
124
125/*
126 *  rtems_libio_check_permissions
127 *
128 *  Macro to check if a file descriptor is open for this operation.
129 */
130
131#define rtems_libio_check_permissions(_iop, _flag)          \
132  do {                                                      \
133      if (((_iop)->flags & (_flag)) == 0) {                 \
134            rtems_set_errno_and_return_minus_one( EINVAL ); \
135            return -1;                                      \
136      }                                                     \
137  } while (0)
138
139/*
140 *  rtems_filesystem_freenode
141 *
142 *  Macro to free a node.
143 */
144
145void rtems_filesystem_freenode( rtems_filesystem_location_info_t*  node );
146
147/*
148 *  External structures
149 */
150#include <rtems/userenv.h>
151
152extern rtems_user_env_t * rtems_current_user_env;
153extern rtems_user_env_t   rtems_global_user_env;
154
155/*
156 *  Instantiate a private copy of the per user information for the calling task.
157 */
158
159rtems_status_code rtems_libio_set_private_env(void);
160rtems_status_code rtems_libio_share_private_env(rtems_id task_id) ;
161
162static inline void rtems_libio_lock( void )
163{
164  rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
165}
166
167static inline void rtems_libio_unlock( void )
168{
169  rtems_semaphore_release( rtems_libio_semaphore );
170}
171
172/*
173 *  File Descriptor Routine Prototypes
174 */
175
176rtems_libio_t *rtems_libio_allocate(void);
177
178uint32_t   rtems_libio_fcntl_flags(
179  uint32_t   fcntl_flags
180);
181
182uint32_t   rtems_libio_to_fcntl_flags(
183  uint32_t   flags
184);
185
186void rtems_libio_free(
187  rtems_libio_t *iop
188);
189
190int rtems_libio_is_open_files_in_fs(
191  rtems_filesystem_mount_table_entry_t *mt_entry
192);
193
194int rtems_libio_is_file_open(
195  void  *node_access
196);
197
198/*
199 *  File System Routine Prototypes
200 */
201
202int rtems_filesystem_evaluate_relative_path(
203  const char                        *pathname,
204  size_t                             pathnamelen,
205  int                                flags,
206  rtems_filesystem_location_info_t  *pathloc,
207  int                                follow_link
208);
209
210int rtems_filesystem_evaluate_path(
211  const char                        *pathname,
212  size_t                             pathnamelen,
213  int                                flags,
214  rtems_filesystem_location_info_t  *pathloc,
215  int                                follow_link
216);
217
218int rtems_filesystem_dirname(
219  const char  *pathname
220);
221
222int rtems_filesystem_prefix_separators(
223  const char  *pathname,
224  int          pathnamelen
225);
226
227void rtems_filesystem_initialize(void);
228
229int init_fs_mount_table(void);
230
231int rtems_filesystem_is_separator(char ch);
232
233void rtems_filesystem_get_start_loc(const char *path,
234                                    int *index,
235                                    rtems_filesystem_location_info_t *loc);
236
237void rtems_filesystem_get_sym_start_loc(const char *path,
238                                        int *index,
239                                        rtems_filesystem_location_info_t *loc);
240
241#ifdef __cplusplus
242}
243#endif
244
245#endif
246/* end of include file */
Note: See TracBrowser for help on using the repository browser.