source: rtems/cpukit/libcsupport/include/rtems/libio_.h @ 955a34b5

4.10
Last change on this file since 955a34b5 was 955a34b5, checked in by Sebastian Huber <sebastian.huber@…>, on 07/01/10 at 15:18:06

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

  • libcsupport/include/rtems/libio_.h: Removed rtems_filesystem_mount_table_control.
  • libcsupport/include/rtems/libio.h, libcsupport/src/mount-mgr.c, libcsupport/src/mount.c libcsupport/src/statvfs.c, libcsupport/src/unmount.c, libmisc/shell/main_mount.c: Documentation. Removed rtems_filesystem_mounts_first() and rtems_filesystem_mounts_next(). Added rtems_filesystem_mount_iterate(). Changed return type of rtems_filesystem_iterate(). Removed rtems_filesystem_nodes_equal().

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

  • libfs/src/nfsclient/src/nfs.c, libfs/src/nfsclient/src/nfs.c, libfs/src/nfsclient/src/librtemsNfs.h: Renamed rtems_nfsfs_initialize() in rtems_nfs_initialize().
  • sapi/include/confdefs.h: Reflect changes above. Renamed *_miniIMFS in *_MINIIMFS. Renamed *_NFSFS in *_NFS.
  • Property mode set to 100644
File size: 6.0 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;
40extern const rtems_filesystem_file_handlers_r rtems_filesystem_null_handlers;
41
42/*
43 *  File descriptor Table Information
44 */
45
46extern uint32_t        rtems_libio_number_iops;
47extern rtems_libio_t  *rtems_libio_iops;
48extern rtems_libio_t  *rtems_libio_last_iop;
49extern rtems_libio_t *rtems_libio_iop_freelist;
50
51/*
52 *  rtems_libio_iop
53 *
54 *  Macro to return the file descriptor pointer.
55 */
56
57#define rtems_libio_iop(_fd) \
58  ((((uint32_t)(_fd)) < rtems_libio_number_iops) ? \
59         &rtems_libio_iops[_fd] : 0)
60
61/*
62 *  rtems_libio_iop_to_descriptor
63 *
64 *  Macro to convert an internal file descriptor pointer (iop) into
65 *  the integer file descriptor used by the "section 2" system calls.
66 */
67
68#define rtems_libio_iop_to_descriptor(_iop) \
69   ((!(_iop)) ? -1 : (_iop - rtems_libio_iops))
70
71/*
72 *  rtems_libio_check_is_open
73 *
74 *  Macro to check if a file descriptor is actually open.
75 */
76
77#define rtems_libio_check_is_open(_iop) \
78  do {                                               \
79      if (((_iop)->flags & LIBIO_FLAGS_OPEN) == 0) { \
80          errno = EBADF;                             \
81          return -1;                                 \
82      }                                              \
83  } while (0)
84
85/*
86 *  rtems_libio_check_fd
87 *
88 *  Macro to check if a file descriptor number is valid.
89 */
90
91#define rtems_libio_check_fd(_fd) \
92  do {                                                     \
93      if ((uint32_t) (_fd) >= rtems_libio_number_iops) {   \
94          errno = EBADF;                                   \
95          return -1;                                       \
96      }                                                    \
97  } while (0)
98
99/*
100 *  rtems_libio_check_buffer
101 *
102 *  Macro to check if a buffer pointer is valid.
103 */
104
105#define rtems_libio_check_buffer(_buffer) \
106  do {                                    \
107      if ((_buffer) == 0) {               \
108          errno = EINVAL;                 \
109          return -1;                      \
110      }                                   \
111  } while (0)
112
113/*
114 *  rtems_libio_check_count
115 *
116 *  Macro to check if a count or length is valid.
117 */
118
119#define rtems_libio_check_count(_count) \
120  do {                                  \
121      if ((_count) == 0) {              \
122          return 0;                     \
123      }                                 \
124  } while (0)
125
126/*
127 *  rtems_libio_check_permissions
128 *
129 *  Macro to check if a file descriptor is open for this operation.
130 */
131
132#define rtems_libio_check_permissions(_iop, _flag)          \
133  do {                                                      \
134      if (((_iop)->flags & (_flag)) == 0) {                 \
135            rtems_set_errno_and_return_minus_one( EINVAL ); \
136            return -1;                                      \
137      }                                                     \
138  } while (0)
139
140/*
141 *  rtems_filesystem_freenode
142 *
143 *  Macro to free a node.
144 */
145
146#define rtems_filesystem_freenode( _node ) \
147  do { \
148    if ( (_node)->ops )\
149      if ( (_node)->ops->freenod_h ) \
150        (*(_node)->ops->freenod_h)( (_node) ); \
151  } while (0)
152
153
154/*
155 *  External structures
156 */
157#include <rtems/userenv.h>
158
159extern rtems_user_env_t * rtems_current_user_env;
160extern rtems_user_env_t   rtems_global_user_env;
161
162/*
163 *  Instantiate a private copy of the per user information for the calling task.
164 */
165
166rtems_status_code rtems_libio_set_private_env(void);
167rtems_status_code rtems_libio_share_private_env(rtems_id task_id) ;
168
169static inline void rtems_libio_lock( void )
170{
171  rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
172}
173
174static inline void rtems_libio_unlock( void )
175{
176  rtems_semaphore_release( rtems_libio_semaphore );
177}
178
179/*
180 *  File Descriptor Routine Prototypes
181 */
182
183rtems_libio_t *rtems_libio_allocate(void);
184
185uint32_t   rtems_libio_fcntl_flags(
186  uint32_t   fcntl_flags
187);
188
189uint32_t   rtems_libio_to_fcntl_flags(
190  uint32_t   flags
191);
192
193void rtems_libio_free(
194  rtems_libio_t *iop
195);
196
197int rtems_libio_is_open_files_in_fs(
198  rtems_filesystem_mount_table_entry_t *mt_entry
199);
200
201int rtems_libio_is_file_open(
202  void  *node_access
203);
204
205/*
206 *  File System Routine Prototypes
207 */
208
209int rtems_filesystem_evaluate_relative_path(
210  const char                        *pathname,
211  size_t                             pathnamelen,
212  int                                flags,
213  rtems_filesystem_location_info_t  *pathloc,
214  int                                follow_link
215);
216
217int rtems_filesystem_evaluate_path(
218  const char                        *pathname,
219  size_t                             pathnamelen,
220  int                                flags,
221  rtems_filesystem_location_info_t  *pathloc,
222  int                                follow_link
223);
224
225int rtems_filesystem_dirname(
226  const char  *pathname
227);
228
229int rtems_filesystem_prefix_separators(
230  const char  *pathname,
231  int          pathnamelen
232);
233
234void rtems_filesystem_initialize(void);
235
236int init_fs_mount_table(void);
237
238int rtems_filesystem_is_separator(char ch);
239
240void rtems_filesystem_get_start_loc(const char *path,
241                                    int *index,
242                                    rtems_filesystem_location_info_t *loc);
243
244void rtems_filesystem_get_sym_start_loc(const char *path,
245                                        int *index,
246                                        rtems_filesystem_location_info_t *loc);
247
248#ifdef __cplusplus
249}
250#endif
251
252#endif
253/* end of include file */
Note: See TracBrowser for help on using the repository browser.