1 | /* |
---|
2 | * rtems_filesystem_evaluate_path() |
---|
3 | * |
---|
4 | * Routine to seed the evaluate path routine. |
---|
5 | * |
---|
6 | * COPYRIGHT (c) 1989-1999. |
---|
7 | * On-Line Applications Research Corporation (OAR). |
---|
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 | #if HAVE_CONFIG_H |
---|
17 | #include "config.h" |
---|
18 | #endif |
---|
19 | |
---|
20 | #include <rtems.h> |
---|
21 | #include <rtems/libio_.h> |
---|
22 | |
---|
23 | int rtems_filesystem_evaluate_path( |
---|
24 | const char *pathname, |
---|
25 | int flags, |
---|
26 | rtems_filesystem_location_info_t *pathloc, |
---|
27 | int follow_link |
---|
28 | ) |
---|
29 | { |
---|
30 | int i; |
---|
31 | int result; |
---|
32 | rtems_filesystem_node_types_t type; |
---|
33 | |
---|
34 | /* |
---|
35 | * Verify Input parameters. |
---|
36 | */ |
---|
37 | |
---|
38 | if ( !pathname ) |
---|
39 | set_errno_and_return_minus_one( EFAULT ); |
---|
40 | |
---|
41 | if ( !pathloc ) |
---|
42 | set_errno_and_return_minus_one( EIO ); /* should never happen */ |
---|
43 | |
---|
44 | /* |
---|
45 | * Evaluate the path using the optable evalpath. |
---|
46 | */ |
---|
47 | |
---|
48 | rtems_filesystem_get_start_loc( pathname, &i, pathloc ); |
---|
49 | |
---|
50 | if ( !pathloc->ops->evalpath_h ) |
---|
51 | set_errno_and_return_minus_one( ENOTSUP ); |
---|
52 | |
---|
53 | result = (*pathloc->ops->evalpath_h)( &pathname[i], flags, pathloc ); |
---|
54 | |
---|
55 | /* |
---|
56 | * Get the Node type and determine if you need to follow the link or |
---|
57 | * not. |
---|
58 | */ |
---|
59 | |
---|
60 | if ( (result == 0) && follow_link ) { |
---|
61 | |
---|
62 | if ( !pathloc->ops->node_type_h ) |
---|
63 | set_errno_and_return_minus_one( ENOTSUP ); |
---|
64 | |
---|
65 | type = (*pathloc->ops->node_type_h)( pathloc ); |
---|
66 | |
---|
67 | if ( ( type == RTEMS_FILESYSTEM_HARD_LINK ) || |
---|
68 | ( type == RTEMS_FILESYSTEM_SYM_LINK ) ) { |
---|
69 | |
---|
70 | if ( !pathloc->ops->eval_link_h ) |
---|
71 | set_errno_and_return_minus_one( ENOTSUP ); |
---|
72 | |
---|
73 | result = (*pathloc->ops->eval_link_h)( pathloc, flags ); |
---|
74 | |
---|
75 | } |
---|
76 | } |
---|
77 | |
---|
78 | return result; |
---|
79 | } |
---|
80 | |
---|