summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libc/chroot.c
diff options
context:
space:
mode:
Diffstat (limited to 'c/src/lib/libc/chroot.c')
-rw-r--r--c/src/lib/libc/chroot.c19
1 files changed, 5 insertions, 14 deletions
diff --git a/c/src/lib/libc/chroot.c b/c/src/lib/libc/chroot.c
index e05e51029e..a7645943b4 100644
--- a/c/src/lib/libc/chroot.c
+++ b/c/src/lib/libc/chroot.c
@@ -30,14 +30,15 @@ int chroot(
int result;
rtems_filesystem_location_info_t loc;
- if (rtems_current_user_env == &rtems_global_user_env)
+ /* an automatic call to new private env the first time */
+ if (rtems_current_user_env == &rtems_global_user_env) {
+ rtems_libio_set_private_env(); /* try to set a new private env*/
+ if (rtems_current_user_env == &rtems_global_user_env) /* not ok */
set_errno_and_return_minus_one( ENOTSUP );
+ };
loc = rtems_filesystem_root; /* save the value */
- /* if has been already changed */
- rtems_filesystem_root = rtems_global_user_env.root_directory;
-
result = chdir(pathname);
if (result) {
rtems_filesystem_root = loc; /* restore the value */
@@ -45,15 +46,5 @@ int chroot(
};
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;
}