.\" This manpage is Copyright (C) 1992 Drew Eckhardt; .\" and Copyright (C) 1993 Michael Haardt, Ian Jackson. .\" and Copyright (C) 2006, 2014 Michael Kerrisk .\" .\" %%%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 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. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya .\" all rights reserved. .\" Translated Fri Dec 12 00:32:12 JST 1997 .\" by HANATAKA Shinya .\" Updated & Modifed Sat Feb 12 11:20:18 JST 2005 .\" by Yuichi SATO .\" Updated 2013-05-06, Akihiro MOTOKI .\" .TH SYMLINK 2 2014\-08\-19 Linux "Linux Programmer's Manual" .SH 名前 symlink, symlinkat \- ファイルに新しい名前を付ける .SH 書式 .nf \fB#include \fP .sp \fBint symlink(const char *\fP\fItarget\fP\fB, const char *\fP\fIlinkpath\fP\fB);\fP .sp \fB#include \fP/* AT_* 定数の定義 */ \fB#include \fP .sp \fBint symlinkat(const char *\fP\fItarget\fP\fB, int \fP\fInewdirfd\fP\fB, const char *\fP\fIlinkpath\fP\fB);\fP .sp .fi .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 .sp \fBsymlinkat\fP(): .PD 0 .ad l .RS 4 .TP 4 glibc 2.10 以降: _XOPEN_SOURCE\ >=\ 700 || _POSIX_C_SOURCE\ >=\ 200809L .TP glibc 2.10 より前: _ATFILE_SOURCE .RE .ad b .PD .SH 説明 \fBsymlink\fP() は \fItarget\fP という文字列をファイルの内容として持つ \fIlinkpath\fP というシンボリックリンク (symbolic link) を作成する。 シンボリックリンクは実行時に解釈され、 リンクの内容でパスを置き換えて、そのパスを辿ることで、 ファイルやディレクトリに到達する。 シンボリックリンクはパスの部分に \fI..\fP を含むかもしれない。これは (もしリンクの最初に使用された場合は) リンクの 存在するディレクトリの親ディレクトリが参照される。 シンボリックリンクは (ソフトリンク (soft link) とも呼ばれ) 存在するファイルを指しているかもしれないし、 存在しないファイルを指しているかもしれない; 後者の場合は壊れたリンク (dangling link) とも呼ばれる。 シンボリックリンクの許可 (permission) は無意味である; リンクを追跡する場合には所有権 (ownership) は無視される。 ただし、リンクの削除や名前の変更が要求され、かつリンクが存在する ディレクトリにスティッキービット (sticky bit) (\fBS_ISVTX\fP) が設定されている場合には、所有権のチェックが行われる。 \fIlinkpath\fP が存在する場合には上書きは\fIされない\fP。 .SS symlinkat() \fBsymlinkat\fP() システムコールは \fBsymlink\fP() と全く同様に動作するが、以下で説明する点が異なる。 \fIlinkpath\fP で指定されたパス名が相対パスの場合、このパス名はファイルディスクリプター \fInewdirfd\fP が参照するディレクトリに対する相対パスと解釈される (\fBsymlink\fP() に相対パス名を渡した場合のように、呼び出したプロセスのカレントワーキングディレクトリに対する相対パスではない)。 \fIlinkpath\fP で指定されたパス名が相対パスで、 \fInewdirfd\fP が特別な値 \fBAT_FDCWD\fP の場合、 (\fBsymlink\fP() と同様に) \fIlinkpath\fP は呼び出したプロセスのカレントワーキングディレクトリに対する相対パスと解釈される。 \fIlinkpath\fP で指定されたパス名が絶対パスの場合、 \fInewdirfd\fP は無視される。 .SH 返り値 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 \fIerrno\fP が適切に設定される。 .SH エラー .TP \fBEACCES\fP \fIlinkpath\fP を含んでいるディレクトリへの書き込みが拒否されたか、 \fIlinkpath\fP に含まれているディレクトリのどれかに検索許可が与えられていない (\fBpath_resolution\fP(7) も参照すること)。 .TP \fBEDQUOT\fP そのファイルシステムのリソース使用量がユーザークォータに達している。対象となるリソースは inode かディスクブロックで、どちらになるかはファイルシステムの実装依存である。 .TP \fBEEXIST\fP \fIlinkpath\fP が既に存在する。 .TP \fBEFAULT\fP \fItarget\fP や \fIlinkpath\fP がアクセス可能なアドレス空間の外を指している。 .TP \fBEIO\fP I/O エラーが発生した。 .TP \fBELOOP\fP \fIlinkpath\fP を解決する際に遭遇したシンボリックリンクが多過ぎる。 .TP \fBENAMETOOLONG\fP \fItarget\fP または \fIlinkpath\fP が長過ぎる。 .TP \fBENOENT\fP \fIlinkpath\fP に含まれるディレクトリ部分が存在しないか、壊れたリンクであるか、 \fItarget\fP が空文字列である。 .TP \fBENOMEM\fP 十分なカーネルメモリーがない。 .TP \fBENOSPC\fP そのファイルを含んでいるデバイスに新しいディレクトリエントリーを 作成するための空きがない。 .TP \fBENOTDIR\fP \fIlinkpath\fP に含まれるディレクトリ部分が、実際には、ディレクトリではない。 .TP \fBEPERM\fP \fIlinkpath\fP を含んでいるファイルシステム (file system) が シンボリックリンクの作成をサポートしていない。 .TP \fBEROFS\fP \fIlinkpath\fP が読み込み専用のファイルシステムに存在している。 .PP \fBsymlinkat\fP() では以下のエラーも発生する。 .TP \fBEBADF\fP \fInewdirfd\fP が有効なファイルディスクリプターでない。 .TP \fBENOENT\fP \fIlinkpath\fP が相対パス名で、 \fInewdirfd\fP が削除されたディレクトリを参照している。 .TP \fBENOTDIR\fP \fIlinkpath\fP が相対パスで、 \fInewdirfd\fP がディレクトリ以外のファイルを参照しているファイルディスクリプターである。 .SH バージョン \fBsymlinkat\fP() はカーネル 2.6.16 で Linux に追加された。 ライブラリによるサポートはバージョン 2.4 で glibc に追加された。 .SH 準拠 .\" SVr4 documents additional error codes EDQUOT and ENOSYS. .\" See .\" .BR open (2) .\" re multiple files with the same name, and NFS. \fBsymlink\fP(): SVr4, 4.3BSD, POSIX.1\-2001, POSIX.1\-2008. \fBsymlinkat\fP(): POSIX.1\-2008. .SH 注意 \fItarget\fP についてのチェックは行なわれない。 シンボリックリンクによって参照される名前を削除すると (それが他にハードリンク (hard link) を持たなければ) 実際にファイルが削除される。 この動作が望んだものでない場合は、 \fBlink\fP(2) を使用すること。 .SS "glibc での注意" \fBsymlinkat\fP() が利用できない古いカーネルでは、 glibc ラッパー関数は \fBsymlink\fP(2) を使用するモードにフォールバックする。 \fIpathname\fP が相対パスの場合、 glibc は \fInewdirfd\fP 引き数に対応する \fI/proc/self/fd\fP のシンボリックリンクに基づいてパス名を構成する。 .SH 関連項目 \fBln\fP(1), \fBlchown\fP(2), \fBlink\fP(2), \fBlstat\fP(2), \fBopen\fP(2), \fBreadlink\fP(2), \fBrename\fP(2), \fBunlink\fP(2), \fBpath_resolution\fP(7), \fBsymlink\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.79 の一部 である。プロジェクトの説明とバグ報告に関する情報は http://www.kernel.org/doc/man\-pages/ に書かれている。