xref: /csrg-svn/lib/libc/sys/chroot.2 (revision 47208)
1*47208Scael.\" Copyright (c) 1983, 1991 Regents of the University of California.
2*47208Scael.\" All rights reserved.
320209Smckusick.\"
4*47208Scael.\" %sccs.include.redist.man%
520209Smckusick.\"
6*47208Scael.\"     @(#)chroot.2	6.5 (Berkeley) 03/10/91
7*47208Scael.\"
8*47208Scael.Dd
9*47208Scael.Dt CHROOT 2
10*47208Scael.Os BSD 4.2
11*47208Scael.Sh NAME
12*47208Scael.Nm chroot
13*47208Scael.Nd change root directory
14*47208Scael.Sh SYNOPSIS
15*47208Scael.Fd #include <unistd.h>
16*47208Scael.Ft int
17*47208Scael.Fn chroot "const char *dirname"
18*47208Scael.Sh DESCRIPTION
19*47208Scael.Fa Dirname
20*47208Scaelis the address of the pathname of a directory, terminated by an ASCII NUL.
21*47208Scael.Fn Chroot
22*47208Scaelcauses
23*47208Scael.Fa dirname
2420209Smckusickto become the root directory,
25*47208Scaelthat is, the starting point for path searches of pathnames
26*47208Scaelbeginning with
27*47208Scael.Ql / .
28*47208Scael.Pp
2920209SmckusickIn order for a directory to become the root directory
30*47208Scaela process must have execute (search) access for that directory.
31*47208Scael.Pp
3236616SbosticIt should be noted that
33*47208Scael.Fn chroot
3436616Sbostichas no effect on the process's current directory.
35*47208Scael.Pp
3620209SmckusickThis call is restricted to the super-user.
37*47208Scael.Sh RETURN VALUES
3820209SmckusickUpon successful completion, a value of 0 is returned.  Otherwise,
39*47208Scaela value of -1 is returned and
40*47208Scael.Va errno
41*47208Scaelis set to indicate an error.
42*47208Scael.Sh ERRORS
43*47208Scael.Fn Chroot
44*47208Scaelwill fail and the root directory will be unchanged if:
45*47208Scael.Bl -tag -width [ENOTDIR]
46*47208Scael.It Bq Er ENOTDIR
4720209SmckusickA component of the path name is not a directory.
48*47208Scael.It Bq Er EINVAL
4921004SmckusickThe pathname contains a character with the high-order bit set.
50*47208Scael.It Bq Er ENAMETOOLONG
5121004SmckusickA component of a pathname exceeded 255 characters,
5221004Smckusickor an entire path name exceeded 1023 characters.
53*47208Scael.It Bq Er ENOENT
5420209SmckusickThe named directory does not exist.
55*47208Scael.It Bq Er EACCES
5621004SmckusickSearch permission is denied for any component of the path name.
57*47208Scael.It Bq Er ELOOP
5821004SmckusickToo many symbolic links were encountered in translating the pathname.
59*47208Scael.It Bq Er EFAULT
60*47208Scael.Fa Path
6120209Smckusickpoints outside the process's allocated address space.
62*47208Scael.It Bq Er EIO
6324440SmckusickAn I/O error occurred while reading from or writing to the file system.
64*47208Scael.El
65*47208Scael.Sh SEE ALSO
66*47208Scael.Xr chdir 2
67*47208Scael.Sh HISTORY
68*47208ScaelThe
69*47208Scael.Nm
70*47208Scaelfunction call appeared in
71*47208Scael.Bx 4.2 .
72