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

Subversion Repositories or1k

[/] [or1k/] [trunk/] [rtems-20020807/] [cpukit/] [libcsupport/] [src/] [chroot.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 1026 ivang
/*
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.OARcorp.com/rtems/license.html.
11
 *
12
 *  chroot.c,v 1.4 2002/01/04 18:29:36 joel Exp
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
 
27
int 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
  loc = rtems_filesystem_root;     /* save the value */
42
 
43
  result = chdir(pathname);
44
  if (result) {
45
    rtems_filesystem_root = loc; /* restore the value */
46
    rtems_set_errno_and_return_minus_one( errno );
47
  };
48
  rtems_filesystem_root = rtems_filesystem_current;
49
 
50
  return 0;
51
}

powered by: WebSVN 2.1.0

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