1 |
786 |
skrzyp |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// devfs.cxx
|
4 |
|
|
//
|
5 |
|
|
// Fileio device filesystem
|
6 |
|
|
//
|
7 |
|
|
//==========================================================================
|
8 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
// -------------------------------------------
|
10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
12 |
|
|
//
|
13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
15 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
16 |
|
|
// version.
|
17 |
|
|
//
|
18 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
19 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
20 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
21 |
|
|
// for more details.
|
22 |
|
|
//
|
23 |
|
|
// You should have received a copy of the GNU General Public License
|
24 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
25 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
26 |
|
|
//
|
27 |
|
|
// As a special exception, if other files instantiate templates or use
|
28 |
|
|
// macros or inline functions from this file, or you compile this file
|
29 |
|
|
// and link it with other works to produce a work based on this file,
|
30 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
31 |
|
|
// the GNU General Public License. However the source code for this file
|
32 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
33 |
|
|
// General Public License v2.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based
|
36 |
|
|
// on this file might be covered by the GNU General Public License.
|
37 |
|
|
// -------------------------------------------
|
38 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
39 |
|
|
//==========================================================================
|
40 |
|
|
//#####DESCRIPTIONBEGIN####
|
41 |
|
|
//
|
42 |
|
|
// Author(s): nickg
|
43 |
|
|
// Contributors: nickg, gthomas
|
44 |
|
|
// Date: 2000-05-25
|
45 |
|
|
// Purpose: Fileio device filesystem
|
46 |
|
|
// Description: This file implements a simple filesystem that interfaces
|
47 |
|
|
// to the existing device IO subsystem.
|
48 |
|
|
//
|
49 |
|
|
//
|
50 |
|
|
//
|
51 |
|
|
//
|
52 |
|
|
//####DESCRIPTIONEND####
|
53 |
|
|
//
|
54 |
|
|
//==========================================================================
|
55 |
|
|
|
56 |
|
|
#include <pkgconf/hal.h>
|
57 |
|
|
#include <pkgconf/io_fileio.h>
|
58 |
|
|
|
59 |
|
|
#include <cyg/infra/cyg_trac.h> // tracing macros
|
60 |
|
|
#include <cyg/infra/cyg_ass.h> // assertion macros
|
61 |
|
|
|
62 |
|
|
#include "fio.h" // Private header
|
63 |
|
|
|
64 |
|
|
#include <cyg/io/devtab.h> // device subsystem
|
65 |
|
|
#include <cyg/io/config_keys.h> // CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN
|
66 |
|
|
|
67 |
|
|
//==========================================================================
|
68 |
|
|
// Forward definitions
|
69 |
|
|
|
70 |
|
|
// Filesystem operations
|
71 |
|
|
static int dev_mount ( cyg_fstab_entry *fste, cyg_mtab_entry *mte );
|
72 |
|
|
static int dev_umount ( cyg_mtab_entry *mte );
|
73 |
|
|
static int dev_open ( cyg_mtab_entry *mte, cyg_dir dir, const char *name,
|
74 |
|
|
int mode, cyg_file *fte );
|
75 |
|
|
static int dev_unlink ( cyg_mtab_entry *mte, cyg_dir dir, const char *name );
|
76 |
|
|
static int dev_mkdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name );
|
77 |
|
|
static int dev_rmdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name );
|
78 |
|
|
static int dev_rename ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1,
|
79 |
|
|
cyg_dir dir2, const char *name2 );
|
80 |
|
|
static int dev_link ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1,
|
81 |
|
|
cyg_dir dir2, const char *name2, int type );
|
82 |
|
|
static int dev_opendir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name,
|
83 |
|
|
cyg_file *fte );
|
84 |
|
|
static int dev_chdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name,
|
85 |
|
|
cyg_dir *dir_out );
|
86 |
|
|
static int dev_stat ( cyg_mtab_entry *mte, cyg_dir dir, const char *name,
|
87 |
|
|
struct stat *buf);
|
88 |
|
|
static int dev_getinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *name,
|
89 |
|
|
int key, void *buf, int len );
|
90 |
|
|
static int dev_setinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *name,
|
91 |
|
|
int key, void *buf, int len );
|
92 |
|
|
|
93 |
|
|
// File operations
|
94 |
|
|
static int dev_fo_read (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio);
|
95 |
|
|
static int dev_fo_write (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio);
|
96 |
|
|
static int dev_fo_lseek (struct CYG_FILE_TAG *fp, off_t *pos, int whence );
|
97 |
|
|
static int dev_fo_ioctl (struct CYG_FILE_TAG *fp, CYG_ADDRWORD com,
|
98 |
|
|
CYG_ADDRWORD data);
|
99 |
|
|
static cyg_bool dev_fo_select (struct CYG_FILE_TAG *fp, int which, CYG_ADDRWORD info);
|
100 |
|
|
static int dev_fo_fsync (struct CYG_FILE_TAG *fp, int mode );
|
101 |
|
|
static int dev_fo_close (struct CYG_FILE_TAG *fp);
|
102 |
|
|
static int dev_fo_fstat (struct CYG_FILE_TAG *fp, struct stat *buf );
|
103 |
|
|
static int dev_fo_getinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len );
|
104 |
|
|
static int dev_fo_setinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len );
|
105 |
|
|
|
106 |
|
|
|
107 |
|
|
//==========================================================================
|
108 |
|
|
// Filesystem table entries
|
109 |
|
|
|
110 |
|
|
FSTAB_ENTRY( dev_fste, "devfs", 0,
|
111 |
|
|
CYG_SYNCMODE_NONE, // dev system has its own sync mechanism
|
112 |
|
|
dev_mount,
|
113 |
|
|
dev_umount,
|
114 |
|
|
dev_open,
|
115 |
|
|
dev_unlink,
|
116 |
|
|
dev_mkdir,
|
117 |
|
|
dev_rmdir,
|
118 |
|
|
dev_rename,
|
119 |
|
|
dev_link,
|
120 |
|
|
dev_opendir,
|
121 |
|
|
dev_chdir,
|
122 |
|
|
dev_stat,
|
123 |
|
|
dev_getinfo,
|
124 |
|
|
dev_setinfo);
|
125 |
|
|
|
126 |
|
|
MTAB_ENTRY( dev_mte,
|
127 |
|
|
"/dev",
|
128 |
|
|
"devfs",
|
129 |
|
|
"",
|
130 |
|
|
0);
|
131 |
|
|
|
132 |
|
|
static cyg_fileops dev_fileops =
|
133 |
|
|
{
|
134 |
|
|
dev_fo_read,
|
135 |
|
|
dev_fo_write,
|
136 |
|
|
dev_fo_lseek,
|
137 |
|
|
dev_fo_ioctl,
|
138 |
|
|
dev_fo_select,
|
139 |
|
|
dev_fo_fsync,
|
140 |
|
|
dev_fo_close,
|
141 |
|
|
dev_fo_fstat,
|
142 |
|
|
dev_fo_getinfo,
|
143 |
|
|
dev_fo_setinfo
|
144 |
|
|
};
|
145 |
|
|
|
146 |
|
|
//==========================================================================
|
147 |
|
|
// Filesystem operations
|
148 |
|
|
|
149 |
|
|
// -------------------------------------------------------------------------
|
150 |
|
|
|
151 |
|
|
static int dev_mount ( cyg_fstab_entry *fste, cyg_mtab_entry *mte )
|
152 |
|
|
{
|
153 |
|
|
// Nothing to do here. The device IO subsystem has already initialized
|
154 |
|
|
// iteslf, and the fileio infrastructure will do the rest.
|
155 |
|
|
|
156 |
|
|
return 0;
|
157 |
|
|
}
|
158 |
|
|
|
159 |
|
|
// -------------------------------------------------------------------------
|
160 |
|
|
|
161 |
|
|
static int dev_umount ( cyg_mtab_entry *mte )
|
162 |
|
|
{
|
163 |
|
|
// Nothing to do here.
|
164 |
|
|
|
165 |
|
|
return 0;
|
166 |
|
|
}
|
167 |
|
|
|
168 |
|
|
// -------------------------------------------------------------------------
|
169 |
|
|
|
170 |
|
|
static int dev_open ( cyg_mtab_entry *mte, cyg_dir dir, const char *name,
|
171 |
|
|
int mode, cyg_file *file )
|
172 |
|
|
{
|
173 |
|
|
Cyg_ErrNo err;
|
174 |
|
|
cyg_io_handle_t handle;
|
175 |
|
|
|
176 |
|
|
// The name we are passed will point to the first character after
|
177 |
|
|
// "/dev/". We know that the full string contains the prefix string,
|
178 |
|
|
// so we back the pointer up by 5 chars.
|
179 |
|
|
// A better approach would be for the device table entries to only
|
180 |
|
|
// contain the part of the string after the prefix.
|
181 |
|
|
|
182 |
|
|
name -= 5;
|
183 |
|
|
|
184 |
|
|
err = cyg_io_lookup( name, &handle );
|
185 |
|
|
|
186 |
|
|
if( err < 0 )
|
187 |
|
|
return -err;
|
188 |
|
|
|
189 |
|
|
// If we want non-blocking mode, configure the device for it.
|
190 |
|
|
if( (mode & (O_NONBLOCK|O_RDONLY)) == (O_NONBLOCK|O_RDONLY) )
|
191 |
|
|
{
|
192 |
|
|
cyg_uint32 f = 0;
|
193 |
|
|
cyg_uint32 fsize = sizeof(f);
|
194 |
|
|
err = cyg_io_set_config( handle, CYG_IO_SET_CONFIG_READ_BLOCKING,
|
195 |
|
|
(void *)&f, &fsize);
|
196 |
|
|
if( err < 0 )
|
197 |
|
|
return -err;
|
198 |
|
|
}
|
199 |
|
|
|
200 |
|
|
if( (mode & (O_NONBLOCK|O_WRONLY)) == (O_NONBLOCK|O_WRONLY) )
|
201 |
|
|
{
|
202 |
|
|
cyg_uint32 f = 0;
|
203 |
|
|
cyg_uint32 fsize = sizeof(f);
|
204 |
|
|
err = cyg_io_set_config( handle, CYG_IO_SET_CONFIG_WRITE_BLOCKING,
|
205 |
|
|
(void *)&f, &fsize);
|
206 |
|
|
if( err < 0 )
|
207 |
|
|
return -err;
|
208 |
|
|
}
|
209 |
|
|
|
210 |
|
|
// Initialize the file object
|
211 |
|
|
|
212 |
|
|
file->f_flag |= mode & CYG_FILE_MODE_MASK;
|
213 |
|
|
file->f_type = CYG_FILE_TYPE_FILE;
|
214 |
|
|
file->f_ops = &dev_fileops;
|
215 |
|
|
file->f_offset = 0;
|
216 |
|
|
file->f_data = (CYG_ADDRWORD)handle;
|
217 |
|
|
file->f_xops = 0;
|
218 |
|
|
|
219 |
|
|
return 0;
|
220 |
|
|
}
|
221 |
|
|
|
222 |
|
|
// -------------------------------------------------------------------------
|
223 |
|
|
|
224 |
|
|
static int dev_unlink ( cyg_mtab_entry *mte, cyg_dir dir, const char *name )
|
225 |
|
|
{
|
226 |
|
|
return EROFS;
|
227 |
|
|
}
|
228 |
|
|
|
229 |
|
|
// -------------------------------------------------------------------------
|
230 |
|
|
|
231 |
|
|
static int dev_mkdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name )
|
232 |
|
|
{
|
233 |
|
|
return EROFS;
|
234 |
|
|
}
|
235 |
|
|
|
236 |
|
|
// -------------------------------------------------------------------------
|
237 |
|
|
|
238 |
|
|
static int dev_rmdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name )
|
239 |
|
|
{
|
240 |
|
|
return EROFS;
|
241 |
|
|
}
|
242 |
|
|
|
243 |
|
|
// -------------------------------------------------------------------------
|
244 |
|
|
|
245 |
|
|
static int dev_rename ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1,
|
246 |
|
|
cyg_dir dir2, const char *name2 )
|
247 |
|
|
{
|
248 |
|
|
return EROFS;
|
249 |
|
|
}
|
250 |
|
|
|
251 |
|
|
// -------------------------------------------------------------------------
|
252 |
|
|
|
253 |
|
|
static int dev_link ( cyg_mtab_entry *mte, cyg_dir dir1, const char *name1,
|
254 |
|
|
cyg_dir dir2, const char *name2, int type )
|
255 |
|
|
{
|
256 |
|
|
return EROFS;
|
257 |
|
|
}
|
258 |
|
|
|
259 |
|
|
// -------------------------------------------------------------------------
|
260 |
|
|
|
261 |
|
|
static int dev_opendir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name,
|
262 |
|
|
cyg_file *fte )
|
263 |
|
|
{
|
264 |
|
|
return ENOTDIR;
|
265 |
|
|
}
|
266 |
|
|
|
267 |
|
|
// -------------------------------------------------------------------------
|
268 |
|
|
|
269 |
|
|
static int dev_chdir ( cyg_mtab_entry *mte, cyg_dir dir, const char *name,
|
270 |
|
|
cyg_dir *dir_out )
|
271 |
|
|
{
|
272 |
|
|
return ENOTDIR;
|
273 |
|
|
}
|
274 |
|
|
|
275 |
|
|
// -------------------------------------------------------------------------
|
276 |
|
|
|
277 |
|
|
static int dev_stat ( cyg_mtab_entry *mte, cyg_dir dir, const char *name,
|
278 |
|
|
struct stat *buf)
|
279 |
|
|
{
|
280 |
|
|
Cyg_ErrNo err;
|
281 |
|
|
cyg_io_handle_t handle;
|
282 |
|
|
cyg_devtab_entry_t *dev;
|
283 |
|
|
|
284 |
|
|
name -= 5; // See comment in dev_open()
|
285 |
|
|
|
286 |
|
|
err = cyg_io_lookup( name, &handle );
|
287 |
|
|
|
288 |
|
|
if( err < 0 )
|
289 |
|
|
return -err;
|
290 |
|
|
|
291 |
|
|
// Just fill in the stat buffer with some constant values.
|
292 |
|
|
dev = (cyg_devtab_entry_t *)handle;
|
293 |
|
|
|
294 |
|
|
if (dev->status & CYG_DEVTAB_STATUS_BLOCK)
|
295 |
|
|
buf->st_mode = __stat_mode_BLK;
|
296 |
|
|
else
|
297 |
|
|
buf->st_mode = __stat_mode_CHR;
|
298 |
|
|
|
299 |
|
|
buf->st_ino = (ino_t)handle; // map dev handle to inode
|
300 |
|
|
buf->st_dev = 0; // (dev_t)handle; // same with dev id
|
301 |
|
|
buf->st_nlink = 1;
|
302 |
|
|
buf->st_uid = 0;
|
303 |
|
|
buf->st_gid = 0;
|
304 |
|
|
buf->st_size = 0;
|
305 |
|
|
buf->st_atime = 0;
|
306 |
|
|
buf->st_mtime = 0;
|
307 |
|
|
buf->st_ctime = 0;
|
308 |
|
|
|
309 |
|
|
return ENOERR;
|
310 |
|
|
}
|
311 |
|
|
|
312 |
|
|
// -------------------------------------------------------------------------
|
313 |
|
|
|
314 |
|
|
static int dev_getinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *name,
|
315 |
|
|
int key, void *buf, int len )
|
316 |
|
|
{
|
317 |
|
|
return ENOSYS;
|
318 |
|
|
}
|
319 |
|
|
|
320 |
|
|
// -------------------------------------------------------------------------
|
321 |
|
|
|
322 |
|
|
static int dev_setinfo ( cyg_mtab_entry *mte, cyg_dir dir, const char *name,
|
323 |
|
|
int key, void *buf, int len )
|
324 |
|
|
{
|
325 |
|
|
return ENOSYS;
|
326 |
|
|
}
|
327 |
|
|
|
328 |
|
|
//==========================================================================
|
329 |
|
|
// File operations
|
330 |
|
|
|
331 |
|
|
|
332 |
|
|
// -------------------------------------------------------------------------
|
333 |
|
|
|
334 |
|
|
static int dev_fo_read (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio)
|
335 |
|
|
{
|
336 |
|
|
Cyg_ErrNo err = 0;
|
337 |
|
|
int i;
|
338 |
|
|
|
339 |
|
|
// Now loop over the iovecs until they are all done, or
|
340 |
|
|
// we get an error.
|
341 |
|
|
for( i = 0; i < uio->uio_iovcnt; i++ )
|
342 |
|
|
{
|
343 |
|
|
cyg_iovec *iov = &uio->uio_iov[i];
|
344 |
|
|
cyg_uint32 len = iov->iov_len;
|
345 |
|
|
cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)fp->f_data;
|
346 |
|
|
|
347 |
|
|
if (t->status & CYG_DEVTAB_STATUS_BLOCK)
|
348 |
|
|
err = cyg_io_bread( (cyg_io_handle_t)t,
|
349 |
|
|
iov->iov_base,
|
350 |
|
|
&len, fp->f_offset);
|
351 |
|
|
else
|
352 |
|
|
err = cyg_io_read( (cyg_io_handle_t)t,
|
353 |
|
|
iov->iov_base,
|
354 |
|
|
&len);
|
355 |
|
|
|
356 |
|
|
if( err < 0 ) break;
|
357 |
|
|
|
358 |
|
|
uio->uio_resid -= len;
|
359 |
|
|
}
|
360 |
|
|
|
361 |
|
|
return -err;
|
362 |
|
|
}
|
363 |
|
|
|
364 |
|
|
// -------------------------------------------------------------------------
|
365 |
|
|
|
366 |
|
|
static int dev_fo_write (struct CYG_FILE_TAG *fp, struct CYG_UIO_TAG *uio)
|
367 |
|
|
{
|
368 |
|
|
Cyg_ErrNo err = 0;
|
369 |
|
|
int i;
|
370 |
|
|
|
371 |
|
|
// Now loop over the iovecs until they are all done, or
|
372 |
|
|
// we get an error.
|
373 |
|
|
for( i = 0; i < uio->uio_iovcnt; i++ )
|
374 |
|
|
{
|
375 |
|
|
cyg_iovec *iov = &uio->uio_iov[i];
|
376 |
|
|
cyg_uint32 len = iov->iov_len;
|
377 |
|
|
cyg_devtab_entry_t *t = (cyg_devtab_entry_t *)fp->f_data;
|
378 |
|
|
|
379 |
|
|
if (t->status & CYG_DEVTAB_STATUS_BLOCK)
|
380 |
|
|
err = cyg_io_bwrite( (cyg_io_handle_t)t,
|
381 |
|
|
iov->iov_base,
|
382 |
|
|
&len, fp->f_offset);
|
383 |
|
|
else
|
384 |
|
|
err = cyg_io_write( (cyg_io_handle_t)t,
|
385 |
|
|
iov->iov_base,
|
386 |
|
|
&len);
|
387 |
|
|
|
388 |
|
|
if( err < 0 ) break;
|
389 |
|
|
|
390 |
|
|
uio->uio_resid -= len;
|
391 |
|
|
}
|
392 |
|
|
|
393 |
|
|
return -err;
|
394 |
|
|
}
|
395 |
|
|
|
396 |
|
|
// -------------------------------------------------------------------------
|
397 |
|
|
|
398 |
|
|
static int dev_fo_lseek (struct CYG_FILE_TAG *fp, off_t *pos, int whence )
|
399 |
|
|
{
|
400 |
|
|
// All current devices have no notion of position. Just return zero
|
401 |
|
|
// as the new position.
|
402 |
|
|
|
403 |
|
|
*pos = 0;
|
404 |
|
|
|
405 |
|
|
return ENOERR;
|
406 |
|
|
}
|
407 |
|
|
|
408 |
|
|
// -------------------------------------------------------------------------
|
409 |
|
|
|
410 |
|
|
static int dev_fo_ioctl (struct CYG_FILE_TAG *fp, CYG_ADDRWORD com,
|
411 |
|
|
CYG_ADDRWORD data)
|
412 |
|
|
{
|
413 |
|
|
return ENOSYS;
|
414 |
|
|
}
|
415 |
|
|
|
416 |
|
|
// -------------------------------------------------------------------------
|
417 |
|
|
|
418 |
|
|
static cyg_bool dev_fo_select (struct CYG_FILE_TAG *fp, int which, CYG_ADDRWORD info)
|
419 |
|
|
{
|
420 |
|
|
return cyg_io_select( (cyg_io_handle_t)fp->f_data,
|
421 |
|
|
which,
|
422 |
|
|
info);
|
423 |
|
|
}
|
424 |
|
|
|
425 |
|
|
// -------------------------------------------------------------------------
|
426 |
|
|
|
427 |
|
|
static int dev_fo_fsync (struct CYG_FILE_TAG *fp, int mode )
|
428 |
|
|
{
|
429 |
|
|
Cyg_ErrNo err;
|
430 |
|
|
|
431 |
|
|
err = cyg_io_get_config((cyg_io_handle_t)fp->f_data,
|
432 |
|
|
CYG_IO_GET_CONFIG_SERIAL_OUTPUT_DRAIN,
|
433 |
|
|
NULL, NULL);
|
434 |
|
|
|
435 |
|
|
return -err;
|
436 |
|
|
}
|
437 |
|
|
|
438 |
|
|
// -------------------------------------------------------------------------
|
439 |
|
|
|
440 |
|
|
static int dev_fo_close (struct CYG_FILE_TAG *fp)
|
441 |
|
|
{
|
442 |
|
|
return ENOERR;
|
443 |
|
|
}
|
444 |
|
|
|
445 |
|
|
// -------------------------------------------------------------------------
|
446 |
|
|
|
447 |
|
|
static int dev_fo_fstat (struct CYG_FILE_TAG *fp, struct stat *buf )
|
448 |
|
|
{
|
449 |
|
|
cyg_devtab_entry_t *dev = (cyg_devtab_entry_t *)fp->f_data;
|
450 |
|
|
|
451 |
|
|
// Just fill in the stat buffer with some constant values.
|
452 |
|
|
if (dev->status & CYG_DEVTAB_STATUS_BLOCK)
|
453 |
|
|
buf->st_mode = __stat_mode_BLK;
|
454 |
|
|
else
|
455 |
|
|
buf->st_mode = __stat_mode_CHR;
|
456 |
|
|
|
457 |
|
|
buf->st_ino = (ino_t)fp->f_data; // map dev handle to inode
|
458 |
|
|
buf->st_dev = 0; //(dev_t)fp->f_data; // same with dev id
|
459 |
|
|
buf->st_nlink = 1;
|
460 |
|
|
buf->st_uid = 0;
|
461 |
|
|
buf->st_gid = 0;
|
462 |
|
|
buf->st_size = 0;
|
463 |
|
|
buf->st_atime = 0;
|
464 |
|
|
buf->st_mtime = 0;
|
465 |
|
|
buf->st_ctime = 0;
|
466 |
|
|
|
467 |
|
|
return ENOERR;
|
468 |
|
|
}
|
469 |
|
|
|
470 |
|
|
// -------------------------------------------------------------------------
|
471 |
|
|
|
472 |
|
|
static int dev_fo_getinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len )
|
473 |
|
|
{
|
474 |
|
|
Cyg_ErrNo err = 0;
|
475 |
|
|
cyg_uint32 ll = len;
|
476 |
|
|
|
477 |
|
|
err = cyg_io_get_config( (cyg_io_handle_t)fp->f_data, key, buf, &ll );
|
478 |
|
|
|
479 |
|
|
return -err;
|
480 |
|
|
}
|
481 |
|
|
|
482 |
|
|
// -------------------------------------------------------------------------
|
483 |
|
|
|
484 |
|
|
static int dev_fo_setinfo (struct CYG_FILE_TAG *fp, int key, void *buf, int len )
|
485 |
|
|
{
|
486 |
|
|
Cyg_ErrNo err = 0;
|
487 |
|
|
cyg_uint32 ll = len;
|
488 |
|
|
|
489 |
|
|
err = cyg_io_set_config( (cyg_io_handle_t)fp->f_data, key, buf, &ll );
|
490 |
|
|
|
491 |
|
|
return -err;
|
492 |
|
|
}
|
493 |
|
|
|
494 |
|
|
// -------------------------------------------------------------------------
|
495 |
|
|
// EOF devfs.cxx
|