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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libc/] [chdir.c] - Blame information for rev 228

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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
 *  $Id: chdir.c,v 1.2 2001-09-27 12:01:15 chris Exp $
12
 */
13
 
14
#include <rtems.h>
15
 
16
#include <unistd.h>
17
#include <errno.h>
18
 
19
#include "libio_.h"
20
 
21
int chdir(
22
  const char *pathname
23
)
24
{
25
  rtems_filesystem_location_info_t  loc;
26
  int                               result;
27
 
28
  /*
29
   *  Get the node where we wish to go.
30
   */
31
 
32
  result = rtems_filesystem_evaluate_path( pathname, 0, &loc, TRUE );
33
  if ( result != 0 )
34
     return -1;
35
 
36
  /*
37
   * Verify you can change directory into this node.
38
   */
39
 
40
  if ( !loc.ops->node_type ) {
41
    rtems_filesystem_freenode( &loc );
42
    set_errno_and_return_minus_one( ENOTSUP );
43
  }
44
 
45
  if (  (*loc.ops->node_type)( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
46
    rtems_filesystem_freenode( &loc );
47
    set_errno_and_return_minus_one( ENOTDIR );
48
  }
49
 
50
  rtems_filesystem_freenode( &rtems_filesystem_current );
51
 
52
  rtems_filesystem_current = loc;
53
 
54
  return 0;
55
}

powered by: WebSVN 2.1.0

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