date and time created 91/04/12 13:40:31 by bostic
[unix-history] / usr / src / lib / libc / sys / chroot.2
CommitLineData
931b8415
CL
1.\" Copyright (c) 1983, 1991 Regents of the University of California.
2.\" All rights reserved.
b7793121 3.\"
931b8415 4.\" %sccs.include.redist.man%
b7793121 5.\"
931b8415
CL
6.\" @(#)chroot.2 6.5 (Berkeley) %G%
7.\"
8.Dd
9.Dt CHROOT 2
10.Os BSD 4.2
11.Sh NAME
12.Nm chroot
13.Nd change root directory
14.Sh SYNOPSIS
15.Fd #include <unistd.h>
16.Ft int
17.Fn chroot "const char *dirname"
18.Sh DESCRIPTION
19.Fa Dirname
20is the address of the pathname of a directory, terminated by an ASCII NUL.
21.Fn Chroot
22causes
23.Fa dirname
b7793121 24to become the root directory,
931b8415
CL
25that is, the starting point for path searches of pathnames
26beginning with
27.Ql / .
28.Pp
b7793121 29In order for a directory to become the root directory
931b8415
CL
30a process must have execute (search) access for that directory.
31.Pp
9369d86e 32It should be noted that
931b8415 33.Fn chroot
9369d86e 34has no effect on the process's current directory.
931b8415 35.Pp
b7793121 36This call is restricted to the super-user.
931b8415 37.Sh RETURN VALUES
b7793121 38Upon successful completion, a value of 0 is returned. Otherwise,
931b8415
CL
39a value of -1 is returned and
40.Va errno
41is set to indicate an error.
42.Sh ERRORS
43.Fn Chroot
44will fail and the root directory will be unchanged if:
45.Bl -tag -width [ENOTDIR]
46.It Bq Er ENOTDIR
b7793121 47A component of the path name is not a directory.
931b8415 48.It Bq Er EINVAL
b5984ffe 49The pathname contains a character with the high-order bit set.
931b8415 50.It Bq Er ENAMETOOLONG
b5984ffe
KM
51A component of a pathname exceeded 255 characters,
52or an entire path name exceeded 1023 characters.
931b8415 53.It Bq Er ENOENT
b7793121 54The named directory does not exist.
931b8415 55.It Bq Er EACCES
b5984ffe 56Search permission is denied for any component of the path name.
931b8415 57.It Bq Er ELOOP
b5984ffe 58Too many symbolic links were encountered in translating the pathname.
931b8415
CL
59.It Bq Er EFAULT
60.Fa Path
b7793121 61points outside the process's allocated address space.
931b8415 62.It Bq Er EIO
fd690c8b 63An I/O error occurred while reading from or writing to the file system.
931b8415
CL
64.El
65.Sh SEE ALSO
66.Xr chdir 2
67.Sh HISTORY
68The
69.Nm
70function call appeared in
71.Bx 4.2 .