1*61181Sbostic.\" Copyright (c) 1983, 1991, 1993 2*61181Sbostic.\" The Regents of the University of California. All rights reserved. 320209Smckusick.\" 447208Scael.\" %sccs.include.redist.man% 520209Smckusick.\" 6*61181Sbostic.\" @(#)chroot.2 8.1 (Berkeley) 06/04/93 747208Scael.\" 847208Scael.Dd 947208Scael.Dt CHROOT 2 1047208Scael.Os BSD 4.2 1147208Scael.Sh NAME 1247208Scael.Nm chroot 1347208Scael.Nd change root directory 1447208Scael.Sh SYNOPSIS 1547208Scael.Fd #include <unistd.h> 1647208Scael.Ft int 1747208Scael.Fn chroot "const char *dirname" 1847208Scael.Sh DESCRIPTION 1947208Scael.Fa Dirname 2047208Scaelis the address of the pathname of a directory, terminated by an ASCII NUL. 2147208Scael.Fn Chroot 2247208Scaelcauses 2347208Scael.Fa dirname 2420209Smckusickto become the root directory, 2547208Scaelthat is, the starting point for path searches of pathnames 2647208Scaelbeginning with 2747208Scael.Ql / . 2847208Scael.Pp 2920209SmckusickIn order for a directory to become the root directory 3047208Scaela process must have execute (search) access for that directory. 3147208Scael.Pp 3236616SbosticIt should be noted that 3347208Scael.Fn chroot 3436616Sbostichas no effect on the process's current directory. 3547208Scael.Pp 3620209SmckusickThis call is restricted to the super-user. 3747208Scael.Sh RETURN VALUES 3820209SmckusickUpon successful completion, a value of 0 is returned. Otherwise, 3947208Scaela value of -1 is returned and 4047208Scael.Va errno 4147208Scaelis set to indicate an error. 4247208Scael.Sh ERRORS 4347208Scael.Fn Chroot 4447208Scaelwill fail and the root directory will be unchanged if: 4547208Scael.Bl -tag -width [ENOTDIR] 4647208Scael.It Bq Er ENOTDIR 4720209SmckusickA component of the path name is not a directory. 4847208Scael.It Bq Er EINVAL 4921004SmckusickThe pathname contains a character with the high-order bit set. 5047208Scael.It Bq Er ENAMETOOLONG 5121004SmckusickA component of a pathname exceeded 255 characters, 5221004Smckusickor an entire path name exceeded 1023 characters. 5347208Scael.It Bq Er ENOENT 5420209SmckusickThe named directory does not exist. 5547208Scael.It Bq Er EACCES 5621004SmckusickSearch permission is denied for any component of the path name. 5747208Scael.It Bq Er ELOOP 5821004SmckusickToo many symbolic links were encountered in translating the pathname. 5947208Scael.It Bq Er EFAULT 6047208Scael.Fa Path 6120209Smckusickpoints outside the process's allocated address space. 6247208Scael.It Bq Er EIO 6324440SmckusickAn I/O error occurred while reading from or writing to the file system. 6447208Scael.El 6547208Scael.Sh SEE ALSO 6647208Scael.Xr chdir 2 6747208Scael.Sh HISTORY 6847208ScaelThe 6947208Scael.Nm 7047208Scaelfunction call appeared in 7147208Scael.Bx 4.2 . 72