chroot()
QNX SDP8.0C Library ReferenceAPIDeveloper
Change the root directory
Synopsis:
#include <unistd.h>
int chroot( const char *path );
Arguments:
- path
- The name of the new root directory.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The chroot() function causes the path directory
to become the root directory, the starting point for path
searches for path names beginning with /
.
The function also changes the current working directory to
path; in earlier versions, it was unaffected.
The .. entry in the root directory is interpreted to mean the root directory itself. Thus, you can't use .. to access files outside the subtree rooted at the root directory.
Note:
In order to change the root directory, your process must have the
PROCMGR_AID_CHROOT ability enabled.
For more information, see
procmgr_ability().
Returns:
- 0
- Success.
- -1
- An error occurred; errno is set.
Errors:
- EACCES
- Search permission is denied for a component of path.
- EBADF
- The descriptor isn't valid.
- EFAULT
- The path argument points to an illegal address.
- EINTR
- A signal was caught during the chroot() function.
- EIO
- An I/O error occurred while reading from or writing to the filesystem.
- ELOOP
- Too many symbolic links were encountered in translating path.
- EMULTIHOP
- Components of path require hopping to multiple remote machines, and the filesystem type doesn't allow it.
- ENAMETOOLONG
- The length of the path string exceeds PATH_MAX.
- ENOENT
- The named directory doesn't exist or is a null pathname.
- ENOLINK
- The path points to a remote machine and the link to that machine is no longer active.
- ENOTDIR
- Any component of the path name isn't a directory.
- EPERM
- The effective user of the calling process isn't the superuser.
Classification:
Safety: | |
---|---|
Cancellation point | No |
Signal handler | No |
Thread | Yes |
Page updated: