source: rtems/cpukit/libcsupport/include/rtems/libio_.h @ 00bf6744

4.10
Last change on this file since 00bf6744 was 00bf6744, checked in by Sebastian Huber <sebastian.huber@…>, on 07/01/10 at 14:10:54

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

  • libcsupport/include/rtems/libio_.h: Declare rtems_filesystem_mount_table_control.
  • libcsupport/include/rtems/libio.h: Removed rtems_filesystem_table_first(), rtems_filesystem_table_next() and rtems_filesystem_table_node_t declarations. Declare rtems_per_filesystem_routine, rtems_filesystem_iterate() and rtems_filesystem_get_mount_handler().
  • libcsupport/src/mount.c: Added rtems_filesystem_mounts_first() and rtems_filesystem_mounts_next(). Simplify mount(). Removed rtems_filesystem_mount_table_control_init. Use rtems_filesystem_get_mount_handler().
  • libcsupport/src/mount-mgr.c: Removed rtems_filesystem_mounts_first() and rtems_filesystem_mounts_next(). Added rtems_filesystem_iterate() and rtems_filesystem_get_mount_handler(). Use rtems_libio_lock() and rtems_libio_unlock();
  • sapi/include/confdefs.h, libmisc/shell/main_mount.c: Update for mount API changes.

2010-06-07 Bharath Suri <bharath.s.jois@…>

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