2 .\" Copyright 1989 AT&T. Copyright (c) 2003, Sun Microsystems, Inc. All Rights Reserved
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License"). You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing. See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE. If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH CHROOT 2 "Jan 20, 2003"
8 chroot, fchroot \- change root directory
14 \fBint\fR \fBchroot\fR(\fBconst char *\fR\fIpath\fR);
19 \fBint\fR \fBfchroot\fR(\fBint\fR \fIfildes\fR);
25 The \fBchroot()\fR and \fBfchroot()\fR functions cause a directory to become
26 the root directory, the starting point for path searches for path names
27 beginning with \fB/\fR (slash). The user's working directory is unaffected by
28 the \fBchroot()\fR and \fBfchroot()\fR functions.
31 The \fIpath\fR argument points to a path name naming a directory. The
32 \fIfildes\fR argument to \fBfchroot()\fR is the open file descriptor of the
33 directory which is to become the root.
36 The privilege {\fBPRIV_PROC_CHROOT\fR} must be asserted in the effective set of
37 the process to change the root directory. While it is always possible to change
38 to the system root using the \fBfchroot()\fR function, it is not guaranteed to
39 succeed in any other case, even if \fIfildes\fR is valid in all respects.
42 The ".\|." entry in the root directory is interpreted to mean the root
43 directory itself. Therefore, ".\|." cannot be used to access files outside the
44 subtree rooted at the root directory. Instead, \fBfchroot()\fR can be used to
45 reset the root to a directory that was opened before the root directory was
50 Upon successful completion, \fB0\fR is returned. Otherwise, \fB\(mi1\fR is
51 returned, the root directory remains unchanged, and \fBerrno\fR is set to
56 The \fBchroot()\fR function will fail if:
63 Search permission is denied for a component of the path prefix of
64 \fIdirname\fR, or search permission is denied for the directory referred to by
74 The descriptor is not valid.
83 The \fIpath\fR argument points to an illegal address.
92 The \fBfchroot()\fR function attempted to change to a directory the is not the
93 system root and external circumstances do not allow this.
102 A signal was caught during the execution of the \fBchroot()\fR function.
111 An I/O error occurred while reading from or writing to the file system.
120 Too many symbolic links were encountered in translating \fIpath\fR.
126 \fB\fBENAMETOOLONG\fR\fR
129 The length of the \fIpath\fR argument exceeds \fBPATH_MAX\fR, or the length of
130 a \fIpath\fR component exceeds \fB\fR\fBNAME_MAX\fR while \fB_POSIX_NO_TRUNC\fR
140 The named directory does not exist or is a null pathname.
149 The \fIpath\fR argument points to a remote machine and the link to that machine
159 Any component of the path name is not a directory.
168 The {\fBPRIV_PROC_CHROOT\fR} privilege is not asserted in the effective set of
175 \fBchroot\fR(1M), \fBchdir\fR(2), \fBprivileges\fR(5)
179 The only use of \fBfchroot()\fR that is appropriate is to change back to the