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

4.104.114.84.95
Last change on this file since c058578 was c058578, checked in by Joel Sherrill <joel.sherrill@…>, on 11/01/00 at 21:02:46

2000-11-01 Joel Sherrill <joel@…>

  • src/imfs/Makefile.am, src/imfs/deviceio.c, src/imfs/imfs_chown.c, src/imfs/imfs_config.c, src/imfs/imfs_creat.c, src/imfs/imfs_debug.c, src/imfs/imfs_directory.c, src/imfs/imfs_eval.c, src/imfs/imfs_fchmod.c, src/imfs/imfs_free.c, src/imfs/imfs_fsunmount.c, src/imfs/imfs_gtkn.c, src/imfs/imfs_init.c, src/imfs/imfs_initsupp.c, src/imfs/imfs_link.c, src/imfs/imfs_mknod.c, src/imfs/imfs_mount.c, src/imfs/imfs_readlink.c, src/imfs/imfs_rmnod.c, src/imfs/imfs_stat.c, src/imfs/imfs_symlink.c, src/imfs/imfs_unixstub.c, src/imfs/imfs_unlink.c, src/imfs/imfs_unmount.c, src/imfs/imfs_utime.c, src/imfs/ioman.c, src/imfs/memfile.c, src/imfs/miniimfs_init.c: assoc.h, error.h, libio_.h, libio.h, and libcsupport.h moved from libc to lib/include/rtems and now must be referenced as <rtems/XXX.h>. Now we do not have to reach up and over to libc to pick them up.
  • 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 <rtems/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_h ) {
84    rtems_filesystem_freenode( &loc );
85    set_errno_and_return_minus_one( ENOTSUP );
86  }
87
88  node_type = (*loc.ops->node_type_h)( &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.