.\" Copyright (c) 1983, 1991, 1993 .\" The Regents of the University of California. All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by the University of .\" California, Berkeley and its contributors. .\" 4. Neither the name of the University nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .\" @(#)readlink.2 8.1 (Berkeley) 6/4/93 .\" %FreeBSD: src/lib/libc/sys/readlink.2,v 1.13 2002/12/19 09:40:25 ru Exp % .\" .\" $FreeBSD$ .Dd June 4, 1993 .Dt READLINK 2 .Os .Sh 名称 .Nm readlink .Nd シンボリックリンクの値を読み取る .Sh ライブラリ .Lb libc .Sh 書式 .In unistd.h .Ft int .Fn readlink "const char *path" "char *buf" "int bufsiz" .Sh 解説 .Fn readlink システムコールは、 .Fa bufsiz サイズであるバッファ .Fa buf 内にシンボリックリンク .Fa path の内容を配置します。 .Fn readlink システムコールは .Fa buf の末尾に .Dv NUL 文字を追加しません。 .Sh 戻り値 呼び出しが正常に完了した場合、バッファ内に配置した文字数を返します。 エラーが起きた場合は -1 を返し、エラーコードがグローバル変数 .Va errno に設定されます。 .Sh エラー .Fn readlink システムコールは次の場合に失敗します: .Bl -tag -width Er .It Bq Er ENOTDIR パスの構成要素中にディレクトリ以外のものが含まれています。 .It Bq Er ENAMETOOLONG パス名の構成要素が 255 文字を越えているか、 またはパス名全体が 1023 文字を越えています。 .It Bq Er ENOENT 指定されたファイルが存在しません。 .It Bq Er EACCES 指定されたパスには、検索が許可されていないディレクトリが含まれています。 .It Bq Er ELOOP パス名を変換するときに検出されたシンボリックリンクが多すぎます。 .It Bq Er EINVAL 指定のファイルがシンボリックリンクではありません。 .It Bq Er EIO ファイルシステムから読み取る間に入出力エラーが発生しました。 .It Bq Er EFAULT .Fa buf 引数が、プロセスに割り当てられたアドレス空間の範囲外を指しています。 .El .Sh 関連項目 .Xr lstat 2 , .Xr stat 2 , .Xr symlink 2 , .Xr symlink 7 .Sh 歴史 .Fn readlink システムコールは .Bx 4.2 で登場しました。