.\" 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 .\" .\" 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 .\" .\"WORD: symbolic link シンボリック・リンク .\"WORD: directory ディレクトリ .\"WORD: soft link ソフト・リンク .\"WORD: hard link ハード・リンク .\"WORD: dangling link 壊れたリンク .\"WORD: sticky bit スティッキー・ビット .\"WORD: ownership 所有権 .\"WORD: file system ファイル・システム .\"WORD: effective uid 実効ユーザーID .\"WORD: kernel カーネル .\"WORD: entry エントリ .\" .TH SYMLINK 2 2010-09-20 "Linux" "Linux Programmer's Manual" .SH 名前 symlink \- ファイルに新しい名前を付ける .SH 書式 .B #include .sp .BI "int symlink(const char *" oldpath ", const char *" newpath ); .sp .in -4n glibc 向けの機能検査マクロの要件 .RB ( feature_test_macros (7) 参照): .in .sp .ad l .BR symlink (): .RS 4 _BSD_SOURCE || _XOPEN_SOURCE\ >=\ 500 || _XOPEN_SOURCE\ &&\ _XOPEN_SOURCE_EXTENDED || _POSIX_C_SOURCE\ >=\ 200112L .RE .ad b .SH 説明 .BR symlink () は .I oldpath という文字列をファイルの内容として持つ .I newpath というシンボリック・リンク (symbolic link) を作成する。 シンボリック・リンクは実行時に解釈され、 リンクの内容でパスを置き換えて、そのパスを辿ることで、 ファイルやディレクトリに到達する。 シンボリック・リンクはパスの部分に .I .. を含むかもしれない。これは (もしリンクの最初に使用された場合は) リンクの 存在するディレクトリの親ディレクトリが参照される。 シンボリック・リンクは (ソフト・リンク (soft link) とも呼ばれ) 存在するファイルを指しているかもしれないし、 存在しないファイルを指しているかもしれない; 後者の場合は壊れたリンク (dangling link) とも呼ばれる。 シンボリック・リンクの許可 (permission) は無意味である; リンクを追跡する場合には所有権 (ownership) は無視される。 ただし、リンクの削除や名前の変更が要求され、かつリンクが存在する ディレクトリにスティッキー・ビット (sticky bit) .RB ( S_ISVTX ) が設定されている場合には、所有権のチェックが行われる。 .I newpath が既に存在する場合には上書きは\fBされない\fR。 .SH 返り値 成功した場合には 0 を返す。エラーの場合には \-1 を返し、 .I errno が適切に設定される。 .SH エラー .TP .B EACCES .I newpath を含んでいるディレクトリへの書き込みが拒否されたか、 .I newpath に含まれているディレクトリのどれかに検索許可が与えられていない .RB ( path_resolution (7) も参照すること)。 .TP .B EEXIST .I newpath が既に存在している。 .TP .B EFAULT .IR oldpath " や " newpath " がアクセス可能なアドレス空間の外を指している。" .TP .B EIO I/O エラーが発生した。 .TP .B ELOOP .I newpath を解決する際に遭遇したシンボリック・リンクが多過ぎる。 .TP .B ENAMETOOLONG .IR oldpath " または " newpath " が長過ぎる。" .TP .B ENOENT .I newpath に含まれるディレクトリ部分が存在しないか、壊れたリンクであるか、 .I oldpath が空文字列である。 .TP .B ENOMEM 十分なカーネル (kernel) のメモリーがない。 .TP .B ENOSPC ファイルが含まれているデバイスに新しいディレクトリ・エントリ (directory entry) を作成するだけの十分な容量がない。 .TP .B ENOTDIR .I newpath に含まれるディレクトリ部分が、実際には、ディレクトリではない。 .TP .B EPERM .I newpath を含んでいるファイル・システム (file system) が シンボリック・リンクの作成をサポートしていない。 .TP .B EROFS .I newpath が読み込み専用のファイル・システムに存在している。 .SH 準拠 SVr4, 4.3BSD, POSIX.1-2001. .\" SVr4 には他に EDQUOT, ENOSYS エラーについての記述がある。 .\" .BR open (2) .\" を見て、同じ名前の重複と NFS について参照すること。 .SH 注意 .I oldpath についてのチェックは行なわれない。 symlink によって参照される名前を削除すると (それが他にハード・リンク (hard link) を持たなければ) 実際にファイルが削除される。 この動作が望んだものでない場合は、 .BR link (2) を使用すること。 .SH 関連項目 .BR ln (1), .BR lchown (2), .BR link (2), .BR lstat (2), .BR open (2), .BR readlink (2), .BR rename (2), .BR symlinkat (2), .BR unlink (2), .BR path_resolution (7), .BR symlink (7)