1 .\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it)
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.
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.
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
20 .\" Formatted or processed versions of this manual, if unaccompanied by
21 .\" the source, must acknowledge the copyright and authors of this work.
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.
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
31 .TH FTOK 3 2001-11-28 "Linux" "Linux Programmer's Manual"
33 .\"O ftok \- convert a pathname and a project identifier to a System V IPC key
35 ftok \- ¥Ñ¥¹Ì¾¤È¥×¥í¥¸¥§¥¯¥È¼±Ê̻Ҥò System V IPC ¥¡¼¤ËÊÑ´¹¤¹¤ë
39 .B #include <sys/types.h>
40 .B #include <sys/ipc.h>
43 .BI "key_t ftok(const char *" pathname ", int " proj_id );
48 .\"O function uses the identity of the file named by the given
50 .\"O (which must refer to an existing, accessible file)
51 .\"O and the least significant 8 bits of
53 .\"O (which must be nonzero) to generate a
55 .\"O type System V IPC key, suitable for use with
63 ¤ÇÍ¿¤¨¤é¤ì¤¿¥Õ¥¡¥¤¥ë (¸ºß¤·¡¢¥¢¥¯¥»¥¹²Äǽ¤Ç¤Ê¤±¤ì¤Ð¤Ê¤é¤Ê¤¤)
64 ¤Î¥Õ¥¡¥¤¥ë̾¤Î¼±Ê̾ðÊó (identity) ¤È¡¢
66 (0 ¤Ç¤¢¤Ã¤Æ¤Ï¤Ê¤é¤Ê¤¤) ¤ÎÄã°Ì 8 ¥Ó¥Ã¥È¤È¤òÍѤ¤¤Æ¡¢
68 ·¿¤Î System V IPC ¥¡¼¤òÀ¸À®¤¹¤ë¡£
73 ¤Ê¤É¤Ç¤ÎÍøÍѤËŬ¤·¤Æ¤¤¤ë¡£
75 .\"O The resulting value is the same for all pathnames that
76 .\"O name the same file, when the same value of
79 .\"O The value returned should be different when the
80 .\"O (simultaneously existing) files or the project IDs differ.
81 Ʊ¤¸¥Õ¥¡¥¤¥ë¤ò¼¨¤¹¤¢¤é¤æ¤ë¥Ñ¥¹Ì¾¤È¡¢Æ±¤¸
83 ¤ËÂФ·¤Æ¤Ï¡¢·ë²Ì¤ÎÃͤÏÅù¤·¤¯¤Ê¤ë¡£
84 ¥Õ¥¡¥¤¥ë¤¬°ã¤Ã¤¿¤ê (¤³¤Î¾ì¹çξ¼Ô¤ÏƱ»þ¤Ë¸ºß¤·¤Æ¤¤¤ë¤Ï¤º)¡¢
86 ¤¬°Û¤Ê¤ë¤È¡¢ÊÖ¤êÃͤâ°Û¤Ê¤ë¡£
87 .\"O .SH "RETURN VALUE"
89 .\"O On success, the generated
91 .\"O value is returned.
92 .\"O On failure \-1 is returned, with
94 .\"O indicating the error as for the
97 À®¸ù¤·¤¿¾ì¹ç¤ÏÀ¸À®¤µ¤ì¤¿
100 ¼ºÇÔ¤¹¤ë¤È \-1 ¤¬ÊÖ¤µ¤ì¡¢¥¨¥é¡¼¤ÎÆâÍƤ¬
102 ¤Ë½ñ¤¹þ¤Þ¤ì¤ë¡£¤³¤ÎÆâÍƤϥ·¥¹¥Æ¥à¥³¡¼¥ë
105 .\"O .SH "CONFORMING TO"
110 .\"O Under libc4 and libc5 (and under SunOS 4.x) the prototype was:
111 libc4 ¤È libc5 (¤ª¤è¤Ó SunOS 4.x) ¤Ç¤Ï¡¢
112 ¥×¥í¥È¥¿¥¤¥×¤Ï°Ê²¼¤Î¤è¤¦¤Ë¤Ê¤Ã¤Æ¤¤¤ë¡£
115 .BI "key_t ftok(char *" pathname ", char " proj_id );
122 .\"O but still only 8 bits are used.
123 .\"O Typical usage has an ASCII character
125 .\"O that is why the behavior is said to be undefined when
132 ¤À¤¬¡¢°ÍÁ³¤È¤·¤Æ 8 ¥Ó¥Ã¥È¤·¤«ÍѤ¤¤é¤ì¤Ê¤¤¡£
133 Ä̾ï¤Ï ASCII ¥¥ã¥é¥¯¥¿¤¬
137 ¤¬ 0 ¤Î¤È¤¤Î¿¶¤ëÉñ¤¤¤¬Ì¤ÄêµÁ¤Ë¤Ê¤Ã¤Æ¤¤¤ë¤Î¤Ï¡¢¤³¤ì¤¬Íýͳ¤Ç¤¢¤ë¡£
139 .\"O Of course no guarantee can be given that the resulting
142 .\"O Typically, a best effort attempt combines the given
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
152 ¤¬Â¾¤È½Å¤Ê¤é¤Ê¤¤¤â¤Î¤Ç¤¢¤ë¤«¤É¤¦¤«¤ÏÊݾڤµ¤ì¤Ê¤¤¡£
153 ºÇÁ±¤Î¾ì¹ç¤ÎÁȤ߹ç¤ï¤»¤ò¹Í¤¨¤Æ¤â¡¢
155 ¤Î 1 ¥Ð¥¤¥È¡¢i ¥Î¡¼¥ÉÈÖ¹æ¤ÎÄã°Ì 16 ¥Ó¥Ã¥È¡¢¤ª¤è¤Ó
156 ¥Ç¥Ð¥¤¥¹ÈÖ¹æ¤ÎÄã°Ì 8 ¥Ó¥Ã¥È¤Ê¤Î¤Ç¡¢·ë²Ì¤Ï 32 ¥Ó¥Ã¥È¤Ë²á¤®¤Ê¤¤¡£
161 ¤½¤ì¤¾¤ì¤Ë¤¢¤ë¥Õ¥¡¥¤¥ë¤ËÂФ·¤Æ¡¢¾×ÆͤÏÍưפ˵¯¤³¤ê¤¦¤ë¡£