OSDN Git Service

(split) LDP: Release pages for LDP v3.39.
[linuxjm/LDP_man-pages.git] / release / man3 / ftok.3
1 .\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it)
2 .\"
3 .\" Permission is granted to make and distribute verbatim copies of this
4 .\" manual provided the copyright notice and this permission notice are
5 .\" preserved on all copies.
6 .\"
7 .\" Permission is granted to copy and distribute modified versions of this
8 .\" manual under the conditions for verbatim copying, provided that the
9 .\" entire resulting derived work is distributed under the terms of a
10 .\" permission notice identical to this one.
11 .\"
12 .\" Since the Linux kernel and libraries are constantly changing, this
13 .\" manual page may be incorrect or out-of-date.  The author(s) assume no
14 .\" responsibility for errors or omissions, or for damages resulting from
15 .\" the use of the information contained herein.  The author(s) may not
16 .\" have taken the same level of care in the production of this manual,
17 .\" which is licensed free of charge, as they might when working
18 .\" professionally.
19 .\"
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
22 .\"
23 .\" Modified 2001-11-28, by Michael Kerrisk, <mtk.manpages@gmail.com>
24 .\"     Changed data type of proj_id; minor fixes
25 .\"     aeb: further fixes; added notes.
26 .\"
27 .\"*******************************************************************
28 .\"
29 .\" This file was generated with po4a. Translate the source file.
30 .\"
31 .\"*******************************************************************
32 .TH FTOK 3 2001\-11\-28 GNU "Linux Programmer's Manual"
33 .SH 名前
34 ftok \- パス名とプロジェクト識別子を System V IPC キーに変換する
35 .SH 書式
36 .nf
37 \fB#include <sys/types.h>\fP
38 \fB#include <sys/ipc.h>\fP
39 .fi
40 .sp
41 \fBkey_t ftok(const char *\fP\fIpathname\fP\fB, int \fP\fIproj_id\fP\fB);\fP
42 .SH 説明
43 \fBftok\fP()  関数は \fIpathname\fP で与えられたファイル (存在し、アクセス可能でなければならない)  のファイル名の識別情報
44 (identity) と、 \fIproj_id\fP (0 であってはならない) の低位 8 ビットとを用いて、 \fIkey_t\fP 型の System V
45 IPC キーを生成する。 このキーは \fBmsgget\fP(2), \fBsemget\fP(2), \fBshmget\fP(2)  などでの利用に適している。
46 .LP
47 同じファイルを示すあらゆるパス名と、同じ \fIproj_id\fP に対しては、結果の値は等しくなる。 ファイルが違ったり
48 (この場合両者は同時に存在しているはず)、 \fIproj_id\fP が異なると、返り値も異なる。
49 .SH 返り値
50 成功した場合は生成された \fIkey_t\fP の値が返される。 失敗すると \-1 が返され、エラーの内容が \fBerrno\fP
51 に書き込まれる。この内容はシステムコール \fBstat\fP(2)  のものと同じである。
52 .SH 準拠
53 POSIX.1\-2001.
54 .SH 注意
55 libc4 と libc5 (および SunOS 4.x) では、 プロトタイプは以下のようになっている。
56 .sp
57 .RS
58 \fBkey_t ftok(char *\fP\fIpathname\fP\fB, char \fP\fIproj_id\fP\fB);\fP
59 .RE
60 .PP
61 現在では \fIproj_id\fP は \fIint\fP だが、依然として 8 ビットしか用いられない。 通常は ASCII キャラクタが \fIproj_id\fP
62 に用いられる。 \fIproj_id\fP が 0 のときの振る舞いが未定義になっているのは、これが理由である。
63 .LP
64 もちろん \fIkey_t\fP が他と重ならないものであるかどうかは保証されない。 最善の場合の組み合わせを考えても、 \fIproj_id\fP の 1
65 バイト、i ノード番号の低位 16 ビット、および デバイス番号の低位 8 ビットなので、結果は 32 ビットに過ぎない。 例えば
66 \fI/dev/hda1\fP と \fI/dev/sda1\fP それぞれにあるファイルに対して、衝突は容易に起こりうる。
67 .SH 関連項目
68 \fBmsgget\fP(2), \fBsemget\fP(2), \fBshmget\fP(2), \fBstat\fP(2), \fBsvipc\fP(7)