source: rtems/c/src/exec/libcsupport/src/chdir.c @ d71fcab

4.104.114.84.95
Last change on this file since d71fcab was d71fcab, checked in by Joel Sherrill <joel.sherrill@…>, on 10/12/99 at 18:44:40

Added call to freenod to let each filesystem free its own internal
node used to manage file access.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/* 
2 *  chdir() - POSIX 1003.1b - 5.2.1 - Change Current Working Directory
3 *
4 *  COPYRIGHT (c) 1989-1998.
5 *  On-Line Applications Research Corporation (OAR).
6 *  Copyright assigned to U.S. Government, 1994.
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.OARcorp.com/rtems/license.html.
11 *
12 *  $Id$
13 */
14
15#include <rtems.h>
16
17#include <unistd.h>
18#include <errno.h>
19
20#include "libio_.h"
21
22int chdir(
23  const char *pathname
24)
25{
26  rtems_filesystem_location_info_t  loc;
27  int                               result;
28
29  /*
30   *  Get the node where we wish to go.
31   */
32
33  result = rtems_filesystem_evaluate_path( pathname, 0, &loc, TRUE );
34  if ( result != 0 )
35     return -1;
36
37  /*
38   * Verify you can change directory into this node.
39   */
40
41  if ( !loc.ops->node_type ) {
42    if ( loc.ops->freenod )
43      (*loc.ops->freenod)( &loc );
44    set_errno_and_return_minus_one( ENOTSUP );
45  }
46
47  if (  (*loc.ops->node_type)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
48    if ( loc.ops->freenod )
49      (*loc.ops->freenod)( &loc );
50    set_errno_and_return_minus_one( ENOTDIR );
51  }
52 
53  if ( rtems_filesystem_current.ops->freenod )
54    (*rtems_filesystem_current.ops->freenod)( &rtems_filesystem_current );
55   
56  rtems_filesystem_current = loc;
57 
58  return 0;
59}
Note: See TracBrowser for help on using the repository browser.