source: rtems/c/src/exec/libfs/src/imfs/ioman.c @ c873f40

4.104.114.84.95
Last change on this file since c873f40 was c873f40, checked in by Joel Sherrill <joel.sherrill@…>, on 04/08/02 at 18:28:59

2002-04-06 Ralf Corsepius <corsepiu@…>

  • src/imfs/imfs_getchild.c: include <string.h>.
  • src/imfs/imfs_gtkn.c: Include <string.h>.
  • src/imfs/ioman.c: Include <string.h>.
  • src/imfs/linearfile.c: Include <string.h>.
  • src/imfs/memfile.c: Include <string.h>.
  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 *  This file emulates the old Classic RTEMS IO manager directives
3 *  which register and lookup names using the in-memory filesystem.
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <sys/types.h>
20#include <sys/stat.h>
21#include <fcntl.h>
22#include <unistd.h>
23#include <string.h>
24
25#include <assert.h>
26
27#include <rtems.h>
28#include <rtems/libio_.h>
29#include <rtems/seterr.h>
30#include "imfs.h"
31
32#if defined(__linux__)
33#define S_IFCHR __S_IFCHR
34#endif
35
36/*
37 *  rtems_io_register_name
38 *
39 *  This assumes that all registered devices are character devices.
40 */
41
42rtems_status_code rtems_io_register_name(
43  char *device_name,
44  rtems_device_major_number major,
45  rtems_device_minor_number minor
46)
47{
48#if !defined(RTEMS_UNIX)
49  int    status;
50  dev_t  dev;
51
52  dev = rtems_filesystem_make_dev_t( major, minor );
53  status = mknod( device_name, 0777 | S_IFCHR, dev );
54
55  /* this is the only error returned by the old version */
56  if ( status )
57    return RTEMS_TOO_MANY;
58 
59#endif
60  return RTEMS_SUCCESSFUL;
61}
62
63/*
64 *  rtems_io_lookup_name
65 *
66 *  This version is not reentrant.
67 *
68 *  XXX - This is dependent upon IMFS and should not be. 
69 *        Suggest adding a filesystem routine to fill in the device_info.
70 */
71
72rtems_status_code rtems_io_lookup_name(
73  const char           *name,
74  rtems_driver_name_t **device_info
75)
76{
77#if !defined(RTEMS_UNIX)
78  IMFS_jnode_t                      *the_jnode;
79  rtems_filesystem_location_info_t   loc;
80  static rtems_driver_name_t         device;
81  int                                result;
82  rtems_filesystem_node_types_t      node_type;
83
84  result = rtems_filesystem_evaluate_path( name, 0x00, &loc, TRUE );
85  the_jnode = loc.node_access;
86
87  if ( !loc.ops->node_type_h ) {
88    rtems_filesystem_freenode( &loc );
89    rtems_set_errno_and_return_minus_one( ENOTSUP );
90  }
91
92  node_type = (*loc.ops->node_type_h)( &loc );
93
94  if ( (result != 0) || node_type != RTEMS_FILESYSTEM_DEVICE ) {
95    *device_info = 0;
96    rtems_filesystem_freenode( &loc );
97    return RTEMS_UNSATISFIED;
98  }
99
100  device.device_name        = (char *) name;
101  device.device_name_length = strlen( name );
102  device.major              = the_jnode->info.device.major;
103  device.minor              = the_jnode->info.device.minor;
104  *device_info              = &device;
105
106  rtems_filesystem_freenode( &loc );
107   
108#endif
109  return RTEMS_SUCCESSFUL;
110}
Note: See TracBrowser for help on using the repository browser.