source: rtems/cpukit/libcsupport/src/chroot.c @ 50f32b11

4.104.114.84.95
Last change on this file since 50f32b11 was 50f32b11, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/18/04 at 06:05:35

Remove stray white spaces.

  • Property mode set to 100644
File size: 1.3 KB
Line 
1/*
2 *  chroot() -  Change Root Directory
3 *  Author: fernando.ruiz@ctv.es
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#if HAVE_CONFIG_H
16#include "config.h"
17#endif
18
19#include <rtems.h>
20
21#include <unistd.h>
22#include <errno.h>
23
24#include <rtems/libio_.h>
25#include <rtems/seterr.h>
26
27int chroot(
28  const char *pathname
29)
30{
31  int                               result;
32  rtems_filesystem_location_info_t  loc;
33
34  /* an automatic call to new private env the first time */
35  if (rtems_current_user_env == &rtems_global_user_env) {
36   rtems_libio_set_private_env(); /* try to set a new private env*/
37   if (rtems_current_user_env == &rtems_global_user_env) /* not ok */
38    rtems_set_errno_and_return_minus_one( ENOTSUP );
39  };
40
41  result = chdir(pathname);
42  if (result) {
43    rtems_set_errno_and_return_minus_one( errno );
44  };
45  /* clone the new root location */
46  if (rtems_filesystem_evaluate_path(".", 0, &loc, 0)) {
47        /* our cwd has changed, though - but there is no easy way of return :-( */
48    rtems_set_errno_and_return_minus_one( errno );
49  }
50  rtems_filesystem_freenode(&rtems_filesystem_root);
51  rtems_filesystem_root = loc;
52
53  return 0;
54}
Note: See TracBrowser for help on using the repository browser.