1 | /* |
---|
2 | * rtems_filesystem_evaluate_path() |
---|
3 | * |
---|
4 | * Routine to seed the evaluate path routine. |
---|
5 | * |
---|
6 | * COPYRIGHT (c) 1989-1998. |
---|
7 | * On-Line Applications Research Corporation (OAR). |
---|
8 | * Copyright assigned to U.S. Government, 1994. |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.OARcorp.com/rtems/license.html. |
---|
13 | * |
---|
14 | * $Id$ |
---|
15 | */ |
---|
16 | |
---|
17 | #include <rtems.h> |
---|
18 | #include "libio_.h" |
---|
19 | |
---|
20 | int rtems_filesystem_evaluate_path( |
---|
21 | const char *pathname, |
---|
22 | int flags, |
---|
23 | rtems_filesystem_location_info_t *pathloc, |
---|
24 | int follow_link |
---|
25 | ) |
---|
26 | { |
---|
27 | int i; |
---|
28 | int result; |
---|
29 | rtems_filesystem_node_types_t type; |
---|
30 | |
---|
31 | /* |
---|
32 | * Verify Input parameters. |
---|
33 | */ |
---|
34 | |
---|
35 | if ( !pathname ) |
---|
36 | set_errno_and_return_minus_one( EFAULT ); |
---|
37 | |
---|
38 | if ( !pathloc ) |
---|
39 | set_errno_and_return_minus_one( EIO ); /* should never happen */ |
---|
40 | |
---|
41 | /* |
---|
42 | * Evaluate the path using the optable evalpath. |
---|
43 | */ |
---|
44 | |
---|
45 | rtems_filesystem_get_start_loc( pathname, &i, pathloc ); |
---|
46 | |
---|
47 | result = (*pathloc->ops->evalpath)( &pathname[i], flags, pathloc ); |
---|
48 | |
---|
49 | /* |
---|
50 | * Get the Node type and determine if you need to follow the link or |
---|
51 | * not. |
---|
52 | */ |
---|
53 | |
---|
54 | if ( follow_link ) { |
---|
55 | |
---|
56 | if ( !pathloc->ops->node_type ) |
---|
57 | set_errno_and_return_minus_one( ENOTSUP ); |
---|
58 | |
---|
59 | type = (*pathloc->ops->node_type)( pathloc ); |
---|
60 | |
---|
61 | if ( ( type == RTEMS_FILESYSTEM_HARD_LINK ) || |
---|
62 | ( type == RTEMS_FILESYSTEM_SYM_LINK ) ) { |
---|
63 | |
---|
64 | if ( !pathloc->ops->eval_link ) |
---|
65 | set_errno_and_return_minus_one( ENOTSUP ); |
---|
66 | |
---|
67 | result = (*pathloc->ops->eval_link)( pathloc, flags ); |
---|
68 | |
---|
69 | } |
---|
70 | } |
---|
71 | |
---|
72 | return result; |
---|
73 | } |
---|
74 | |
---|