.\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it) .\" .\" 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 2001-11-28, by Michael Kerrisk, .\" Changed data type of proj_id; minor fixes .\" aeb: further fixes; added notes. .\" .\" 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 2001-11-28 "Linux" "Linux Programmer's Manual" .\"O .SH NAME .\"O ftok \- convert a pathname and a project identifier to a System V IPC key .SH 名前 ftok \- パス名とプロジェクト識別子を System V IPC キーに変換する .\"O .SH SYNOPSIS .SH 書式 .nf .B #include .B #include .fi .sp .BI "key_t ftok(const char *" pathname ", int " proj_id ); .\"O .SH DESCRIPTION .SH 説明 .\"O The .\"O .BR ftok () .\"O function uses the identity of the file named by the given .\"O .I pathname .\"O (which must refer to an existing, accessible file) .\"O and the least significant 8 bits of .\"O .I proj_id .\"O (which must be nonzero) to generate a .\"O .I key_t .\"O type System V IPC key, suitable for use with .\"O .BR msgget (2), .\"O .BR semget (2), .\"O or .\"O .BR shmget (2). .BR ftok () 関数は .I pathname で与えられたファイル (存在し、アクセス可能でなければならない) のファイル名の識別情報 (identity) と、 .I proj_id (0 であってはならない) の低位 8 ビットとを用いて、 .I key_t 型の System V IPC キーを生成する。 このキーは .BR msgget (2), .BR semget (2), .BR shmget (2) などでの利用に適している。 .LP .\"O The resulting value is the same for all pathnames that .\"O name the same file, when the same value of .\"O .I proj_id .\"O is used. .\"O The value returned should be different when the .\"O (simultaneously existing) files or the project IDs differ. 同じファイルを示すあらゆるパス名と、同じ .I proj_id に対しては、結果の値は等しくなる。 ファイルが違ったり (この場合両者は同時に存在しているはず)、 .I proj_id が異なると、返り値も異なる。 .\"O .SH "RETURN VALUE" .SH 返り値 .\"O On success, the generated .\"O .I key_t .\"O value is returned. .\"O On failure \-1 is returned, with .\"O .I errno .\"O indicating the error as for the .\"O .BR stat (2) .\"O system call. 成功した場合は生成された .I key_t の値が返される。 失敗すると \-1 が返され、エラーの内容が .B errno に書き込まれる。この内容はシステムコール .BR stat (2) のものと同じである。 .\"O .SH "CONFORMING TO" .SH 準拠 POSIX.1-2001. .\"O .SH NOTES .SH 注意 .\"O Under libc4 and libc5 (and under SunOS 4.x) the prototype was: libc4 と libc5 (および SunOS 4.x) では、 プロトタイプは以下のようになっている。 .sp .RS .BI "key_t ftok(char *" pathname ", char " proj_id ); .RE .PP .\"O Today .\"O .I proj_id .\"O is an .\"O .IR int , .\"O but still only 8 bits are used. .\"O Typical usage has an ASCII character .\"O .IR proj_id , .\"O that is why the behavior is said to be undefined when .\"O .I proj_id .\"O is zero. 現在では .I proj_id は .I int だが、依然として 8 ビットしか用いられない。 通常は ASCII キャラクタが .I proj_id に用いられる。 .I proj_id が 0 のときの振る舞いが未定義になっているのは、これが理由である。 .LP .\"O Of course no guarantee can be given that the resulting .\"O .I key_t .\"O is unique. .\"O Typically, a best effort attempt combines the given .\"O .I proj_id .\"O byte, the lower 16 bits of the inode number, and the .\"O lower 8 bits of the device number into a 32-bit result. .\"O Collisions may easily happen, for example between files on .\"O .I /dev/hda1 .\"O and files on .\"O .IR /dev/sda1 . もちろん .I key_t が他と重ならないものであるかどうかは保証されない。 最善の場合の組み合わせを考えても、 .I proj_id の 1 バイト、i ノード番号の低位 16 ビット、および デバイス番号の低位 8 ビットなので、結果は 32 ビットに過ぎない。 例えば .I /dev/hda1 と .I /dev/sda1 それぞれにあるファイルに対して、衝突は容易に起こりうる。 .\"O .SH "SEE ALSO" .SH 関連項目 .BR msgget (2), .BR semget (2), .BR shmget (2), .BR stat (2), .BR svipc (7)