diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2001-04-20 21:11:25 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2001-04-20 21:11:25 +0000 |
commit | d8a91555127ade80dfe71e2d9c823c7350eea05f (patch) | |
tree | 3ece886f3f0893e8354619d1db10ccc9cabd2f97 /c/src/lib/libc/chroot.c | |
parent | 2001-04-20 Correo Fernando-ruiz <correo@fernando-ruiz.com> (diff) | |
download | rtems-d8a91555127ade80dfe71e2d9c823c7350eea05f.tar.bz2 |
2001-04-20 Correo Fernando-ruiz <correo@fernando-ruiz.com>
* include/rtems/libio_.h, libc/chroot.c, libc/privateenv.c:
Private environment and chroot() enhancements and fixes. Comments:
+ privateenv has been modified to let at chroot() to be more
POSIX like Sergei Organov recommended.
+ A task owner lets that rtems_set_private_env() will be
called twice or more times.
+ chroot() can be called without a previous
rtems_set_private_env(); (transpanrently)
+ The second call of rtems_set_private_env() makes a internal
chroot("/") into global imfs_root.
+ chroot() runs like chdir() without a previous chdir("/") with
the global root.
+ The current directory can be in a wrong place like Linux and
many other Unices.
Diffstat (limited to 'c/src/lib/libc/chroot.c')
-rw-r--r-- | c/src/lib/libc/chroot.c | 19 |
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; } |