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

4.115
Last change on this file since 3b7c123 was 3b7c123, checked in by Sebastian Huber <sebastian.huber@…>, on 03/13/12 at 10:33:51

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
RevLine 
[0a7278e]1/**
[d40da79b]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
[d934b68]11#include <rtems/libio_.h>
12
[d40da79b]13#ifdef __cplusplus
14extern "C" {
15#endif
16
17/**
18 *  This structure define the type of device table
19 */
[3b7c123]20typedef struct {
21  /** This member points to device name which is not a null-terminated string */
22  const char               *name;
[d40da79b]23  /** This member is the name length of a device */
[3b7c123]24  size_t                    namelen;
[d40da79b]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;
[3b7c123]31} devFS_node;
[d40da79b]32
[3b7c123]33typedef struct {
34  devFS_node *nodes;
35  size_t count;
36} devFS_data;
[d40da79b]37
[3b7c123]38/**
39 *  The following defines the device-only filesystem operating
40 *  operations.
41 */
[d40da79b]42
[3b7c123]43extern const rtems_filesystem_operations_table devFS_ops;
[d40da79b]44
45/**
[3b7c123]46 *  The following defines the device-only filesystem operating
47 *  handlers.
[d40da79b]48 */
49
[3b7c123]50extern const rtems_filesystem_file_handlers_r  devFS_file_handlers;
[d40da79b]51
52/**
[3b7c123]53 *  This routine associates RTEMS status code with errno
[d40da79b]54 */
55
[3b7c123]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);
[d40da79b]68
69/**
70 *  This handler maps open operation to rtems_io_open.
71 *  @param iop This is the RTEMS's internal representation of file.
[0a7278e]72 *  @param pathname a null-terminated string that starts with /dev.
[d40da79b]73 *  @param flag access flags
74 *  @param mode access mode
75 *  @retval the same as open
76 */
77
[d934b68]78extern int devFS_open(
[d40da79b]79  rtems_libio_t *iop,
80  const char    *pathname,
[3b7c123]81  int            oflag,
82  mode_t         mode
[d40da79b]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
[d934b68]93extern int devFS_close(
[d40da79b]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
[d934b68]107extern ssize_t devFS_read(
[d40da79b]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
[d934b68]123extern ssize_t devFS_write(
[d40da79b]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
[d934b68]139extern int devFS_ioctl(
[d40da79b]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
[d934b68]160extern int devFS_stat(
[3b7c123]161  const rtems_filesystem_location_info_t *loc,
162  struct stat *buf
[d40da79b]163);
164
165
166
167/**
168 *  This routine is invoked upon determination of a node type.
[0a7278e]169 *  Since this is a device-only filesystem, so there is only
[d40da79b]170 *  one node type in the system.
[0a7278e]171 *
[3b7c123]172 *  @param loc contains filesytem access information, this
[d40da79b]173 *         parameter is ignored
174 *  @retval always returns RTEMS_FILESYSTEM_DEVICE
175 */
176
[106d8f5]177extern rtems_filesystem_node_types_t devFS_node_type(
[3b7c123]178  const rtems_filesystem_location_info_t*loc
[d40da79b]179);
180
181/**
182 *  This routine is invoked upon registration of a new device
[0a7278e]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
[d40da79b]186 *  with proper values.
187 *
[3b7c123]188 *  @see rtems_filesystem_mknod_t.
[d40da79b]189 */
190
[d934b68]191extern int devFS_mknod(
[3b7c123]192  const rtems_filesystem_location_info_t *parentloc,
193  const char *name,
194  size_t namelen,
195  mode_t mode,
196  dev_t dev
[d40da79b]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
[0a7278e]205 *
[29e92b0]206 *  @param  mt_entry The filesystem mount table entry.
207 *  @param  data Filesystem specific data.
[d40da79b]208 *  @retval upon success, this routine returns 0; otherwise it returns
[0a7278e]209 *  -1 and errno is set to proper value. The only error is when malloc
[d40da79b]210 *  failed, and errno is set to NOMEM.
211 */
212
[d934b68]213extern int devFS_initialize(
[29e92b0]214  rtems_filesystem_mount_table_entry_t *mt_entry,
215  const void                           *data
[d40da79b]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:
[0a7278e]223 *
[d40da79b]224 *  /dev/console     0  0
225 *  /dev/clock       1  0
226 *  /dev/tty0        0  0
227 *  /flash           2  0
[0a7278e]228 *
229 *  This routine is intended for debugging, and can be used by shell
[d40da79b]230 *  program to provide user with the system information.
231 */
232
[3b7c123]233extern void devFS_Show(void);
[d40da79b]234
235#ifdef __cplusplus
236}
237#endif
238
239#endif
240
Note: See TracBrowser for help on using the repository browser.