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

4.115
Last change on this file since 66e5e144 was 66e5e144, checked in by Joel Sherrill <joel.sherrill@…>, on 07/06/10 at 22:32:23

2010-07-06 Joel Sherrill <joel.sherrilL@…>

  • libfs/src/imfs/ioman.c: Remove unneeded operation check.
  • Property mode set to 100644
File size: 2.2 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 <rtems.h>
26#include <rtems/libio_.h>
27#include <rtems/seterr.h>
28#include "imfs.h"
29
30/*
31 *  rtems_io_register_name
32 *
33 *  This assumes that all registered devices are character devices.
34 */
35
36rtems_status_code rtems_io_register_name(
37  const char                *device_name,
38  rtems_device_major_number  major,
39  rtems_device_minor_number  minor
40)
41{
42  int    status;
43  dev_t  dev;
44
45  dev = rtems_filesystem_make_dev_t( major, minor );
46  status = mknod( device_name, 0777 | S_IFCHR, dev );
47
48  /* this is the only error returned by the old version */
49  if ( status )
50    return RTEMS_TOO_MANY;
51
52  return RTEMS_SUCCESSFUL;
53}
54
55/*
56 *  rtems_io_lookup_name
57 *
58 *  This version is reentrant.
59 *
60 *  XXX - This is dependent upon IMFS and should not be.
61 *        Suggest adding a filesystem routine to fill in the device_info.
62 */
63
64rtems_status_code rtems_io_lookup_name(
65  const char           *name,
66  rtems_driver_name_t  *device_info
67)
68{
69  IMFS_jnode_t                      *the_jnode;
70  rtems_filesystem_location_info_t   loc;
71  int                                result;
72  rtems_filesystem_node_types_t      node_type;
73
74  result = rtems_filesystem_evaluate_path(
75      name, strlen( name ), 0x00, &loc, true );
76  the_jnode = loc.node_access;
77
78  node_type = (*loc.ops->node_type_h)( &loc );
79
80  if ( (result != 0) || node_type != RTEMS_FILESYSTEM_DEVICE ) {
81    rtems_filesystem_freenode( &loc );
82    return RTEMS_UNSATISFIED;
83  }
84
85  device_info->device_name        = (char *) name;
86  device_info->device_name_length = strlen( name );
87  device_info->major              = the_jnode->info.device.major;
88  device_info->minor              = the_jnode->info.device.minor;
89
90  rtems_filesystem_freenode( &loc );
91
92  return RTEMS_SUCCESSFUL;
93}
Note: See TracBrowser for help on using the repository browser.