.\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it) .\" .\" %%%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 2001-11-28, by Michael Kerrisk, .\" Changed data type of proj_id; minor fixes .\" aeb: further fixes; added notes. .\" .\"******************************************************************* .\" .\" This file was generated with po4a. Translate the source file. .\" .\"******************************************************************* .\" .\" Japanese Version Copyright (c) 1998 NAKANO Takeo all rights reserved. .\" Translated Tue Apr 28 1998 by NAKANO Takeo .\" Updated Sun 6 Jan 2002 by NAKANO Takeo .\" .TH FTOK 3 2020\-04\-11 GNU "Linux Programmer's Manual" .SH 名前 ftok \- パス名とプロジェクト識別子を System V IPC キーに変換する .SH 書式 .nf \fB#include \fP \fB#include \fP .fi .PP \fBkey_t ftok(const char *\fP\fIpathname\fP\fB, int \fP\fIproj_id\fP\fB);\fP .SH 説明 \fBftok\fP() 関数は \fIpathname\fP で与えられたファイル (存在し、アクセス可能でなければならない) のファイル名の識別情報 (identity) と、 \fIproj_id\fP (0 であってはならない) の低位 8 ビットとを用いて、 \fIkey_t\fP 型の System V IPC キーを生成する。 このキーは \fBmsgget\fP(2), \fBsemget\fP(2), \fBshmget\fP(2) などでの利用に適している。 .PP 同じファイルを示すあらゆるパス名と、同じ \fIproj_id\fP に対しては、結果の値は等しくなる。 ファイルが違ったり (この場合両者は同時に存在しているはず)、 \fIproj_id\fP が異なると、返り値も異なる。 .SH 返り値 成功した場合は生成された \fIkey_t\fP の値が返される。 失敗すると \-1 が返され、エラーの内容が \fBerrno\fP に書き込まれる。この内容はシステムコール \fBstat\fP(2) のものと同じである。 .SH 属性 この節で使用されている用語の説明については、 \fBattributes\fP(7) を参照。 .TS allbox; lb lb lb l l l. インターフェース 属性 値 T{ \fBftok\fP() T} Thread safety MT\-Safe .TE .SH 準拠 POSIX.1\-2001, POSIX.1\-2008. .SH 注意 いくつかの古いシステムでは、プロトタイプは以下のようになっていた。 .PP .in +4n .EX \fBkey_t ftok(char *\fP\fIpathname\fP\fB, char \fP\fIproj_id\fP\fB);\fP .EE .in .PP 現在では \fIproj_id\fP は \fIint\fP だが、依然として 8 ビットしか用いられない。 通常は ASCII キャラクターが \fIproj_id\fP に用いられる。 \fIproj_id\fP が 0 のときの振る舞いが未定義になっているのは、これが理由である。 .PP もちろん \fIkey_t\fP が他と重ならないものであるかどうかは保証されない。 最善の場合の組み合わせを考えても、 \fIproj_id\fP の 1 バイト、i ノード番号の低位 16 ビット、および デバイス番号の低位 8 ビットなので、結果は 32 ビットに過ぎない。 例えば \fI/dev/hda1\fP と \fI/dev/sda1\fP それぞれにあるファイルに対して、衝突は容易に起こりうる。 .SH 例 \fBsemget\fP(2) を参照。 .SH 関連項目 \fBmsgget\fP(2), \fBsemget\fP(2), \fBshmget\fP(2), \fBstat\fP(2), \fBsysvipc\fP(7) .SH この文書について この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 5.10 の一部である。プロジェクトの説明とバグ報告に関する情報は \%https://www.kernel.org/doc/man\-pages/ に書かれている。