xref: /original-bsd/lib/libc/sys/chroot.2 (revision c3e32dec)
1.\" Copyright (c) 1983, 1991, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" %sccs.include.redist.man%
5.\"
6.\"     @(#)chroot.2	8.1 (Berkeley) 06/04/93
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
24to become the root directory,
25that is, the starting point for path searches of pathnames
26beginning with
27.Ql / .
28.Pp
29In order for a directory to become the root directory
30a process must have execute (search) access for that directory.
31.Pp
32It should be noted that
33.Fn chroot
34has no effect on the process's current directory.
35.Pp
36This call is restricted to the super-user.
37.Sh RETURN VALUES
38Upon successful completion, a value of 0 is returned.  Otherwise,
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
47A component of the path name is not a directory.
48.It Bq Er EINVAL
49The pathname contains a character with the high-order bit set.
50.It Bq Er ENAMETOOLONG
51A component of a pathname exceeded 255 characters,
52or an entire path name exceeded 1023 characters.
53.It Bq Er ENOENT
54The named directory does not exist.
55.It Bq Er EACCES
56Search permission is denied for any component of the path name.
57.It Bq Er ELOOP
58Too many symbolic links were encountered in translating the pathname.
59.It Bq Er EFAULT
60.Fa Path
61points outside the process's allocated address space.
62.It Bq Er EIO
63An I/O error occurred while reading from or writing to the file system.
64.El
65.Sh SEE ALSO
66.Xr chdir 2
67.Sh HISTORY
68The
69.Nm
70function call appeared in
71.Bx 4.2 .
72