2004-11-03 13:51:07 +00:00
|
|
|
.\" Hey Emacs! This file is -*- nroff -*- source.
|
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
2007-04-12 22:42:49 +00:00
|
|
|
.\"
|
2004-11-03 13:51:07 +00:00
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
|
|
.\"
|
|
|
|
.\" Modified by Michael Haardt <michael@moria.de>
|
|
|
|
.\" Modified 1993-07-21 by Rik Faith <faith@cs.unc.edu>
|
|
|
|
.\" Modified 1995-04-15 by Michael Chastain <mec@shell.portal.com>:
|
|
|
|
.\" Added 'fchdir'. Fixed bugs in error section.
|
|
|
|
.\" Modified 1996-10-21 by Eric S. Raymond <esr@thyrsus.com>
|
|
|
|
.\" Modified 1997-08-21 by Joseph S. Myers <jsm28@cam.ac.uk>
|
2007-09-20 06:52:22 +00:00
|
|
|
.\" Modified 2004-06-23 by Michael Kerrisk <mtk.manpages@gmail.com>
|
2004-11-03 13:51:07 +00:00
|
|
|
.\"
|
2010-11-25 05:35:48 +00:00
|
|
|
.TH CHDIR 2 2010-11-25 "Linux" "Linux Programmer's Manual"
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NAME
|
|
|
|
chdir, fchdir \- change working directory
|
|
|
|
.SH SYNOPSIS
|
|
|
|
.B #include <unistd.h>
|
|
|
|
.sp
|
|
|
|
.BI "int chdir(const char *" path );
|
|
|
|
.br
|
|
|
|
.BI "int fchdir(int " fd );
|
2007-07-08 12:11:40 +00:00
|
|
|
.sp
|
|
|
|
.in -4n
|
|
|
|
Feature Test Macro Requirements for glibc (see
|
|
|
|
.BR feature_test_macros (7)):
|
|
|
|
.in
|
|
|
|
.sp
|
|
|
|
.BR fchdir ():
|
2010-09-18 03:35:48 +00:00
|
|
|
.PD 0
|
|
|
|
.ad l
|
|
|
|
.RS 4
|
|
|
|
_BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 ||
|
2010-10-04 03:04:21 +00:00
|
|
|
_XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED
|
chdir.2, chmod.2, chown.2, gethostname.2, getsid.2, pread.2, setpgid.2, sigaltstack.2, stat.2, truncate.2, wait.2, dirfd.3, getsubopt.3, mkdtemp.3, mkstemp.3, siginterrupt.3, strdup.3: Simplify feature test macro requirements
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-09-26 15:16:57 +00:00
|
|
|
.br
|
|
|
|
|| /* Since glibc 2.12: */ _POSIX_C_SOURCE\ >=\ 200809L
|
2010-09-18 03:35:48 +00:00
|
|
|
.RE
|
|
|
|
.ad
|
|
|
|
.PD
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH DESCRIPTION
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR chdir ()
|
2007-12-11 09:31:41 +00:00
|
|
|
changes the current working directory of the calling process to the
|
2007-06-12 05:23:03 +00:00
|
|
|
directory specified in
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR path .
|
|
|
|
.PP
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR fchdir ()
|
2004-11-03 13:51:07 +00:00
|
|
|
is identical to
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR chdir ();
|
2004-11-03 13:51:07 +00:00
|
|
|
the only difference is that the directory is given as an
|
|
|
|
open file descriptor.
|
|
|
|
.SH "RETURN VALUE"
|
2007-04-12 22:42:49 +00:00
|
|
|
On success, zero is returned.
|
|
|
|
On error, \-1 is returned, and
|
2004-11-03 13:51:07 +00:00
|
|
|
.I errno
|
|
|
|
is set appropriately.
|
|
|
|
.SH ERRORS
|
2007-04-12 22:42:49 +00:00
|
|
|
Depending on the file system, other errors can be returned.
|
|
|
|
The more
|
2004-11-03 13:51:07 +00:00
|
|
|
general errors for
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR chdir ()
|
2004-11-03 13:51:07 +00:00
|
|
|
are listed below:
|
|
|
|
.TP
|
|
|
|
.B EACCES
|
2007-06-12 05:23:03 +00:00
|
|
|
Search permission is denied for one of the components of
|
2004-11-03 13:51:07 +00:00
|
|
|
.IR path .
|
|
|
|
(See also
|
2007-05-26 12:41:39 +00:00
|
|
|
.BR path_resolution (7).)
|
2004-11-03 13:51:07 +00:00
|
|
|
.TP
|
|
|
|
.B EFAULT
|
|
|
|
.I path
|
|
|
|
points outside your accessible address space.
|
|
|
|
.TP
|
|
|
|
.B EIO
|
|
|
|
An I/O error occurred.
|
|
|
|
.TP
|
|
|
|
.B ELOOP
|
|
|
|
Too many symbolic links were encountered in resolving
|
|
|
|
.IR path .
|
|
|
|
.TP
|
|
|
|
.B ENAMETOOLONG
|
|
|
|
.I path
|
|
|
|
is too long.
|
|
|
|
.TP
|
|
|
|
.B ENOENT
|
|
|
|
The file does not exist.
|
|
|
|
.TP
|
|
|
|
.B ENOMEM
|
|
|
|
Insufficient kernel memory was available.
|
|
|
|
.TP
|
|
|
|
.B ENOTDIR
|
|
|
|
A component of
|
|
|
|
.I path
|
|
|
|
is not a directory.
|
|
|
|
.PP
|
|
|
|
The general errors for
|
2005-10-19 06:54:38 +00:00
|
|
|
.BR fchdir ()
|
2004-11-03 13:51:07 +00:00
|
|
|
are listed below:
|
|
|
|
.TP
|
|
|
|
.B EACCES
|
|
|
|
Search permission was denied on the directory open on
|
|
|
|
.IR fd .
|
|
|
|
.TP
|
|
|
|
.B EBADF
|
|
|
|
.I fd
|
|
|
|
is not a valid file descriptor.
|
2007-05-18 16:06:42 +00:00
|
|
|
.SH "CONFORMING TO"
|
|
|
|
SVr4, 4.4BSD, POSIX.1-2001.
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH NOTES
|
2007-06-12 05:23:03 +00:00
|
|
|
The current working directory is the starting point for interpreting
|
2008-06-09 15:49:35 +00:00
|
|
|
relative pathnames (those not starting with \(aq/\(aq).
|
2007-06-12 05:23:03 +00:00
|
|
|
|
2006-07-22 14:21:39 +00:00
|
|
|
A child process created via
|
|
|
|
.BR fork (2)
|
|
|
|
inherits its parent's current working directory.
|
|
|
|
The current working directory is left unchanged by
|
|
|
|
.BR execve (2).
|
2004-11-03 13:51:07 +00:00
|
|
|
.SH "SEE ALSO"
|
|
|
|
.BR chroot (2),
|
2007-05-26 12:41:39 +00:00
|
|
|
.BR getcwd (3),
|
2007-06-01 05:25:42 +00:00
|
|
|
.BR path_resolution (7)
|