8815 mega_sas: variable set but not used
[unleashed.git] / usr / src / man / man2 / chroot.2
blob2c81f34038bd258d5a64cb09c92b16d4f2ae5bb1
1 '\" te
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"
7 .SH NAME
8 chroot, fchroot \- change root directory
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <unistd.h>
14 \fBint\fR \fBchroot\fR(\fBconst char *\fR\fIpath\fR);
15 .fi
17 .LP
18 .nf
19 \fBint\fR \fBfchroot\fR(\fBint\fR \fIfildes\fR);
20 .fi
22 .SH DESCRIPTION
23 .sp
24 .LP
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.
29 .sp
30 .LP
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.
34 .sp
35 .LP
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.
40 .sp
41 .LP
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
46 changed.
47 .SH RETURN VALUES
48 .sp
49 .LP
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
52 indicate the error.
53 .SH ERRORS
54 .sp
55 .LP
56 The \fBchroot()\fR function will fail if:
57 .sp
58 .ne 2
59 .na
60 \fB\fBEACCES\fR\fR
61 .ad
62 .RS 16n
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
65 \fIdirname\fR.
66 .RE
68 .sp
69 .ne 2
70 .na
71 \fB\fBEBADF\fR\fR
72 .ad
73 .RS 16n
74 The descriptor is not valid.
75 .RE
77 .sp
78 .ne 2
79 .na
80 \fB\fBEFAULT\fR\fR
81 .ad
82 .RS 16n
83 The \fIpath\fR argument points to an illegal address.
84 .RE
86 .sp
87 .ne 2
88 .na
89 \fB\fBEINVAL\fR\fR
90 .ad
91 .RS 16n
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.
94 .RE
96 .sp
97 .ne 2
98 .na
99 \fB\fBEINTR\fR\fR
101 .RS 16n
102 A signal was caught during the execution of the \fBchroot()\fR function.
106 .ne 2
108 \fB\fBEIO\fR\fR
110 .RS 16n
111 An I/O error occurred while reading from or writing to the file system.
115 .ne 2
117 \fB\fBELOOP\fR\fR
119 .RS 16n
120 Too many symbolic links were encountered in translating \fIpath\fR.
124 .ne 2
126 \fB\fBENAMETOOLONG\fR\fR
128 .RS 16n
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
131 is in effect.
135 .ne 2
137 \fB\fBENOENT\fR\fR
139 .RS 16n
140 The named directory does not exist or is a null pathname.
144 .ne 2
146 \fB\fBENOLINK\fR\fR
148 .RS 16n
149 The \fIpath\fR argument points to a remote machine and the link to that machine
150 is no longer active.
154 .ne 2
156 \fB\fBENOTDIR\fR\fR
158 .RS 16n
159 Any component of the path name is not a directory.
163 .ne 2
165 \fB\fBEPERM\fR\fR
167 .RS 16n
168 The {\fBPRIV_PROC_CHROOT\fR} privilege is not asserted in the effective set of
169 the calling process.
172 .SH SEE ALSO
175 \fBchroot\fR(1M), \fBchdir\fR(2), \fBprivileges\fR(5)
176 .SH WARNINGS
179 The only use of \fBfchroot()\fR that is appropriate is to change back to the
180 system root.