source: rtems/cpukit/libcsupport/src/eval.c @ 0eae36c7

4.104.114.84.9
Last change on this file since 0eae36c7 was 0eae36c7, checked in by Joel Sherrill <joel.sherrill@…>, on Sep 4, 2003 at 6:54:13 PM

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

  • include/chain.h, include/clockdrv.h, include/console.h, include/iosupp.h, include/rtc.h, include/spurious.h, include/timerdrv.h, include/vmeintr.h, include/motorola/mc68230.h, include/rtems/libcsupport.h, include/rtems/libio.h, include/rtems/libio_.h, include/rtems/termiostypes.h, include/sys/termios.h, include/zilog/z8036.h, include/zilog/z8530.h, include/zilog/z8536.h, src/brk.c, src/gettod.c, src/sbrk.c, src/times.c, src/access.c, src/base_fs.c, src/cfgetispeed.c, src/cfgetospeed.c, src/cfsetispeed.c, src/cfsetospeed.c, src/chdir.c, src/chmod.c, src/chown.c, src/chroot.c, src/close.c, src/ctermid.c, src/dup.c, src/dup2.c, src/eval.c, src/fchdir.c, src/fchmod.c, src/fcntl.c, src/fdatasync.c, src/fpathconf.c, src/fs_null_handlers.c, src/fstat.c, src/fsync.c, src/ftruncate.c, src/getdents.c, src/getpwent.c, src/hosterr.c, src/ioctl.c, src/isatty.c, src/libio.c, src/libio_sockets.c, src/link.c, src/lseek.c, src/lstat.c, src/malloc.c, src/mallocfreespace.c, src/mkdir.c, src/mkfifo.c, src/mknod.c, src/mount.c, src/newlibc.c, src/no_libc.c, src/no_posix.c, src/open.c, src/pathconf.c, src/pipe.c, src/privateenv.c, src/read.c, src/readlink.c, src/rewinddir.c, src/rmdir.c, src/seekdir.c, src/stat.c, src/symlink.c, src/sync.c, src/tcdrain.c, src/tcflow.c, src/tcflush.c, src/tcgetattr.c, src/tcgetprgrp.c, src/tcsendbreak.c, src/tcsetattr.c, src/tcsetpgrp.c, src/telldir.c, src/termios.c, src/termiosinitialize.c, src/truncate.c, src/umask.c, src/unixlibc.c, src/unlink.c, src/unmount.c, src/utime.c, src/write.c: URL for license changed.
  • Property mode set to 100644
File size: 2.6 KB
Line 
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.rtems.com/license/LICENSE.
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#include <rtems/seterr.h>
23
24int rtems_filesystem_evaluate_path(
25  const char                        *pathname,
26  int                                flags,
27  rtems_filesystem_location_info_t  *pathloc,
28  int                                follow_link
29)
30{
31  int                           i;
32  int                           result;
33  rtems_filesystem_node_types_t type;
34
35  /*
36   * Verify Input parameters.
37   */
38
39  if ( !pathname )
40    rtems_set_errno_and_return_minus_one( EFAULT );
41
42  if ( !pathloc )
43    rtems_set_errno_and_return_minus_one( EIO );       /* should never happen */
44 
45  /*
46   * Evaluate the path using the optable evalpath.
47   */
48
49  rtems_filesystem_get_start_loc( pathname, &i, pathloc );
50
51  if ( !pathloc->ops->evalpath_h )
52    rtems_set_errno_and_return_minus_one( ENOTSUP );
53
54  result = (*pathloc->ops->evalpath_h)( &pathname[i], flags, pathloc );
55
56  /*
57   * Get the Node type and determine if you need to follow the link or
58   * not.
59   */
60
61  if ( (result == 0) && follow_link ) {
62
63    if ( !pathloc->ops->node_type_h ){
64      rtems_filesystem_freenode( pathloc );
65      rtems_set_errno_and_return_minus_one( ENOTSUP );
66    }
67
68    type = (*pathloc->ops->node_type_h)( pathloc );
69
70    if ( ( type == RTEMS_FILESYSTEM_HARD_LINK ) ||
71         ( type == RTEMS_FILESYSTEM_SYM_LINK ) ) {
72
73        if ( !pathloc->ops->eval_link_h ){
74          rtems_filesystem_freenode( pathloc );
75          rtems_set_errno_and_return_minus_one( ENOTSUP );
76        }
77
78        /* what to do with the valid node pathloc points to
79         * if eval_link_h fails?
80         * Let the FS implementation deal with this case.  It
81         * should probably free pathloc in either case:
82         *  - if the link evaluation fails, it must free the
83         *    original (valid) pathloc because we are going
84         *    to return -1 and hence the FS generics won't
85         *    cleanup pathloc.
86         *  - if the link evaluation is successful, the updated
87         *    pathloc will be passed up (and eventually released).
88         *    Hence, the (valid) originial node that we submit to
89         *    eval_link_h() should be released by the handler.
90         */
91
92        result =  (*pathloc->ops->eval_link_h)( pathloc, flags );
93 
94    }
95  }
96
97  return result;
98}
99
Note: See TracBrowser for help on using the repository browser.