1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
5 .\" Permission is granted to make and distribute verbatim copies of this
6 .\" manual provided the copyright notice and this permission notice are
7 .\" preserved on all copies.
9 .\" Permission is granted to copy and distribute modified versions of this
10 .\" manual under the conditions for verbatim copying, provided that the
11 .\" entire resulting derived work is distributed under the terms of a
12 .\" permission notice identical to this one.
14 .\" Since the Linux kernel and libraries are constantly changing, this
15 .\" manual page may be incorrect or out-of-date. The author(s) assume no
16 .\" responsibility for errors or omissions, or for damages resulting from
17 .\" the use of the information contained herein. The author(s) may not
18 .\" have taken the same level of care in the production of this manual,
19 .\" which is licensed free of charge, as they might when working
22 .\" Formatted or processed versions of this manual, if unaccompanied by
23 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified by Michael Haardt <michael@moria.de>
26 .\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
27 .\" Modified 1994-08-21 by Michael Chastain <mec@shell.portal.com>
28 .\" Modified 1996-06-13 by aeb
29 .\" Modified 1996-11-06 by Eric S. Raymond <esr@thyrsus.com>
30 .\" Modified 1997-08-21 by Joseph S. Myers <jsm28@cam.ac.uk>
31 .\" Modified 2004-06-23 by Michael Kerrisk <mtk-manpages@gmx.net>
33 .TH CHROOT 2 2004-06-23 "Linux 2.6.7" "Linux Programmer's Manual"
35 chroot \- change root directory
37 .B #include <unistd.h>
39 .BI "int chroot(const char *" path );
42 changes the root directory to that specified in
44 This directory will be used for path names beginning with /. The root
45 directory is inherited by all children of the current process.
47 Only a privileged process (Linux: one with the
52 This call changes an ingredient in the pathname resolution process
53 and does nothing else.
55 This call does not change the current working directory,
56 so that after the call `.' can be outside the tree rooted at `/'.
57 In particular, the superuser can escape from a `chroot jail'
58 by doing `mkdir foo; chroot foo; cd ..'.
60 This call does not close open file descriptors, and such file
61 descriptors may allow access to files outside the chroot tree.
64 On success, zero is returned. On error, \-1 is returned, and
68 Depending on the file system, other errors can be returned. The more
69 general errors are listed below:
72 Search permission is denied on a component of the path prefix.
74 .BR path_resolution (2).)
75 .\" Also search permission is required on the final component,
76 .\" maybe just to guarantee that it is a directory?
80 points outside your accessible address space.
83 An I/O error occurred.
86 Too many symbolic links were encountered in resolving
94 The file does not exist.
97 Insufficient kernel memory was available.
105 The caller has insufficient privilege.
107 SVr4, SVID, 4.4BSD, X/OPEN. This function is not part of POSIX.1.
108 SVr4 documents additional EINTR, ENOLINK and EMULTIHOP error conditions.
109 X/OPEN does not document EIO, ENOMEM or EFAULT error conditions.
110 This interface is marked as legacy by X/OPEN.
112 FreeBSD has a stronger
117 .BR path_resolution (2)