4.104.114.84.95
Last change
on this file since d8a9155 was
d8a9155,
checked in by Joel Sherrill <joel.sherrill@…>, on 04/20/01 at 21:11:25
|
2001-04-20 Correo Fernando-ruiz <correo@…>
- 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.
|
-
Property mode set to
100644
|
File size:
1.2 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.OARcorp.com/rtems/license.html. |
---|
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 | |
---|
26 | int chroot( |
---|
27 | const char *pathname |
---|
28 | ) |
---|
29 | { |
---|
30 | int result; |
---|
31 | rtems_filesystem_location_info_t loc; |
---|
32 | |
---|
33 | /* an automatic call to new private env the first time */ |
---|
34 | if (rtems_current_user_env == &rtems_global_user_env) { |
---|
35 | rtems_libio_set_private_env(); /* try to set a new private env*/ |
---|
36 | if (rtems_current_user_env == &rtems_global_user_env) /* not ok */ |
---|
37 | set_errno_and_return_minus_one( ENOTSUP ); |
---|
38 | }; |
---|
39 | |
---|
40 | loc = rtems_filesystem_root; /* save the value */ |
---|
41 | |
---|
42 | result = chdir(pathname); |
---|
43 | if (result) { |
---|
44 | rtems_filesystem_root = loc; /* restore the value */ |
---|
45 | set_errno_and_return_minus_one( errno ); |
---|
46 | }; |
---|
47 | rtems_filesystem_root = rtems_filesystem_current; |
---|
48 | |
---|
49 | return 0; |
---|
50 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.