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-1998. |
---|
6 | * On-Line Applications Research Corporation (OAR). |
---|
7 | * Copyright assigned to U.S. Government, 1994. |
---|
8 | * |
---|
9 | * The license and distribution terms for this file may be |
---|
10 | * found in the file LICENSE in this distribution or at |
---|
11 | * http://www.OARcorp.com/rtems/license.html. |
---|
12 | * |
---|
13 | * $Id$ |
---|
14 | */ |
---|
15 | |
---|
16 | #include <sys/types.h> |
---|
17 | #include <sys/stat.h> |
---|
18 | #include <fcntl.h> |
---|
19 | #include <unistd.h> |
---|
20 | |
---|
21 | #include <assert.h> |
---|
22 | |
---|
23 | #include <rtems.h> |
---|
24 | #include "libio_.h" |
---|
25 | #include "imfs.h" |
---|
26 | |
---|
27 | /* |
---|
28 | * rtems_io_register_name |
---|
29 | * |
---|
30 | * This assumes that all registered devices are character devices. |
---|
31 | */ |
---|
32 | |
---|
33 | rtems_status_code rtems_io_register_name( |
---|
34 | char *device_name, |
---|
35 | rtems_device_major_number major, |
---|
36 | rtems_device_minor_number minor |
---|
37 | ) |
---|
38 | { |
---|
39 | int status; |
---|
40 | dev_t dev; |
---|
41 | |
---|
42 | dev = rtems_filesystem_make_dev_t( major, minor ); |
---|
43 | status = mknod( device_name, 0777 | S_IFCHR, dev ); |
---|
44 | |
---|
45 | /* this is the only error returned by the old version */ |
---|
46 | if ( status ) |
---|
47 | return RTEMS_TOO_MANY; |
---|
48 | |
---|
49 | return RTEMS_SUCCESSFUL; |
---|
50 | } |
---|
51 | |
---|
52 | /* |
---|
53 | * rtems_io_lookup_name |
---|
54 | * |
---|
55 | * This version is not reentrant. |
---|
56 | */ |
---|
57 | |
---|
58 | rtems_status_code rtems_io_lookup_name( |
---|
59 | const char *name, |
---|
60 | rtems_driver_name_t **device_info |
---|
61 | ) |
---|
62 | { |
---|
63 | IMFS_jnode_t *the_jnode; |
---|
64 | rtems_filesystem_location_info_t temp_loc; |
---|
65 | static rtems_driver_name_t device; |
---|
66 | int result; |
---|
67 | |
---|
68 | result = rtems_filesystem_evaluate_path( name, 0x00, &temp_loc, TRUE ); |
---|
69 | the_jnode = temp_loc.node_access; |
---|
70 | |
---|
71 | if ( (result != 0) || the_jnode->type != IMFS_DEVICE ) { |
---|
72 | *device_info = 0; |
---|
73 | return RTEMS_UNSATISFIED; |
---|
74 | } |
---|
75 | |
---|
76 | device.device_name = (char *) name; |
---|
77 | device.device_name_length = strlen( name ); |
---|
78 | device.major = the_jnode->info.device.major; |
---|
79 | device.minor = the_jnode->info.device.minor; |
---|
80 | *device_info = &device; |
---|
81 | return RTEMS_SUCCESSFUL; |
---|
82 | |
---|
83 | } |
---|