diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2001-01-26 14:12:48 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2001-01-26 14:12:48 +0000 |
commit | 37535317d9612bb365a3dce08b0b1d2d71e387b3 (patch) | |
tree | 72f4dbb6405ebc2af27e656c69adda17b374b85a /c/src/exec/libcsupport/src/chroot.c | |
parent | 2001-01-25 Eric Norum <eric.norum@usask.ca> (diff) | |
download | rtems-37535317d9612bb365a3dce08b0b1d2d71e387b3.tar.bz2 |
2001-01-25 Joel Sherrill <joel@OARcorp.com>
* cpu.c, rtems/score/cpu.h: Bug report from Peter Mueller
<peter.o.mueller@gmx.de> because of not correcting for the ISR
vector table now being allocated from the workspace.
Diffstat (limited to '')
-rw-r--r-- | c/src/exec/libcsupport/src/chroot.c | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/c/src/exec/libcsupport/src/chroot.c b/c/src/exec/libcsupport/src/chroot.c new file mode 100644 index 0000000000..b48082bda7 --- /dev/null +++ b/c/src/exec/libcsupport/src/chroot.c @@ -0,0 +1,59 @@ +/* + * chroot() - Change Root Directory + * Author: fernando.ruiz@ctv.es + * + * COPYRIGHT (c) 1989-1999. + * On-Line Applications Research Corporation (OAR). + * + * The license and distribution terms for this file may be + * found in the file LICENSE in this distribution or at + * http://www.OARcorp.com/rtems/license.html. + * + * $Id$ + */ + +#if HAVE_CONFIG_H +#include "config.h" +#endif + +#include <rtems.h> + +#include <unistd.h> +#include <errno.h> + +#include <rtems/libio_.h> + +int chroot( + const char *pathname +) +{ + int result; + rtems_filesystem_location_info_t loc; + + if (rtems_current_user_env == &rtems_global_user_env) + set_errno_and_return_minus_one( ENOTSUP ); + + loc = rtems_filesystem_root;i /* save the value */ + + /* if has been already changed */ + rtems_filesystem_root = rtems_global_user_env.filesystem_root; + + result = chdir(pathname); + if (result) { + rtems_filesystem_root = loc; /* restore the value */ + set_errno_and_return_minus_one( errno ); + }; + rtems_filesystem_root = rtems_filesystem_current; + + result = chdir("/"); + if (result) { + rtems_filesystem_root = loc; /* restore the value */ + set_errno_and_return_minus_one( errno ); + }; + + /*XXX : Call this? Sorry but I don't known if it is necesary */ + /* The old root. + rtems_filesystem_freenode( &loc ); + */ + return 0; +} |