Scroll to navigation

chdir(2) System Calls Manual chdir(2)

이름

chdir, fchdir - 작업 디렉토리를 바꾼다.

라이브러리

표준 C 라이브러리 (libc, -lc)

요약

#include <unistd.h>
int chdir(const char *path);
int fchdir(int fd);

Feature Test Macro Requirements for glibc (see feature_test_macros(7)):

fchdir():


_XOPEN_SOURCE >= 500
|| /* Since glibc 2.12: */ _POSIX_C_SOURCE >= 200809L
|| /* glibc up to and including 2.19: */ _BSD_SOURCE

설명

chdir() changes the current working directory of the calling process to the directory specified in path.

fchdir() is identical to chdir(); the only difference is that the directory is given as an open file descriptor.

반환값

On success, zero is returned. On error, -1 is returned, and errno is set to indicate the error.

에러

파일 시스템에 의존적이며, 다른 에러가 리턴될 수 있다. chdir()에서 발생하는 일반적인 에러는 다음과 같다:

Search permission is denied for one of the components of path. (See also path_resolution(7).)
path가 접근할 수 없는 메모리 영역을 가리키고 있다.
I/O 에러가 발생했다.
path를 찾아갈 때, 너무 많은 심볼릭 링크가 존재한다.
path 가 너무 길다.
The directory specified in path does not exist.
이용할수 있는 커널 메모리가 충분하지 않다.
path가 디렉토리가 아니다.

fchdir()에서 발생하는 일반적인 에러는 다음과 같다:

fd로 지정된 디렉토리를 여는데 허가가 거부되었다.
fd가 유효한 파일 기술자가 아니다.
fd does not refer to a directory.

표준

POSIX.1-2008.

이력

POSIX.1-2001, SVr4, 4.4BSD.

주의

The current working directory is the starting point for interpreting relative pathnames (those not starting with '/').

A child process created via fork(2) inherits its parent's current working directory. The current working directory is left unchanged by execve(2).

추가 참조

chroot(2), getcwd(3), path_resolution(7)

번역

이 매뉴얼 페이지의 한국어 번역은 다음에 의해 편집되었습니다: 정강훈 <skyeyes@soback.kornet.net>

이 번역은 무료 문서입니다. 저작권 조건에 대해서는 GNU General Public License 버전 3 이상을 읽으십시오. 책임이 없습니다.

이 매뉴얼 페이지의 번역에서 오류를 발견하면 translation-team-ko@googlegroups.com 로 이메일을 보내주십시오.

2023년 3월 30일 Linux man-pages 6.05.01