OSDN Git Service

75afe1ad30c59a8dd5daa71442987119e221cc93
[linuxjm/LDP_man-pages.git] / draft / 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 .\" Japanese Version Copyright (c) 1998 NAKANO Takeo all rights reserved.
28 .\" Translated Tue Apr 28 1998 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
29 .\" Updated Sun 6 Jan 2002 by NAKANO Takeo
30 .\"
31 .TH FTOK 3 2001-11-28 "Linux" "Linux Programmer's Manual"
32 .\"O .SH NAME
33 .\"O ftok \- convert a pathname and a project identifier to a System V IPC key
34 .SH 名前
35 ftok \- パス名とプロジェクト識別子を System V IPC キーに変換する
36 .\"O .SH SYNOPSIS
37 .SH 書式
38 .nf
39 .B #include <sys/types.h>
40 .B #include <sys/ipc.h>
41 .fi
42 .sp
43 .BI "key_t ftok(const char *" pathname ", int " proj_id );
44 .\"O .SH DESCRIPTION
45 .SH 説明
46 .\"O The
47 .\"O .BR ftok ()
48 .\"O function uses the identity of the file named by the given
49 .\"O .I pathname
50 .\"O (which must refer to an existing, accessible file)
51 .\"O and the least significant 8 bits of
52 .\"O .I proj_id
53 .\"O (which must be nonzero) to generate a
54 .\"O .I key_t
55 .\"O type System V IPC key, suitable for use with
56 .\"O .BR msgget (2),
57 .\"O .BR semget (2),
58 .\"O or
59 .\"O .BR shmget (2).
60 .BR ftok ()
61 関数は
62 .I pathname
63 で与えられたファイル (存在し、アクセス可能でなければならない)
64 のファイル名の識別情報 (identity) と、
65 .I proj_id
66 (0 であってはならない) の低位 8 ビットとを用いて、
67 .I key_t
68 型の System V IPC キーを生成する。
69 このキーは
70 .BR msgget (2),
71 .BR semget (2),
72 .BR shmget (2)
73 などでの利用に適している。
74 .LP
75 .\"O The resulting value is the same for all pathnames that
76 .\"O name the same file, when the same value of
77 .\"O .I proj_id
78 .\"O is used.
79 .\"O The value returned should be different when the
80 .\"O (simultaneously existing) files or the project IDs differ.
81 同じファイルを示すあらゆるパス名と、同じ
82 .I proj_id
83 に対しては、結果の値は等しくなる。
84 ファイルが違ったり (この場合両者は同時に存在しているはず)、
85 .I proj_id
86 が異なると、返り値も異なる。
87 .\"O .SH "RETURN VALUE"
88 .SH 返り値
89 .\"O On success, the generated
90 .\"O .I key_t
91 .\"O value is returned.
92 .\"O On failure \-1 is returned, with
93 .\"O .I errno
94 .\"O indicating the error as for the
95 .\"O .BR stat (2)
96 .\"O system call.
97 成功した場合は生成された
98 .I key_t
99 の値が返される。
100 失敗すると \-1 が返され、エラーの内容が
101 .B errno
102 に書き込まれる。この内容はシステムコール
103 .BR stat (2)
104 のものと同じである。
105 .\"O .SH "CONFORMING TO"
106 .SH 準拠
107 POSIX.1-2001.
108 .\"O .SH NOTES
109 .SH 注意
110 .\"O Under libc4 and libc5 (and under SunOS 4.x) the prototype was:
111 libc4 と libc5 (および SunOS 4.x) では、
112 プロトタイプは以下のようになっている。
113 .sp
114 .RS
115 .BI "key_t ftok(char *" pathname ", char " proj_id );
116 .RE
117 .PP
118 .\"O Today
119 .\"O .I proj_id
120 .\"O is an
121 .\"O .IR int ,
122 .\"O but still only 8 bits are used.
123 .\"O Typical usage has an ASCII character
124 .\"O .IR proj_id ,
125 .\"O that is why the behavior is said to be undefined when
126 .\"O .I proj_id
127 .\"O is zero.
128 現在では
129 .I proj_id
130
131 .I int
132 だが、依然として 8 ビットしか用いられない。
133 通常は ASCII キャラクタが
134 .I proj_id
135 に用いられる。
136 .I proj_id
137 が 0 のときの振る舞いが未定義になっているのは、これが理由である。
138 .LP
139 .\"O Of course no guarantee can be given that the resulting
140 .\"O .I key_t
141 .\"O is unique.
142 .\"O Typically, a best effort attempt combines the given
143 .\"O .I proj_id
144 .\"O byte, the lower 16 bits of the inode number, and the
145 .\"O lower 8 bits of the device number into a 32-bit result.
146 .\"O Collisions may easily happen, for example between files on
147 .\"O .I /dev/hda1
148 .\"O and files on
149 .\"O .IR /dev/sda1 .
150 もちろん
151 .I key_t
152 が他と重ならないものであるかどうかは保証されない。
153 最善の場合の組み合わせを考えても、
154 .I proj_id
155 の 1 バイト、i ノード番号の低位 16 ビット、および
156 デバイス番号の低位 8 ビットなので、結果は 32 ビットに過ぎない。
157 例えば
158 .I /dev/hda1
159
160 .I /dev/sda1
161 それぞれにあるファイルに対して、衝突は容易に起こりうる。
162 .\"O .SH "SEE ALSO"
163 .SH 関連項目
164 .BR msgget (2),
165 .BR semget (2),
166 .BR shmget (2),
167 .BR stat (2),
168 .BR svipc (7)