.\" Copyright (c) 1992 Drew Eckhardt (drew@cs.colorado.edu), March 28, 1992 .\" .\" %%%LICENSE_START(VERBATIM) .\" 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. .\" .\" 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. .\" .\" Formatted or processed versions of this manual, if unaccompanied by .\" the source, must acknowledge the copyright and authors of this work. .\" %%%LICENSE_END .\" .\" Modified by Michael Haardt .\" Modified 1993-07-21 by Rik Faith .\" Modified 1995-04-15 by Michael Chastain : .\" Added 'fchdir'. Fixed bugs in error section. .\" Modified 1996-10-21 by Eric S. Raymond .\" Modified 1997-08-21 by Joseph S. Myers .\" Modified 2004-06-23 by Michael Kerrisk .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1996 Yosiaki Yanagihara .\" all rights reserved. .\" Translated 1996-06-24, Yosiaki Yanagihara .\" Modified 1997-12-13, HANATAKA Shinya .\" Updated & Modified 2005-02-05, Yuichi SATO .\" Updated 2006-08-12, Akihiro MOTOKI , LDP v2.39 .\" Updated 2007-09-04, Akihiro MOTOKI , LDP v2.64 .\" .TH CHDIR 2 2010\-11\-25 Linux "Linux Programmer's Manual" .SH 名前 chdir, fchdir \- 作業ディレクトリの変更 .SH 書式 \fB#include \fP .sp \fBint chdir(const char *\fP\fIpath\fP\fB);\fP .br \fBint fchdir(int \fP\fIfd\fP\fB);\fP .sp .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp \fBfchdir\fP(): .PD 0 .ad l .RS 4 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED .br || /* glibc 2.12 以降: */ _POSIX_C_SOURCE\ >=\ 200809L .RE .ad .PD .SH 説明 \fBchdir\fP() は、呼び出し元プロセスの現在の作業ディレクトリ (current working directory) を、 \fIpath\fP に指定されたディレクトリに変更する。 .PP \fBfchdir\fP() は、ディレクトリがオープンされたファイルディスクリプターとして 指定される以外は、 \fBchdir\fP() と同じである。 .SH 返り値 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。 .SH エラー ファイルシステムによっては他のエラーが返される事がある。 \fBchdir\fP() で一般的なエラーを以下に挙げる: .TP \fBEACCES\fP \fIpath\fP の構成要素のいずれかに検索許可 (search permission) がない (\fBpath_resolution\fP(7) も参照すること)。 .TP \fBEFAULT\fP \fIpath\fP がアクセスできるアドレス空間外を指している。 .TP \fBEIO\fP I/O エラーが発生した。 .TP \fBELOOP\fP \fIpath\fP を解決する際に遭遇したシンボリックリンクが多過ぎる。 .TP \fBENAMETOOLONG\fP \fIpath\fP が長過ぎる。 .TP \fBENOENT\fP ファイルが存在しない。 .TP \fBENOMEM\fP カーネルに十分なメモリーがない。 .TP \fBENOTDIR\fP \fIpath\fP の構成要素がディレクトリではない。 .PP \fBfchdir\fP() で一般的なエラーを以下に挙げる: .TP \fBEACCES\fP \fIfd\fP をディレクトリとしてオープンするための検索許可がない。 .TP \fBEBADF\fP \fIfd\fP が適切なファイルディスクリプターでない。 .SH 準拠 SVr4, 4.4BSD, POSIX.1\-2001. .SH 注意 現在の作業ディレクトリは、相対パス名 (\(aq/\(aq) で始まっていないパス名) を 解釈する際の開始点である。 \fBfork\fP(2) で作成された子プロセスは、親プロセスの現在の作業ディレクトリを 継承する。 \fBexecve\fP(2) の前後で、現在の作業ディレクトリは変更されない。 .SH 関連項目 \fBchroot\fP(2), \fBgetcwd\fP(3), \fBpath_resolution\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。