1 .\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it)
3 .\" %%%LICENSE_START(VERBATIM)
4 .\" Permission is granted to make and distribute verbatim copies of this
5 .\" manual provided the copyright notice and this permission notice are
6 .\" preserved on all copies.
8 .\" Permission is granted to copy and distribute modified versions of this
9 .\" manual under the conditions for verbatim copying, provided that the
10 .\" entire resulting derived work is distributed under the terms of a
11 .\" permission notice identical to this one.
13 .\" Since the Linux kernel and libraries are constantly changing, this
14 .\" manual page may be incorrect or out-of-date. The author(s) assume no
15 .\" responsibility for errors or omissions, or for damages resulting from
16 .\" the use of the information contained herein. The author(s) may not
17 .\" have taken the same level of care in the production of this manual,
18 .\" which is licensed free of charge, as they might when working
21 .\" Formatted or processed versions of this manual, if unaccompanied by
22 .\" the source, must acknowledge the copyright and authors of this work.
25 .\" Modified 2001-11-28, by Michael Kerrisk, <mtk.manpages@gmail.com>
26 .\" Changed data type of proj_id; minor fixes
27 .\" aeb: further fixes; added notes.
29 .TH FTOK 3 2014-08-19 "GNU" "Linux Programmer's Manual"
31 ftok \- convert a pathname and a project identifier to a System V IPC key
34 .B #include <sys/types.h>
35 .B #include <sys/ipc.h>
38 .BI "key_t ftok(const char *" pathname ", int " proj_id );
42 function uses the identity of the file named by the given
44 (which must refer to an existing, accessible file)
45 and the least significant 8 bits of
47 (which must be nonzero) to generate a
49 type System V IPC key, suitable for use with
55 The resulting value is the same for all pathnames that
56 name the same file, when the same value of
59 The value returned should be different when the
60 (simultaneously existing) files or the project IDs differ.
62 On success, the generated
65 On failure \-1 is returned, with
67 indicating the error as for the
71 .SS Multithreading (see pthreads(7))
74 function is thread-safe.
78 On some ancient systems, the prototype was:
81 .BI "key_t ftok(char *" pathname ", char " proj_id );
88 but still only 8 bits are used.
89 Typical usage has an ASCII character
91 that is why the behavior is said to be undefined when
95 Of course, no guarantee can be given that the resulting
98 Typically, a best-effort attempt combines the given
100 byte, the lower 16 bits of the inode number, and the
101 lower 8 bits of the device number into a 32-bit result.
102 Collisions may easily happen, for example between files on