source: rtems/c/src/lib/libc/ioman.c @ ddaa60f

4.104.114.84.95
Last change on this file since ddaa60f was 7a3878b, checked in by Jennifer Averett <Jennifer.Averett@…>, on 12/03/98 at 22:17:13

Modifications for RTEMS_UNIX.

  • Property mode set to 100644
File size: 2.1 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-1998.
6 *  On-Line Applications Research Corporation (OAR).
7 *  Copyright assigned to U.S. Government, 1994.
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.OARcorp.com/rtems/license.html.
12 *
13 *  $Id$
14 */
15
16
17
18#include <sys/types.h>
19#include <sys/stat.h>
20#include <fcntl.h>
21#include <unistd.h>
22
23#include <assert.h>
24
25#include <rtems.h>
26#include "libio_.h"
27#include "imfs.h"
28
29#if defined(__linux__)
30#define S_IFCHR __S_IFCHR
31#endif
32
33/*
34 *  rtems_io_register_name
35 *
36 *  This assumes that all registered devices are character devices.
37 */
38
39rtems_status_code rtems_io_register_name(
40  char *device_name,
41  rtems_device_major_number major,
42  rtems_device_minor_number minor
43)
44{
45#if !defined(RTEMS_UNIX)
46  int    status;
47  dev_t  dev;
48
49  dev = rtems_filesystem_make_dev_t( major, minor );
50  status = mknod( device_name, 0777 | S_IFCHR, dev );
51
52  /* this is the only error returned by the old version */
53  if ( status )
54    return RTEMS_TOO_MANY;
55 
56#endif
57  return RTEMS_SUCCESSFUL;
58}
59
60/*
61 *  rtems_io_lookup_name
62 *
63 *  This version is not reentrant.
64 */
65
66rtems_status_code rtems_io_lookup_name(
67  const char           *name,
68  rtems_driver_name_t **device_info
69)
70{
71#if !defined(RTEMS_UNIX)
72  IMFS_jnode_t                      *the_jnode;
73  rtems_filesystem_location_info_t   temp_loc;
74  static rtems_driver_name_t         device;
75  int                                result;
76
77  result = rtems_filesystem_evaluate_path( name, 0x00, &temp_loc, TRUE );
78  the_jnode = temp_loc.node_access;
79
80  if ( (result != 0) || the_jnode->type != IMFS_DEVICE ) {
81    *device_info = 0;
82    return RTEMS_UNSATISFIED;
83  }
84
85  device.device_name        = (char *) name;
86  device.device_name_length = strlen( name );
87  device.major              = the_jnode->info.device.major;
88  device.minor              = the_jnode->info.device.minor;
89  *device_info              = &device;
90#endif
91  return RTEMS_SUCCESSFUL;
92}
Note: See TracBrowser for help on using the repository browser.