source: rtems/c/src/libfs/src/imfs/ioman.c @ b2709481

4.104.114.84.95
Last change on this file since b2709481 was b2709481, checked in by Joel Sherrill <joel.sherrill@…>, on 01/04/02 at 18:30:58

2002-01-04 Ralf Corsepius <corsepiu@…>

  • src/imfs/imfs_eval.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • src/imfs/memfile.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • src/imfs/imfs_readlink.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • src/imfs/imfs_unlink.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • src/imfs/imfs_link.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • src/imfs/imfs_chown.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • src/imfs/ioman.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • src/imfs/imfs_mount.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • src/imfs/imfs_directory.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • src/imfs/imfs_stat.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • src/imfs/imfs_fchmod.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • src/imfs/imfs_symlink.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • src/imfs/imfs_mknod.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • src/imfs/linearfile.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • src/imfs/imfs_unmount.c: Include <rtems/seterr.h>. Apply rtems_set_errno_and_return_minus_one.
  • src/imfs/imfs.h: Apply rtems_set_errno_and_return_minus_one. Comment out increment_and_check_linkcounts.
  • 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#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
24#include <assert.h>
25
26#include <rtems.h>
27#include <rtems/libio_.h>
28#include <rtems/seterr.h>
29#include "imfs.h"
30
31#if defined(__linux__)
32#define S_IFCHR __S_IFCHR
33#endif
34
35/*
36 *  rtems_io_register_name
37 *
38 *  This assumes that all registered devices are character devices.
39 */
40
41rtems_status_code rtems_io_register_name(
42  char *device_name,
43  rtems_device_major_number major,
44  rtems_device_minor_number minor
45)
46{
47#if !defined(RTEMS_UNIX)
48  int    status;
49  dev_t  dev;
50
51  dev = rtems_filesystem_make_dev_t( major, minor );
52  status = mknod( device_name, 0777 | S_IFCHR, dev );
53
54  /* this is the only error returned by the old version */
55  if ( status )
56    return RTEMS_TOO_MANY;
57 
58#endif
59  return RTEMS_SUCCESSFUL;
60}
61
62/*
63 *  rtems_io_lookup_name
64 *
65 *  This version is not reentrant.
66 *
67 *  XXX - This is dependent upon IMFS and should not be. 
68 *        Suggest adding a filesystem routine to fill in the device_info.
69 */
70
71rtems_status_code rtems_io_lookup_name(
72  const char           *name,
73  rtems_driver_name_t **device_info
74)
75{
76#if !defined(RTEMS_UNIX)
77  IMFS_jnode_t                      *the_jnode;
78  rtems_filesystem_location_info_t   loc;
79  static rtems_driver_name_t         device;
80  int                                result;
81  rtems_filesystem_node_types_t      node_type;
82
83  result = rtems_filesystem_evaluate_path( name, 0x00, &loc, TRUE );
84  the_jnode = loc.node_access;
85
86  if ( !loc.ops->node_type_h ) {
87    rtems_filesystem_freenode( &loc );
88    rtems_set_errno_and_return_minus_one( ENOTSUP );
89  }
90
91  node_type = (*loc.ops->node_type_h)( &loc );
92
93  if ( (result != 0) || node_type != RTEMS_FILESYSTEM_DEVICE ) {
94    *device_info = 0;
95    rtems_filesystem_freenode( &loc );
96    return RTEMS_UNSATISFIED;
97  }
98
99  device.device_name        = (char *) name;
100  device.device_name_length = strlen( name );
101  device.major              = the_jnode->info.device.major;
102  device.minor              = the_jnode->info.device.minor;
103  *device_info              = &device;
104
105  rtems_filesystem_freenode( &loc );
106   
107#endif
108  return RTEMS_SUCCESSFUL;
109}
Note: See TracBrowser for help on using the repository browser.