source: rtems/c/src/lib/libc/fchdir.c @ cff0d64

4.104.114.84.95
Last change on this file since cff0d64 was 9c49db4, checked in by Joel Sherrill <joel.sherrill@…>, on 01/08/01 at 18:26:44

2001-01-08 Ralf Corsepius <corsepiu@…>

  • configure.in: Add libc/config.h
  • libc/Makefile.am: Add INCLUDES += -I. to pickup config.h
  • libc/.cvsignore: Add config.h and stamp-h
  • libc/*.c: Add config.h support.
  • Property mode set to 100644
File size: 1.6 KB
Line 
1/*
2 *  fchdir() - compatible with SVr4, 4.4BSD and X/OPEN - Change Directory
3 *
4 *  COPYRIGHT (c) 1989-2000.
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#if HAVE_CONFIG_H
15#include "config.h"
16#endif
17
18#include <unistd.h>
19#include <sys/stat.h>
20#include <errno.h>
21
22#include <rtems.h>
23#include <rtems/libio.h>
24#include <rtems/libio_.h>
25
26int fchdir(
27  int       fd
28)
29{
30  rtems_libio_t *iop;
31 
32  rtems_libio_check_fd( fd );
33  iop = rtems_libio_iop( fd );
34  rtems_libio_check_is_open(iop);
35
36  /*
37   *  Now process the fchmod().
38   */
39
40  rtems_libio_check_permissions( iop, LIBIO_FLAGS_READ );
41
42  /*
43   * Verify you can change directory into this node.
44   */
45
46  if ( !iop->pathinfo.ops ) {
47    set_errno_and_return_minus_one( ENOTSUP );
48  }
49
50  if ( !iop->pathinfo.ops->node_type_h ) {
51    set_errno_and_return_minus_one( ENOTSUP );
52  }
53
54  if (  (*iop->pathinfo.ops->node_type_h)( &iop->pathinfo ) !=
55                                          RTEMS_FILESYSTEM_DIRECTORY ) {
56    set_errno_and_return_minus_one( ENOTDIR );
57  }
58 
59  rtems_filesystem_freenode( &rtems_filesystem_current );
60
61  /*
62   * FIXME : I feel there should be another call to
63   *         actually take into account the extra reference to
64   *         this node which we are making here. I can
65   *         see the freenode interface but do not see
66   *         allocnode node interface. It maybe node_type.
67   */
68 
69  rtems_filesystem_current = iop->pathinfo;
70 
71  return 0;
72}
73
Note: See TracBrowser for help on using the repository browser.