OSDN Git Service

(split) Apply minor changes from v3.32 to v3.35 in the upstream.
[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)