source: rtems/cpukit/libcsupport/include/rtems/libio_.h @ 29e92b0

4.104.11
Last change on this file since 29e92b0 was 29e92b0, checked in by Chris Johns <chrisj@…>, on May 31, 2010 at 1:56:37 PM

2010-05-31 Chris Johns <chrisj@…>

  • libcsupport/Makefile.am: Add mount-mgr.c.
  • libcsupport/src/mount-mgr.c: New.
  • include/rtems/fs.h: Added rtems_filesystem_location_mount.
  • libcsupport/include/rtems/libio.h, libcsupport/src/mount.c: New mount interface. It is similar to Linux.
  • libcsupport/include/rtems/libio_.h: Remove the init_fs_mount_table call.
  • libcsupport/src/base_fs.c: Remove init_fs_mount_table_call. Use the new mount call. Remove setting the root node in the global pathloc. Mount does this now.
  • libcsupport/src/privateenv.c: Remove the hack to set the root mount table entry in the environment.
  • libcsupport/src/unmount.cL Free the target string.
  • libblock/src/bdpart-mount.c: New mount API.
  • libfs/src/devfs/devfs.h, libfs/src/devfs/devfs_init.c, libfs/src/dosfs/dosfs.h, libfs/src/dosfs/msdos.h, libfs/src/dosfs/msdos_init.c, libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_eval.c, libfs/src/imfs/imfs_init.c, libfs/src/imfs/miniimfs_init.c, libfs/src/nfsclient/src/librtemsNfs.h, libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs.h, libnetworking/lib/ftpfs.c, libnetworking/rtems/ftpfs.h, libnetworking/rtems/tftp.h: New mount_h API.
  • libfs/src/devfs/devfs_eval.c: Local include of extern ops.
  • libfs/src/nfsclient/src/nfs.c: New mount API. Removed the mount me call and fixed the initialisation to happen when mounting.
  • libmisc/Makefile.am, libmisc/shell/shellconfig.h: Remove mount filesystem files.
  • libmisc/fsmount/fsmount.c, libmisc/fsmount/fsmount.h: Updated to the new mount table values.
  • libmisc/shell/main_mount_ftp.c, libmisc/shell/main_mount_msdos.c, libmisc/shell/main_mount_rfs.c, libmisc/shell/main_mount_tftp.c: Removed.
  • libmisc/shell/main_mount.c: Use the new mount API. Also access the file system table for the file system types.
  • libnetworking/lib/tftpDriver.c: Updated to the new mount API. Fixed to allow mounting from any mount point. Also can now have more than file system mounted.
  • sapi/include/confdefs.h: Add file system configuration support.
  • Property mode set to 100644
File size: 7.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 *  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 *  rtems_filesystem_is_separator
155 *
156 *  Macro to determine if a character is a path name separator.
157 *
158 *  NOTE:  This macro handles MS-DOS and UNIX style names.
159 */
160
161#define rtems_filesystem_is_separator( _ch ) \
162   ( ((_ch) == '/') || ((_ch) == '\\') || ((_ch) == '\0'))
163
164/*
165 *  rtems_filesystem_get_start_loc
166 *
167 *  Macro to determine if path is absolute or relative.
168 */
169
170#define rtems_filesystem_get_start_loc( _path, _index, _loc )  \
171  do {                                                         \
172    if ( rtems_filesystem_is_separator( (_path)[ 0 ] ) ) {     \
173      *(_loc) = rtems_filesystem_root;                         \
174      *(_index) = 1;                                           \
175    } else {                                                   \
176      *(_loc) = rtems_filesystem_current;                      \
177      *(_index) = 0;                                           \
178    }                                                          \
179  } while (0)
180
181#define rtems_filesystem_get_sym_start_loc( _path, _index, _loc )  \
182  do {                                                         \
183    if ( rtems_filesystem_is_separator( (_path)[ 0 ] ) ) {     \
184      *(_loc) = rtems_filesystem_root;                         \
185      *(_index) = 1;                                           \
186    } else {                                                   \
187      *(_index) = 0;                                           \
188    }                                                          \
189  } while (0)
190
191
192/*
193 *  External structures
194 */
195#include <rtems/userenv.h>
196
197extern rtems_user_env_t * rtems_current_user_env;
198extern rtems_user_env_t   rtems_global_user_env;
199
200/*
201 *  Instantiate a private copy of the per user information for the calling task.
202 */
203
204rtems_status_code rtems_libio_set_private_env(void);
205rtems_status_code rtems_libio_share_private_env(rtems_id task_id) ;
206
207static inline void rtems_libio_lock( void )
208{
209  rtems_semaphore_obtain( rtems_libio_semaphore, RTEMS_WAIT, RTEMS_NO_TIMEOUT );
210}
211
212static inline void rtems_libio_unlock( void )
213{
214  rtems_semaphore_release( rtems_libio_semaphore );
215}
216
217/*
218 *  File Descriptor Routine Prototypes
219 */
220
221rtems_libio_t *rtems_libio_allocate(void);
222
223uint32_t   rtems_libio_fcntl_flags(
224  uint32_t   fcntl_flags
225);
226
227uint32_t   rtems_libio_to_fcntl_flags(
228  uint32_t   flags
229);
230
231void rtems_libio_free(
232  rtems_libio_t *iop
233);
234
235int rtems_libio_is_open_files_in_fs(
236  rtems_filesystem_mount_table_entry_t *mt_entry
237);
238
239int rtems_libio_is_file_open(
240  void  *node_access
241);
242
243/*
244 *  File System Routine Prototypes
245 */
246
247int rtems_filesystem_evaluate_relative_path(
248  const char                        *pathname,
249  size_t                             pathnamelen,
250  int                                flags,
251  rtems_filesystem_location_info_t  *pathloc,
252  int                                follow_link
253);
254
255int rtems_filesystem_evaluate_path(
256  const char                        *pathname,
257  size_t                             pathnamelen,
258  int                                flags,
259  rtems_filesystem_location_info_t  *pathloc,
260  int                                follow_link
261);
262
263int rtems_filesystem_dirname(
264  const char  *pathname
265);
266
267int rtems_filesystem_prefix_separators(
268  const char  *pathname,
269  int          pathnamelen
270);
271
272void rtems_filesystem_initialize(void);
273
274#ifdef __cplusplus
275}
276#endif
277
278#endif
279/* end of include file */
Note: See TracBrowser for help on using the repository browser.