OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [libcsupport/] [src/] [chdir.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
2
 *  chdir() - POSIX 1003.1b - 5.2.1 - Change Current Working Directory
3
 *
4
 *  COPYRIGHT (c) 1989-1999.
5
 *  On-Line Applications Research Corporation (OAR).
6
 *
7
 *  The license and distribution terms for this file may be
8
 *  found in the file LICENSE in this distribution or at
9
 *  http://www.OARcorp.com/rtems/license.html.
10
 *
11
 *  chdir.c,v 1.9 2002/01/04 18:29:36 joel Exp
12
 */
13
 
14
#if HAVE_CONFIG_H
15
#include "config.h"
16
#endif
17
 
18
#include <rtems.h>
19
 
20
#include <unistd.h>
21
#include <errno.h>
22
 
23
#include <rtems/libio_.h>
24
#include <rtems/seterr.h>
25
 
26
int chdir(
27
  const char *pathname
28
)
29
{
30
  rtems_filesystem_location_info_t  loc;
31
  int                               result;
32
 
33
  /*
34
   *  Get the node where we wish to go.
35
   */
36
 
37
  result = rtems_filesystem_evaluate_path(
38
    pathname, RTEMS_LIBIO_PERMS_SEARCH, &loc, TRUE );
39
  if ( result != 0 )
40
     return -1;
41
 
42
  /*
43
   * Verify you can change directory into this node.
44
   */
45
 
46
  if ( !loc.ops->node_type_h ) {
47
    rtems_filesystem_freenode( &loc );
48
    rtems_set_errno_and_return_minus_one( ENOTSUP );
49
  }
50
 
51
  if (  (*loc.ops->node_type_h)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
52
    rtems_filesystem_freenode( &loc );
53
    rtems_set_errno_and_return_minus_one( ENOTDIR );
54
  }
55
 
56
  rtems_filesystem_freenode( &rtems_filesystem_current );
57
 
58
  rtems_filesystem_current = loc;
59
 
60
  return 0;
61
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.