source: rtems/c/src/lib/libc/ioman.c @ 2782e69

4.104.114.84.95
Last change on this file since 2782e69 was dd0f326, checked in by Joel Sherrill <joel.sherrill@…>, on 10/12/99 at 19:10:46

Added rtems_filesystem_freenode() macro and added calls at appropriate
places to make sure memory allocated for filesystem specifif nodes
gets freed.

  • Property mode set to 100644
File size: 2.4 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 *  XXX - This is dependent upon IMFS and should not be. 
66 *        Suggest adding a filesystem routine to fill in the device_info.
67 */
68
69rtems_status_code rtems_io_lookup_name(
70  const char           *name,
71  rtems_driver_name_t **device_info
72)
73{
74#if !defined(RTEMS_UNIX)
75  IMFS_jnode_t                      *the_jnode;
76  rtems_filesystem_location_info_t   loc;
77  static rtems_driver_name_t         device;
78  int                                result;
79  rtems_filesystem_node_types_t      node_type;
80
81  result = rtems_filesystem_evaluate_path( name, 0x00, &loc, TRUE );
82  the_jnode = loc.node_access;
83
84  node_type = (*loc.ops->node_type)( &loc );
85
86  if ( (result != 0) || node_type != RTEMS_FILESYSTEM_DEVICE ) {
87    *device_info = 0;
88    rtems_filesystem_freenode( &loc );
89    return RTEMS_UNSATISFIED;
90  }
91
92  device.device_name        = (char *) name;
93  device.device_name_length = strlen( name );
94  device.major              = the_jnode->info.device.major;
95  device.minor              = the_jnode->info.device.minor;
96  *device_info              = &device;
97
98  rtems_filesystem_freenode( &loc );
99   
100#endif
101  return RTEMS_SUCCESSFUL;
102}
Note: See TracBrowser for help on using the repository browser.