source: rtems/cpukit/libfs/src/imfs/imfs_fifo.c @ 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: 2.7 KB
Line 
1/*
2 * imfs_fifo.c: FIFO support for IMFS
3 *
4 * Author: Wei Shen <cquark@gmail.com>
5 *
6 * The license and distribution terms for this file may be
7 * found in the file LICENSE in this distribution or at
8 * http://www.rtems.com/license/LICENSE.
9 *
10 * $Id$
11 */
12
13#if HAVE_CONFIG_H
14  #include "config.h"
15#endif
16
17#include "imfs.h"
18
19#define JNODE2PIPE(_jnode)  ( (_jnode)->info.fifo.pipe )
20
21#define LIBIO2PIPE(_iop)  ( JNODE2PIPE((IMFS_jnode_t *)(_iop)->pathinfo.node_access) )
22
23/* Set errno and return -1 if error, else return _err */
24#define IMFS_FIFO_RETURN(_err) \
25do {  \
26  if (_err < 0) \
27    rtems_set_errno_and_return_minus_one(-_err); \
28  return _err; \
29} while (0)
30
31static int IMFS_fifo_open(
32  rtems_libio_t *iop,
33  const char    *pathname,
34  int            oflag,
35  mode_t         mode
36)
37{
38  IMFS_jnode_t *jnode = iop->pathinfo.node_access;
39
40  int err = fifo_open(&JNODE2PIPE(jnode), iop);
41  IMFS_FIFO_RETURN(err);
42}
43
44static int IMFS_fifo_close(
45  rtems_libio_t *iop
46)
47{
48  int err = 0;
49  IMFS_jnode_t *jnode = iop->pathinfo.node_access;
50
51  pipe_release(&JNODE2PIPE(jnode), iop);
52
53  iop->flags &= ~LIBIO_FLAGS_OPEN;
54  IMFS_check_node_remove(jnode);
55
56  IMFS_FIFO_RETURN(err);
57}
58
59static ssize_t IMFS_fifo_read(
60  rtems_libio_t *iop,
61  void          *buffer,
62  size_t         count
63)
64{
65  IMFS_jnode_t *jnode = iop->pathinfo.node_access;
66
67  int err = pipe_read(JNODE2PIPE(jnode), buffer, count, iop);
68  if (err > 0)
69    IMFS_update_atime(jnode);
70
71  IMFS_FIFO_RETURN(err);
72}
73
74static ssize_t IMFS_fifo_write(
75  rtems_libio_t *iop,
76  const void    *buffer,
77  size_t         count
78)
79{
80  IMFS_jnode_t *jnode = iop->pathinfo.node_access;
81
82  int err = pipe_write(JNODE2PIPE(jnode), buffer, count, iop);
83  if (err > 0) {
84    IMFS_mtime_ctime_update(jnode);
85  }
86
87  IMFS_FIFO_RETURN(err);
88}
89
90static int IMFS_fifo_ioctl(
91  rtems_libio_t *iop,
92  uint32_t       command,
93  void          *buffer
94)
95{
96  int err;
97
98  if (command == FIONBIO) {
99    if (buffer == NULL)
100      err = -EFAULT;
101    else {
102      if (*(int *)buffer)
103        iop->flags |= LIBIO_FLAGS_NO_DELAY;
104      else
105        iop->flags &= ~LIBIO_FLAGS_NO_DELAY;
106      return 0;
107    }
108  }
109  else
110    err = pipe_ioctl(LIBIO2PIPE(iop), command, buffer, iop);
111
112  IMFS_FIFO_RETURN(err);
113}
114
115static off_t IMFS_fifo_lseek(
116  rtems_libio_t *iop,
117  off_t          offset,
118  int            whence
119)
120{
121  off_t err = pipe_lseek(LIBIO2PIPE(iop), offset, whence, iop);
122  IMFS_FIFO_RETURN(err);
123}
124
125/*
126 *  Handler table for IMFS FIFO nodes
127 */
128
129const rtems_filesystem_file_handlers_r IMFS_fifo_handlers = {
130  IMFS_fifo_open,
131  IMFS_fifo_close,
132  IMFS_fifo_read,
133  IMFS_fifo_write,
134  IMFS_fifo_ioctl,
135  IMFS_fifo_lseek,
136  IMFS_stat,
137  rtems_filesystem_default_ftruncate,
138  rtems_filesystem_default_fsync,
139  rtems_filesystem_default_fdatasync,
140  rtems_filesystem_default_fcntl
141};
Note: See TracBrowser for help on using the repository browser.