xref: /xnu-12377.41.6/bsd/man/man2/chdir.2 (revision bbb1b6f9e71b8cdde6e5cd6f4841f207dee3d828)
1*bbb1b6f9SApple OSS Distributions.\"	$NetBSD: chdir.2,v 1.7 1995/02/27 12:32:00 cgd Exp $
2*bbb1b6f9SApple OSS Distributions.\"
3*bbb1b6f9SApple OSS Distributions.\" Copyright (c) 1980, 1991, 1993
4*bbb1b6f9SApple OSS Distributions.\"	The Regents of the University of California.  All rights reserved.
5*bbb1b6f9SApple OSS Distributions.\"
6*bbb1b6f9SApple OSS Distributions.\" Redistribution and use in source and binary forms, with or without
7*bbb1b6f9SApple OSS Distributions.\" modification, are permitted provided that the following conditions
8*bbb1b6f9SApple OSS Distributions.\" are met:
9*bbb1b6f9SApple OSS Distributions.\" 1. Redistributions of source code must retain the above copyright
10*bbb1b6f9SApple OSS Distributions.\"    notice, this list of conditions and the following disclaimer.
11*bbb1b6f9SApple OSS Distributions.\" 2. Redistributions in binary form must reproduce the above copyright
12*bbb1b6f9SApple OSS Distributions.\"    notice, this list of conditions and the following disclaimer in the
13*bbb1b6f9SApple OSS Distributions.\"    documentation and/or other materials provided with the distribution.
14*bbb1b6f9SApple OSS Distributions.\" 3. All advertising materials mentioning features or use of this software
15*bbb1b6f9SApple OSS Distributions.\"    must display the following acknowledgement:
16*bbb1b6f9SApple OSS Distributions.\"	This product includes software developed by the University of
17*bbb1b6f9SApple OSS Distributions.\"	California, Berkeley and its contributors.
18*bbb1b6f9SApple OSS Distributions.\" 4. Neither the name of the University nor the names of its contributors
19*bbb1b6f9SApple OSS Distributions.\"    may be used to endorse or promote products derived from this software
20*bbb1b6f9SApple OSS Distributions.\"    without specific prior written permission.
21*bbb1b6f9SApple OSS Distributions.\"
22*bbb1b6f9SApple OSS Distributions.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23*bbb1b6f9SApple OSS Distributions.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24*bbb1b6f9SApple OSS Distributions.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25*bbb1b6f9SApple OSS Distributions.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26*bbb1b6f9SApple OSS Distributions.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27*bbb1b6f9SApple OSS Distributions.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28*bbb1b6f9SApple OSS Distributions.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29*bbb1b6f9SApple OSS Distributions.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30*bbb1b6f9SApple OSS Distributions.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31*bbb1b6f9SApple OSS Distributions.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32*bbb1b6f9SApple OSS Distributions.\" SUCH DAMAGE.
33*bbb1b6f9SApple OSS Distributions.\"
34*bbb1b6f9SApple OSS Distributions.\"     @(#)chdir.2	8.2 (Berkeley) 12/11/93
35*bbb1b6f9SApple OSS Distributions.\"
36*bbb1b6f9SApple OSS Distributions.Dd December 11, 1993
37*bbb1b6f9SApple OSS Distributions.Dt CHDIR 2
38*bbb1b6f9SApple OSS Distributions.Os BSD 4
39*bbb1b6f9SApple OSS Distributions.Sh NAME
40*bbb1b6f9SApple OSS Distributions.Nm chdir ,
41*bbb1b6f9SApple OSS Distributions.Nm fchdir
42*bbb1b6f9SApple OSS Distributions.Nd change current working directory
43*bbb1b6f9SApple OSS Distributions.Sh SYNOPSIS
44*bbb1b6f9SApple OSS Distributions.Fd #include <unistd.h>
45*bbb1b6f9SApple OSS Distributions.Ft int
46*bbb1b6f9SApple OSS Distributions.Fo chdir
47*bbb1b6f9SApple OSS Distributions.Fa "const char *path"
48*bbb1b6f9SApple OSS Distributions.Fc
49*bbb1b6f9SApple OSS Distributions.Ft int
50*bbb1b6f9SApple OSS Distributions.Fo fchdir
51*bbb1b6f9SApple OSS Distributions.Fa "int fildes"
52*bbb1b6f9SApple OSS Distributions.Fc
53*bbb1b6f9SApple OSS Distributions.Sh DESCRIPTION
54*bbb1b6f9SApple OSS DistributionsThe
55*bbb1b6f9SApple OSS Distributions.Fa path
56*bbb1b6f9SApple OSS Distributionsargument points to the pathname of a directory.
57*bbb1b6f9SApple OSS DistributionsThe
58*bbb1b6f9SApple OSS Distributions.Fn chdir
59*bbb1b6f9SApple OSS Distributionsfunction
60*bbb1b6f9SApple OSS Distributionscauses the named directory
61*bbb1b6f9SApple OSS Distributionsto become the current working directory, that is,
62*bbb1b6f9SApple OSS Distributionsthe starting point for path searches of pathnames not beginning with
63*bbb1b6f9SApple OSS Distributionsa slash,
64*bbb1b6f9SApple OSS Distributions.Ql / .
65*bbb1b6f9SApple OSS Distributions.Pp
66*bbb1b6f9SApple OSS DistributionsThe
67*bbb1b6f9SApple OSS Distributions.Fn fchdir
68*bbb1b6f9SApple OSS Distributionsfunction
69*bbb1b6f9SApple OSS Distributionscauses the directory referenced by
70*bbb1b6f9SApple OSS Distributions.Fa fildes
71*bbb1b6f9SApple OSS Distributionsto become the current working directory,
72*bbb1b6f9SApple OSS Distributionsthe starting point for path searches of pathnames not beginning with
73*bbb1b6f9SApple OSS Distributionsa slash,
74*bbb1b6f9SApple OSS Distributions.Ql / .
75*bbb1b6f9SApple OSS Distributions.Pp
76*bbb1b6f9SApple OSS DistributionsIn order for a directory to become the current directory,
77*bbb1b6f9SApple OSS Distributionsa process must have execute (search) access to the directory.
78*bbb1b6f9SApple OSS Distributions.Sh RETURN VALUES
79*bbb1b6f9SApple OSS DistributionsUpon successful completion, a value of 0 is returned.
80*bbb1b6f9SApple OSS DistributionsOtherwise, a value of -1 is returned and
81*bbb1b6f9SApple OSS Distributions.Va errno
82*bbb1b6f9SApple OSS Distributionsis set to indicate
83*bbb1b6f9SApple OSS Distributionsthe error.
84*bbb1b6f9SApple OSS Distributions.Sh ERRORS
85*bbb1b6f9SApple OSS DistributionsThe
86*bbb1b6f9SApple OSS Distributions.Fn chdir
87*bbb1b6f9SApple OSS Distributionssystem call will fail
88*bbb1b6f9SApple OSS Distributionsand the current working directory will be unchanged
89*bbb1b6f9SApple OSS Distributionsif one or more of the following are true:
90*bbb1b6f9SApple OSS Distributions.Bl -tag -width Er
91*bbb1b6f9SApple OSS Distributions.\" ==========
92*bbb1b6f9SApple OSS Distributions.It Bq Er EACCES
93*bbb1b6f9SApple OSS DistributionsSearch permission is denied for any component of
94*bbb1b6f9SApple OSS Distributionsthe path name.
95*bbb1b6f9SApple OSS Distributions.\" ==========
96*bbb1b6f9SApple OSS Distributions.It Bq Er EFAULT
97*bbb1b6f9SApple OSS Distributions.Fa Path
98*bbb1b6f9SApple OSS Distributionspoints outside the process's allocated address space.
99*bbb1b6f9SApple OSS Distributions.\" ==========
100*bbb1b6f9SApple OSS Distributions.It Bq Er EIO
101*bbb1b6f9SApple OSS DistributionsAn I/O error occurred while reading from or writing to the file system.
102*bbb1b6f9SApple OSS Distributions.\" ==========
103*bbb1b6f9SApple OSS Distributions.It Bq Er ELOOP
104*bbb1b6f9SApple OSS DistributionsToo many symbolic links were encountered in translating the pathname.
105*bbb1b6f9SApple OSS DistributionsThis is taken to be indicative of a looping symbolic link.
106*bbb1b6f9SApple OSS Distributions.\" ==========
107*bbb1b6f9SApple OSS Distributions.It Bq Er ENAMETOOLONG
108*bbb1b6f9SApple OSS DistributionsA component of a pathname exceeded
109*bbb1b6f9SApple OSS Distributions.Dv {NAME_MAX}
110*bbb1b6f9SApple OSS Distributionscharacters, or an entire path name exceeded
111*bbb1b6f9SApple OSS Distributions.Dv {PATH_MAX}
112*bbb1b6f9SApple OSS Distributionscharacters.
113*bbb1b6f9SApple OSS Distributions.\" ==========
114*bbb1b6f9SApple OSS Distributions.It Bq Er ENOENT
115*bbb1b6f9SApple OSS DistributionsThe named directory does not exist.
116*bbb1b6f9SApple OSS Distributions.\" ==========
117*bbb1b6f9SApple OSS Distributions.It Bq Er ENOTDIR
118*bbb1b6f9SApple OSS DistributionsA component of the path prefix is not a directory.
119*bbb1b6f9SApple OSS Distributions.El
120*bbb1b6f9SApple OSS Distributions.Pp
121*bbb1b6f9SApple OSS Distributions.Fn fchdir
122*bbb1b6f9SApple OSS Distributionswill fail and the current working directory will be unchanged if
123*bbb1b6f9SApple OSS Distributionsone or more of the following are true:
124*bbb1b6f9SApple OSS Distributions.Bl -tag -width Er
125*bbb1b6f9SApple OSS Distributions.\" ==========
126*bbb1b6f9SApple OSS Distributions.It Bq Er EACCES
127*bbb1b6f9SApple OSS DistributionsSearch permission is denied for the directory referenced by the
128*bbb1b6f9SApple OSS Distributionsfile descriptor.
129*bbb1b6f9SApple OSS Distributions.\" ==========
130*bbb1b6f9SApple OSS Distributions.It Bq Er EBADF
131*bbb1b6f9SApple OSS DistributionsThe argument
132*bbb1b6f9SApple OSS Distributions.Fa fildes
133*bbb1b6f9SApple OSS Distributionsis not a valid file descriptor.
134*bbb1b6f9SApple OSS Distributions.\" ==========
135*bbb1b6f9SApple OSS Distributions.It Bq Er EINTR
136*bbb1b6f9SApple OSS Distributions.Fn fchdir
137*bbb1b6f9SApple OSS Distributionswas interrupted by a signal.
138*bbb1b6f9SApple OSS Distributions.\" ==========
139*bbb1b6f9SApple OSS Distributions.It Bq Er EIO
140*bbb1b6f9SApple OSS DistributionsAn I/O error occurred while reading from or writing to the file system.
141*bbb1b6f9SApple OSS Distributions.\" ==========
142*bbb1b6f9SApple OSS Distributions.It Bq Er ENOTDIR
143*bbb1b6f9SApple OSS DistributionsThe file descriptor does not reference a directory.
144*bbb1b6f9SApple OSS Distributions.El
145*bbb1b6f9SApple OSS Distributions.Sh SEE ALSO
146*bbb1b6f9SApple OSS Distributions.Xr chroot 2
147*bbb1b6f9SApple OSS Distributions.Sh STANDARDS
148*bbb1b6f9SApple OSS DistributionsThe
149*bbb1b6f9SApple OSS Distributions.Fn chdir
150*bbb1b6f9SApple OSS Distributionsis expected to conform to
151*bbb1b6f9SApple OSS Distributions.St -p1003.1-88 .
152*bbb1b6f9SApple OSS Distributions.Sh HISTORY
153*bbb1b6f9SApple OSS DistributionsThe
154*bbb1b6f9SApple OSS Distributions.Fn fchdir
155*bbb1b6f9SApple OSS Distributionsfunction call
156*bbb1b6f9SApple OSS Distributionsappeared in
157*bbb1b6f9SApple OSS Distributions.Bx 4.2 .
158