source: rtems/cpukit/libcsupport/src/fchdir.c @ 92119ed

4.115
Last change on this file since 92119ed was 92119ed, checked in by Jennifer Averett <Jennifer.Averett@…>, on 07/01/10 at 15:12:38

2010-07-01 Jennifer Averett <Jennifer.Averett@…>

  • libcsupport/src/chdir.c, libcsupport/src/chmod.c, libcsupport/src/chown.c, libcsupport/src/close.c, libcsupport/src/eval.c, libcsupport/src/fchdir.c, libcsupport/src/fchmod.c, libcsupport/src/fchown.c, libcsupport/src/fcntl.c, libcsupport/src/fdatasync.c, libcsupport/src/freenode.c, libcsupport/src/fstat.c, libcsupport/src/fsync.c, libcsupport/src/ftruncate.c, libcsupport/src/ioctl.c, libcsupport/src/link.c, libcsupport/src/lseek.c, libcsupport/src/mknod.c, libcsupport/src/mount.c, libcsupport/src/open.c, libcsupport/src/read.c, libcsupport/src/readlink.c, libcsupport/src/readv.c, libcsupport/src/rmdir.c, libcsupport/src/stat.c, libcsupport/src/statvfs.c, libcsupport/src/symlink.c, libcsupport/src/unlink.c, libcsupport/src/unmount.c, libcsupport/src/write.c: Removed filesystem checks for NULL methods checks from the main posix rountines. These are now required to have at a miminum default routines in the tables.
  • Property mode set to 100644
File size: 2.0 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.rtems.com/license/LICENSE.
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#include <rtems/seterr.h>
26
27int fchdir(
28  int       fd
29)
30{
31  rtems_libio_t *iop;
32  rtems_filesystem_location_info_t loc, saved;
33
34  rtems_libio_check_fd( fd );
35  iop = rtems_libio_iop( fd );
36  rtems_libio_check_is_open(iop);
37
38  /*
39   *  Now process the fchmod().
40   */
41
42  rtems_libio_check_permissions( iop, LIBIO_FLAGS_READ );
43
44  /*
45   * Verify you can change directory into this node.
46   */
47
48  if (  (*iop->pathinfo.ops->node_type_h)( &iop->pathinfo ) !=
49                                          RTEMS_FILESYSTEM_DIRECTORY ) {
50    rtems_set_errno_and_return_minus_one( ENOTDIR );
51  }
52
53
54  /*
55   * FIXME : I feel there should be another call to
56   *         actually take into account the extra reference to
57   *         this node which we are making here. I can
58   *         see the freenode interface but do not see
59   *         allocnode node interface. It maybe node_type.
60   *
61   * FIXED:  T.Straumann: it is evaluate_path()
62   *         but note the race condition. Threads who
63   *         share their rtems_filesystem_current better
64   *         be synchronized!
65   */
66
67  saved                    = rtems_filesystem_current;
68  rtems_filesystem_current = iop->pathinfo;
69
70  /* clone the current node */
71  if (rtems_filesystem_evaluate_path(".", 1, 0, &loc, 0)) {
72    /* cloning failed; restore original and bail out */
73    rtems_filesystem_current = saved;
74    return -1;
75  }
76  /* release the old one */
77  rtems_filesystem_freenode( &saved );
78
79  rtems_filesystem_current = loc;
80
81  return 0;
82}
Note: See TracBrowser for help on using the repository browser.