source: rtems/cpukit/libfs/src/imfs/ioman.c @ 0a896eb

4.104.114.95
Last change on this file since 0a896eb was 0a896eb, checked in by Ralf Corsepius <ralf.corsepius@…>, on 09/04/08 at 08:33:06

Use "bool" instead of "rtems_boolean|boolean".

  • Property mode set to 100644
File size: 2.5 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.rtems.com/license/LICENSE.
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  const 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 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  int                                result;
81  rtems_filesystem_node_types_t      node_type;
82
83  result = rtems_filesystem_evaluate_path( name, 0x00, &loc, true );
84  the_jnode = loc.node_access;
85
86  if ( !loc.ops->node_type_h ) {
87    rtems_filesystem_freenode( &loc );
88    rtems_set_errno_and_return_minus_one( ENOTSUP );
89  }
90
91  node_type = (*loc.ops->node_type_h)( &loc );
92
93  if ( (result != 0) || node_type != RTEMS_FILESYSTEM_DEVICE ) {
94    rtems_filesystem_freenode( &loc );
95    return RTEMS_UNSATISFIED;
96  }
97
98  device_info->device_name        = (char *) name;
99  device_info->device_name_length = strlen( name );
100  device_info->major              = the_jnode->info.device.major;
101  device_info->minor              = the_jnode->info.device.minor;
102
103  rtems_filesystem_freenode( &loc );
104
105#endif
106  return RTEMS_SUCCESSFUL;
107}
Note: See TracBrowser for help on using the repository browser.