source: rtems/c/src/lib/libc/eval.c @ 0139484

4.104.114.84.95
Last change on this file since 0139484 was 0139484, checked in by Joel Sherrill <joel.sherrill@…>, on 10/05/99 at 16:34:20

Patch from Wayne Bullaughey <wayne@…>. Comments follow:

I'm working on code to mount my host based file system on the base file
system (imfs) and have a suggestion for a change to eval.c in the
c/src/lib/libc directory of the 8/20/1999 snapshot. The current version
does not test the result value returned from the evalpath callback (line 47)
in the case where follow_link is true. Attached is my suggested change.
Without this test the node_type callback may be called after evalpath
failed. node_type could set the type to some value other then
RTEMS_FILESYSTEM_HARD_LINK or RTEMS_FILESYSTEM_SYM_LINK but it seems cleaner
to add the check on result.

  • Property mode set to 100644
File size: 1.7 KB
Line 
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
20int 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 ( (result == 0) && 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
Note: See TracBrowser for help on using the repository browser.