source: rtems/cpukit/libfs/src/devfs/devfs.h @ 3b7c123

4.11
Last change on this file since 3b7c123 was 3b7c123, checked in by Sebastian Huber <sebastian.huber@…>, on Mar 13, 2012 at 10:33:51 AM

Filesystem: Reference counting for locations

o A new data structure rtems_filesystem_global_location_t was

introduced to be used for

o the mount point location in the mount table entry,
o the file system root location in the mount table entry,
o the root directory location in the user environment, and
o the current directory location in the user environment.

During the path evaluation global start locations are obtained to
ensure that the current file system instance will be not unmounted in
the meantime.

o The user environment uses now reference counting and is protected

from concurrent access.

o The path evaluation process was completely rewritten and simplified.

The IMFS, RFS, NFS, and DOSFS use now a generic path evaluation
method. Recursive calls in the path evaluation have been replaced
with iteration to avoid stack overflows. Only the evaluation of
symbolic links is recursive. No dynamic memory allocations and
intermediate buffers are used in the high level path evaluation. No
global locks are held during the file system instance specific path
evaluation process.

o Recursive symbolic link evaluation is now limited by

RTEMS_FILESYSTEM_SYMLOOP_MAX. Applications can retrieve this value
via sysconf().

o The device file system (devFS) uses now no global variables and

allocation from the workspace. Node names are allocated from the
heap.

o The upper layer lseek() performs now some parameter checks.
o The upper layer ftruncate() performs now some parameter checks.
o unmask() is now restricted to the RWX flags and protected from

concurrent access.

o The fchmod_h and rmnod_h file system node handlers are now a file

system operation.

o The unlink_h operation has been removed. All nodes are now destroyed

with the rmnod_h operation.

o New lock_h, unlock_h, clonenod_h, and are_nodes_equal_h file system

operations.

o The path evaluation and file system operations are now protected by

per file system instance lock and unlock operations.

o Fix and test file descriptor duplicate in fcntl().
o New test fstests/fsnofs01.

  • Property mode set to 100644
File size: 6.0 KB
Line 
1/**
2*  @file  libfs/devfs/devfs.h
3*
4*  This include file contains all constants and structures associated
5*  with the 'device-only' filesystem.
6*/
7
8#ifndef _RTEMS_DEVFS_H
9#define _RTEMS_DEVFS_H
10
11#include <rtems/libio_.h>
12
13#ifdef __cplusplus
14extern "C" {
15#endif
16
17/**
18 *  This structure define the type of device table
19 */
20typedef struct {
21  /** This member points to device name which is not a null-terminated string */
22  const char               *name;
23  /** This member is the name length of a device */
24  size_t                    namelen;
25  /** major number of a device */
26  rtems_device_major_number major;
27  /** minor number of a device */
28  rtems_device_minor_number minor;
29  /** device creation mode, only device file can be created */
30  mode_t                    mode;
31} devFS_node;
32
33typedef struct {
34  devFS_node *nodes;
35  size_t count;
36} devFS_data;
37
38/**
39 *  The following defines the device-only filesystem operating
40 *  operations.
41 */
42
43extern const rtems_filesystem_operations_table devFS_ops;
44
45/**
46 *  The following defines the device-only filesystem operating
47 *  handlers.
48 */
49
50extern const rtems_filesystem_file_handlers_r  devFS_file_handlers;
51
52/**
53 *  This routine associates RTEMS status code with errno
54 */
55
56extern int rtems_deviceio_errno(rtems_status_code code);
57
58static inline const devFS_data *devFS_get_data(
59  const rtems_filesystem_location_info_t *loc
60)
61{
62  return loc->mt_entry->immutable_fs_info;
63}
64
65extern void devFS_eval_path(
66  rtems_filesystem_eval_path_context_t *ctx
67);
68
69/**
70 *  This handler maps open operation to rtems_io_open.
71 *  @param iop This is the RTEMS's internal representation of file.
72 *  @param pathname a null-terminated string that starts with /dev.
73 *  @param flag access flags
74 *  @param mode access mode
75 *  @retval the same as open
76 */
77
78extern int devFS_open(
79  rtems_libio_t *iop,
80  const char    *pathname,
81  int            oflag,
82  mode_t         mode
83);
84
85
86/**
87 *  This handler maps close operation to rtems_io_close.
88 *  @param iop This is the RTEMS's internal representation of file
89 *  @retval the same as close
90 */
91
92
93extern int devFS_close(
94  rtems_libio_t *iop
95);
96
97
98/**
99 *  This handler maps read operation to rtems_io_read.
100 *  @param iop This is the RTEMS's internal representation of file
101 *  @param  buffer memory location to store read data
102 *  @param  count  how many bytes to read
103 *  @retval On successful, this routine returns total bytes read. On error
104 *  it returns -1 and errno is set to proper value.
105 */
106
107extern ssize_t devFS_read(
108  rtems_libio_t *iop,
109  void          *buffer,
110  size_t         count
111);
112
113
114/**
115 *  This handler maps write operation to rtems_io_write.
116 *  @param iop This is the RTEMS's internal representation of file
117 *  @param buffer data to be written
118 *  @param count  how many bytes to write
119 *  @retval On successful, this routine returns total bytes written. On error
120 *  it returns -1 and errno is set to proper value.
121 */
122
123extern ssize_t devFS_write(
124  rtems_libio_t *iop,
125  const void    *buffer,
126  size_t         count
127);
128
129
130/**
131 *  This handler maps ioctl operation to rtems_io_ioctl.
132 *  @param iop This is the RTEMS's internal representation of file
133 *  @param command io control command
134 *  @param buffer  io control parameters
135 *  @retval On successful, this routine returns total bytes written. On error
136 *  it returns -1 and errno is set to proper value.
137 */
138
139extern int devFS_ioctl(
140  rtems_libio_t *iop,
141  uint32_t       command,
142  void          *buffer
143);
144
145
146
147
148/**
149 *  This handler gets the device file information. This routine only set the following member of struct stat:
150 *  st_dev : device number
151 *  st_mode: device file creation mode, only two mode are accepted:
152 *           S_IFCHR: character device file
153 *           S_IFBLK: block device file
154 *  @param loc contains filesystem access information
155 *  @param buf buffer to hold the device file's information
156 *  @retval On successful, this routine returns 0. On error
157 *  it returns -1 and errno is set to proper value.
158 */
159
160extern int devFS_stat(
161  const rtems_filesystem_location_info_t *loc,
162  struct stat *buf
163);
164
165
166
167/**
168 *  This routine is invoked upon determination of a node type.
169 *  Since this is a device-only filesystem, so there is only
170 *  one node type in the system.
171 *
172 *  @param loc contains filesytem access information, this
173 *         parameter is ignored
174 *  @retval always returns RTEMS_FILESYSTEM_DEVICE
175 */
176
177extern rtems_filesystem_node_types_t devFS_node_type(
178  const rtems_filesystem_location_info_t*loc
179);
180
181/**
182 *  This routine is invoked upon registration of a new device
183 *  file. It is responsible for creating a item in the main
184 *  device table. This routine searches the device table in
185 *  sequential order, when found a empty slot, it fills the slot
186 *  with proper values.
187 *
188 *  @see rtems_filesystem_mknod_t.
189 */
190
191extern int devFS_mknod(
192  const rtems_filesystem_location_info_t *parentloc,
193  const char *name,
194  size_t namelen,
195  mode_t mode,
196  dev_t dev
197);
198
199
200/**
201 *  This routine is invoked upon rtems filesystem initialization.
202 *  It is responsible for creating the main device table,
203 *  initializing it to a known state, and set device file operation
204 *  handlers. After this, the device-only filesytem is ready for use
205 *
206 *  @param  mt_entry The filesystem mount table entry.
207 *  @param  data Filesystem specific data.
208 *  @retval upon success, this routine returns 0; otherwise it returns
209 *  -1 and errno is set to proper value. The only error is when malloc
210 *  failed, and errno is set to NOMEM.
211 */
212
213extern int devFS_initialize(
214  rtems_filesystem_mount_table_entry_t *mt_entry,
215  const void                           *data
216);
217
218
219/**
220 *  This routine retrieves all the device registered in system, and
221 *  prints out their detail information. For example, on one system,
222 *  devFS_show will print out following message:
223 *
224 *  /dev/console     0  0
225 *  /dev/clock       1  0
226 *  /dev/tty0        0  0
227 *  /flash           2  0
228 *
229 *  This routine is intended for debugging, and can be used by shell
230 *  program to provide user with the system information.
231 */
232
233extern void devFS_Show(void);
234
235#ifdef __cplusplus
236}
237#endif
238
239#endif
240
Note: See TracBrowser for help on using the repository browser.