2 .\" Copyright 1993 Giorgio Ciucci (giorgio@crcc.it)
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" Modified 2001-11-28, by Michael Kerrisk, <mtk.manpages@gmail.com>
7 .\" Changed data type of proj_id; minor fixes
8 .\" aeb: further fixes; added notes.
10 .TH ftok 3 (date) "Linux man-pages (unreleased)"
12 ftok \- convert a pathname and a project identifier to a System V IPC key
15 .RI ( libc ", " \-lc )
18 .B #include <sys/ipc.h>
21 .BI "key_t ftok(const char *" pathname ", int " proj_id );
25 function uses the identity of the file named by the given
27 (which must refer to an existing, accessible file)
28 and the least significant 8 bits of
30 (which must be nonzero) to generate a
32 type System V IPC key, suitable for use with
38 The resulting value is the same for all pathnames that
39 name the same file, when the same value of
42 The value returned should be different when the
43 (simultaneously existing) files or the project IDs differ.
45 On success, the generated
48 On failure \-1 is returned, with
50 indicating the error as for the
54 For an explanation of the terms used in this section, see
60 Interface Attribute Value
65 T} Thread safety MT-Safe
73 On some ancient systems, the prototype was:
77 .BI "key_t ftok(char *" pathname ", char " proj_id );
85 but still only 8 bits are used.
86 Typical usage has an ASCII character
88 that is why the behavior is said to be undefined when
92 Of course, no guarantee can be given that the resulting
95 Typically, a best-effort attempt combines the given
97 byte, the lower 16 bits of the inode number, and the
98 lower 8 bits of the device number into a 32-bit result.
99 Collisions may easily happen, for example between files on