source: rtems/c/src/lib/libc/ioman.c @ 74835d7

Last change on this file since 74835d7 was 74835d7, checked in by Joel Sherrill <joel.sherrill@…>, on 08/11/00 at 20:04:03

2000-08-11 Chris Johns <ccj@…>

  • libc/chmod.c: Return ENOTSUP if filesystem does not have handler.
  • libc/eval.c: Ditto.
  • libc/fcntl.c: Ditto.
  • libc/fsync.c: Ditto.
  • libc/ioctl.c: Ditto.
  • libc/ioman.c: Ditto.
  • libc/link.c: Ditto.
  • libc/memfile.c: Ditto.
  • libc/mknod.c: Ditto.
  • libc/symlink.c: Ditto.
  • libc/libio.h(rtems_filesystem_dev_major_t): New macro.
  • libc/libio.h(rtems_filesystem_dev_minor_t): New macro.
  • 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.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15
16
17#include <sys/types.h>
18#include <sys/stat.h>
19#include <fcntl.h>
20#include <unistd.h>
21
22#include <assert.h>
23
24#include <rtems.h>
25#include "libio_.h"
26#include "imfs.h"
27
28#if defined(__linux__)
29#define S_IFCHR __S_IFCHR
30#endif
31
32/*
33 *  rtems_io_register_name
34 *
35 *  This assumes that all registered devices are character devices.
36 */
37
38rtems_status_code rtems_io_register_name(
39  char *device_name,
40  rtems_device_major_number major,
41  rtems_device_minor_number minor
42)
43{
44#if !defined(RTEMS_UNIX)
45  int    status;
46  dev_t  dev;
47
48  dev = rtems_filesystem_make_dev_t( major, minor );
49  status = mknod( device_name, 0777 | S_IFCHR, dev );
50
51  /* this is the only error returned by the old version */
52  if ( status )
53    return RTEMS_TOO_MANY;
54 
55#endif
56  return RTEMS_SUCCESSFUL;
57}
58
59/*
60 *  rtems_io_lookup_name
61 *
62 *  This version is not reentrant.
63 *
64 *  XXX - This is dependent upon IMFS and should not be. 
65 *        Suggest adding a filesystem routine to fill in the device_info.
66 */
67
68rtems_status_code rtems_io_lookup_name(
69  const char           *name,
70  rtems_driver_name_t **device_info
71)
72{
73#if !defined(RTEMS_UNIX)
74  IMFS_jnode_t                      *the_jnode;
75  rtems_filesystem_location_info_t   loc;
76  static rtems_driver_name_t         device;
77  int                                result;
78  rtems_filesystem_node_types_t      node_type;
79
80  result = rtems_filesystem_evaluate_path( name, 0x00, &loc, TRUE );
81  the_jnode = loc.node_access;
82
83  if ( !loc.ops->node_type ) {
84    rtems_filesystem_freenode( &loc );
85    set_errno_and_return_minus_one( ENOTSUP );
86  }
87
88  node_type = (*loc.ops->node_type)( &loc );
89
90  if ( (result != 0) || node_type != RTEMS_FILESYSTEM_DEVICE ) {
91    *device_info = 0;
92    rtems_filesystem_freenode( &loc );
93    return RTEMS_UNSATISFIED;
94  }
95
96  device.device_name        = (char *) name;
97  device.device_name_length = strlen( name );
98  device.major              = the_jnode->info.device.major;
99  device.minor              = the_jnode->info.device.minor;
100  *device_info              = &device;
101
102  rtems_filesystem_freenode( &loc );
103   
104#endif
105  return RTEMS_SUCCESSFUL;
106}
Note: See TracBrowser for help on using the repository browser.