source:
rtems/c/src/exec/libcsupport/src/chdir.c
@
9c3fa30
Last change on this file since 9c3fa30 was 9c3fa30, checked in by Joel Sherrill <joel.sherrill@…>, on 09/28/00 at 20:19:23 | |
---|---|
|
|
File size: 1.2 KB |
Line | |
---|---|
1 | /* |
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$ |
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_h ) { |
41 | rtems_filesystem_freenode( &loc ); |
42 | set_errno_and_return_minus_one( ENOTSUP ); |
43 | } |
44 | |
45 | if ( (*loc.ops->node_type_h)( &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 | } |
Note: See TracBrowser
for help on using the repository browser.