Commit | Line | Data |
---|---|---|
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 | |
20 | is the address of the pathname of a directory, terminated by an ASCII NUL. | |
21 | .Fn Chroot | |
22 | causes | |
23 | .Fa dirname | |
b7793121 | 24 | to become the root directory, |
931b8415 CL |
25 | that is, the starting point for path searches of pathnames |
26 | beginning with | |
27 | .Ql / . | |
28 | .Pp | |
b7793121 | 29 | In order for a directory to become the root directory |
931b8415 CL |
30 | a process must have execute (search) access for that directory. |
31 | .Pp | |
9369d86e | 32 | It should be noted that |
931b8415 | 33 | .Fn chroot |
9369d86e | 34 | has no effect on the process's current directory. |
931b8415 | 35 | .Pp |
b7793121 | 36 | This call is restricted to the super-user. |
931b8415 | 37 | .Sh RETURN VALUES |
b7793121 | 38 | Upon successful completion, a value of 0 is returned. Otherwise, |
931b8415 CL |
39 | a value of -1 is returned and |
40 | .Va errno | |
41 | is set to indicate an error. | |
42 | .Sh ERRORS | |
43 | .Fn Chroot | |
44 | will fail and the root directory will be unchanged if: | |
45 | .Bl -tag -width [ENOTDIR] | |
46 | .It Bq Er ENOTDIR | |
b7793121 | 47 | A component of the path name is not a directory. |
931b8415 | 48 | .It Bq Er EINVAL |
b5984ffe | 49 | The pathname contains a character with the high-order bit set. |
931b8415 | 50 | .It Bq Er ENAMETOOLONG |
b5984ffe KM |
51 | A component of a pathname exceeded 255 characters, |
52 | or an entire path name exceeded 1023 characters. | |
931b8415 | 53 | .It Bq Er ENOENT |
b7793121 | 54 | The named directory does not exist. |
931b8415 | 55 | .It Bq Er EACCES |
b5984ffe | 56 | Search permission is denied for any component of the path name. |
931b8415 | 57 | .It Bq Er ELOOP |
b5984ffe | 58 | Too many symbolic links were encountered in translating the pathname. |
931b8415 CL |
59 | .It Bq Er EFAULT |
60 | .Fa Path | |
b7793121 | 61 | points outside the process's allocated address space. |
931b8415 | 62 | .It Bq Er EIO |
fd690c8b | 63 | An 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 | |
68 | The | |
69 | .Nm | |
70 | function call appeared in | |
71 | .Bx 4.2 . |