.\" Copyright (c) 1980, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)chdir.2 8.2 (Berkeley) 12/11/93 .\" .TH CHDIR 2 "26 January 1997" GNO "System Calls" .SH NAME .BR chdir , .BR fchdir \- change current working directory .SH SYNOPSIS #include .sp 1 int \fBchdir\fR (const char *\fIpath\fR); .br int \fBfchdir\fR (int \fIfd\fR); .SH DESCRIPTION The .I path argument points to the pathname of a directory. The .BR chdir function causes the named directory to become the current working directory, that is, the starting point for path searches of pathnames not beginning with a slash .RB ( / ), a colon .RB ( : ), or a device name. .LP The .BR fchdir function causes the directory referenced by .I fd to become the current working directory, the starting point for path searches of pathnames not beginning with a slash .RB ( / ), a colon .RB ( : ), or a device name. .LP Under GNO, these calls are wrappers to the GS/OS .BR SetPrefix call. If the length of .IR path is equal to or less than 64 characters, both GS/OS prefix 0 (zero) and 8 will be set. If the length of .IR path is over 64 characters, then GS/OS prefix 0 is set to a zero length string and prefix 8 is set to the value of .IR path . .LP If an error occurs in setting prefix 8 or both prefixes 0 and 8, then neither prefix will be set and these calls fail. If the setting of prefix 8 succeeds but an error occurs when setting prefix 0, then prefix 0 is set to a zero length string. In the latter case these calls are considered to have succeeded. .LP In order for a directory to become the current directory, a process must have execute (search) access to the directory. .SH RETURN VALUES Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and .IR errno is set to indicate the error. .SH SEE ALSO .BR chroot (2) .SH STANDARDS .BR chdir is expected to conform to IEEE Std 1003.1-1988 (POSIX). .SH HISTORY The .BR fchdir function call appeared in 4.2BSD.