.\" 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-23 by Rik Faith .\" Modified 1994-08-21 by Michael Haardt .\" Modified 2004-06-23 by Michael Kerrisk .\" Modified 2005-04-04, as per suggestion by Michael Hardt for rename.2 .\" .\" Japanese Version Copyright (c) 1997 HANATAKA Shinya .\" all rights reserved. .\" Translated Thu Dec 11 23:47:55 JST 1997 .\" by HANATAKA Shinya .\" Updated & Modified Tue Feb 8 06:36:08 JST 2005 .\" by Yuichi SATO .\" Updated & Modified Fri Apr 22 02:05:00 JST 2005 by Yuichi SATO .\" Updated 2008-09-07, Akihiro MOTOKI , LDP v3.08 .\" .\"WORD: link リンク .\"WORD: hard link ハード・リンク .\"WORD: overwrite 上書き .\"WORD: permission 許可(permission) .\"WORD: ownership 所有者(ownership) .\"WORD: file system ファイル・システム .\"WORD: effective uid 実効ユーザーID .\"WORD: kernel カーネル .\"WORD: symbolic link シンボリック・リンク .\"WORD: dangling symbolic link 壊れたシンボリック・リンク .\"WORD: directory entry ディレクトリ・エントリ .\" .TH LINK 2 2008-08-21 "Linux" "Linux Programmer's Manual" .\"O .SH NAME .SH 名前 .\"O link \- make a new name for a file link \- ファイルの新しい名前を作成する .\"O .SH SYNOPSIS .SH 書式 .B #include .sp .BI "int link(const char *" oldpath ", const char *" newpath ); .\"O .SH DESCRIPTION .SH 説明 .\"O .BR link () .\"O creates a new link (also known as a hard link) to an existing file. .BR link () は存在するファイルへの新しいリンク (link) (ハード・リンク (hard link) ともいう) を作成する。 .\"O If .\"O .I newpath .\"O exists it will .\"O .I not .\"O be overwritten. .I newpath が存在する場合には上書きは\fIされない\fR。 .\"O This new name may be used exactly as the old one for any operation; .\"O both names refer to the same file (and so have the same permissions .\"O and ownership) and it is impossible to tell which name was the .\"O original. この新しい名前は全ての操作において古い名前と完全に同じように使用される; 両方の名前は同じファイルを参照しており (それで同じ許可 (permission) や所有者 (ownership) となるので)、 どちらの名前が本来のものであるか判別できない。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O On success, zero is returned. .\"O On error, \-1 is returned, and .\"O .I errno .\"O is set appropriately. 成功した場合は 0 が返される。エラーの場合は \-1 が返され、 .I errno が適切に設定される。 .\"O .SH ERRORS .SH エラー .TP .B EACCES .\"O Write access to the directory containing .\"O .I newpath .\"O is denied, or search permission is denied for one of the directories .\"O in the path prefix of .\"O .I oldpath .\"O or .\"O .IR newpath . .\"O (See also .\"O .BR path_resolution (7).) .I newpath を含んでいるディレクトリへの書き込みが許されていないか、 .I oldpath または .I newpath へのディレクトリのどれかに検索許可がない .RB ( path_resolution (7) を参照)。 .TP .B EEXIST .\"O .I newpath .\"O already exists. .I newpath が既に存在する。 .TP .B EFAULT .\"O .IR oldpath " or " newpath " points outside your accessible address space." .IR oldpath " または " newpath " がアクセス可能なアドレス空間の外を指している。 .TP .B EIO .\"O An I/O error occurred. I/O エラーが発生した。 .TP .B ELOOP .\"O Too many symbolic links were encountered in resolving .\"O .IR oldpath " or " newpath . .IR oldpath " または " newpath を解決する際に遭遇したシンボリック・リンクが多過ぎる。 .TP .B EMLINK .\"O The file referred to by .\"O .I oldpath .\"O already has the maximum number of links to it. .I oldpath によって参照されるファイルは 既に最大数までのリンクを持っている。 .TP .B ENAMETOOLONG .\"O .IR oldpath " or " newpath " was too long." .IR oldpath " または " newpath " が長過ぎる。 .TP .B ENOENT .\"O A directory component in .\"O .IR oldpath " or " newpath .\"O does not exist or is a dangling symbolic link. .IR oldpath " または " newpath のディレクトリ部分が存在しないか、 壊れた(dangling)シンボリック・リンクである。 .TP .B ENOMEM .\"O Insufficient kernel memory was available. カーネルに十分なメモリがない。 .TP .B ENOSPC .\"O The device containing the file has no room for the new directory .\"O entry. そのファイルを含んでいるデバイスに新しいディレクトリ・エントリを 作成するための空きがない。 .TP .B ENOTDIR .\"O A component used as a directory in .\"O .IR oldpath " or " newpath .\"O is not, in fact, a directory. .IR oldpath " または " newpath のディレクトリ部分が、実際には、ディレクトリでない。 .TP .B EPERM .\"O .I oldpath .\"O is a directory. .I oldpath がディレクトリである。 .TP .B EPERM .\"O The file system containing .\"O .IR oldpath " and " newpath .\"O does not support the creation of hard links. .IR oldpath " と " newpath を含んでいるファイル・システムがハード・リンクをサポートしていない。 .TP .B EROFS .\"O The file is on a read-only file system. ファイルが読み込み専用のファイル・システムに存在する。 .TP .B EXDEV .\"O .IR oldpath " and " newpath .\"O are not on the same mounted file system. .IR oldpath " と " newpath が同じマウントされたファイル・システムに存在しない。 .\"O (Linux permits a file system to be mounted at multiple points, but .\"O .BR link () .\"O does not work across different mount points, .\"O even if the same file system is mounted on both.) (Linux は 1 つのファイル・システムを複数のマウント位置に マウントすることを許可している。 しかし .BR link () は、たとえ同じファイル・システムであっても、 別々のマウント位置を跨いでは動作しない。) .\"O .SH "CONFORMING TO" .SH 準拠 .\"O SVr4, 4.3BSD, POSIX.1-2001 (but see NOTES) .\"O .\" SVr4 documents additional ENOLINK and .\"O .\" EMULTIHOP error conditions; POSIX.1 does not document ELOOP. .\"O .\" X/OPEN does not document EFAULT, ENOMEM or EIO. SVr4, 4.3BSD, POSIX.1-2001 (但し「注意」を参照)。 .\" SVr4 は他に ENOLINK, EMULTIHOP エラー状態についても記述している。 .\" POSIX.1 には ELOOP についての記述はない。 .\" X/OPEN には EFAULT, ENOMEM, EIO についての記述はない。 .\"O .SH NOTES .SH 注意 .\"O Hard links, as created by .\"O .BR link (), .\"O cannot span file systems. .\"O Use .\"O .BR symlink (2) .\"O if this is required. .BR link () でファイル・システムを超えてハード・リンクを作成することはできない。 このような場合は .BR symlink (2) を使用すること。 .\"O POSIX.1-2001 says that .\"O .BR link () .\"O should dereference .\"O .I oldpath .\"O if it is a symbolic link. POSIX.1-2001 では、 .I oldpath がシンボリック・リンクである場合、 .BR link () は .I oldpath の参照を解決すべきであると記述されている。 .\"O However, since kernel 2.0, .\"O .\" more precisely: since kernel 1.3.56 .\"O Linux does not do so: if .\"O .I oldpath .\"O is a symbolic link, then .\"O .I newpath .\"O is created as a (hard) link to the same symbolic link file しかし、カーネル 2.0 以降の .\" 正確にはカーネル 1.3.56 以降 Linux ではそのようになっていない。 .I oldpath がシンボリック・リンクである場合、 .I newpath は同じシンボリック・リンクファイルへの (ハード) リンクとして作成される .\"O (i.e., .\"O .I newpath .\"O becomes a symbolic link to the same file that .\"O .I oldpath .\"O refers to). (つまり .I newpath は .I oldpath が参照していた同じファイルへのシンボリックリンクになる)。 .\"O Some other implementations behave in the same manner as Linux. 他のいくつかの実装でも Linux と同じように動作する。 .\"O .\" For example, the default Solaris compilation environment .\"O .\" behaves like Linux, and contributors to a March 2005 .\"O .\" thread in the Austin mailing list reported that some .\"O .\" other (System V) implementations did/do the same -- MTK, Apr 05 .\" 例えば、デフォルトの Solaris のコンパイル環境では .\" Linux と同じように動作する。そして Austin メーリングリストの .\" 2005 年 3 月のスレッドに投稿した人たちは、 .\" その他のいくつかの (System V) 実装でも同じであった/ある、 .\" と報告している -- MTK, Apr 05 .\"O POSIX.1-2008 changes the specification of .\"O .BR link (), .\"O making it implementation-dependent whether or not .\"O .I oldpath .\"O is dereferenced if it is a symbolic link. .\"O For precise control over the treatment of symbolic links when .\"O creating a link, see .\"O .BR linkat (2). POSIX.1-2008 では .BR link () の仕様が変更され、 .I oldpath がシンボリック・リンクの場合にシンボリック・リンクの参照を 解決するかどうかは実装依存となった。 リンク作成時のシンボリック・リンクの扱いについての詳細な制御に 関しては .BR linkat (2) を参照のこと。 .\"O .SH BUGS .SH バグ .\"O On NFS file systems, the return code may be wrong in case the NFS server .\"O performs the link creation and dies before it can say so. .\"O Use .\"O .BR stat (2) .\"O to find out if the link got created. NFS ファイル・システムでは、NFS サーバーがリンクを作成した後に、 それを伝える前に死んだ場合には返り値が不正な場合がある。 リンクが作成できたかどうか見つけるためには .BR stat (2) を使用すること。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR ln (1), .BR linkat (2), .BR open (2), .BR rename (2), .BR stat (2), .BR symlink (2), .BR unlink (2), .BR path_resolution (7), .BR symlink (7)