.\" Hey Emacs! This file is -*- nroff -*- source. .\" .\" This manpage is Copyright (C) 1992 Drew Eckhardt; .\" 1993 Michael Haardt, Ian Jackson. .\" .\" 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. .\" .\" Modified 1993-07-24 by Rik Faith .\" Modified 1996-04-26 by Nick Duffek .\" Modified 1996-11-06 by Eric S. Raymond .\" Modified 1997-01-31 by Eric S. Raymond .\" Modified 2004-06-23 by Michael Kerrisk .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .TH SYMLINK 2 2010\-09\-20 Linux "Linux Programmer's Manual" .SH 名前 symlink \- ファイルに新しい名前を付ける .SH 書式 \fB#include \fP .sp \fBint symlink(const char *\fP\fIoldpath\fP\fB, const char *\fP\fInewpath\fP\fB);\fP .sp .in -4n glibc 向けの機能検査マクロの要件 (\fBfeature_test_macros\fP(7) 参照): .in .sp .ad l \fBsymlink\fP(): .RS 4 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED || _POSIX_C_SOURCE\ >=\ 200112L .RE .ad b .SH 説明 \fBsymlink\fP() は \fIoldpath\fP という文字列をファイルの内容として持つ \fInewpath\fP というシンボリックリンク (symbolic link) を作成する。 シンボリックリンクは実行時に解釈され、 リンクの内容でパスを置き換えて、そのパスを辿ることで、 ファイルやディレクトリに到達する。 シンボリックリンクはパスの部分に \fI..\fP を含むかもしれない。これは (もしリンクの最初に使用された場合は) リンクの 存在するディレクトリの親ディレクトリが参照される。 シンボリックリンクは (ソフトリンク (soft link) とも呼ばれ) 存在するファイルを指しているかもしれないし、 存在しないファイルを指しているかもしれない; 後者の場合は壊れたリンク (dangling link) とも呼ばれる。 シンボリックリンクの許可 (permission) は無意味である; リンクを追跡する場合には所有権 (ownership) は無視される。 ただし、リンクの削除や名前の変更が要求され、かつリンクが存在する ディレクトリにスティッキービット (sticky bit) (\fBS_ISVTX\fP) が設定されている場合には、所有権のチェックが行われる。 \fInewpath\fP が存在する場合には上書きは\fIされない\fP。 .SH 返り値 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。 .SH エラー .TP \fBEACCES\fP \fInewpath\fP を含んでいるディレクトリへの書き込みが拒否されたか、 \fInewpath\fP に含まれているディレクトリのどれかに検索許可が与えられていない (\fBpath_resolution\fP(7) も参照すること)。 .TP \fBEEXIST\fP \fInewpath\fP が既に存在する。 .TP \fBEFAULT\fP \fIoldpath\fP や \fInewpath\fP がアクセス可能なアドレス空間の外を指している。 .TP \fBEIO\fP I/O エラーが発生した。 .TP \fBELOOP\fP \fInewpath\fP を解決する際に遭遇したシンボリックリンクが多過ぎる。 .TP \fBENAMETOOLONG\fP \fIoldpath\fP または \fInewpath\fP が長過ぎる。 .TP \fBENOENT\fP \fInewpath\fP に含まれるディレクトリ部分が存在しないか、壊れたリンクであるか、 \fIoldpath\fP が空文字列である。 .TP \fBENOMEM\fP 十分なカーネルメモリーがない。 .TP \fBENOSPC\fP そのファイルを含んでいるデバイスに新しいディレクトリエントリを 作成するための空きがない。 .TP \fBENOTDIR\fP \fInewpath\fP に含まれるディレクトリ部分が、実際には、ディレクトリではない。 .TP \fBEPERM\fP \fInewpath\fP を含んでいるファイルシステム (file system) が シンボリックリンクの作成をサポートしていない。 .TP \fBEROFS\fP \fInewpath\fP が読み込み専用のファイルシステムに存在している。 .SH 準拠 .\" SVr4 documents additional error codes EDQUOT and ENOSYS. .\" See .\" .BR open (2) .\" re multiple files with the same name, and NFS. SVr4, 4.3BSD, POSIX.1\-2001. .SH 注意 \fIoldpath\fP についてのチェックは行なわれない。 symlink によって参照される名前を削除すると (それが他にハードリンク (hard link) を持たなければ) 実際にファイルが削除される。 この動作が望んだものでない場合は、 \fBlink\fP(2) を使用すること。 .SH 関連項目 \fBln\fP(1), \fBlchown\fP(2), \fBlink\fP(2), \fBlstat\fP(2), \fBopen\fP(2), \fBreadlink\fP(2), \fBrename\fP(2), \fBsymlinkat\fP(2), \fBunlink\fP(2), \fBpath_resolution\fP(7), \fBsymlink\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.41 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。