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

4.104.115
Last change on this file since f855b9e3 was f855b9e3, checked in by Joel Sherrill <joel.sherrill@…>, on 03/09/09 at 14:11:23

2009-03-09 Joel Sherrill <joel.sherrill@…>

PR 1376/filesystem

  • libcsupport/include/rtems/libio.h, libfs/src/dosfs/fat_file.c, libfs/src/dosfs/msdos.h, libfs/src/dosfs/msdos_dir.c, libfs/src/dosfs/msdos_file.c, libfs/src/imfs/deviceio.c, libfs/src/imfs/imfs.h, libfs/src/imfs/imfs_directory.c, libfs/src/imfs/imfs_fifo.c, libfs/src/imfs/memfile.c, libfs/src/nfsclient/src/nfs.c: lseek handlers should return off_t.
  • Property mode set to 100644
File size: 4.3 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-2008.
8 *  On-Line Applications Research Corporation (OAR).
9 *
10 *  The license and distribution terms for this file may be
11 *  found in the file LICENSE in this distribution or at
12 *  http://www.rtems.com/license/LICENSE.
13 *
14 *  $Id$
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems.h>
22#include <rtems/libio.h>
23#include <rtems/assoc.h>                /* assoc.h not included by rtems.h */
24#include <errno.h>
25
26#include "imfs.h"
27
28/*
29 * Convert RTEMS status to a UNIX errno
30 */
31extern int rtems_deviceio_errno(rtems_status_code code);
32
33/*
34 *  device_open
35 *
36 *  This handler maps an open() operation onto rtems_io_open().
37 */
38
39int device_open(
40  rtems_libio_t *iop,
41  const char    *pathname,
42  uint32_t       flag,
43  uint32_t       mode
44)
45{
46  rtems_libio_open_close_args_t  args;
47  rtems_status_code              status;
48  IMFS_jnode_t                  *the_jnode;
49
50  the_jnode  = iop->file_info;
51
52  args.iop   = iop;
53  args.flags = iop->flags;
54  args.mode  = mode;
55
56  status = rtems_io_open(
57    the_jnode->info.device.major,
58    the_jnode->info.device.minor,
59    (void *) &args
60  );
61  if ( status )
62    return rtems_deviceio_errno(status);
63
64  return 0;
65}
66
67/*
68 *  device_close
69 *
70 *  This handler maps a close() operation onto rtems_io_close().
71 */
72
73int device_close(
74  rtems_libio_t *iop
75)
76{
77  rtems_libio_open_close_args_t  args;
78  rtems_status_code              status;
79  IMFS_jnode_t                  *the_jnode;
80
81  the_jnode = iop->file_info;
82
83  args.iop   = iop;
84  args.flags = 0;
85  args.mode  = 0;
86
87  status = rtems_io_close(
88    the_jnode->info.device.major,
89    the_jnode->info.device.minor,
90    (void *) &args
91  );
92  if ( status ) {
93    return rtems_deviceio_errno(status);
94  }
95  return 0;
96}
97
98/*
99 *  device_read
100 *
101 *  This handler maps a read() operation onto rtems_io_read().
102 */
103
104ssize_t device_read(
105  rtems_libio_t *iop,
106  void          *buffer,
107  size_t         count
108)
109{
110  rtems_libio_rw_args_t   args;
111  rtems_status_code       status;
112  IMFS_jnode_t           *the_jnode;
113
114  the_jnode = iop->file_info;
115
116  args.iop         = iop;
117  args.offset      = iop->offset;
118  args.buffer      = buffer;
119  args.count       = count;
120  args.flags       = iop->flags;
121  args.bytes_moved = 0;
122
123  status = rtems_io_read(
124    the_jnode->info.device.major,
125    the_jnode->info.device.minor,
126    (void *) &args
127  );
128
129  if ( status )
130    return rtems_deviceio_errno(status);
131
132  return (ssize_t) args.bytes_moved;
133}
134
135/*
136 *  device_write
137 *
138 *  This handler maps a write() operation onto rtems_io_write().
139 */
140
141ssize_t device_write(
142  rtems_libio_t *iop,
143  const void    *buffer,
144  size_t         count
145)
146{
147  rtems_libio_rw_args_t   args;
148  rtems_status_code       status;
149  IMFS_jnode_t           *the_jnode;
150
151  the_jnode = iop->file_info;
152
153  args.iop         = iop;
154  args.offset      = iop->offset;
155  args.buffer      = (void *) buffer;
156  args.count       = count;
157  args.flags       = iop->flags;
158  args.bytes_moved = 0;
159
160  status = rtems_io_write(
161    the_jnode->info.device.major,
162    the_jnode->info.device.minor,
163    (void *) &args
164  );
165
166  if ( status )
167    return rtems_deviceio_errno(status);
168
169  return (ssize_t) args.bytes_moved;
170}
171
172/*
173 *  device_ioctl
174 *
175 *  This handler maps an ioctl() operation onto rtems_io_ioctl().
176 */
177
178int device_ioctl(
179  rtems_libio_t *iop,
180  uint32_t       command,
181  void          *buffer
182)
183{
184  rtems_libio_ioctl_args_t  args;
185  rtems_status_code         status;
186  IMFS_jnode_t             *the_jnode;
187
188  args.iop     = iop;
189  args.command = command;
190  args.buffer  = buffer;
191
192  the_jnode = iop->file_info;
193
194  status = rtems_io_control(
195    the_jnode->info.device.major,
196    the_jnode->info.device.minor,
197    (void *) &args
198  );
199
200  if ( status )
201    return rtems_deviceio_errno(status);
202
203  return args.ioctl_return;
204}
205
206/*
207 *  device_lseek
208 *
209 *  This handler eats all lseek() operations.
210 */
211
212off_t device_lseek(
213  rtems_libio_t *iop,
214  off_t          offset,
215  int            whence
216)
217{
218  return 0;
219}
220
221/*
222 *  device_stat
223 *
224 *  The IMFS_stat() is used.
225 */
226
227/*
228 *  device_rmnod
229 *
230 *  The IMFS_rmnod() is used.
231 */
232
233int device_ftruncate(
234  rtems_libio_t *iop,
235  off_t          length
236)
237{
238  return 0;
239}
Note: See TracBrowser for help on using the repository browser.