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

4.104.114.84.95
Last change on this file since cf0539b1 was cf0539b1, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:54:17

2003-09-04 Joel Sherrill <joel@…>

  • src/dosfs/dosfs.h, src/dosfs/fat.h, src/dosfs/fat_fat_operations.h, src/dosfs/fat_file.h, src/dosfs/msdos.h, src/dosfs/msdos_create.c, src/dosfs/msdos_dir.c, src/dosfs/msdos_eval.c, src/dosfs/msdos_file.c, src/dosfs/msdos_free.c, src/dosfs/msdos_fsunmount.c, src/dosfs/msdos_handlers_dir.c, src/dosfs/msdos_handlers_file.c, src/dosfs/msdos_init.c, src/dosfs/msdos_initsupp.c, src/dosfs/msdos_misc.c, src/dosfs/msdos_mknod.c, src/dosfs/msdos_node_type.c, src/imfs/deviceio.c, src/imfs/imfs.h, 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_fcntl.c, src/imfs/imfs_fdatasync.c, src/imfs/imfs_free.c, src/imfs/imfs_fsunmount.c, src/imfs/imfs_getchild.c, src/imfs/imfs_gtkn.c, src/imfs/imfs_handlers_device.c, src/imfs/imfs_handlers_directory.c, src/imfs/imfs_handlers_link.c, src/imfs/imfs_handlers_memfile.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_ntype.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/linearfile.c, src/imfs/memfile.c, src/imfs/miniimfs_init.c: URL for license changed.
  • 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.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 <assert.h>
26
27#include <rtems.h>
28#include <rtems/libio_.h>
29#include <rtems/seterr.h>
30#include "imfs.h"
31
32#if defined(__linux__)
33#define S_IFCHR __S_IFCHR
34#endif
35
36/*
37 *  rtems_io_register_name
38 *
39 *  This assumes that all registered devices are character devices.
40 */
41
42rtems_status_code rtems_io_register_name(
43  char *device_name,
44  rtems_device_major_number major,
45  rtems_device_minor_number minor
46)
47{
48#if !defined(RTEMS_UNIX)
49  int    status;
50  dev_t  dev;
51
52  dev = rtems_filesystem_make_dev_t( major, minor );
53  status = mknod( device_name, 0777 | S_IFCHR, dev );
54
55  /* this is the only error returned by the old version */
56  if ( status )
57    return RTEMS_TOO_MANY;
58 
59#endif
60  return RTEMS_SUCCESSFUL;
61}
62
63/*
64 *  rtems_io_lookup_name
65 *
66 *  This version is reentrant.
67 *
68 *  XXX - This is dependent upon IMFS and should not be. 
69 *        Suggest adding a filesystem routine to fill in the device_info.
70 */
71
72rtems_status_code rtems_io_lookup_name(
73  const char           *name,
74  rtems_driver_name_t  *device_info
75)
76{
77#if !defined(RTEMS_UNIX)
78  IMFS_jnode_t                      *the_jnode;
79  rtems_filesystem_location_info_t   loc;
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    rtems_filesystem_freenode( &loc );
95    return RTEMS_UNSATISFIED;
96  }
97
98  device_info->device_name        = (char *) name;
99  device_info->device_name_length = strlen( name );
100  device_info->major              = the_jnode->info.device.major;
101  device_info->minor              = the_jnode->info.device.minor;
102
103  rtems_filesystem_freenode( &loc );
104   
105#endif
106  return RTEMS_SUCCESSFUL;
107}
Note: See TracBrowser for help on using the repository browser.