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

4.104.115
Last change on this file since 07d6fd5 was 07d6fd5, checked in by Chris Johns <chrisj@…>, on 04/29/09 at 08:31:27

2009-04-29 Chris Johns <chrisj@…>

  • libcsupport/include/rtems/libio.h: Add rtems_off64_t for internal use. Update the internal off_t to the 64bit offset.
  • libnetworking/lib/ftpfs.c, libnetworking/lib/tftpDriver.c, libfs/src/nfsclient/src/nfs.c, libfs/src/imfs/imfs_fifo.c, libfs/src/imfs/memfile.c, libfs/src/imfs/imfs_directory.c, libfs/src/imfs/imfs.h, libfs/src/imfs/deviceio.c: Change off_t to rtems_off64_t.
  • libmisc/shell/main_msdosfmt.c: Add an info level so the format code can tell the user what is happening. Add more options to control the format configuration.
  • libfs/src/dosfs/msdos_format.c: Add a print function to display the format progress and print statements. Select a better default cluster size depending on the size of the disk. This lowers the size of the FAT on large disks. Read and maintain the MRB partition information.
  • libfs/src/dosfs/dosfs.h, libfs/src/dosfs/fat.h, libfs/src/dosfs/fat_file.c, libfs/src/dosfs/fat_file.h, libfs/src/dosfs/msdos.h, libfs/src/dosfs/msdos_conv.c, libfs/src/dosfs/msdos_create.c, libfs/src/dosfs/msdos_file.c, libfs/src/dosfs/msdos_handlers_dir.c, libfs/src/dosfs/msdos_handlers_file.c, libfs/src/dosfs/msdos_init.c, libfs/src/dosfs/msdos_initsupp.c, libfs/src/dosfs/msdos_misc.c, libfs/src/dosfs/msdos_mknod.c: Add long file name support. Change off_t to rtems_off64_t.
  • Property mode set to 100644
File size: 4.4 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 and does not create
210 *  an error. It assumes all devices can handle the seek. The
211 *  writes fail.
212 */
213
214rtems_off64_t device_lseek(
215  rtems_libio_t *iop,
216  rtems_off64_t  offset,
217  int            whence
218)
219{
220  return offset;
221}
222
223/*
224 *  device_stat
225 *
226 *  The IMFS_stat() is used.
227 */
228
229/*
230 *  device_rmnod
231 *
232 *  The IMFS_rmnod() is used.
233 */
234
235int device_ftruncate(
236  rtems_libio_t *iop,
237  rtems_off64_t  length
238)
239{
240  return 0;
241}
Note: See TracBrowser for help on using the repository browser.