source: rtems/cpukit/libfs/src/imfs/deviceio.c @ 07a3253d

4.104.114.84.95
Last change on this file since 07a3253d was 07a3253d, checked in by Joel Sherrill <joel.sherrill@…>, on 11/23/98 at 19:07:58

Added base version of file system infrastructure. This includes a major
overhaul of the RTEMS system call interface. This base file system is
the "In-Memory File System" aka IMFS.

The design and implementation was done by the following people:

+ Joel Sherrill (joel@…)
+ Jennifer Averett (jennifer@…)
+ Steve "Mr Mount" Salitasc (salitasc@…)
+ Kerwin Wade (wade@…)

PROBLEMS
========

+ It is VERY likely that merging this will break the UNIX port. This

can/will be fixed.

+ There is likely some reentrancy/mutual exclusion needed.

+ Eventually, there should be a "mini-IMFS" description table to

eliminate links, symlinks, etc to save memory. All you need to
have "classic RTEMS" functionality is technically directories
and device IO. All the rest could be left out to save memory.

  • Property mode set to 100644
File size: 3.8 KB
Line 
1/*
2 *  IMFS Device Node Handlers
3 *
4 *  This file contains the set of handlers used to map operations on
5 *  IMFS device nodes onto calls to the RTEMS Classic API IO Manager.
6 *
7 *  COPYRIGHT (c) 1989-1998.
8 *  On-Line Applications Research Corporation (OAR).
9 *  Copyright assigned to U.S. Government, 1994.
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.OARcorp.com/rtems/license.html.
14 *
15 *  $Id$
16 */
17
18#include <rtems.h>
19#include <rtems/libio.h>
20
21#include "imfs.h"
22
23/*
24 *  device_open
25 *
26 *  This handler maps an open() operation onto rtems_io_open().
27 */
28
29int device_open(
30  rtems_libio_t *iop,
31  const char    *pathname,
32  unsigned32     flag,
33  unsigned32     mode
34)
35{
36  rtems_libio_open_close_args_t  args;
37  rtems_status_code              status;
38  IMFS_jnode_t                  *the_jnode;
39
40  the_jnode  = iop->file_info;
41
42  args.iop   = iop;
43  args.flags = iop->flags;
44  args.mode  = mode;
45
46  status = rtems_io_open(
47    the_jnode->info.device.major,
48    the_jnode->info.device.minor,
49    (void *) &args
50  );
51  if ( status )
52    return RTEMS_UNSATISFIED;
53
54  return 0;
55}
56
57/*
58 *  device_close
59 *
60 *  This handler maps a close() operation onto rtems_io_close().
61 */
62
63int device_close(
64  rtems_libio_t *iop
65)
66{
67  rtems_libio_open_close_args_t  args;
68  rtems_status_code              status;
69  IMFS_jnode_t                  *the_jnode;
70
71  the_jnode = iop->file_info;
72
73  args.iop   = iop;
74  args.flags = 0;
75  args.mode  = 0;
76
77  status = rtems_io_close(
78    the_jnode->info.device.major,
79    the_jnode->info.device.minor,
80    (void *) &args
81  );
82  if ( status )
83    return RTEMS_UNSATISFIED;
84
85  return 0;
86}
87
88/*
89 *  device_read
90 *
91 *  This handler maps a read() operation onto rtems_io_read().
92 */
93
94int device_read(
95  rtems_libio_t *iop,
96  void          *buffer,
97  unsigned32     count
98)
99{
100  rtems_libio_rw_args_t   args;
101  rtems_status_code       status;
102  IMFS_jnode_t           *the_jnode;
103
104  the_jnode = iop->file_info;
105
106  args.iop         = iop;
107  args.offset      = iop->offset;
108  args.buffer      = buffer;
109  args.count       = count;
110  args.flags       = iop->flags;
111  args.bytes_moved = 0;
112
113  status = rtems_io_read(
114    the_jnode->info.device.major,
115    the_jnode->info.device.minor,
116    (void *) &args
117  );
118
119  if ( status )
120    return -1;
121
122  return args.bytes_moved;
123}
124
125/*
126 *  device_write
127 *
128 *  This handler maps a write() operation onto rtems_io_write().
129 */
130
131int device_write(
132  rtems_libio_t *iop,
133  const void    *buffer,
134  unsigned32     count
135)
136{
137  rtems_libio_rw_args_t   args;
138  rtems_status_code       status;
139  IMFS_jnode_t           *the_jnode;
140
141  the_jnode = iop->file_info;
142
143  args.iop         = iop;
144  args.offset      = iop->offset;
145  args.buffer      = (void *) buffer;
146  args.count       = count;
147  args.flags       = iop->flags;
148  args.bytes_moved = 0;
149
150  status = rtems_io_write(
151    the_jnode->info.device.major,
152    the_jnode->info.device.minor,
153    (void *) &args
154  );
155
156  if ( status )
157    return -1;
158
159  return args.bytes_moved;
160}
161
162/*
163 *  device_ioctl
164 *
165 *  This handler maps an ioctl() operation onto rtems_io_ioctl().
166 */
167
168int device_ioctl(
169  rtems_libio_t *iop,
170  unsigned32     command,
171  void          *buffer
172)
173{
174  rtems_libio_ioctl_args_t  args;
175  rtems_status_code         status;
176  IMFS_jnode_t             *the_jnode;
177
178  args.iop     = iop;
179  args.command = command;
180  args.buffer  = buffer;
181
182  the_jnode = iop->file_info;
183
184  status = rtems_io_control(
185    the_jnode->info.device.major,
186    the_jnode->info.device.minor,
187    (void *) &args
188  );
189
190  if ( status )
191    return -1;
192
193  return args.ioctl_return;
194}
195
196/*
197 *  device_lseek
198 *
199 *  This handler eats all lseek() operations.
200 */
201
202int device_lseek(
203  rtems_libio_t *iop,
204  off_t          offset,
205  int            whence
206)
207{
208  return 0;
209}
210
211/*
212 *  device_stat
213 *
214 *  This IMFS_stat() is used.
215 */
Note: See TracBrowser for help on using the repository browser.